* Introduced common abstract AssetDataBase implementing IAssetProvider

* changed the semantics of SQLiteBase to SQLiteUtils
* Added abstract placeholder files for the other db providers
This commit is contained in:
lbsa71
2008-03-28 14:54:20 +00:00
parent 830626999c
commit 8c901e9347
12 changed files with 108 additions and 48 deletions

View File

@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary>
/// A User storage interface for the DB4o database system
/// </summary>
public class SQLiteAssetData : SQLiteBase, IAssetProvider
public class SQLiteAssetData : AssetDataBase
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@@ -63,7 +63,7 @@ namespace OpenSim.Framework.Data.SQLite
return;
}
public AssetBase FetchAsset(LLUUID uuid)
override public AssetBase FetchAsset(LLUUID uuid)
{
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
@@ -86,7 +86,7 @@ namespace OpenSim.Framework.Data.SQLite
}
}
public void CreateAsset(AssetBase asset)
override public void CreateAsset(AssetBase asset)
{
m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID));
if (ExistsAsset(asset.FullID))
@@ -111,7 +111,7 @@ namespace OpenSim.Framework.Data.SQLite
}
}
public void UpdateAsset(AssetBase asset)
override public void UpdateAsset(AssetBase asset)
{
LogAssetLoad(asset);
@@ -144,7 +144,7 @@ namespace OpenSim.Framework.Data.SQLite
asset.InvType, temporary, local, assetLength));
}
public bool ExistsAsset(LLUUID uuid)
override public bool ExistsAsset(LLUUID uuid)
{
using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn))
{
@@ -175,7 +175,7 @@ namespace OpenSim.Framework.Data.SQLite
}
}
public void CommitAssets() // force a sync to the database
override public void CommitAssets() // force a sync to the database
{
m_log.Info("[SQLITE]: Attempting commit");
// lock (ds)
@@ -197,14 +197,14 @@ namespace OpenSim.Framework.Data.SQLite
{
DataTable assets = new DataTable("assets");
createCol(assets, "UUID", typeof (String));
createCol(assets, "Name", typeof (String));
createCol(assets, "Description", typeof (String));
createCol(assets, "Type", typeof (Int32));
createCol(assets, "InvType", typeof (Int32));
createCol(assets, "Local", typeof (Boolean));
createCol(assets, "Temporary", typeof (Boolean));
createCol(assets, "Data", typeof (Byte[]));
SQLiteUtil.createCol(assets, "UUID", typeof (String));
SQLiteUtil.createCol(assets, "Name", typeof (String));
SQLiteUtil.createCol(assets, "Description", typeof (String));
SQLiteUtil.createCol(assets, "Type", typeof (Int32));
SQLiteUtil.createCol(assets, "InvType", typeof (Int32));
SQLiteUtil.createCol(assets, "Local", typeof (Boolean));
SQLiteUtil.createCol(assets, "Temporary", typeof (Boolean));
SQLiteUtil.createCol(assets, "Data", typeof (Byte[]));
// Add in contraints
assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]};
return assets;
@@ -248,7 +248,7 @@ namespace OpenSim.Framework.Data.SQLite
private void InitDB(SqliteConnection conn)
{
string createAssets = defineTable(createAssetsTable());
string createAssets = SQLiteUtil.defineTable(createAssetsTable());
SqliteCommand pcmd = new SqliteCommand(createAssets, conn);
pcmd.ExecuteNonQuery();
}
@@ -272,7 +272,7 @@ namespace OpenSim.Framework.Data.SQLite
#region IPlugin interface
public string Version
override public string Version
{
get
{
@@ -286,12 +286,12 @@ namespace OpenSim.Framework.Data.SQLite
}
}
public void Initialise()
override public void Initialise()
{
Initialise("AssetStorage.db", "");
}
public string Name
override public string Name
{
get { return "SQLite Asset storage engine"; }
}

View File

@@ -35,7 +35,7 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
public class SQLiteInventoryStore : SQLiteBase, IInventoryData
public class SQLiteInventoryStore : SQLiteUtil, IInventoryData
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

View File

@@ -35,7 +35,7 @@ using OpenSim.Framework.Console;
namespace OpenSim.Framework.Data.SQLite
{
internal class SQLiteManager : SQLiteBase
internal class SQLiteManager : SQLiteUtil
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

View File

@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary>
/// A User storage interface for the SQLite database system
/// </summary>
public class SQLiteUserData : SQLiteBase, IUserData
public class SQLiteUserData : SQLiteUtil, IUserData
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

View File

@@ -34,17 +34,17 @@ namespace OpenSim.Framework.Data.SQLite
/// <summary>
/// A base class for methods needed by all SQLite database classes
/// </summary>
public class SQLiteBase
public class SQLiteUtil
{
/***********************************************************************
*
* Database Definition Functions
* Database Definition Helper Functions
*
* This should be db agnostic as we define them in ADO.NET terms
*
**********************************************************************/
protected static void createCol(DataTable dt, string name, Type type)
public static void createCol(DataTable dt, string name, Type type)
{
DataColumn col = new DataColumn(name, type);
dt.Columns.Add(col);
@@ -60,7 +60,7 @@ namespace OpenSim.Framework.Data.SQLite
*
**********************************************************************/
protected static SqliteCommand createInsertCommand(string table, DataTable dt)
public static SqliteCommand createInsertCommand(string table, DataTable dt)
{
/**
* This is subtle enough to deserve some commentary.
@@ -95,7 +95,7 @@ namespace OpenSim.Framework.Data.SQLite
return cmd;
}
protected static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt)
{
string sql = "update " + table + " set ";
string subsql = String.Empty;
@@ -123,7 +123,7 @@ namespace OpenSim.Framework.Data.SQLite
}
protected static string defineTable(DataTable dt)
public static string defineTable(DataTable dt)
{
string sql = "create table " + dt.TableName + "(";
string subsql = String.Empty;
@@ -168,7 +168,7 @@ namespace OpenSim.Framework.Data.SQLite
/// for us.
///</summary>
///<returns>a built sqlite parameter</returns>
protected static SqliteParameter createSqliteParameter(string name, Type type)
public static SqliteParameter createSqliteParameter(string name, Type type)
{
SqliteParameter param = new SqliteParameter();
param.ParameterName = ":" + name;
@@ -184,7 +184,7 @@ namespace OpenSim.Framework.Data.SQLite
*
**********************************************************************/
protected static DbType dbtypeFromType(Type type)
public static DbType dbtypeFromType(Type type)
{
if (type == typeof (String))
{
@@ -226,7 +226,7 @@ namespace OpenSim.Framework.Data.SQLite
// this is something we'll need to implement for each db
// slightly differently.
protected static string sqliteType(Type type)
public static string sqliteType(Type type)
{
if (type == typeof (String))
{