diff options
author | Sean Dague | 2008-04-09 13:43:35 +0000 |
---|---|---|
committer | Sean Dague | 2008-04-09 13:43:35 +0000 |
commit | 750291447ea53f35f277ad9e79c09c77c8471b4d (patch) | |
tree | c2e9f7d94641851296e905120fa74d5261eacf54 /OpenSim/Data | |
parent | NHibernate Inventory getting close, except for some of the (diff) | |
download | opensim-SC-750291447ea53f35f277ad9e79c09c77c8471b4d.zip opensim-SC-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.gz opensim-SC-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.bz2 opensim-SC-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.xz |
changing around types a bit to make stuff more readable for
me.
Diffstat (limited to 'OpenSim/Data')
5 files changed, 48 insertions, 46 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs index 8bc41c9..8043348 100644 --- a/OpenSim/Data/NHibernate/NHibernateInventoryData.cs +++ b/OpenSim/Data/NHibernate/NHibernateInventoryData.cs | |||
@@ -99,8 +99,9 @@ namespace OpenSim.Data.NHibernate | |||
99 | { | 99 | { |
100 | using(ISession session = factory.OpenSession()) { | 100 | using(ISession session = factory.OpenSession()) { |
101 | try { | 101 | try { |
102 | return session.Load(typeof(InventoryItemBase), item.ToString()) as InventoryItemBase; | 102 | return session.Load(typeof(InventoryItemBase), item) as InventoryItemBase; |
103 | } catch { | 103 | } catch { |
104 | m_log.ErrorFormat("Couldn't find inventory item: {0}", item); | ||
104 | return null; | 105 | return null; |
105 | } | 106 | } |
106 | } | 107 | } |
@@ -151,7 +152,7 @@ namespace OpenSim.Data.NHibernate | |||
151 | { | 152 | { |
152 | using(ISession session = factory.OpenSession()) { | 153 | using(ISession session = factory.OpenSession()) { |
153 | using(ITransaction transaction = session.BeginTransaction()) { | 154 | using(ITransaction transaction = session.BeginTransaction()) { |
154 | session.Delete(itemID.ToString()); | 155 | session.Delete(itemID); |
155 | transaction.Commit(); | 156 | transaction.Commit(); |
156 | } | 157 | } |
157 | } | 158 | } |
@@ -167,8 +168,9 @@ namespace OpenSim.Data.NHibernate | |||
167 | { | 168 | { |
168 | using(ISession session = factory.OpenSession()) { | 169 | using(ISession session = factory.OpenSession()) { |
169 | try { | 170 | try { |
170 | return session.Load(typeof(InventoryFolderBase), folder.ToString()) as InventoryFolderBase; | 171 | return session.Load(typeof(InventoryFolderBase), folder) as InventoryFolderBase; |
171 | } catch { | 172 | } catch { |
173 | m_log.ErrorFormat("Couldn't find inventory item: {0}", folder); | ||
172 | return null; | 174 | return null; |
173 | } | 175 | } |
174 | } | 176 | } |
@@ -296,8 +298,8 @@ namespace OpenSim.Data.NHibernate | |||
296 | { | 298 | { |
297 | using(ISession session = factory.OpenSession()) { | 299 | using(ISession session = factory.OpenSession()) { |
298 | try { | 300 | try { |
299 | IQuery query = session.CreateQuery("from InventoryItems i where i.parentFolderID = :parent"); | 301 | IQuery query = session.CreateQuery("from InventoryItems i where i.Folder = :folder"); |
300 | query.SetString("parent", folderID.ToString()); | 302 | query.SetString("folder", folderID.ToString()); |
301 | List<InventoryItemBase> list = new List<InventoryItemBase>(); | 303 | List<InventoryItemBase> list = new List<InventoryItemBase>(); |
302 | foreach (InventoryItemBase item in query.List()) | 304 | foreach (InventoryItemBase item in query.List()) |
303 | { | 305 | { |
@@ -318,21 +320,21 @@ namespace OpenSim.Data.NHibernate | |||
318 | // see InventoryItemBase.getUserRootFolder | 320 | // see InventoryItemBase.getUserRootFolder |
319 | public InventoryFolderBase getUserRootFolder(LLUUID user) | 321 | public InventoryFolderBase getUserRootFolder(LLUUID user) |
320 | { | 322 | { |
321 | // using(ISession session = factory.OpenSession()) { | 323 | using(ISession session = factory.OpenSession()) { |
322 | // try { | 324 | try { |
323 | // IQuery query = session.CreateQuery("from InventoryItems i where i.parentFolderID = :parent"); | 325 | IQuery query = session.CreateQuery("from InventoryFolders i where i.ParentID = :parent and i.Owner = :owner"); |
324 | // query.SetString("parent", folderID.ToString()); | 326 | query.SetParameter("parent", LLUUID.Zero, NHibernateUtil.Custom(typeof(LLUUIDUserType))); |
325 | // List<InventoryItemBase> list = new List<InventoryItemBase>(); | 327 | query.SetParameter("owner", user, NHibernateUtil.Custom(typeof(LLUUIDUserType))); |
326 | // foreach (InventoryItemBase item in query.List()) | 328 | foreach (InventoryFolderBase folder in query.List()) |
327 | // { | 329 | { |
328 | // list.Add(item); | 330 | return folder; |
329 | // } | 331 | } |
330 | // return list; | 332 | m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user); |
331 | // } catch { | 333 | return new InventoryFolderBase(); |
332 | // return new List<InventoryItemBase>(); | 334 | } catch { |
333 | // } | 335 | return new InventoryFolderBase(); |
334 | // } | 336 | } |
335 | return new InventoryFolderBase(); | 337 | } |
336 | } | 338 | } |
337 | 339 | ||
338 | /// <summary> | 340 | /// <summary> |
@@ -340,19 +342,19 @@ namespace OpenSim.Data.NHibernate | |||
340 | /// </summary> | 342 | /// </summary> |
341 | /// <param name="folders">list where folders will be appended</param> | 343 | /// <param name="folders">list where folders will be appended</param> |
342 | /// <param name="parentID">ID of parent</param> | 344 | /// <param name="parentID">ID of parent</param> |
343 | protected void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID) | 345 | private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID) |
344 | { | 346 | { |
345 | using(ISession session = factory.OpenSession()) { | 347 | using(ISession session = factory.OpenSession()) { |
346 | try { | 348 | // try { |
347 | IQuery query = session.CreateQuery("from InventoryFolders i where i.parentFolderID = :parent"); | 349 | IQuery query = session.CreateQuery("from InventoryFolders i where i.ParentID = :parent"); |
348 | query.SetString("parent", parentID.ToString()); | 350 | query.SetParameter("parent", parentID, NHibernateUtil.Custom(typeof(LLUUIDUserType))); |
349 | foreach (InventoryFolderBase item in query.List()) | 351 | foreach (InventoryFolderBase item in query.List()) |
350 | { | 352 | { |
351 | folders.Add(item); | 353 | folders.Add(item); |
352 | } | 354 | } |
353 | } catch { | 355 | // } catch { |
354 | 356 | // m_log.ErrorFormat("Can't run getInventoryFolders for Folder ID: {0}", parentID); | |
355 | } | 357 | // } |
356 | } | 358 | } |
357 | } | 359 | } |
358 | 360 | ||
@@ -364,7 +366,7 @@ namespace OpenSim.Data.NHibernate | |||
364 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) | 366 | public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) |
365 | { | 367 | { |
366 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 368 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
367 | getInventoryFolders(ref folders, Util.ToRawUuidString(parentID)); | 369 | getInventoryFolders(ref folders, parentID); |
368 | return folders; | 370 | return folders; |
369 | } | 371 | } |
370 | 372 | ||
@@ -372,11 +374,11 @@ namespace OpenSim.Data.NHibernate | |||
372 | public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) | 374 | public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) |
373 | { | 375 | { |
374 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); | 376 | List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); |
375 | getInventoryFolders(ref folders, Util.ToRawUuidString(parentID)); | 377 | getInventoryFolders(ref folders, parentID); |
376 | 378 | ||
377 | for (int i = 0; i < folders.Count; i++) | 379 | for (int i = 0; i < folders.Count; i++) |
378 | getInventoryFolders(ref folders, Util.ToRawUuidString(folders[i].ID)); | 380 | getInventoryFolders(ref folders, folders[i].ID); |
379 | 381 | ||
380 | return folders; | 382 | return folders; |
381 | } | 383 | } |
382 | } | 384 | } |
diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml index 086fbc1..3c94d92 100644 --- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml | |||
@@ -1,7 +1,7 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | 1 | <?xml version="1.0" encoding="utf-8" ?> |
2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> | 2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> |
3 | <class name="OpenSim.Framework.AssetBase, OpenSim.Framework" table="Assets" lazy="false"> | 3 | <class name="OpenSim.Framework.AssetBase, OpenSim.Framework" table="Assets" lazy="false"> |
4 | <id name="FullID" column="UUID" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate"> | 4 | <id name="FullID" column="UUID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
7 | <property name="Type" type="SByte" /> | 7 | <property name="Type" type="SByte" /> |
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml index 4de0b7c..71a6602 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml | |||
@@ -1,13 +1,13 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | 1 | <?xml version="1.0" encoding="utf-8" ?> |
2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> | 2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> |
3 | <class name="OpenSim.Framework.InventoryFolderBase, OpenSim.Framework" table="InventoryFolders" lazy="false"> | 3 | <class name="OpenSim.Framework.InventoryFolderBase, OpenSim.Framework" table="InventoryFolders" lazy="false"> |
4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate"> | 4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
7 | <property name="Type" type="short" /> | 7 | <property name="Type" type="short" /> |
8 | <property name="Version" type="short" /> | 8 | <property name="Version" type="short" /> |
9 | <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 9 | <property name="ParentID" index="folder_parent_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
10 | <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 10 | <property name="Owner" index="folder_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
11 | <property name="Name" type="String" length="64" /> | 11 | <property name="Name" type="String" length="64" /> |
12 | </class> | 12 | </class> |
13 | </hibernate-mapping> \ No newline at end of file | 13 | </hibernate-mapping> \ No newline at end of file |
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml index c4e9b01..851f5fc 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml | |||
@@ -1,15 +1,15 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | 1 | <?xml version="1.0" encoding="utf-8" ?> |
2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> | 2 | <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> |
3 | <class name="OpenSim.Framework.InventoryItemBase, OpenSim.Framework" table="InventoryItems" lazy="false"> | 3 | <class name="OpenSim.Framework.InventoryItemBase, OpenSim.Framework" table="InventoryItems" lazy="false"> |
4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate"> | 4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
7 | <property name="InvType" type="int" /> | 7 | <property name="InvType" type="int" /> |
8 | <property name="AssetType" type="int" /> | 8 | <property name="AssetType" type="int" /> |
9 | <property name="AssetID" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 9 | <property name="AssetID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
10 | <property name="Folder" index="item_folder_id" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 10 | <property name="Folder" index="item_folder_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
11 | <property name="Owner" index="item_owner_id" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 11 | <property name="Owner" index="item_owner_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
12 | <property name="Creator" type="OpenSim.Data.NHibernate.LLUUIDString, OpenSim.Data.NHibernate" /> | 12 | <property name="Creator" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
13 | <property name="Name" type="String" length="64" /> | 13 | <property name="Name" type="String" length="64" /> |
14 | <property name="Description" type="String" length="64" /> | 14 | <property name="Description" type="String" length="64" /> |
15 | <property name="NextPermissions" type="UInt32" /> | 15 | <property name="NextPermissions" type="UInt32" /> |
diff --git a/OpenSim/Data/NHibernate/Types/LLUUIDType.cs b/OpenSim/Data/NHibernate/Types/LLUUIDType.cs index b8e5739..babc7fd 100644 --- a/OpenSim/Data/NHibernate/Types/LLUUIDType.cs +++ b/OpenSim/Data/NHibernate/Types/LLUUIDType.cs | |||
@@ -1,5 +1,6 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Data; | 2 | using System.Data; |
3 | using NHibernate; | ||
3 | using NHibernate.SqlTypes; | 4 | using NHibernate.SqlTypes; |
4 | using NHibernate.UserTypes; | 5 | using NHibernate.UserTypes; |
5 | using libsecondlife; | 6 | using libsecondlife; |
@@ -7,14 +8,14 @@ using libsecondlife; | |||
7 | namespace OpenSim.Data.NHibernate | 8 | namespace OpenSim.Data.NHibernate |
8 | { | 9 | { |
9 | [Serializable] | 10 | [Serializable] |
10 | public class LLUUIDString : IUserType | 11 | public class LLUUIDUserType: IUserType |
11 | { | 12 | { |
12 | public object Assemble(object cached, object owner) | 13 | public object Assemble(object cached, object owner) |
13 | { | 14 | { |
14 | return cached; | 15 | return cached; |
15 | } | 16 | } |
16 | 17 | ||
17 | bool IUserType.Equals(object uuid1, object uuid2) | 18 | public bool IUserType.Equals(object uuid1, object uuid2) |
18 | { | 19 | { |
19 | return uuid1.Equals(uuid2); | 20 | return uuid1.Equals(uuid2); |
20 | } | 21 | } |
@@ -55,9 +56,8 @@ namespace OpenSim.Data.NHibernate | |||
55 | 56 | ||
56 | public void NullSafeSet(System.Data.IDbCommand cmd, object obj, int index) | 57 | public void NullSafeSet(System.Data.IDbCommand cmd, object obj, int index) |
57 | { | 58 | { |
58 | LLUUID UUID = (LLUUID)obj; | 59 | LLUUID uuid = (LLUUID)obj; |
59 | ((IDataParameter)cmd.Parameters[index]).Value = UUID.ToString(); | 60 | ((IDataParameter)cmd.Parameters[index]).Value = uuid.ToString(); |
60 | System.Console.WriteLine("Setting UUID {0}", UUID.ToString()); | ||
61 | } | 61 | } |
62 | 62 | ||
63 | public object Replace(object original, object target, object owner) | 63 | public object Replace(object original, object target, object owner) |
@@ -72,7 +72,7 @@ namespace OpenSim.Data.NHibernate | |||
72 | 72 | ||
73 | public SqlType[] SqlTypes | 73 | public SqlType[] SqlTypes |
74 | { | 74 | { |
75 | get { return new SqlType [] { SqlTypeFactory.GetString(32) }; } | 75 | get { return new SqlType [] { NHibernateUtil.String.SqlType }; } |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } | 78 | } |