refactor: move common inventory folder version update code to parent class in mysql, mssql and sqlite database plugins

0.7.4-extended
Justin Clark-Casey (justincc) 2012-11-15 04:01:30 +00:00
parent e8e6bc0c6a
commit 468d1cf03e
6 changed files with 30 additions and 117 deletions

View File

@ -122,7 +122,7 @@ namespace OpenSim.Data.MSSQL
}
}
public class MSSQLItemHandler : MSSQLGenericTableHandler<XInventoryItem>
public class MSSQLItemHandler : MSSQLInventoryHandler<XInventoryItem>
{
public MSSQLItemHandler(string c, string t, string m) :
base(c, t, m)
@ -213,43 +213,9 @@ namespace OpenSim.Data.MSSQL
return true;
}
private bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();
string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
conn.Open();
cmd.Parameters.AddWithValue("@folderID", folderID);
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
return false;
}
}
}
return true;
}
}
public class MSSQLFolderHandler : MSSQLGenericTableHandler<XInventoryFolder>
public class MSSQLFolderHandler : MSSQLInventoryHandler<XInventoryFolder>
{
public MSSQLFolderHandler(string c, string t, string m) :
base(c, t, m)
@ -296,13 +262,18 @@ namespace OpenSim.Data.MSSQL
return true;
}
}
private bool IncrementFolderVersion(UUID folderID)
public class MSSQLInventoryHandler<T> : MSSQLGenericTableHandler<T> where T: class, new()
{
public MSSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
protected bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
protected bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();

View File

@ -122,7 +122,7 @@ namespace OpenSim.Data.MySQL
}
}
public class MySqlItemHandler : MySQLGenericTableHandler<XInventoryItem>
public class MySqlItemHandler : MySqlInventoryHandler<XInventoryItem>
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -241,47 +241,9 @@ namespace OpenSim.Data.MySQL
return true;
}
private bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand())
{
cmd.Connection = dbcon;
cmd.CommandText = String.Format("update inventoryfolders set version=version+1 where folderID = ?folderID");
cmd.Parameters.AddWithValue("?folderID", folderID);
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
return false;
}
cmd.Dispose();
}
dbcon.Close();
}
return true;
}
}
public class MySqlFolderHandler : MySQLGenericTableHandler<XInventoryFolder>
public class MySqlFolderHandler : MySqlInventoryHandler<XInventoryFolder>
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -326,13 +288,18 @@ namespace OpenSim.Data.MySQL
return true;
}
}
private bool IncrementFolderVersion(UUID folderID)
public class MySqlInventoryHandler<T> : MySQLGenericTableHandler<T> where T: class, new()
{
public MySqlInventoryHandler(string c, string t, string m) : base(c, t, m) {}
protected bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
protected bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL FOLDER HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();

View File

@ -1366,7 +1366,6 @@ namespace OpenSim.Data.SQLite
createCol(land, "UserLookAtZ", typeof(Double));
createCol(land, "AuthbuyerID", typeof(String));
createCol(land, "OtherCleanTime", typeof(Int32));
createCol(land, "Dwell", typeof(Int32));
createCol(land, "MediaType", typeof(String));
createCol(land, "MediaDescription", typeof(String));
createCol(land, "MediaSize", typeof(String));
@ -1788,7 +1787,6 @@ namespace OpenSim.Data.SQLite
newData.PassHours = Convert.ToSingle(row["PassHours"]);
newData.PassPrice = Convert.ToInt32(row["PassPrice"]);
newData.SnapshotID = (UUID)(String)row["SnapshotUUID"];
newData.Dwell = Convert.ToInt32(row["Dwell"]);
newData.MediaType = (String)row["MediaType"];
newData.MediaDescription = (String)row["MediaDescription"];
newData.MediaWidth = Convert.ToInt32((((string)row["MediaSize"]).Split(','))[0]);
@ -2209,7 +2207,6 @@ namespace OpenSim.Data.SQLite
row["UserLookAtZ"] = land.UserLookAt.Z;
row["AuthbuyerID"] = land.AuthBuyerID.ToString();
row["OtherCleanTime"] = land.OtherCleanTime;
row["Dwell"] = land.Dwell;
row["MediaType"] = land.MediaType;
row["MediaDescription"] = land.MediaDescription;
row["MediaSize"] = String.Format("{0},{1}", land.MediaWidth, land.MediaHeight);

View File

@ -130,7 +130,7 @@ namespace OpenSim.Data.SQLite
}
}
public class SqliteItemHandler : SQLiteGenericTableHandler<XInventoryItem>
public class SqliteItemHandler : SqliteInventoryHandler<XInventoryItem>
{
public SqliteItemHandler(string c, string t, string m) :
base(c, t, m)
@ -243,37 +243,9 @@ namespace OpenSim.Data.SQLite
return perms;
}
private bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();
using (SqliteCommand cmd = new SqliteCommand())
{
cmd.CommandText = "update inventoryfolders set version=version+1 where folderID = ?folderID";
cmd.Parameters.Add(new SqliteParameter(":folderID", folderID));
try
{
cmd.ExecuteNonQuery();
}
catch (Exception)
{
return false;
}
}
return true;
}
}
public class SqliteFolderHandler : SQLiteGenericTableHandler<XInventoryFolder>
public class SqliteFolderHandler : SqliteInventoryHandler<XInventoryFolder>
{
public SqliteFolderHandler(string c, string t, string m) :
base(c, t, m)
@ -315,12 +287,18 @@ namespace OpenSim.Data.SQLite
return true;
}
private bool IncrementFolderVersion(UUID folderID)
}
public class SqliteInventoryHandler<T> : SQLiteGenericTableHandler<T> where T: class, new()
{
public SqliteInventoryHandler(string c, string t, string m) : base(c, t, m) {}
protected bool IncrementFolderVersion(UUID folderID)
{
return IncrementFolderVersion(folderID.ToString());
}
private bool IncrementFolderVersion(string folderID)
protected bool IncrementFolderVersion(string folderID)
{
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
// Util.PrintCallStack();

View File

@ -950,7 +950,6 @@ namespace OpenSim.Region.CoreModules.World.Land
ILandObject newLand = startLandObject.Copy();
newLand.LandData.Name = newLand.LandData.Name;
newLand.LandData.GlobalID = UUID.Random();
newLand.LandData.Dwell = 0;
newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y));

View File

@ -2062,7 +2062,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGetPos()
{
m_host.AddScriptLPS(1);
return m_host.GetWorldPosition();
Vector3 pos = m_host.GetWorldPosition();
return new LSL_Vector(pos.X, pos.Y, pos.Z);
}
public LSL_Vector llGetLocalPos()