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.
0.6.2-post-fixes
Charles Krinke 2009-01-11 18:24:16 +00:00
parent 16561bd528
commit 40f34aeffd
19 changed files with 763 additions and 131 deletions

View File

@ -0,0 +1,106 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Data;
using OpenMetaverse;
using OpenSim.Framework;
using NHibernate;
using NHibernate.SqlTypes;
using NHibernate.UserTypes;
using System.Drawing;
namespace OpenSim.Data.NHibernate
{
[Serializable]
public class ColorUserType : IUserType
{
public object Assemble(object cached, object owner)
{
return cached;
}
bool IUserType.Equals(object color1, object color2)
{
return color1.Equals(color2);
}
public object DeepCopy(object color)
{
return color;
}
public object Disassemble(object color)
{
return color;
}
public int GetHashCode(object color)
{
return (color == null) ? 0 : color.GetHashCode();
}
public bool IsMutable
{
get { return false; }
}
public object NullSafeGet(IDataReader rs, string[] names, object owner)
{
Color color=Color.Empty;
int ord = rs.GetOrdinal(names[0]);
if (!rs.IsDBNull(ord))
{
color = Color.FromArgb(rs.GetInt32(ord));
}
return color;
}
public void NullSafeSet(IDbCommand cmd, object obj, int index)
{
Color color = (Color)obj;
((IDataParameter)cmd.Parameters[index]).Value = color.ToArgb();
}
public object Replace(object original, object target, object owner)
{
return original;
}
public Type ReturnedType
{
get { return typeof(Color); }
}
public SqlType[] SqlTypes
{
get { return new SqlType [] { NHibernateUtil.Int32.SqlType }; }
}
}
}

View File

@ -344,7 +344,14 @@ namespace OpenSim.Data.NHibernate
// See IInventoryDataPlugin
public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
{
if (parentID == UUID.Zero)
{
// Zero UUID is not a real parent folder.
return new List<InventoryFolderBase>();
}
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
getInventoryFolders(ref folders, parentID);
for (int i = 0; i < folders.Count; i++)

View File

@ -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
/// <param name="regionUUID">the region UUID</param>
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

View File

@ -97,11 +97,18 @@ namespace OpenSim.Data.NHibernate
override public void AddNewUserProfile(UserProfileData profile)
{
if (profile.ID == UUID.Zero)
{
m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} with zero UUID, throwintg exception as this is programming error ", profile.FirstName, profile.SurName);
return;
}
if (!ExistsUser(profile.ID))
{
m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID);
manager.Save(profile);
SetAgentData(profile.ID, profile.CurrentAgent);
// Agent should not be saved according to BasicUserTest.T015_UserPersistency()
// SetAgentData(profile.ID, profile.CurrentAgent);
}
else
@ -131,7 +138,8 @@ namespace OpenSim.Data.NHibernate
if (ExistsUser(profile.ID))
{
manager.Update(profile);
SetAgentData(profile.ID, profile.CurrentAgent);
// Agent should not be saved according to BasicUserTest.T015_UserPersistency()
// SetAgentData(profile.ID, profile.CurrentAgent);
return true;
}
else
@ -144,6 +152,19 @@ namespace OpenSim.Data.NHibernate
override public void AddNewUserAgent(UserAgentData agent)
{
if (agent.ProfileID == UUID.Zero)
{
m_log.ErrorFormat("[NHIBERNATE] Attempted to add new user agent with zero user id. Agent session id: {0}", agent.SessionID);
return;
}
if (agent.SessionID == UUID.Zero)
{
m_log.ErrorFormat("[NHIBERNATE] Attempted to add new user agent with zero session id. User profile id: {0}", agent.SessionID);
return;
}
UserAgentData old = (UserAgentData)manager.Load(typeof(UserAgentData), agent.ProfileID);
if (old != null)
{
@ -214,12 +235,163 @@ namespace OpenSim.Data.NHibernate
}
// TODO: actually implement these
public override void StoreWebLoginKey(UUID agentID, UUID webLoginKey) { return; }
public override void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) { return; }
public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { return; }
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { return; }
public override List<FriendListItem> GetUserFriendList(UUID friendlistowner) { return new List<FriendListItem>(); }
public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) { return new Dictionary<UUID, FriendRegionInfo>(); }
public override void StoreWebLoginKey(UUID agentID, UUID webLoginKey)
{
UserProfileData user=GetUserByUUID(agentID);
user.WebLoginKey = webLoginKey;
UpdateUserProfile(user);
return;
}
public override void AddNewUserFriend(UUID ownerId, UUID friendId, uint perms)
{
if (!FriendRelationExists(ownerId,friendId))
{
manager.Save(new UserFriend(UUID.Random(), ownerId, friendId, perms));
}
if (!FriendRelationExists(friendId, ownerId))
{
manager.Save(new UserFriend(UUID.Random(), friendId, ownerId, perms));
}
return;
}
private bool FriendRelationExists(UUID ownerId, UUID friendId)
{
using (ISession session = manager.GetSession())
{
ICriteria criteria = session.CreateCriteria(typeof(UserFriend));
criteria.Add(Expression.Eq("OwnerID", ownerId));
criteria.Add(Expression.Eq("FriendID", friendId));
return criteria.List().Count > 0;
}
}
public override void RemoveUserFriend(UUID ownerId, UUID friendId)
{
using (ISession session = manager.GetSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
{
ICriteria criteria = session.CreateCriteria(typeof(UserFriend));
criteria.Add(Expression.Eq("OwnerID", ownerId));
criteria.Add(Expression.Eq("FriendID", friendId));
foreach (UserFriend userFriend in criteria.List())
{
session.Delete(userFriend);
}
}
{
ICriteria criteria = session.CreateCriteria(typeof(UserFriend));
criteria.Add(Expression.Eq("OwnerID", friendId));
criteria.Add(Expression.Eq("FriendID", ownerId));
foreach (UserFriend userFriend in criteria.List())
{
session.Delete(userFriend);
}
}
transaction.Commit();
}
}
return;
}
public override void UpdateUserFriendPerms(UUID ownerId, UUID friendId, uint perms)
{
using (ISession session = manager.GetSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
{
ICriteria criteria = session.CreateCriteria(typeof(UserFriend));
criteria.Add(Expression.Eq("OwnerID", ownerId));
criteria.Add(Expression.Eq("FriendID", friendId));
foreach (UserFriend userFriend in criteria.List())
{
userFriend.FriendPermissions = perms;
session.Update(userFriend);
}
}
transaction.Commit();
}
}
return;
}
public override List<FriendListItem> GetUserFriendList(UUID ownerId)
{
List<FriendListItem> friendList=new List<FriendListItem>();
Dictionary<UUID, FriendListItem> friendListItemDictionary = new Dictionary<UUID, FriendListItem>();
using (ISession session = manager.GetSession())
{
ICriteria criteria = session.CreateCriteria(typeof(UserFriend));
criteria.Add(Expression.Or(
Expression.Eq("OwnerID", ownerId),
Expression.Eq("FriendID", ownerId)
));
foreach (UserFriend userFriend in criteria.List())
{
if (userFriend.OwnerID == ownerId)
{
FriendListItem friendListItem = new FriendListItem();
friendListItem.FriendListOwner = userFriend.OwnerID;
friendListItem.Friend = userFriend.FriendID;
friendListItem.FriendPerms = userFriend.FriendPermissions;
friendListItemDictionary.Add(userFriend.FriendID, friendListItem);
friendList.Add(friendListItem);
}
}
// Reading permissions to other direction
foreach (UserFriend userFriend in criteria.List())
{
if (userFriend.FriendID == ownerId)
{
//Ignore if there is no reverse relation existing.
//if (friendListItemDictionary.ContainsKey(userFriend.OwnerID))
{
FriendListItem friendListItem = friendListItemDictionary[userFriend.OwnerID];
friendListItem.FriendListOwnerPerms = userFriend.FriendPermissions;
}
}
}
}
return friendList;
}
public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> friendsIds)
{
Dictionary<UUID, FriendRegionInfo> friendRegionInfos=new Dictionary<UUID, FriendRegionInfo>();
foreach(UUID friendId in friendsIds)
{
UserAgentData agent=GetAgentByUUID(friendId);
if (agent != null)
{
FriendRegionInfo fri = new FriendRegionInfo();
fri.isOnline = agent.AgentOnline;
fri.regionHandle = agent.Handle;
friendRegionInfos[friendId] = fri;
}
}
return friendRegionInfos;
}
public override bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return true; }
public override bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return true; }

View File

@ -1,8 +1,15 @@
CREATE TABLE `Prims` (
`UUID` char(36) NOT NULL default '',
`RegionID` char(36) default NULL,
`GroupID` char(36) default NULL,
`ParentID` int(11) default NULL,
`CreationDate` int(11) default NULL,
`Name` varchar(255) default NULL,
`ParentUUID` char(36) default NULL,
`OwnerID` char(36) default NULL,
`LastOwnerID` char(36) default NULL,
`CreatorID` char(36) default NULL,
`CreationDate` int(11) default NULL,
`LinkNum` int(11) default NULL,
`Name` varchar(255) default NULL,
`Text` varchar(255) default NULL,
`Description` varchar(255) default NULL,
`SitName` varchar(255) default NULL,
@ -13,43 +20,43 @@ CREATE TABLE `Prims` (
`GroupMask` int(11) default NULL,
`EveryoneMask` int(11) default NULL,
`BaseMask` int(11) default NULL,
`PositionX` float default NULL,
`PositionY` float default NULL,
`PositionZ` float default NULL,
`GroupPositionX` float default NULL,
`GroupPositionY` float default NULL,
`GroupPositionZ` float default NULL,
`VelocityX` float default NULL,
`VelocityY` float default NULL,
`VelocityZ` float default NULL,
`AngularVelocityX` float default NULL,
`AngularVelocityY` float default NULL,
`AngularVelocityZ` float default NULL,
`AccelerationX` float default NULL,
`AccelerationY` float default NULL,
`AccelerationZ` float default NULL,
`RotationX` float default NULL,
`RotationY` float default NULL,
`RotationZ` float default NULL,
`RotationW` float default NULL,
`SitTargetOffsetX` float default NULL,
`SitTargetOffsetY` float default NULL,
`SitTargetOffsetZ` float default NULL,
`SitTargetOrientW` float default NULL,
`SitTargetOrientX` float default NULL,
`SitTargetOrientY` float default NULL,
`SitTargetOrientZ` float default NULL,
`UUID` char(36) NOT NULL default '',
`RegionID` char(36) default NULL,
`CreatorID` char(36) default NULL,
`OwnerID` char(36) default NULL,
`GroupID` char(36) default NULL,
`LastOwnerID` char(36) default NULL,
`Material` int(1) default NULL,
`ScriptAccessPin` int(11) default NULL,
`TextureAnimation` blob,
`ParticleSystem` blob,
`ClickAction` int(1) default NULL,
`Color` int(11) default NULL,
`PositionX` double default NULL,
`PositionY` double default NULL,
`PositionZ` double default NULL,
`GroupPositionX` double default NULL,
`GroupPositionY` double default NULL,
`GroupPositionZ` double default NULL,
`VelocityX` double default NULL,
`VelocityY` double default NULL,
`VelocityZ` double default NULL,
`AngularVelocityX` double default NULL,
`AngularVelocityY` double default NULL,
`AngularVelocityZ` double default NULL,
`AccelerationX` double default NULL,
`AccelerationY` double default NULL,
`AccelerationZ` double default NULL,
`RotationX` double default NULL,
`RotationY` double default NULL,
`RotationZ` double default NULL,
`RotationW` double default NULL,
`SitTargetOffsetX` double default NULL,
`SitTargetOffsetY` double default NULL,
`SitTargetOffsetZ` double default NULL,
`SitTargetOrientW` double default NULL,
`SitTargetOrientX` double default NULL,
`SitTargetOrientY` double default NULL,
`SitTargetOrientZ` double default NULL,
-- this is the shape
`Shape` int(11) default NULL,
`ScaleX` float default NULL,
`ScaleY` float default NULL,
`ScaleZ` float default NULL,
`ScaleX` double default NULL,
`ScaleY` double default NULL,
`ScaleZ` double default NULL,
`PCode` int(11) default NULL,
`PathBegin` int(11) default NULL,
`PathEnd` int(11) default NULL,
@ -77,3 +84,4 @@ CREATE TABLE `Prims` (
KEY `prims_parentuuid` (`ParentUUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -1,12 +1,12 @@
START TRANSACTION;
CREATE TABLE `UserAgents` (
`ProfileID` varchar(255) NOT NULL,
`ProfileID` varchar(36) NOT NULL,
`AgentIP` varchar(24) default NULL,
`AgentPort` int(11) default NULL,
`AgentOnline` tinyint(1) default NULL,
`SessionID` varchar(255) default NULL,
`SecureSessionID` varchar(255) default NULL,
`SessionID` varchar(36) default NULL,
`SecureSessionID` varchar(36) default NULL,
`InitialRegion` varchar(255) default NULL,
`Region` varchar(255) default NULL,
`LoginTime` int(11) default NULL,
@ -15,16 +15,21 @@ CREATE TABLE `UserAgents` (
`PositionX` float default NULL,
`PositionY` float default NULL,
`PositionZ` float default NULL,
`LookAtX` float default NULL,
`LookAtY` float default NULL,
`LookAtZ` float default NULL,
PRIMARY KEY (`ProfileID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `UserProfiles` (
`ID` varchar(255) NOT NULL,
`ID` varchar(36) NOT NULL,
`WebLoginKey` varchar(36) default NULL,
`FirstName` varchar(32) default NULL,
`SurName` varchar(32) default NULL,
`Email` varchar(250) default NULL,
`PasswordHash` varchar(32) default NULL,
`PasswordSalt` varchar(32) default NULL,
`WebLoginKey` varchar(255) default NULL,
`HomeRegionID` varchar(36) default NULL,
`HomeRegionX` int(11) default NULL,
`HomeRegionY` int(11) default NULL,
`HomeLocationX` float default NULL,
@ -35,50 +40,67 @@ CREATE TABLE `UserProfiles` (
`HomeLookAtZ` float default NULL,
`Created` int(11) default NULL,
`LastLogin` int(11) default NULL,
`RootInventoryFolderID` varchar(255) default NULL,
`UserInventoryURI` varchar(255) default NULL,
`UserAssetURI` varchar(255) default NULL,
`Image` varchar(255) default NULL,
`FirstLifeImage` varchar(255) default NULL,
`AboutText` varchar(255) default NULL,
`FirstLifeAboutText` varchar(255) default NULL,
`Image` varchar(36) default NULL,
`FirstLifeImage` varchar(36) default NULL,
`AboutText` text default NULL,
`FirstLifeAboutText` text default NULL,
`CanDoMask` int(11) default NULL,
`WantDoMask` int(11) default NULL,
`UserFlags` int(11) default NULL,
`GodLevel` int(11) default NULL,
`CustomType` varchar(32) default NULL,
`Partner` varchar(36) default NULL,
`RootInventoryFolderID` varchar(36) default NULL,
PRIMARY KEY (`ID`),
KEY `user_surname` (`SurName`),
KEY `user_firstname` (`FirstName`)
INDEX `UserSurnameIndex` (`SurName`),
INDEX `UserFirstNameIndex` (`FirstName`),
UNIQUE INDEX `UserFullNameIndex` (`SurName`,`FirstName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `UserAppearances` (
`Owner` varchar(255) NOT NULL,
`BodyItem` varchar(255) default NULL,
`BodyAsset` varchar(255) default NULL,
`SkinItem` varchar(255) default NULL,
`SkinAsset` varchar(255) default NULL,
`HairItem` varchar(255) default NULL,
`HairAsset` varchar(255) default NULL,
`EyesItem` varchar(255) default NULL,
`EyesAsset` varchar(255) default NULL,
`ShirtItem` varchar(255) default NULL,
`ShirtAsset` varchar(255) default NULL,
`PantsItem` varchar(255) default NULL,
`PantsAsset` varchar(255) default NULL,
`ShoesItem` varchar(255) default NULL,
`ShoesAsset` varchar(255) default NULL,
`SocksItem` varchar(255) default NULL,
`SocksAsset` varchar(255) default NULL,
`JacketItem` varchar(255) default NULL,
`JacketAsset` varchar(255) default NULL,
`GlovesItem` varchar(255) default NULL,
`GlovesAsset` varchar(255) default NULL,
`UnderShirtItem` varchar(255) default NULL,
`UnderShirtAsset` varchar(255) default NULL,
`UnderPantsItem` varchar(255) default NULL,
`UnderPantsAsset` varchar(255) default NULL,
`SkirtItem` varchar(255) default NULL,
`SkirtAsset` varchar(255) default NULL,
`Owner` varchar(36) NOT NULL,
`BodyItem` varchar(36) default NULL,
`BodyAsset` varchar(36) default NULL,
`SkinItem` varchar(36) default NULL,
`SkinAsset` varchar(36) default NULL,
`HairItem` varchar(36) default NULL,
`HairAsset` varchar(36) default NULL,
`EyesItem` varchar(36) default NULL,
`EyesAsset` varchar(36) default NULL,
`ShirtItem` varchar(36) default NULL,
`ShirtAsset` varchar(36) default NULL,
`PantsItem` varchar(36) default NULL,
`PantsAsset` varchar(36) default NULL,
`ShoesItem` varchar(36) default NULL,
`ShoesAsset` varchar(36) default NULL,
`SocksItem` varchar(36) default NULL,
`SocksAsset` varchar(36) default NULL,
`JacketItem` varchar(36) default NULL,
`JacketAsset` varchar(36) default NULL,
`GlovesItem` varchar(36) default NULL,
`GlovesAsset` varchar(36) default NULL,
`UnderShirtItem` varchar(36) default NULL,
`UnderShirtAsset` varchar(36) default NULL,
`UnderPantsItem` varchar(36) default NULL,
`UnderPantsAsset` varchar(36) default NULL,
`SkirtItem` varchar(36) default NULL,
`SkirtAsset` varchar(36) default NULL,
`Texture` longblob,
`VisualParams` longblob,
`Serial` int(11) default NULL,
`AvatarHeight` float default NULL,
PRIMARY KEY (`Owner`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;
CREATE TABLE `UserFriends` (
`UserFriendID` VARCHAR(36) NOT NULL,
`OwnerID` VARCHAR(36) NOT NULL,
`FriendID` VARCHAR(36) NOT NULL,
`FriendPermissions` INT(11) NOT NULL,
PRIMARY KEY (`UserFriendID`),
UNIQUE INDEX (`OwnerID`,`FriendID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -1,26 +1,78 @@
BEGIN;
CREATE TABLE `PrimItems` (
`ItemID` char(36) NOT NULL default '',
`GroupID` char(36) default NULL,
`PrimID` char(36) default NULL,
`ParentFolderID` char(36) default NULL,
`AssetID` char(36) default NULL,
`OwnerID` char(36) default NULL,
`LastOwnerID` char(36) default NULL,
`CreatorID` char(36) default NULL,
`CreationDate` bigint(20) default NULL,
`InvType` int(11) default NULL,
`Name` varchar(255) default NULL,
`Description` varchar(255) default NULL,
`CreationDate` bigint(20) default NULL,
`NextPermissions` int(11) default NULL,
`CurrentPermissions` int(11) default NULL,
`BasePermissions` int(11) default NULL,
`EveryonePermissions` int(11) default NULL,
`GroupPermissions` int(11) default NULL,
`Flags` int(11) NOT NULL default '0',
`ItemID` char(36) NOT NULL default '',
`PrimID` char(36) default NULL,
`AssetID` char(36) default NULL,
`ParentFolderID` char(36) default NULL,
`CreatorID` char(36) default NULL,
`OwnerID` char(36) default NULL,
`GroupID` char(36) default NULL,
`LastOwnerID` char(36) default NULL,
PRIMARY KEY (`ItemID`),
KEY `primitems_primid` (`PrimID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;
CREATE TABLE RegionSettings (
`RegionID` char(36) default NULL,
`BlockTerraform` bit(1) default NULL,
`BlockFly` bit(1) default NULL,
`AllowDamage` bit(1) default NULL,
`RestrictPushing` bit(1) default NULL,
`AllowLandResell` bit(1) default NULL,
`AllowLandJoinDivide` bit(1) default NULL,
`BlockShowInSearch` bit(1) default NULL,
`AgentLimit` int(11) default NULL,
`ObjectBonus` double default NULL,
`Maturity` int(11) default NULL,
`DisableScripts` bit(1) default NULL,
`DisableCollisions` bit(1) default NULL,
`DisablePhysics` bit(1) default NULL,
`TerrainTexture1` char(36) default NULL,
`TerrainTexture2` char(36) default NULL,
`TerrainTexture3` char(36) default NULL,
`TerrainTexture4` char(36) default NULL,
`Elevation1NW` double default NULL,
`Elevation2NW` double default NULL,
`Elevation1NE` double default NULL,
`Elevation2NE` double default NULL,
`Elevation1SE` double default NULL,
`Elevation2SE` double default NULL,
`Elevation1SW` double default NULL,
`Elevation2SW` double default NULL,
`WaterHeight` double default NULL,
`TerrainRaiseLimit` double default NULL,
`TerrainLowerLimit` double default NULL,
`UseEstateSun` bit(1) default NULL,
`Sandbox` bit(1) default NULL,
`SunVectorX` double default NULL,
`SunVectorY` double default NULL,
`SunVectorZ` double default NULL,
`FixedSun` bit(1) default NULL,
`SunPosition` double default NULL,
`Covenant` char(36) default NULL,
PRIMARY KEY (RegionID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
COMMIT;

View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OpenSim.Framework.RegionSettings, OpenSim.Framework" table="RegionSettings" lazy="false">
<id name="RegionUUID" column="RegionId" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
<property name="BlockTerraform" type="System.Boolean" />
<property name="BlockFly" type="System.Boolean" />
<property name="AllowDamage" type="System.Boolean" />
<property name="RestrictPushing" type="System.Boolean" />
<property name="AllowLandResell" type="System.Boolean" />
<property name="AllowLandJoinDivide" type="System.Boolean" />
<property name="BlockShowInSearch" type="System.Boolean" />
<property name="AgentLimit" type="System.Int32" />
<property name="ObjectBonus" type="System.Double" />
<property name="Maturity" type="System.Int32" />
<property name="DisableScripts" type="System.Boolean" />
<property name="DisableCollisions" type="System.Boolean" />
<property name="DisablePhysics" type="System.Boolean" />
<property name="TerrainTexture1" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="TerrainTexture2" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="TerrainTexture3" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="TerrainTexture4" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="Elevation1NW" type="System.Double" />
<property name="Elevation2NW" type="System.Double" />
<property name="Elevation1NE" type="System.Double" />
<property name="Elevation2NE" type="System.Double" />
<property name="Elevation1SE" type="System.Double" />
<property name="Elevation2SE" type="System.Double" />
<property name="Elevation1SW" type="System.Double" />
<property name="Elevation2SW" type="System.Double" />
<property name="WaterHeight" type="System.Double" />
<property name="TerrainRaiseLimit" type="System.Double" />
<property name="TerrainLowerLimit" type="System.Double" />
<property name="UseEstateSun" type="System.Boolean" />
<property name="Sandbox" type="System.Boolean" />
<property name="SunVector" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" >
<column name="SunVectorX" />
<column name="SunVectorY" />
<column name="SunVectorZ" />
</property>
<property name="FixedSun" type="System.Boolean" />
<property name="SunPosition" type="System.Double" />
<property name="Covenant" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
</class>
</hibernate-mapping>

View File

@ -13,12 +13,14 @@
<property name="Description" type="String" length="255" />
<property name="SitName" type="String" length="255" />
<property name="TouchName" type="String" length="255" />
<property name="Color" type="OpenSim.Data.NHibernate.ColorUserType, OpenSim.Data.NHibernate" />
<property name="ObjectFlags" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="CreatorID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="GroupID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="LastOwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="LinkNum" type="System.Int32" />
<property name="OwnerMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="NextOwnerMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
@ -26,6 +28,12 @@
<property name="EveryoneMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="BaseMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="Material" type="Byte" />
<property name="ScriptAccessPin" type="System.Int32" />
<property name="TextureAnimation" type="binary" />
<property name="ParticleSystem" type="binary" />
<property name="ClickAction" type="Byte" />
<property name="OffsetPosition" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" >
<column name="PositionX" />
<column name="PositionY" />

View File

@ -2,25 +2,32 @@ BEGIN TRANSACTION;
create table Prims (
UUID TEXT not null,
RegionID TEXT,
GroupID TEXT,
ParentID INTEGER,
ParentUUID TEXT,
RegionID TEXT,
OwnerID TEXT,
LastOwnerID TEXT,
CreatorID TEXT,
CreationDate INTEGER,
LinkNum INTEGER,
Name TEXT,
Text TEXT,
Description TEXT,
SitName TEXT,
TouchName TEXT,
ObjectFlags INTEGER,
CreatorID TEXT,
OwnerID TEXT,
GroupID TEXT,
LastOwnerID TEXT,
OwnerMask INTEGER,
NextOwnerMask INTEGER,
GroupMask INTEGER,
EveryoneMask INTEGER,
BaseMask INTEGER,
Material INTEGER,
ScriptAccessPin INTEGER,
TextureAnimation BLOB,
ParticleSystem BLOB,
ClickAction INTEGER,
Color INTEGER,
PositionX NUMERIC,
PositionY NUMERIC,
PositionZ NUMERIC,
@ -99,4 +106,45 @@ create table PrimItems (
primary key (ItemID)
);
COMMIT;
CREATE TABLE RegionSettings (
RegionID TEXT not null,
BlockTerraform BIT,
BlockFly BIT,
AllowDamage BIT,
RestrictPushing BIT,
AllowLandResell BIT,
AllowLandJoinDivide BIT,
BlockShowInSearch BIT,
AgentLimit INTEGER,
ObjectBonus NUMERIC,
Maturity INTEGER,
DisableScripts BIT,
DisableCollisions BIT,
DisablePhysics BIT,
TerrainTexture1 TEXT,
TerrainTexture2 TEXT,
TerrainTexture3 TEXT,
TerrainTexture4 TEXT,
Elevation1NW NUMERIC,
Elevation2NW NUMERIC,
Elevation1NE NUMERIC,
Elevation2NE NUMERIC,
Elevation1SE NUMERIC,
Elevation2SE NUMERIC,
Elevation1SW NUMERIC,
Elevation2SW NUMERIC,
WaterHeight NUMERIC,
TerrainRaiseLimit NUMERIC,
TerrainLowerLimit NUMERIC,
UseEstateSun BIT,
Sandbox BIT,
SunVectorX NUMERIC,
SunVectorY NUMERIC,
SunVectorZ NUMERIC,
FixedSun BIT,
SunPosition NUMERIC,
Covenant TEXT,
primary key (RegionID)
);
COMMIT;

View File

@ -12,15 +12,24 @@ create table UserAgents (
LoginTime INTEGER,
LogoutTime INTEGER,
Handle INTEGER,
PositionX NUMERIC,
PositionY NUMERIC,
PositionZ NUMERIC,
LookAtX NUMERIC,
LookAtY NUMERIC,
LookAtZ NUMERIC,
primary key (ProfileID)
);
create table UserProfiles (
ID TEXT not null,
WebLoginKey TEXT,
FirstName TEXT,
SurName TEXT,
Email TEXT,
PasswordHash TEXT,
PasswordSalt TEXT,
WebLoginKey TEXT,
HomeRegionID TEXT,
HomeRegionX INTEGER,
HomeRegionY INTEGER,
HomeLocationX NUMERIC,
@ -31,15 +40,22 @@ create table UserProfiles (
HomeLookAtZ NUMERIC,
Created INTEGER,
LastLogin INTEGER,
RootInventoryFolderID TEXT,
UserInventoryURI TEXT,
UserAssetURI TEXT,
Image TEXT,
FirstLifeImage TEXT,
AboutText TEXT,
FirstLifeAboutText TEXT,
RootInventoryFolderID TEXT,
`CanDoMask` INTEGER,
`WantDoMask` INTEGER,
`UserFlags` INTEGER,
`GodLevel` INTEGER,
`CustomType` TEXT,
`Partner` TEXT,
primary key (ID)
);
create table UserAppearances (
Owner TEXT not null,
BodyItem TEXT,
@ -71,9 +87,22 @@ create table UserAppearances (
Texture BLOB,
VisualParams BLOB,
Serial INTEGER,
AvatarHeight NUMERIC,
primary key (Owner)
);
create index user_firstname on UserProfiles (FirstName);
create index user_surname on UserProfiles (SurName);
COMMIT;
CREATE TABLE UserFriends (
UserFriendID TEXT,
OwnerID TEXT,
FriendID TEXT,
FriendPermissions INTEGER,
primary key (UserFriendID)
);
create index UserFirstNameIndex on UserProfiles (FirstName);
create index UserSurnameIndex on UserProfiles (SurName);
create unique index UserFullNameIndex on UserProfiles (FirstName,SurName);
create unique index UserFriendsOwnerFriendIndex on UserFriends (OwnerID,FriendID);
COMMIT;

View File

@ -4,6 +4,7 @@
<id name="ProfileID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
<property name="AgentIP" type="String" length="24" />
<property name="AgentPort" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="AgentOnline" type="boolean" />
@ -14,8 +15,18 @@
<property name="LoginTime" type="Int32" />
<property name="LogoutTime" type="Int32" />
<property name="Handle" type="OpenSim.Data.NHibernate.UInt64Type, OpenSim.Data.NHibernate" />
<!-- <property name="PositionX" type="Single" />
<property name="PositionY" type="Single" />
<property name="PositionZ" type="Single" /> -->
<property name="Position" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" >
<column name="PositionX" />
<column name="PositionY" />
<column name="PositionZ" />
</property>
<property name="LookAt" type="OpenSim.Data.NHibernate.Vector3UserType, OpenSim.Data.NHibernate" >
<column name="LookAtX" />
<column name="LookAtY" />
<column name="LookAtZ" />
</property>
</class>
</hibernate-mapping>

View File

@ -33,5 +33,6 @@
<property name="Texture" type="OpenSim.Data.NHibernate.TextureUserType, OpenSim.Data.NHibernate" />
<property name="VisualParams" type="binary" />
<property name="Serial" type="Int32" />
<property name="AvatarHeight" type="Single" />
</class>
</hibernate-mapping>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="OpenSim.Data.NHibernate.UserFriend, OpenSim.Data.NHibernate" table="UserFriends" lazy="false">
<id name="UserFriendID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
<property name="OwnerID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="FriendID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="FriendPermissions" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
</class>
</hibernate-mapping>

View File

@ -4,11 +4,13 @@
<id name="ID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate">
<generator class="assigned" />
</id>
<property name="FirstName" index="user_firstname" type="String" length="32" />
<property name="SurName" index="user_surname" type="String" length="32" />
<property name="WebLoginKey" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="FirstName" index="UserFirstNameIndex" type="String" length="32" />
<property name="SurName" index="UserSurnameIndex" type="String" length="32" />
<property name="Email" type="String" length="250" />
<property name="PasswordHash" type="String" length="32" />
<property name="PasswordSalt" type="String" length="32" />
<property name="WebLoginKey" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="HomeRegionID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="HomeRegionX" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="HomeRegionY" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="HomeLocationX" type="Single" />
@ -19,12 +21,18 @@
<property name="HomeLookAtZ" type="Single" />
<property name="Created" type="Int32" />
<property name="LastLogin" type="Int32" />
<property name="RootInventoryFolderID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="UserInventoryURI" type="String" length="255"/>
<property name="UserAssetURI" type="String" length="255"/>
<property name="Image" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="FirstLifeImage" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="AboutText" type="String" length="255" />
<property name="FirstLifeAboutText" type="String" length="255" />
<property name="CanDoMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="WantDoMask" type="OpenSim.Data.NHibernate.UInt32Type, OpenSim.Data.NHibernate" />
<property name="UserFlags" type="Int32" />
<property name="GodLevel" type="Int32" />
<property name="CustomType" type="String" length="32" />
<property name="Partner" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
<property name="RootInventoryFolderID" type="OpenSim.Data.NHibernate.UUIDUserType, OpenSim.Data.NHibernate" />
</class>
</hibernate-mapping>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
namespace OpenSim.Data.NHibernate
{
public class UserFriend
{
public UserFriend()
{
}
public UserFriend(UUID userFriendID, UUID ownerID, UUID friendID, uint friendPermissions)
{
this.UserFriendID = userFriendID;
this.OwnerID = ownerID;
this.FriendID = friendID;
this.FriendPermissions = friendPermissions;
}
public UUID UserFriendID { get; set; }
public UUID OwnerID { get; set; }
public UUID FriendID { get; set; }
public uint FriendPermissions { get; set; }
}
}

View File

@ -130,8 +130,8 @@ namespace OpenSim.Data.Tests
[Test]
public void T010_StoreSimpleObject()
{
SceneObjectGroup sog = NewSOG("object1", prim1);
SceneObjectGroup sog2 = NewSOG("object2", prim2);
SceneObjectGroup sog = NewSOG("object1", prim1, region1);
SceneObjectGroup sog2 = NewSOG("object2", prim2, region1);
// in case the objects don't store
try
@ -183,7 +183,7 @@ namespace OpenSim.Data.Tests
SceneObjectPart p1 = NewSOP("SoP 1",tmp1);
SceneObjectPart p2 = NewSOP("SoP 2",tmp2);
SceneObjectPart p3 = NewSOP("SoP 3",tmp3);
SceneObjectGroup sog = NewSOG("Sop 0",tmp0);
SceneObjectGroup sog = NewSOG("Sop 0", tmp0, newregion);
sog.AddPart(p1);
sog.AddPart(p2);
sog.AddPart(p3);
@ -246,7 +246,14 @@ namespace OpenSim.Data.Tests
pbshap = PrimitiveBaseShape.Default;
Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next());
byte updatef = (byte) random.Next(127);
RegionInfo regionInfo = new RegionInfo();
regionInfo.RegionID = region3;
regionInfo.RegionLocX = 0;
regionInfo.RegionLocY = 0;
Scene scene = new Scene(regionInfo);
SceneObjectPart sop = new SceneObjectPart();
sop.RegionHandle = regionh;
sop.UUID = uuid;
@ -313,9 +320,10 @@ namespace OpenSim.Data.Tests
Assert.That(updatef,Is.EqualTo(sop.UpdateFlag));
// This is necessary or object will not be inserted in DB
sop.ObjectFlags = 0;
sop.ObjectFlags = 0;
SceneObjectGroup sog = new SceneObjectGroup();
sog.SetScene(scene); // Reguired by nhibernate database module.
sog.SetRootPart(sop);
// Inserts group in DB
@ -365,7 +373,6 @@ namespace OpenSim.Data.Tests
[Test]
public void T014_UpdateObject()
{
string text1 = "object1 text";
SceneObjectGroup sog = FindSOG("object1", region1);
sog.RootPart.Text = text1;
@ -373,8 +380,7 @@ namespace OpenSim.Data.Tests
sog = FindSOG("object1", region1);
Assert.That(text1, Is.EqualTo(sog.RootPart.Text));
// Creates random values
UUID creator = new UUID();
creator = UUID.Random();
@ -474,7 +480,7 @@ namespace OpenSim.Data.Tests
{
UUID id = UUID.Random();
Dictionary<UUID, SceneObjectPart> mydic = new Dictionary<UUID, SceneObjectPart>();
SceneObjectGroup sog = NewSOG("Test SOG",id);
SceneObjectGroup sog = NewSOG("Test SOG", id, region4);
mydic.Add(sog.RootPart.UUID,sog.RootPart);
for (int i=0;i<30;i++)
{
@ -888,9 +894,18 @@ namespace OpenSim.Data.Tests
{
SceneObjectPart p = sog.RootPart;
if (p.Name == name) {
RegionInfo regionInfo = new RegionInfo();
regionInfo.RegionID = r;
regionInfo.RegionLocX = 0;
regionInfo.RegionLocY = 0;
Scene scene = new Scene(regionInfo);
sog.SetScene(scene);
return sog;
}
}
return null;
}
@ -906,8 +921,15 @@ namespace OpenSim.Data.Tests
// causes the application to crash at the database layer because of null values
// in NOT NULL fields
//
private SceneObjectGroup NewSOG(string name, UUID uuid)
private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId)
{
RegionInfo regionInfo = new RegionInfo();
regionInfo.RegionID = regionId;
regionInfo.RegionLocX = 0;
regionInfo.RegionLocY = 0;
Scene scene = new Scene(regionInfo);
SceneObjectPart sop = new SceneObjectPart();
sop.Name = name;
sop.Description = name;
@ -916,9 +938,11 @@ namespace OpenSim.Data.Tests
sop.TouchName = RandomName();
sop.UUID = uuid;
sop.Shape = PrimitiveBaseShape.Default;
SceneObjectGroup sog = new SceneObjectGroup();
sog.SetScene(scene);
sog.SetRootPart(sop);
return sog;
}

View File

@ -404,6 +404,17 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
/// Mock constructor for scene group persistency unit tests.
/// SceneObjectGroup RegionId property is delegated to Scene.
/// </summary>
/// <param name="regInfo"></param>
public Scene(RegionInfo regInfo)
{
m_regInfo = regInfo;
m_eventManager = new EventManager();
}
#endregion
#region Startup / Close Methods

View File

@ -1588,6 +1588,7 @@
<Reference name="System" localCopy="false"/>
<Reference name="System.Xml"/>
<Reference name="System.Data"/>
<Reference name="System.Drawing"/>
<Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/>