From 40f34aeffd64e2aa81cecb2e861f60d6e8886198 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sun, 11 Jan 2009 18:24:16 +0000 Subject: Thank you kindly, Tlaukkan (Tommil) for a patch that: Fixed all NHibernate unit tests by implementing missing persistency methods, tables, columns and fixing bugs in the existing implementation. Two minor changes to classes outside NHibernate module: Added Scene instantiation for SceneObjectGroup in OpenSim.Data.Tests.BasicRegionTest as this was required by the NHibernate persistency. In the process added also mock constructor to Scene which only populates RegionInfo in the scene which is used by ScenePart.RegionUUID. NHibernate module is still in experimental state and has not been tested at opensim region or ugaim runtime configuration. Adding unit tests to build is not yet advisable nor using NHibernate module in any production setup. --- OpenSim/Data/NHibernate/NHibernateRegionData.cs | 37 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data/NHibernate/NHibernateRegionData.cs') diff --git a/OpenSim/Data/NHibernate/NHibernateRegionData.cs b/OpenSim/Data/NHibernate/NHibernateRegionData.cs index 871013b..b8b1863 100644 --- a/OpenSim/Data/NHibernate/NHibernateRegionData.cs +++ b/OpenSim/Data/NHibernate/NHibernateRegionData.cs @@ -67,11 +67,31 @@ namespace OpenSim.Data.NHibernate public void StoreRegionSettings(RegionSettings rs) { + RegionSettings oldRegionSettings = (RegionSettings)manager.Load(typeof(RegionSettings), rs.RegionUUID); + if (oldRegionSettings != null) + { + manager.Update(rs); + } + else + { + manager.Save(rs); + } } public RegionSettings LoadRegionSettings(UUID regionUUID) { - return null; + RegionSettings regionSettings = (RegionSettings) manager.Load(typeof(RegionSettings), regionUUID); + + if (regionSettings == null) + { + regionSettings = new RegionSettings(); + regionSettings.RegionUUID = regionUUID; + manager.Save(regionSettings); + } + + regionSettings.OnSave += StoreRegionSettings; + + return regionSettings; } // This looks inefficient, but it turns out that it isn't @@ -84,7 +104,7 @@ namespace OpenSim.Data.NHibernate if (old != null) { m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID); - manager.Update(old); + manager.Update(p); } else { @@ -108,7 +128,7 @@ namespace OpenSim.Data.NHibernate if (old != null) { m_log.InfoFormat("[NHIBERNATE] updating terrain {0}", t.RegionID); - manager.Update(old); + manager.Update(t); } else { @@ -131,6 +151,14 @@ namespace OpenSim.Data.NHibernate /// the region UUID public void StoreObject(SceneObjectGroup obj, UUID regionUUID) { + uint flags = obj.RootPart.GetEffectiveObjectFlags(); + + // Eligibility check + if ((flags & (uint)PrimFlags.Temporary) != 0) + return; + if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) + return; + try { foreach (SceneObjectPart part in obj.Children.Values) @@ -199,7 +227,8 @@ namespace OpenSim.Data.NHibernate ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); criteria.Add(Expression.Eq("RegionID", regionUUID)); - criteria.AddOrder( Order.Asc("ParentID") ); + criteria.AddOrder(Order.Asc("ParentID")); + criteria.AddOrder(Order.Asc("LinkNum")); foreach (SceneObjectPart p in criteria.List()) { // root part -- cgit v1.1