diff options
author | Charles Krinke | 2009-01-11 18:24:16 +0000 |
---|---|---|
committer | Charles Krinke | 2009-01-11 18:24:16 +0000 |
commit | 40f34aeffd64e2aa81cecb2e861f60d6e8886198 (patch) | |
tree | 5d0059eb7aa70799c8239bb273efc997138cabb5 /OpenSim/Data/NHibernate/NHibernateRegionData.cs | |
parent | Thank you kindly, Tlaukkan (Tommil) for a patch that: (diff) | |
download | opensim-SC-40f34aeffd64e2aa81cecb2e861f60d6e8886198.zip opensim-SC-40f34aeffd64e2aa81cecb2e861f60d6e8886198.tar.gz opensim-SC-40f34aeffd64e2aa81cecb2e861f60d6e8886198.tar.bz2 opensim-SC-40f34aeffd64e2aa81cecb2e861f60d6e8886198.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/NHibernate/NHibernateRegionData.cs | 37 |
1 files changed, 33 insertions, 4 deletions
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 | |||
67 | 67 | ||
68 | public void StoreRegionSettings(RegionSettings rs) | 68 | public void StoreRegionSettings(RegionSettings rs) |
69 | { | 69 | { |
70 | RegionSettings oldRegionSettings = (RegionSettings)manager.Load(typeof(RegionSettings), rs.RegionUUID); | ||
71 | if (oldRegionSettings != null) | ||
72 | { | ||
73 | manager.Update(rs); | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | manager.Save(rs); | ||
78 | } | ||
70 | } | 79 | } |
71 | 80 | ||
72 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 81 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
73 | { | 82 | { |
74 | return null; | 83 | RegionSettings regionSettings = (RegionSettings) manager.Load(typeof(RegionSettings), regionUUID); |
84 | |||
85 | if (regionSettings == null) | ||
86 | { | ||
87 | regionSettings = new RegionSettings(); | ||
88 | regionSettings.RegionUUID = regionUUID; | ||
89 | manager.Save(regionSettings); | ||
90 | } | ||
91 | |||
92 | regionSettings.OnSave += StoreRegionSettings; | ||
93 | |||
94 | return regionSettings; | ||
75 | } | 95 | } |
76 | 96 | ||
77 | // This looks inefficient, but it turns out that it isn't | 97 | // This looks inefficient, but it turns out that it isn't |
@@ -84,7 +104,7 @@ namespace OpenSim.Data.NHibernate | |||
84 | if (old != null) | 104 | if (old != null) |
85 | { | 105 | { |
86 | m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID); | 106 | m_log.InfoFormat("[NHIBERNATE] updating object {0}", p.UUID); |
87 | manager.Update(old); | 107 | manager.Update(p); |
88 | } | 108 | } |
89 | else | 109 | else |
90 | { | 110 | { |
@@ -108,7 +128,7 @@ namespace OpenSim.Data.NHibernate | |||
108 | if (old != null) | 128 | if (old != null) |
109 | { | 129 | { |
110 | m_log.InfoFormat("[NHIBERNATE] updating terrain {0}", t.RegionID); | 130 | m_log.InfoFormat("[NHIBERNATE] updating terrain {0}", t.RegionID); |
111 | manager.Update(old); | 131 | manager.Update(t); |
112 | } | 132 | } |
113 | else | 133 | else |
114 | { | 134 | { |
@@ -131,6 +151,14 @@ namespace OpenSim.Data.NHibernate | |||
131 | /// <param name="regionUUID">the region UUID</param> | 151 | /// <param name="regionUUID">the region UUID</param> |
132 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) | 152 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) |
133 | { | 153 | { |
154 | uint flags = obj.RootPart.GetEffectiveObjectFlags(); | ||
155 | |||
156 | // Eligibility check | ||
157 | if ((flags & (uint)PrimFlags.Temporary) != 0) | ||
158 | return; | ||
159 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | ||
160 | return; | ||
161 | |||
134 | try | 162 | try |
135 | { | 163 | { |
136 | foreach (SceneObjectPart part in obj.Children.Values) | 164 | foreach (SceneObjectPart part in obj.Children.Values) |
@@ -199,7 +227,8 @@ namespace OpenSim.Data.NHibernate | |||
199 | 227 | ||
200 | ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); | 228 | ICriteria criteria = manager.GetSession().CreateCriteria(typeof(SceneObjectPart)); |
201 | criteria.Add(Expression.Eq("RegionID", regionUUID)); | 229 | criteria.Add(Expression.Eq("RegionID", regionUUID)); |
202 | criteria.AddOrder( Order.Asc("ParentID") ); | 230 | criteria.AddOrder(Order.Asc("ParentID")); |
231 | criteria.AddOrder(Order.Asc("LinkNum")); | ||
203 | foreach (SceneObjectPart p in criteria.List()) | 232 | foreach (SceneObjectPart p in criteria.List()) |
204 | { | 233 | { |
205 | // root part | 234 | // root part |