diff options
author | Sean Dague | 2008-06-25 19:45:56 +0000 |
---|---|---|
committer | Sean Dague | 2008-06-25 19:45:56 +0000 |
commit | d1d846f23ff6e1c97940fb177b5a5a4fc7cfbd4c (patch) | |
tree | 5494a740a4f154a0bcfd3da2c48dfff688ec646e /OpenSim/Data | |
parent | Added support for terrain map to be serialised to xml(as base64 binary). usef... (diff) | |
download | opensim-SC_OLD-d1d846f23ff6e1c97940fb177b5a5a4fc7cfbd4c.zip opensim-SC_OLD-d1d846f23ff6e1c97940fb177b5a5a4fc7cfbd4c.tar.gz opensim-SC_OLD-d1d846f23ff6e1c97940fb177b5a5a4fc7cfbd4c.tar.bz2 opensim-SC_OLD-d1d846f23ff6e1c97940fb177b5a5a4fc7cfbd4c.tar.xz |
chugging away on nhibernate, more incremental process
Diffstat (limited to 'OpenSim/Data')
7 files changed, 49 insertions, 41 deletions
diff --git a/OpenSim/Data/NHibernate/NHibernateUserData.cs b/OpenSim/Data/NHibernate/NHibernateUserData.cs index 3b67d6e..bb11e59 100644 --- a/OpenSim/Data/NHibernate/NHibernateUserData.cs +++ b/OpenSim/Data/NHibernate/NHibernateUserData.cs | |||
@@ -91,8 +91,9 @@ namespace OpenSim.Data.NHibernate | |||
91 | { | 91 | { |
92 | user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; | 92 | user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; |
93 | } | 93 | } |
94 | catch (Exception) | 94 | catch (ObjectNotFoundException e) |
95 | { | 95 | { |
96 | user = null; | ||
96 | } | 97 | } |
97 | 98 | ||
98 | return (user != null); | 99 | return (user != null); |
@@ -102,8 +103,15 @@ namespace OpenSim.Data.NHibernate | |||
102 | { | 103 | { |
103 | UserProfileData user; | 104 | UserProfileData user; |
104 | // TODO: I'm sure I'll have to do something silly here | 105 | // TODO: I'm sure I'll have to do something silly here |
105 | user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; | 106 | try |
106 | user.CurrentAgent = GetAgentByUUID(uuid); | 107 | { |
108 | user = session.Load(typeof(UserProfileData), uuid) as UserProfileData; | ||
109 | user.CurrentAgent = GetAgentByUUID(uuid); | ||
110 | } | ||
111 | catch (ObjectNotFoundException e) | ||
112 | { | ||
113 | user = null; | ||
114 | } | ||
107 | 115 | ||
108 | return user; | 116 | return user; |
109 | } | 117 | } |
@@ -114,8 +122,6 @@ namespace OpenSim.Data.NHibernate | |||
114 | { | 122 | { |
115 | session.Save(profile); | 123 | session.Save(profile); |
116 | SetAgentData(profile.ID, profile.CurrentAgent); | 124 | SetAgentData(profile.ID, profile.CurrentAgent); |
117 | // TODO: save agent | ||
118 | session.Transaction.Commit(); | ||
119 | } | 125 | } |
120 | else | 126 | else |
121 | { | 127 | { |
@@ -132,12 +138,14 @@ namespace OpenSim.Data.NHibernate | |||
132 | } | 138 | } |
133 | else | 139 | else |
134 | { | 140 | { |
135 | UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData; | 141 | try |
136 | if (old != null) | ||
137 | { | 142 | { |
143 | UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData; | ||
138 | session.Delete(old); | 144 | session.Delete(old); |
139 | } | 145 | } |
140 | 146 | catch (ObjectNotFoundException e) | |
147 | { | ||
148 | } | ||
141 | session.Save(agent); | 149 | session.Save(agent); |
142 | } | 150 | } |
143 | 151 | ||
@@ -148,7 +156,6 @@ namespace OpenSim.Data.NHibernate | |||
148 | { | 156 | { |
149 | session.Update(profile); | 157 | session.Update(profile); |
150 | SetAgentData(profile.ID, profile.CurrentAgent); | 158 | SetAgentData(profile.ID, profile.CurrentAgent); |
151 | session.Transaction.Commit(); | ||
152 | return true; | 159 | return true; |
153 | } | 160 | } |
154 | else | 161 | else |
@@ -161,23 +168,20 @@ namespace OpenSim.Data.NHibernate | |||
161 | 168 | ||
162 | override public void AddNewUserAgent(UserAgentData agent) | 169 | override public void AddNewUserAgent(UserAgentData agent) |
163 | { | 170 | { |
164 | UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData; | 171 | try |
165 | |||
166 | if (old == null) | ||
167 | { | 172 | { |
168 | session.Save(agent); | 173 | UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData; |
169 | session.Transaction.Commit(); | 174 | session.Delete(old); |
170 | } | 175 | } |
171 | else | 176 | catch (ObjectNotFoundException e) |
172 | { | 177 | { |
173 | UpdateUserAgent(agent); | ||
174 | } | 178 | } |
179 | session.Save(agent); | ||
175 | } | 180 | } |
176 | 181 | ||
177 | public void UpdateUserAgent(UserAgentData agent) | 182 | public void UpdateUserAgent(UserAgentData agent) |
178 | { | 183 | { |
179 | session.Update(agent); | 184 | session.Update(agent); |
180 | session.Transaction.Commit(); | ||
181 | } | 185 | } |
182 | 186 | ||
183 | override public UserAgentData GetAgentByUUID(LLUUID uuid) | 187 | override public UserAgentData GetAgentByUUID(LLUUID uuid) |
@@ -254,16 +258,22 @@ namespace OpenSim.Data.NHibernate | |||
254 | { | 258 | { |
255 | AvatarAppearance appearance; | 259 | AvatarAppearance appearance; |
256 | // TODO: I'm sure I'll have to do something silly here | 260 | // TODO: I'm sure I'll have to do something silly here |
257 | appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance; | 261 | try { |
258 | 262 | appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance; | |
263 | } catch (ObjectNotFoundException e) { | ||
264 | appearance = null; | ||
265 | } | ||
259 | return appearance; | 266 | return appearance; |
260 | } | 267 | } |
261 | 268 | ||
262 | private bool ExistsAppearance(LLUUID uuid) | 269 | private bool ExistsAppearance(LLUUID uuid) |
263 | { | 270 | { |
264 | AvatarAppearance appearance; | 271 | AvatarAppearance appearance; |
265 | 272 | try { | |
266 | appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance; | 273 | appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance; |
274 | } catch (ObjectNotFoundException e) { | ||
275 | appearance = null; | ||
276 | } | ||
267 | 277 | ||
268 | return (appearance == null) ? false : true; | 278 | return (appearance == null) ? false : true; |
269 | } | 279 | } |
@@ -271,19 +281,17 @@ namespace OpenSim.Data.NHibernate | |||
271 | 281 | ||
272 | public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) | 282 | public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) |
273 | { | 283 | { |
284 | if (appearance == null) | ||
285 | return; | ||
286 | |||
274 | bool exists = ExistsAppearance(user); | 287 | bool exists = ExistsAppearance(user); |
275 | 288 | if (exists) | |
276 | using (ITransaction transaction = session.BeginTransaction()) | ||
277 | { | 289 | { |
278 | if (exists) | 290 | session.Update(appearance); |
279 | { | 291 | } |
280 | session.Update(appearance); | 292 | else |
281 | } | 293 | { |
282 | else | 294 | session.Save(appearance); |
283 | { | ||
284 | session.Save(appearance); | ||
285 | } | ||
286 | transaction.Commit(); | ||
287 | } | 295 | } |
288 | } | 296 | } |
289 | 297 | ||
diff --git a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml index b853c0e..60fc146 100644 --- a/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/AssetBase.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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="true"> | 3 | <class name="OpenSim.Framework.AssetBase, OpenSim.Framework" table="Assets" lazy="false"> |
4 | <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> | 4 | <id name="FullID" column="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml index aa5ed35..6d918fe 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryFolderBase.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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="true"> | 3 | <class name="OpenSim.Framework.InventoryFolderBase, OpenSim.Framework" table="InventoryFolders" lazy="false"> |
4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, 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> |
diff --git a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml index 3b76fa6..f1b4007 100644 --- a/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/InventoryItemBase.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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="true"> | 3 | <class name="OpenSim.Framework.InventoryItemBase, OpenSim.Framework" table="InventoryItems" lazy="false"> |
4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, 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> |
diff --git a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml index 9100112..718cb98 100644 --- a/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/UserAgentData.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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.UserAgentData, OpenSim.Framework" table="UserAgents" lazy="true"> | 3 | <class name="OpenSim.Framework.UserAgentData, OpenSim.Framework" table="UserAgents" lazy="false"> |
4 | <id name="ProfileID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> | 4 | <id name="ProfileID" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
diff --git a/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml index d857764..30f39ef 100644 --- a/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/UserAppearance.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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.AvatarAppearance, OpenSim.Framework" table="UserAppearances" lazy="true"> | 3 | <class name="OpenSim.Framework.AvatarAppearance, OpenSim.Framework" table="UserAppearances" lazy="false"> |
4 | <id name="Owner" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> | 4 | <id name="Owner" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate"> |
5 | <generator class="assigned" /> | 5 | <generator class="assigned" /> |
6 | </id> | 6 | </id> |
@@ -30,8 +30,8 @@ | |||
30 | <property name="UnderPantsAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 30 | <property name="UnderPantsAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
31 | <property name="SkirtItem" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 31 | <property name="SkirtItem" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
32 | <property name="SkirtAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> | 32 | <property name="SkirtAsset" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" /> |
33 | <property name="Texture" type="binary" /> | 33 | <property name="Texture" type="Binary" /> |
34 | <property name="VisualParams" type="binary" /> | 34 | <property name="VisualParams" type="Binary" /> |
35 | <property name="Serial" type="int" /> | 35 | <property name="Serial" type="Int32" /> |
36 | </class> | 36 | </class> |
37 | </hibernate-mapping> \ No newline at end of file | 37 | </hibernate-mapping> \ No newline at end of file |
diff --git a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml index 925465a..4003628 100644 --- a/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml +++ b/OpenSim/Data/NHibernate/Resources/UserProfileData.hbm.xml | |||
@@ -1,6 +1,6 @@ | |||
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.UserProfileData, OpenSim.Framework" table="UserProfiles" lazy="true"> | 3 | <class name="OpenSim.Framework.UserProfileData, OpenSim.Framework" table="UserProfiles" lazy="false"> |
4 | <id name="ID" type="OpenSim.Data.NHibernate.LLUUIDUserType, 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> |