From f43681510725f5b95fcb864a1f3e4b744fcaf992 Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Mon, 7 Apr 2008 23:15:35 +0000
Subject: Refactor InventoryItemBase to do the following: * wrap fields as
Properties * rename some fields/properties to more sensible names * set
style to PropName to match more standard C# approach
---
OpenSim/Data/MSSQL/MSSQLInventoryData.cs | 82 +++++++++++-----------
OpenSim/Data/MySQL/MySQLInventoryData.cs | 52 +++++++-------
OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 8 +--
OpenSim/Data/SQLite/SQLiteInventoryStore.cs | 62 ++++++++--------
4 files changed, 102 insertions(+), 102 deletions(-)
(limited to 'OpenSim/Data')
diff --git a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
index df7020d..15078aa 100644
--- a/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLInventoryData.cs
@@ -301,19 +301,19 @@ namespace OpenSim.Data.MSSQL
{
InventoryItemBase item = new InventoryItemBase();
- item.inventoryID = new LLUUID((string) reader["inventoryID"]);
- item.assetID = new LLUUID((string) reader["assetID"]);
- item.assetType = (int) reader["assetType"];
- item.parentFolderID = new LLUUID((string) reader["parentFolderID"]);
- item.avatarID = new LLUUID((string) reader["avatarID"]);
- item.inventoryName = (string) reader["inventoryName"];
- item.inventoryDescription = (string) reader["inventoryDescription"];
- item.inventoryNextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
- item.inventoryCurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
- item.invType = (int) reader["invType"];
- item.creatorsID = new LLUUID((string) reader["creatorID"]);
- item.inventoryBasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
- item.inventoryEveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
+ item.ID = new LLUUID((string) reader["inventoryID"]);
+ item.AssetID = new LLUUID((string) reader["assetID"]);
+ item.AssetType = (int) reader["assetType"];
+ item.Folder = new LLUUID((string) reader["parentFolderID"]);
+ item.Owner = new LLUUID((string) reader["avatarID"]);
+ item.Name = (string) reader["inventoryName"];
+ item.Description = (string) reader["inventoryDescription"];
+ item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
+ item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
+ item.InvType = (int) reader["invType"];
+ item.Creator = new LLUUID((string) reader["creatorID"]);
+ item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
+ item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
return item;
}
catch (SqlException e)
@@ -425,7 +425,7 @@ namespace OpenSim.Data.MSSQL
/// The inventory item
public void addInventoryItem(InventoryItemBase item)
{
- if (getInventoryItem(item.inventoryID) != null)
+ if (getInventoryItem(item.ID) != null)
{
updateInventoryItem(item);
return;
@@ -440,19 +440,19 @@ namespace OpenSim.Data.MSSQL
try
{
Dictionary param = new Dictionary();
- param["inventoryID"] = item.inventoryID.ToString();
- param["assetID"] = item.assetID.ToString();
- param["assetType"] = item.assetType.ToString();
- param["parentFolderID"] = item.parentFolderID.ToString();
- param["avatarID"] = item.avatarID.ToString();
- param["inventoryName"] = item.inventoryName;
- param["inventoryDescription"] = item.inventoryDescription;
- param["inventoryNextPermissions"] = item.inventoryNextPermissions.ToString();
- param["inventoryCurrentPermissions"] = item.inventoryCurrentPermissions.ToString();
- param["invType"] = Convert.ToString(item.invType);
- param["creatorID"] = item.creatorsID.ToString();
- param["inventoryBasePermissions"] = Convert.ToString(item.inventoryBasePermissions);
- param["inventoryEveryOnePermissions"] = Convert.ToString(item.inventoryEveryOnePermissions);
+ param["inventoryID"] = item.ID.ToString();
+ param["assetID"] = item.AssetID.ToString();
+ param["assetType"] = item.AssetType.ToString();
+ param["parentFolderID"] = item.Folder.ToString();
+ param["avatarID"] = item.Owner.ToString();
+ param["inventoryName"] = item.Name;
+ param["inventoryDescription"] = item.Description;
+ param["inventoryNextPermissions"] = item.NextPermissions.ToString();
+ param["inventoryCurrentPermissions"] = item.CurrentPermissions.ToString();
+ param["invType"] = Convert.ToString(item.InvType);
+ param["creatorID"] = item.Creator.ToString();
+ param["inventoryBasePermissions"] = Convert.ToString(item.BasePermissions);
+ param["inventoryEveryOnePermissions"] = Convert.ToString(item.EveryOnePermissions);
IDbCommand result = database.Query(sql, param);
result.ExecuteNonQuery();
@@ -484,20 +484,20 @@ namespace OpenSim.Data.MSSQL
"inventoryBasePermissions = @inventoryBasePermissions" +
"inventoryEveryOnePermissions = @inventoryEveryOnePermissions) where " +
"inventoryID = @keyInventoryID;", database.getConnection());
- SqlParameter param1 = new SqlParameter("@inventoryID", item.inventoryID.ToString());
- SqlParameter param2 = new SqlParameter("@assetID", item.assetID);
- SqlParameter param3 = new SqlParameter("@assetType", item.assetType);
- SqlParameter param4 = new SqlParameter("@parentFolderID", item.parentFolderID);
- SqlParameter param5 = new SqlParameter("@avatarID", item.avatarID);
- SqlParameter param6 = new SqlParameter("@inventoryName", item.inventoryName);
- SqlParameter param7 = new SqlParameter("@inventoryDescription", item.inventoryDescription);
- SqlParameter param8 = new SqlParameter("@inventoryNextPermissions", item.inventoryNextPermissions);
- SqlParameter param9 = new SqlParameter("@inventoryCurrentPermissions", item.inventoryCurrentPermissions);
- SqlParameter param10 = new SqlParameter("@invType", item.invType);
- SqlParameter param11 = new SqlParameter("@creatorID", item.creatorsID);
- SqlParameter param12 = new SqlParameter("@inventoryBasePermissions", item.inventoryBasePermissions);
- SqlParameter param13 = new SqlParameter("@inventoryEveryOnePermissions", item.inventoryEveryOnePermissions);
- SqlParameter param14 = new SqlParameter("@keyInventoryID", item.inventoryID.ToString());
+ SqlParameter param1 = new SqlParameter("@inventoryID", item.ID.ToString());
+ SqlParameter param2 = new SqlParameter("@assetID", item.AssetID);
+ SqlParameter param3 = new SqlParameter("@assetType", item.AssetType);
+ SqlParameter param4 = new SqlParameter("@parentFolderID", item.Folder);
+ SqlParameter param5 = new SqlParameter("@avatarID", item.Owner);
+ SqlParameter param6 = new SqlParameter("@inventoryName", item.Name);
+ SqlParameter param7 = new SqlParameter("@inventoryDescription", item.Description);
+ SqlParameter param8 = new SqlParameter("@inventoryNextPermissions", item.NextPermissions);
+ SqlParameter param9 = new SqlParameter("@inventoryCurrentPermissions", item.CurrentPermissions);
+ SqlParameter param10 = new SqlParameter("@invType", item.InvType);
+ SqlParameter param11 = new SqlParameter("@creatorID", item.Creator);
+ SqlParameter param12 = new SqlParameter("@inventoryBasePermissions", item.BasePermissions);
+ SqlParameter param13 = new SqlParameter("@inventoryEveryOnePermissions", item.EveryOnePermissions);
+ SqlParameter param14 = new SqlParameter("@keyInventoryID", item.ID.ToString());
command.Parameters.Add(param1);
command.Parameters.Add(param2);
command.Parameters.Add(param3);
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index ceb73c5..6bb7a53 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -312,19 +312,19 @@ namespace OpenSim.Data.MySQL
{
InventoryItemBase item = new InventoryItemBase();
- item.inventoryID = new LLUUID((string) reader["inventoryID"]);
- item.assetID = new LLUUID((string) reader["assetID"]);
- item.assetType = (int) reader["assetType"];
- item.parentFolderID = new LLUUID((string) reader["parentFolderID"]);
- item.avatarID = new LLUUID((string) reader["avatarID"]);
- item.inventoryName = (string) reader["inventoryName"];
- item.inventoryDescription = (string) reader["inventoryDescription"];
- item.inventoryNextPermissions = (uint) reader["inventoryNextPermissions"];
- item.inventoryCurrentPermissions = (uint) reader["inventoryCurrentPermissions"];
- item.invType = (int) reader["invType"];
- item.creatorsID = new LLUUID((string) reader["creatorID"]);
- item.inventoryBasePermissions = (uint) reader["inventoryBasePermissions"];
- item.inventoryEveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
+ item.ID = new LLUUID((string) reader["inventoryID"]);
+ item.AssetID = new LLUUID((string) reader["assetID"]);
+ item.AssetType = (int) reader["assetType"];
+ item.Folder = new LLUUID((string) reader["parentFolderID"]);
+ item.Owner = new LLUUID((string) reader["avatarID"]);
+ item.Name = (string) reader["inventoryName"];
+ item.Description = (string) reader["inventoryDescription"];
+ item.NextPermissions = (uint) reader["inventoryNextPermissions"];
+ item.CurrentPermissions = (uint) reader["inventoryCurrentPermissions"];
+ item.InvType = (int) reader["invType"];
+ item.Creator = new LLUUID((string) reader["creatorID"]);
+ item.BasePermissions = (uint) reader["inventoryBasePermissions"];
+ item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
return item;
}
catch (MySqlException e)
@@ -444,20 +444,20 @@ namespace OpenSim.Data.MySQL
try
{
MySqlCommand result = new MySqlCommand(sql, database.Connection);
- result.Parameters.AddWithValue("?inventoryID", item.inventoryID.ToString());
- result.Parameters.AddWithValue("?assetID", item.assetID.ToString());
- result.Parameters.AddWithValue("?assetType", item.assetType.ToString());
- result.Parameters.AddWithValue("?parentFolderID", item.parentFolderID.ToString());
- result.Parameters.AddWithValue("?avatarID", item.avatarID.ToString());
- result.Parameters.AddWithValue("?inventoryName", item.inventoryName);
- result.Parameters.AddWithValue("?inventoryDescription", item.inventoryDescription);
- result.Parameters.AddWithValue("?inventoryNextPermissions", item.inventoryNextPermissions.ToString());
+ result.Parameters.AddWithValue("?inventoryID", item.ID.ToString());
+ result.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
+ result.Parameters.AddWithValue("?assetType", item.AssetType.ToString());
+ result.Parameters.AddWithValue("?parentFolderID", item.Folder.ToString());
+ result.Parameters.AddWithValue("?avatarID", item.Owner.ToString());
+ result.Parameters.AddWithValue("?inventoryName", item.Name);
+ result.Parameters.AddWithValue("?inventoryDescription", item.Description);
+ result.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions.ToString());
result.Parameters.AddWithValue("?inventoryCurrentPermissions",
- item.inventoryCurrentPermissions.ToString());
- result.Parameters.AddWithValue("?invType", item.invType);
- result.Parameters.AddWithValue("?creatorID", item.creatorsID.ToString());
- result.Parameters.AddWithValue("?inventoryBasePermissions", item.inventoryBasePermissions);
- result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.inventoryEveryOnePermissions);
+ item.CurrentPermissions.ToString());
+ result.Parameters.AddWithValue("?invType", item.InvType);
+ result.Parameters.AddWithValue("?creatorID", item.Creator.ToString());
+ result.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
+ result.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
result.ExecuteNonQuery();
result.Dispose();
}
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
index d6cd664..ba1d3e9 100644
--- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
+++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Data.NHibernate
/// The item to be created
public void addInventoryItem(InventoryItemBase item)
{
- if (!ExistsItem(item.inventoryID)) {
+ if (!ExistsItem(item.ID)) {
using(ISession session = factory.OpenSession()) {
using(ITransaction transaction = session.BeginTransaction()) {
session.Save(item);
@@ -120,7 +120,7 @@ namespace OpenSim.Data.NHibernate
}
}
} else {
- m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.inventoryID);
+ m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID);
updateInventoryItem(item);
}
}
@@ -131,7 +131,7 @@ namespace OpenSim.Data.NHibernate
/// The updated item
public void updateInventoryItem(InventoryItemBase item)
{
- if (ExistsItem(item.inventoryID)) {
+ if (ExistsItem(item.ID)) {
using(ISession session = factory.OpenSession()) {
using(ITransaction transaction = session.BeginTransaction()) {
session.Update(item);
@@ -139,7 +139,7 @@ namespace OpenSim.Data.NHibernate
}
}
} else {
- m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.inventoryID);
+ m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID);
}
}
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 1554aa3..f0ff7c9 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -91,39 +91,39 @@ namespace OpenSim.Data.SQLite
public InventoryItemBase buildItem(DataRow row)
{
InventoryItemBase item = new InventoryItemBase();
- item.inventoryID = new LLUUID((string) row["UUID"]);
- item.assetID = new LLUUID((string) row["assetID"]);
- item.assetType = Convert.ToInt32(row["assetType"]);
- item.invType = Convert.ToInt32(row["invType"]);
- item.parentFolderID = new LLUUID((string) row["parentFolderID"]);
- item.avatarID = new LLUUID((string) row["avatarID"]);
- item.creatorsID = new LLUUID((string) row["creatorsID"]);
- item.inventoryName = (string) row["inventoryName"];
- item.inventoryDescription = (string) row["inventoryDescription"];
-
- item.inventoryNextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]);
- item.inventoryCurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]);
- item.inventoryBasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]);
- item.inventoryEveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]);
+ item.ID = new LLUUID((string) row["UUID"]);
+ item.AssetID = new LLUUID((string) row["assetID"]);
+ item.AssetType = Convert.ToInt32(row["assetType"]);
+ item.InvType = Convert.ToInt32(row["invType"]);
+ item.Folder = new LLUUID((string) row["parentFolderID"]);
+ item.Owner = new LLUUID((string) row["avatarID"]);
+ item.Creator = new LLUUID((string) row["creatorsID"]);
+ item.Name = (string) row["inventoryName"];
+ item.Description = (string) row["inventoryDescription"];
+
+ item.NextPermissions = Convert.ToUInt32(row["inventoryNextPermissions"]);
+ item.CurrentPermissions = Convert.ToUInt32(row["inventoryCurrentPermissions"]);
+ item.BasePermissions = Convert.ToUInt32(row["inventoryBasePermissions"]);
+ item.EveryOnePermissions = Convert.ToUInt32(row["inventoryEveryOnePermissions"]);
return item;
}
private void fillItemRow(DataRow row, InventoryItemBase item)
{
- row["UUID"] = Util.ToRawUuidString(item.inventoryID);
- row["assetID"] = Util.ToRawUuidString(item.assetID);
- row["assetType"] = item.assetType;
- row["invType"] = item.invType;
- row["parentFolderID"] = Util.ToRawUuidString(item.parentFolderID);
- row["avatarID"] = Util.ToRawUuidString(item.avatarID);
- row["creatorsID"] = Util.ToRawUuidString(item.creatorsID);
- row["inventoryName"] = item.inventoryName;
- row["inventoryDescription"] = item.inventoryDescription;
+ row["UUID"] = Util.ToRawUuidString(item.ID);
+ row["assetID"] = Util.ToRawUuidString(item.AssetID);
+ row["assetType"] = item.AssetType;
+ row["invType"] = item.InvType;
+ row["parentFolderID"] = Util.ToRawUuidString(item.Folder);
+ row["avatarID"] = Util.ToRawUuidString(item.Owner);
+ row["creatorsID"] = Util.ToRawUuidString(item.Creator);
+ row["inventoryName"] = item.Name;
+ row["inventoryDescription"] = item.Description;
- row["inventoryNextPermissions"] = item.inventoryNextPermissions;
- row["inventoryCurrentPermissions"] = item.inventoryCurrentPermissions;
- row["inventoryBasePermissions"] = item.inventoryBasePermissions;
- row["inventoryEveryOnePermissions"] = item.inventoryEveryOnePermissions;
+ row["inventoryNextPermissions"] = item.NextPermissions;
+ row["inventoryCurrentPermissions"] = item.CurrentPermissions;
+ row["inventoryBasePermissions"] = item.BasePermissions;
+ row["inventoryEveryOnePermissions"] = item.EveryOnePermissions;
}
private void addFolder(InventoryFolderBase folder, bool add)
@@ -182,11 +182,11 @@ namespace OpenSim.Data.SQLite
{
DataTable inventoryItemTable = ds.Tables["inventoryitems"];
- DataRow inventoryRow = inventoryItemTable.Rows.Find(Util.ToRawUuidString(item.inventoryID));
+ DataRow inventoryRow = inventoryItemTable.Rows.Find(Util.ToRawUuidString(item.ID));
if (inventoryRow == null)
{
if (! add)
- m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory item: {0}", item.inventoryID);
+ m_log.ErrorFormat("Interface Misuse: Attempting to Update non-existant inventory item: {0}", item.ID);
inventoryRow = inventoryItemTable.NewRow();
fillItemRow(inventoryRow, item);
@@ -195,7 +195,7 @@ namespace OpenSim.Data.SQLite
else
{
if (add)
- m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory item that already exists: {0}", item.inventoryID);
+ m_log.ErrorFormat("Interface Misuse: Attempting to Add inventory item that already exists: {0}", item.ID);
fillItemRow(inventoryRow, item);
}
@@ -439,7 +439,7 @@ namespace OpenSim.Data.SQLite
List items = getInventoryInFolder(Util.ToRawUuidString(folderId));
foreach (InventoryItemBase i in items)
- deleteInventoryItem(Util.ToRawUuidString(i.inventoryID));
+ deleteInventoryItem(Util.ToRawUuidString(i.ID));
}
///
--
cgit v1.1