diff options
author | lbsa71 | 2008-03-28 14:54:20 +0000 |
---|---|---|
committer | lbsa71 | 2008-03-28 14:54:20 +0000 |
commit | 8c901e93474af5fcd17a7f37acd711622c5286e0 (patch) | |
tree | 732b8db3dd2480d7cdeed49f4d086194e529ba6f /OpenSim/Framework/Data.SQLite | |
parent | Applied patch from mantis# 825, thanks A_Biondi (diff) | |
download | opensim-SC-8c901e93474af5fcd17a7f37acd711622c5286e0.zip opensim-SC-8c901e93474af5fcd17a7f37acd711622c5286e0.tar.gz opensim-SC-8c901e93474af5fcd17a7f37acd711622c5286e0.tar.bz2 opensim-SC-8c901e93474af5fcd17a7f37acd711622c5286e0.tar.xz |
* Introduced common abstract AssetDataBase implementing IAssetProvider
* changed the semantics of SQLiteBase to SQLiteUtils
* Added abstract placeholder files for the other db providers
Diffstat (limited to 'OpenSim/Framework/Data.SQLite')
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | 36 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteManager.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data.SQLite/SQLiteUtils.cs (renamed from OpenSim/Framework/Data.SQLite/SQLiteBase.cs) | 18 |
5 files changed, 30 insertions, 30 deletions
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs index 0703e54..afa73b1 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteAssetData.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
37 | /// <summary> | 37 | /// <summary> |
38 | /// A User storage interface for the DB4o database system | 38 | /// A User storage interface for the DB4o database system |
39 | /// </summary> | 39 | /// </summary> |
40 | public class SQLiteAssetData : SQLiteBase, IAssetProvider | 40 | public class SQLiteAssetData : AssetDataBase |
41 | { | 41 | { |
42 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
@@ -63,7 +63,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
63 | return; | 63 | return; |
64 | } | 64 | } |
65 | 65 | ||
66 | public AssetBase FetchAsset(LLUUID uuid) | 66 | override public AssetBase FetchAsset(LLUUID uuid) |
67 | { | 67 | { |
68 | 68 | ||
69 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) | 69 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) |
@@ -86,7 +86,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | public void CreateAsset(AssetBase asset) | 89 | override public void CreateAsset(AssetBase asset) |
90 | { | 90 | { |
91 | m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); | 91 | m_log.Info("[SQLITE]: Creating Asset " + Util.ToRawUuidString(asset.FullID)); |
92 | if (ExistsAsset(asset.FullID)) | 92 | if (ExistsAsset(asset.FullID)) |
@@ -111,7 +111,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | public void UpdateAsset(AssetBase asset) | 114 | override public void UpdateAsset(AssetBase asset) |
115 | { | 115 | { |
116 | LogAssetLoad(asset); | 116 | LogAssetLoad(asset); |
117 | 117 | ||
@@ -144,7 +144,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
144 | asset.InvType, temporary, local, assetLength)); | 144 | asset.InvType, temporary, local, assetLength)); |
145 | } | 145 | } |
146 | 146 | ||
147 | public bool ExistsAsset(LLUUID uuid) | 147 | override public bool ExistsAsset(LLUUID uuid) |
148 | { | 148 | { |
149 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) | 149 | using (SqliteCommand cmd = new SqliteCommand(SelectAssetSQL, m_conn)) |
150 | { | 150 | { |
@@ -175,7 +175,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | public void CommitAssets() // force a sync to the database | 178 | override public void CommitAssets() // force a sync to the database |
179 | { | 179 | { |
180 | m_log.Info("[SQLITE]: Attempting commit"); | 180 | m_log.Info("[SQLITE]: Attempting commit"); |
181 | // lock (ds) | 181 | // lock (ds) |
@@ -197,14 +197,14 @@ namespace OpenSim.Framework.Data.SQLite | |||
197 | { | 197 | { |
198 | DataTable assets = new DataTable("assets"); | 198 | DataTable assets = new DataTable("assets"); |
199 | 199 | ||
200 | createCol(assets, "UUID", typeof (String)); | 200 | SQLiteUtil.createCol(assets, "UUID", typeof (String)); |
201 | createCol(assets, "Name", typeof (String)); | 201 | SQLiteUtil.createCol(assets, "Name", typeof (String)); |
202 | createCol(assets, "Description", typeof (String)); | 202 | SQLiteUtil.createCol(assets, "Description", typeof (String)); |
203 | createCol(assets, "Type", typeof (Int32)); | 203 | SQLiteUtil.createCol(assets, "Type", typeof (Int32)); |
204 | createCol(assets, "InvType", typeof (Int32)); | 204 | SQLiteUtil.createCol(assets, "InvType", typeof (Int32)); |
205 | createCol(assets, "Local", typeof (Boolean)); | 205 | SQLiteUtil.createCol(assets, "Local", typeof (Boolean)); |
206 | createCol(assets, "Temporary", typeof (Boolean)); | 206 | SQLiteUtil.createCol(assets, "Temporary", typeof (Boolean)); |
207 | createCol(assets, "Data", typeof (Byte[])); | 207 | SQLiteUtil.createCol(assets, "Data", typeof (Byte[])); |
208 | // Add in contraints | 208 | // Add in contraints |
209 | assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]}; | 209 | assets.PrimaryKey = new DataColumn[] {assets.Columns["UUID"]}; |
210 | return assets; | 210 | return assets; |
@@ -248,7 +248,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
248 | 248 | ||
249 | private void InitDB(SqliteConnection conn) | 249 | private void InitDB(SqliteConnection conn) |
250 | { | 250 | { |
251 | string createAssets = defineTable(createAssetsTable()); | 251 | string createAssets = SQLiteUtil.defineTable(createAssetsTable()); |
252 | SqliteCommand pcmd = new SqliteCommand(createAssets, conn); | 252 | SqliteCommand pcmd = new SqliteCommand(createAssets, conn); |
253 | pcmd.ExecuteNonQuery(); | 253 | pcmd.ExecuteNonQuery(); |
254 | } | 254 | } |
@@ -272,7 +272,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
272 | 272 | ||
273 | #region IPlugin interface | 273 | #region IPlugin interface |
274 | 274 | ||
275 | public string Version | 275 | override public string Version |
276 | { | 276 | { |
277 | get | 277 | get |
278 | { | 278 | { |
@@ -286,12 +286,12 @@ namespace OpenSim.Framework.Data.SQLite | |||
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | public void Initialise() | 289 | override public void Initialise() |
290 | { | 290 | { |
291 | Initialise("AssetStorage.db", ""); | 291 | Initialise("AssetStorage.db", ""); |
292 | } | 292 | } |
293 | 293 | ||
294 | public string Name | 294 | override public string Name |
295 | { | 295 | { |
296 | get { return "SQLite Asset storage engine"; } | 296 | get { return "SQLite Asset storage engine"; } |
297 | } | 297 | } |
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index 97fdc96..14a3e1a 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Framework.Console; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework.Data.SQLite | 36 | namespace OpenSim.Framework.Data.SQLite |
37 | { | 37 | { |
38 | public class SQLiteInventoryStore : SQLiteBase, IInventoryData | 38 | public class SQLiteInventoryStore : SQLiteUtil, IInventoryData |
39 | { | 39 | { |
40 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs index bec0cd8..b383b0d 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Framework.Console; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework.Data.SQLite | 36 | namespace OpenSim.Framework.Data.SQLite |
37 | { | 37 | { |
38 | internal class SQLiteManager : SQLiteBase | 38 | internal class SQLiteManager : SQLiteUtil |
39 | { | 39 | { |
40 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs index 0b2df9d..4a582ac 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
37 | /// <summary> | 37 | /// <summary> |
38 | /// A User storage interface for the SQLite database system | 38 | /// A User storage interface for the SQLite database system |
39 | /// </summary> | 39 | /// </summary> |
40 | public class SQLiteUserData : SQLiteBase, IUserData | 40 | public class SQLiteUserData : SQLiteUtil, IUserData |
41 | { | 41 | { |
42 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 42 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs b/OpenSim/Framework/Data.SQLite/SQLiteUtils.cs index 8997faa..1334e53 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteBase.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteUtils.cs | |||
@@ -34,17 +34,17 @@ namespace OpenSim.Framework.Data.SQLite | |||
34 | /// <summary> | 34 | /// <summary> |
35 | /// A base class for methods needed by all SQLite database classes | 35 | /// A base class for methods needed by all SQLite database classes |
36 | /// </summary> | 36 | /// </summary> |
37 | public class SQLiteBase | 37 | public class SQLiteUtil |
38 | { | 38 | { |
39 | /*********************************************************************** | 39 | /*********************************************************************** |
40 | * | 40 | * |
41 | * Database Definition Functions | 41 | * Database Definition Helper Functions |
42 | * | 42 | * |
43 | * This should be db agnostic as we define them in ADO.NET terms | 43 | * This should be db agnostic as we define them in ADO.NET terms |
44 | * | 44 | * |
45 | **********************************************************************/ | 45 | **********************************************************************/ |
46 | 46 | ||
47 | protected static void createCol(DataTable dt, string name, Type type) | 47 | public static void createCol(DataTable dt, string name, Type type) |
48 | { | 48 | { |
49 | DataColumn col = new DataColumn(name, type); | 49 | DataColumn col = new DataColumn(name, type); |
50 | dt.Columns.Add(col); | 50 | dt.Columns.Add(col); |
@@ -60,7 +60,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
60 | * | 60 | * |
61 | **********************************************************************/ | 61 | **********************************************************************/ |
62 | 62 | ||
63 | protected static SqliteCommand createInsertCommand(string table, DataTable dt) | 63 | public static SqliteCommand createInsertCommand(string table, DataTable dt) |
64 | { | 64 | { |
65 | /** | 65 | /** |
66 | * This is subtle enough to deserve some commentary. | 66 | * This is subtle enough to deserve some commentary. |
@@ -95,7 +95,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
95 | return cmd; | 95 | return cmd; |
96 | } | 96 | } |
97 | 97 | ||
98 | protected static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) | 98 | public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) |
99 | { | 99 | { |
100 | string sql = "update " + table + " set "; | 100 | string sql = "update " + table + " set "; |
101 | string subsql = String.Empty; | 101 | string subsql = String.Empty; |
@@ -123,7 +123,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | protected static string defineTable(DataTable dt) | 126 | public static string defineTable(DataTable dt) |
127 | { | 127 | { |
128 | string sql = "create table " + dt.TableName + "("; | 128 | string sql = "create table " + dt.TableName + "("; |
129 | string subsql = String.Empty; | 129 | string subsql = String.Empty; |
@@ -168,7 +168,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
168 | /// for us. | 168 | /// for us. |
169 | ///</summary> | 169 | ///</summary> |
170 | ///<returns>a built sqlite parameter</returns> | 170 | ///<returns>a built sqlite parameter</returns> |
171 | protected static SqliteParameter createSqliteParameter(string name, Type type) | 171 | public static SqliteParameter createSqliteParameter(string name, Type type) |
172 | { | 172 | { |
173 | SqliteParameter param = new SqliteParameter(); | 173 | SqliteParameter param = new SqliteParameter(); |
174 | param.ParameterName = ":" + name; | 174 | param.ParameterName = ":" + name; |
@@ -184,7 +184,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
184 | * | 184 | * |
185 | **********************************************************************/ | 185 | **********************************************************************/ |
186 | 186 | ||
187 | protected static DbType dbtypeFromType(Type type) | 187 | public static DbType dbtypeFromType(Type type) |
188 | { | 188 | { |
189 | if (type == typeof (String)) | 189 | if (type == typeof (String)) |
190 | { | 190 | { |
@@ -226,7 +226,7 @@ namespace OpenSim.Framework.Data.SQLite | |||
226 | 226 | ||
227 | // this is something we'll need to implement for each db | 227 | // this is something we'll need to implement for each db |
228 | // slightly differently. | 228 | // slightly differently. |
229 | protected static string sqliteType(Type type) | 229 | public static string sqliteType(Type type) |
230 | { | 230 | { |
231 | if (type == typeof (String)) | 231 | if (type == typeof (String)) |
232 | { | 232 | { |