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/NHibernate/NHibernateInventoryData.cs | |
parent | NHibernate Inventory getting close, except for some of the (diff) | |
download | opensim-SC_OLD-750291447ea53f35f277ad9e79c09c77c8471b4d.zip opensim-SC_OLD-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.gz opensim-SC_OLD-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.bz2 opensim-SC_OLD-750291447ea53f35f277ad9e79c09c77c8471b4d.tar.xz |
changing around types a bit to make stuff more readable for
me.
Diffstat (limited to 'OpenSim/Data/NHibernate/NHibernateInventoryData.cs')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateInventoryData.cs | 64 |
1 files changed, 33 insertions, 31 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 | } |