From af5c7e52b1163cf65f897e5c7ecf9ef2d9f6e88e Mon Sep 17 00:00:00 2001
From: Sean Dague
Date: Wed, 3 Sep 2008 18:11:44 +0000
Subject: narrange to do basic cleanup of the CMS module
---
.../Modules/ContentManagementSystem/CMModel.cs | 229 ++++++++++++---------
1 file changed, 126 insertions(+), 103 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs')
diff --git a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs
index a47f83a..3355fa3 100644
--- a/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs
+++ b/OpenSim/Region/Environment/Modules/ContentManagementSystem/CMModel.cs
@@ -1,47 +1,128 @@
+#region Header
+
// CMModel.cs
// User: bongiojp
//
//
+#endregion Header
+
using System;
-using System.Collections.Generic;
using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+
using libsecondlife;
+
using OpenSim;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes;
-using log4net;
using OpenSim.Region.Physics.Manager;
+
+using log4net;
+
using Axiom.Math;
-using System.Diagnostics;
namespace OpenSim.Region.Environment.Modules.ContentManagement
{
-
public class CMModel
- {
+ {
+ #region Static Fields
+
static float TimeToUpdate = 0;
static float TimeToConvertXml = 0;
-
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
-
- IContentDatabase m_database = null;
-
+
+ #endregion Static Fields
+
+ #region Fields
+
///
/// The class that contains all auras and metaentities used in the CMS.
///
CMEntityCollection m_MetaEntityCollection = new CMEntityCollection();
-
+ IContentDatabase m_database = null;
+
+ #endregion Fields
+
+ #region Constructors
+
+ public CMModel()
+ {
+ }
+
+ #endregion Constructors
+
+ #region Public Properties
+
public CMEntityCollection MetaEntityCollection
{
get { return m_MetaEntityCollection; }
}
-
- public CMModel()
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ ///
+ /// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity
+ /// it is a new part that must have a green aura (for diff mode).
+ /// Returns list of ContentManagementEntities
+ ///
+ public ArrayList CheckForNewEntitiesMissingAuras(Scene scene)
+ {
+ ArrayList missingList = null;
+ ArrayList newList = new ArrayList();
+
+ m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName);
+
+ //Check if the current scene has groups not included in the current list of MetaEntities
+ //If so, then the current scene's parts that are new should be marked green.
+ missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
+
+ foreach(Object missingPart in missingList)
+ {
+ if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID))
+ continue;
+ newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart));
+ }
+ m_log.Info("Number of missing objects found: " + newList.Count);
+ return newList;
+ }
+
+ ///
+ /// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message.
+ ///
+ public void CommitRegion(Scene scene, String logMessage)
{
+ m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length);
+ m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage);
+ m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName );
}
-
+
+ public void DeleteAllMetaObjects()
+ {
+ m_MetaEntityCollection.ClearAll();
+ }
+
+ public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid)
+ {
+ ContentManagementEntity ent = GetMetaGroupByPrim(uuid);
+ return ent;
+ }
+
+ //-------------------------------- HELPERS --------------------------------------------------------------------//
+ public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid)
+ {
+ foreach (Object ent in m_MetaEntityCollection.Entities.Values)
+ {
+ if (((ContentManagementEntity)ent).HasChildPrim(uuid))
+ return (ContentManagementEntity)ent;
+ }
+ return null;
+ }
+
public void Initialise(string database)
{
if (database == "FileSystemDatabase")
@@ -49,12 +130,12 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
else if (database == "GitDatabase")
m_database = new GitDatabase();
}
-
+
public void InitialiseDatabase(Scene scene, string dir)
{
m_database.Initialise(scene, dir);
}
-
+
///
/// Should be called just once to finish initializing the database.
///
@@ -62,13 +143,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
{
m_database.PostInitialise();
}
-
- public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid)
- {
- ContentManagementEntity ent = GetMetaGroupByPrim(uuid);
- return ent;
- }
-
+
///
/// Removes the green aura when an a new scene object group is deleted.
///
@@ -79,17 +154,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID);
}
-
- ///
- /// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message.
- ///
- public void CommitRegion(Scene scene, String logMessage)
- {
- m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length);
- m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage);
- m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName );
- }
-
+
///
/// Retrieves the latest revision of a region in xml form,
/// converts it to scene object groups and scene presences,
@@ -105,20 +170,20 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
Dictionary ReplacementList = new Dictionary();
int revision = m_database.GetMostRecentRevision(scene.RegionInfo.RegionID);
EntityBase[] searchArray;
-
+
xmllist = m_database.GetRegionObjectXMLList(scene.RegionInfo.RegionID, revision);
if (xmllist == null)
{
m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") does not have given revision number (" + revision + ").");
return;
}
-
+
m_log.Info("[CMMODEL]: Region (" + scene.RegionInfo.RegionID + ") revision number (" + revision + ").");
m_log.Info("[CMMODEL]: Scene Objects = " + xmllist.Count);
m_log.Info("[CMMODEL]: Converting scene entities list to specified revision.");
-
+
m_log.ErrorFormat("[CMMODEL]: 1");
-
+
foreach (string xml in xmllist)
{
try{
@@ -143,7 +208,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
{
if (entity == null)
continue;
-
+
if (entity is ScenePresence)
{
ReplacementList.Add(entity.UUID, entity);
@@ -162,7 +227,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
}
break;
}
-
+
foreach(LLUUID uuid in deleteListUUIDs.Keys)
{
try
@@ -179,7 +244,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
m_log.ErrorFormat("[CMMODEL]: Error while removing objects from scene: " + e);
}
}
-
+
lock (scene)
{
scene.Entities = ReplacementList;
@@ -191,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
{
if (!(ent is SceneObjectGroup))
continue;
-
+
if ((((SceneObjectGroup)ent).RootPart.GetEffectiveObjectFlags() & (uint) LLObject.ObjectFlags.Phantom) == 0)
((SceneObjectGroup)ent).ApplyPhysics(true);
((SceneObjectGroup)ent).AttachToBackup();
@@ -206,32 +271,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
m_log.Info("[CMMODEL]: Scheduling a backup of new scene object groups to backup.");
scene.Backup();
}
-
- ///
- /// Detects if a scene object group from the scene list has moved or changed scale. The green aura
- /// that surrounds the object is then moved or scaled with the group.
- ///
- public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group)
- {
- System.Collections.ArrayList auraList = new System.Collections.ArrayList();
- if (group == null)
- return null;
- foreach(SceneObjectPart part in group.Children.Values)
- {
- if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
- {
- ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale);
- ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
- auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
- }
- }
- return auraList;
- }
-
- public void DeleteAllMetaObjects()
- {
- m_MetaEntityCollection.ClearAll();
- }
///
/// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences
@@ -257,53 +296,37 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
TimeToConvertXml += y.ElapsedMilliseconds;
m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities for " + scene.RegionInfo.RegionName + ": " + y.ElapsedMilliseconds);
m_log.Info("[FileSystemDatabase] Time spent converting xml to metaentities so far: " + TimeToConvertXml);
-
+
m_log.Info("[FSDB]: checking for new scene object parts missing green auras and create the auras");
CheckForNewEntitiesMissingAuras(scene);
-
+
x.Stop();
TimeToUpdate += x.ElapsedMilliseconds;
m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds);
m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate);
-
}
-
+
///
- /// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity
- /// it is a new part that must have a green aura (for diff mode).
- /// Returns list of ContentManagementEntities
+ /// Detects if a scene object group from the scene list has moved or changed scale. The green aura
+ /// that surrounds the object is then moved or scaled with the group.
///
- public ArrayList CheckForNewEntitiesMissingAuras(Scene scene)
- {
- ArrayList missingList = null;
- ArrayList newList = new ArrayList();
-
- m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName);
-
- //Check if the current scene has groups not included in the current list of MetaEntities
- //If so, then the current scene's parts that are new should be marked green.
- missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
-
- foreach(Object missingPart in missingList)
- {
- if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID))
- continue;
- newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart));
- }
- m_log.Info("Number of missing objects found: " + newList.Count);
- return newList;
- }
-
- //-------------------------------- HELPERS --------------------------------------------------------------------//
-
- public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid)
+ public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group)
{
- foreach (Object ent in m_MetaEntityCollection.Entities.Values)
+ System.Collections.ArrayList auraList = new System.Collections.ArrayList();
+ if (group == null)
+ return null;
+ foreach(SceneObjectPart part in group.Children.Values)
{
- if (((ContentManagementEntity)ent).HasChildPrim(uuid))
- return (ContentManagementEntity)ent;
+ if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
+ {
+ ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale);
+ ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
+ auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
+ }
}
- return null;
+ return auraList;
}
- }
+
+ #endregion Public Methods
+ }
}
\ No newline at end of file
--
cgit v1.1