29 using System.Collections;
30 using System.Collections.Generic;
33 using OpenSim.Framework;
34 using System.Reflection;
40 namespace OpenSim.Data.PGSQL
53 conn,
"inventoryfolders",
"InventoryStore");
55 conn,
"inventoryitems", String.Empty);
60 UUID newUUID = UUID.Zero;
62 UUID.TryParse(strUUID, out newUUID);
69 return m_Folders.Get(fields, vals);
74 return m_Items.Get(fields, vals);
80 folder.folderName = folder.folderName.Substring(0, 64);
81 return m_Folders.Store(folder);
87 item.inventoryName = item.inventoryName.Substring(0, 64);
89 item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
91 return m_Items.Store(item);
96 return m_Folders.Delete(field, val);
101 return m_Folders.Delete(fields, vals);
106 return m_Items.Delete(field, val);
111 return m_Items.Delete(fields, vals);
116 return m_Items.MoveItem(id, newParent);
121 return m_Folders.MoveFolder(id, newParent);
126 return m_Items.GetActiveGestures(principalID.ToString());
131 return m_Items.GetAssetPermissions(principalID, assetID);
144 XInventoryItem[] retrievedItems = Get(
new string[] {
"inventoryID" },
new string[] {
id });
145 if (retrievedItems.Length == 0)
148 UUID oldParent = retrievedItems[0].parentFolderID;
150 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
152 using (NpgsqlCommand cmd =
new NpgsqlCommand())
154 cmd.CommandText = String.Format(
@"update {0} set ""parentFolderID"" = :ParentFolderID where ""inventoryID"" = :InventoryID", m_Realm);
155 cmd.Parameters.Add(m_database.CreateParameter(
"ParentFolderID", newParent));
156 cmd.Parameters.Add(m_database.CreateParameter(
"InventoryID", id ));
157 cmd.Connection = conn;
160 if (cmd.ExecuteNonQuery() == 0)
165 IncrementFolderVersion(oldParent);
166 IncrementFolderVersion(newParent);
173 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
175 using (NpgsqlCommand cmd =
new NpgsqlCommand())
177 cmd.CommandText = String.Format(
@"select * from inventoryitems where ""avatarID"" = :uuid and ""assetType"" = :type and ""flags"" = 1", m_Realm);
179 UUID princID = UUID.Zero;
180 UUID.TryParse(principalID, out princID);
182 cmd.Parameters.Add(m_database.CreateParameter(
"uuid", principalID));
183 cmd.Parameters.Add(m_database.CreateParameter(
"type", (int)AssetType.Gesture));
184 cmd.Connection = conn;
193 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
195 using (NpgsqlCommand cmd =
new NpgsqlCommand())
197 cmd.CommandText = String.Format(
@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
199 where ""avatarID"" = :PrincipalID
200 and ""assetID"" = :AssetID
201 group by ""assetID"" ", m_Realm);
203 cmd.Parameters.Add(m_database.CreateParameter(
"PrincipalID", principalID));
204 cmd.Parameters.Add(m_database.CreateParameter(
"AssetID", assetID));
205 cmd.Connection = conn;
207 using (NpgsqlDataReader reader = cmd.ExecuteReader())
214 perms = Convert.ToInt32(reader[
"inventoryCurrentPermissions"]);
226 if (!base.Store(item))
244 XInventoryFolder[] folders = Get(
new string[] {
"folderID" },
new string[] {
id });
246 if (folders.Length == 0)
249 UUID oldParentFolderUUID = folders[0].parentFolderID;
251 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
253 using (NpgsqlCommand cmd =
new NpgsqlCommand())
255 UUID foldID = UUID.Zero;
256 UUID.TryParse(id, out foldID);
258 UUID newPar = UUID.Zero;
259 UUID.TryParse(newParentFolderID, out newPar);
261 cmd.CommandText = String.Format(
@"update {0} set ""parentFolderID"" = :ParentFolderID where ""folderID"" = :folderID", m_Realm);
262 cmd.Parameters.Add(m_database.CreateParameter(
"ParentFolderID", newPar));
263 cmd.Parameters.Add(m_database.CreateParameter(
"folderID", foldID));
264 cmd.Connection = conn;
267 if (cmd.ExecuteNonQuery() == 0)
272 IncrementFolderVersion(oldParentFolderUUID);
273 IncrementFolderVersion(newParentFolderID);
280 if (!base.Store(folder))
289 public class PGSQLInventoryHandler<T> : PGSQLGenericTableHandler<T> where T: class, new()
295 return IncrementFolderVersion(folderID.ToString());
303 string sql =
@"update inventoryfolders set version=version+1 where ""folderID"" = :folderID";
305 using (NpgsqlConnection conn =
new NpgsqlConnection(m_ConnectionString))
307 using (NpgsqlCommand cmd =
new NpgsqlCommand(sql, conn))
309 UUID foldID = UUID.Zero;
310 UUID.TryParse(folderID, out foldID);
314 cmd.Parameters.Add( m_database.CreateParameter(
"folderID", foldID) );
318 cmd.ExecuteNonQuery();
int GetAssetPermissions(UUID principalID, UUID assetID)
PGSQLFolderHandler(string c, string t, string m)
bool StoreItem(XInventoryItem item)
override bool Store(XInventoryItem item)
bool MoveItem(string id, string newParent)
Move an item to another folder.
bool MoveFolder(string id, string newParent)
Move a folder to another folder.
bool MoveItem(string id, string newParent)
XInventoryItem[] GetActiveGestures(string principalID)
override bool Store(XInventoryFolder folder)
PGSQLInventoryHandler(string c, string t, string m)
bool IncrementFolderVersion(string folderID)
bool DeleteFolders(string[] fields, string[] vals)
Delete folders where field1 == val1, field2 == val2...
string inventoryDescription
bool StoreFolder(XInventoryFolder folder)
PGSQLXInventoryData(string conn, string realm)
PGSQLItemHandler(string c, string t, string m)
static UUID str2UUID(string strUUID)
bool IncrementFolderVersion(UUID folderID)
XInventoryFolder[] GetFolders(string[] fields, string[] vals)
bool DeleteFolders(string field, string val)
Delete folders where field == val
bool MoveFolder(string id, string newParentFolderID)
XInventoryItem[] GetActiveGestures(UUID principalID)
XInventoryItem[] GetItems(string[] fields, string[] vals)
int GetAssetPermissions(UUID principalID, UUID assetID)
bool DeleteItems(string field, string val)
Delete items where field == val
bool DeleteItems(string[] fields, string[] vals)
Delete items where field1 == val1, field2 == val2...