aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteInventoryStore.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteInventoryStore.cs104
1 files changed, 93 insertions, 11 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
index 5b77f82..f7a1fdc 100644
--- a/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
+++ b/OpenSim/Data/SQLite/SQLiteInventoryStore.cs
@@ -36,6 +36,9 @@ using OpenSim.Framework;
36 36
37namespace OpenSim.Data.SQLite 37namespace OpenSim.Data.SQLite
38{ 38{
39 /// <summary>
40 /// An Inventory Interface to the SQLite database
41 /// </summary>
39 public class SQLiteInventoryStore : SQLiteUtil, IInventoryData 42 public class SQLiteInventoryStore : SQLiteUtil, IInventoryData
40 { 43 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -48,8 +51,13 @@ namespace OpenSim.Data.SQLite
48 private SqliteDataAdapter invFoldersDa; 51 private SqliteDataAdapter invFoldersDa;
49 52
50 /// <summary> 53 /// <summary>
51 /// Initialises the interface 54 /// <list type="bullet">
55 /// <item>Initialises Inventory interface</item>
56 /// <item>Loads and initialises a new SQLite connection and maintains it.</item>
57 /// <item>use default URI if connect string string is empty.</item>
58 /// </list>
52 /// </summary> 59 /// </summary>
60 /// <param name="dbconnect">connect string</param>
53 public void Initialise(string dbconnect) 61 public void Initialise(string dbconnect)
54 { 62 {
55 if (dbconnect == string.Empty) 63 if (dbconnect == string.Empty)
@@ -90,6 +98,11 @@ namespace OpenSim.Data.SQLite
90 ds.AcceptChanges(); 98 ds.AcceptChanges();
91 } 99 }
92 100
101 /// <summary>
102 ///
103 /// </summary>
104 /// <param name="row"></param>
105 /// <returns></returns>
93 public InventoryItemBase buildItem(DataRow row) 106 public InventoryItemBase buildItem(DataRow row)
94 { 107 {
95 InventoryItemBase item = new InventoryItemBase(); 108 InventoryItemBase item = new InventoryItemBase();
@@ -130,6 +143,11 @@ namespace OpenSim.Data.SQLite
130 return item; 143 return item;
131 } 144 }
132 145
146 /// <summary>
147 ///
148 /// </summary>
149 /// <param name="row"></param>
150 /// <param name="item"></param>
133 private static void fillItemRow(DataRow row, InventoryItemBase item) 151 private static void fillItemRow(DataRow row, InventoryItemBase item)
134 { 152 {
135 row["UUID"] = Util.ToRawUuidString(item.ID); 153 row["UUID"] = Util.ToRawUuidString(item.ID);
@@ -156,6 +174,12 @@ namespace OpenSim.Data.SQLite
156 row["flags"] = item.Flags; 174 row["flags"] = item.Flags;
157 } 175 }
158 176
177 /// <summary>
178 /// Add inventory folder
179 /// </summary>
180 /// <param name="folder">Folder base</param>
181 /// <param name="add">true=create folder. false=update existing folder</param>
182 /// <remarks>nasty</remarks>
159 private void addFolder(InventoryFolderBase folder, bool add) 183 private void addFolder(InventoryFolderBase folder, bool add)
160 { 184 {
161 lock (ds) 185 lock (ds)
@@ -184,6 +208,10 @@ namespace OpenSim.Data.SQLite
184 } 208 }
185 } 209 }
186 210
211 /// <summary>
212 /// Move an inventory folder
213 /// </summary>
214 /// <param name="folder">folder base</param>
187 private void moveFolder(InventoryFolderBase folder) 215 private void moveFolder(InventoryFolderBase folder)
188 { 216 {
189 lock (ds) 217 lock (ds)
@@ -206,6 +234,11 @@ namespace OpenSim.Data.SQLite
206 } 234 }
207 } 235 }
208 236
237 /// <summary>
238 /// add an item in inventory
239 /// </summary>
240 /// <param name="item">the item</param>
241 /// <param name="add">true=add item ; false=update existing item</param>
209 private void addItem(InventoryItemBase item, bool add) 242 private void addItem(InventoryItemBase item, bool add)
210 { 243 {
211 lock (ds) 244 lock (ds)
@@ -233,31 +266,34 @@ namespace OpenSim.Data.SQLite
233 } 266 }
234 } 267 }
235 268
269 /// <summary>
270 /// TODO : DataSet commit
271 /// </summary>
236 public void Shutdown() 272 public void Shutdown()
237 { 273 {
238 // TODO: DataSet commit 274 // TODO: DataSet commit
239 } 275 }
240 276
241 /// <summary> 277 /// <summary>
242 /// Closes the interface 278 /// Closes the inventory interface
243 /// </summary> 279 /// </summary>
244 public void Close() 280 public void Close()
245 { 281 {
246 } 282 }
247 283
248 /// <summary> 284 /// <summary>
249 /// The plugin being loaded 285 /// The name of this DB provider
250 /// </summary> 286 /// </summary>
251 /// <returns>A string containing the plugin name</returns> 287 /// <returns>Name of DB provider</returns>
252 public string getName() 288 public string getName()
253 { 289 {
254 return "SQLite Inventory Data Interface"; 290 return "SQLite Inventory Data Interface";
255 } 291 }
256 292
257 /// <summary> 293 /// <summary>
258 /// The plugins version 294 /// Returns the version of this DB provider
259 /// </summary> 295 /// </summary>
260 /// <returns>A string containing the plugin version</returns> 296 /// <returns>A string containing the DB provider version</returns>
261 public string getVersion() 297 public string getVersion()
262 { 298 {
263 Module module = GetType().Module; 299 Module module = GetType().Module;
@@ -362,7 +398,11 @@ namespace OpenSim.Data.SQLite
362 return folders; 398 return folders;
363 } 399 }
364 400
365 // See IInventoryData 401 /// <summary>
402 /// See IInventoryData
403 /// </summary>
404 /// <param name="parentID"></param>
405 /// <returns></returns>
366 public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID) 406 public List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
367 { 407 {
368 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 408 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
@@ -440,9 +480,9 @@ namespace OpenSim.Data.SQLite
440 } 480 }
441 481
442 /// <summary> 482 /// <summary>
443 /// 483 /// Delete an inventory item
444 /// </summary> 484 /// </summary>
445 /// <param name="item"></param> 485 /// <param name="item">The item UUID</param>
446 public void deleteInventoryItem(LLUUID itemID) 486 public void deleteInventoryItem(LLUUID itemID)
447 { 487 {
448 lock (ds) 488 lock (ds)
@@ -463,7 +503,7 @@ namespace OpenSim.Data.SQLite
463 /// Delete all items in the specified folder 503 /// Delete all items in the specified folder
464 /// </summary> 504 /// </summary>
465 /// <param name="folderId">id of the folder, whose item content should be deleted</param> 505 /// <param name="folderId">id of the folder, whose item content should be deleted</param>
466 //!TODO, this is horribly inefficient, but I don't want to ruin the overall structure of this implementation 506 /// <todo>this is horribly inefficient, but I don't want to ruin the overall structure of this implementation</todo>
467 private void deleteItemsInFolder(LLUUID folderId) 507 private void deleteItemsInFolder(LLUUID folderId)
468 { 508 {
469 List<InventoryItemBase> items = getInventoryInFolder(Util.ToRawUuidString(folderId)); 509 List<InventoryItemBase> items = getInventoryInFolder(Util.ToRawUuidString(folderId));
@@ -505,7 +545,7 @@ namespace OpenSim.Data.SQLite
505 /// <remarks> 545 /// <remarks>
506 /// This will clean-up any child folders and child items as well 546 /// This will clean-up any child folders and child items as well
507 /// </remarks> 547 /// </remarks>
508 /// <param name="item"></param> 548 /// <param name="folderID">the folder UUID</param>
509 public void deleteInventoryFolder(LLUUID folderID) 549 public void deleteInventoryFolder(LLUUID folderID)
510 { 550 {
511 lock (ds) 551 lock (ds)
@@ -544,6 +584,9 @@ namespace OpenSim.Data.SQLite
544 * 584 *
545 **********************************************************************/ 585 **********************************************************************/
546 586
587 /// <summary>
588 /// Create the "inventoryitems" table
589 /// </summary>
547 private static DataTable createInventoryItemsTable() 590 private static DataTable createInventoryItemsTable()
548 { 591 {
549 DataTable inv = new DataTable("inventoryitems"); 592 DataTable inv = new DataTable("inventoryitems");
@@ -582,6 +625,10 @@ namespace OpenSim.Data.SQLite
582 return inv; 625 return inv;
583 } 626 }
584 627
628 /// <summary>
629 /// Creates the "inventoryfolders" table
630 /// </summary>
631 /// <returns></returns>
585 private static DataTable createInventoryFoldersTable() 632 private static DataTable createInventoryFoldersTable()
586 { 633 {
587 DataTable fol = new DataTable("inventoryfolders"); 634 DataTable fol = new DataTable("inventoryfolders");
@@ -597,6 +644,11 @@ namespace OpenSim.Data.SQLite
597 return fol; 644 return fol;
598 } 645 }
599 646
647 /// <summary>
648 ///
649 /// </summary>
650 /// <param name="da"></param>
651 /// <param name="conn"></param>
600 private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) 652 private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn)
601 { 653 {
602 lock (ds) 654 lock (ds)
@@ -614,6 +666,11 @@ namespace OpenSim.Data.SQLite
614 } 666 }
615 } 667 }
616 668
669 /// <summary>
670 ///
671 /// </summary>
672 /// <param name="da"></param>
673 /// <param name="conn"></param>
617 private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn) 674 private void setupFoldersCommands(SqliteDataAdapter da, SqliteConnection conn)
618 { 675 {
619 lock (ds) 676 lock (ds)
@@ -631,6 +688,11 @@ namespace OpenSim.Data.SQLite
631 } 688 }
632 } 689 }
633 690
691 /// <summary>
692 ///
693 /// </summary>
694 /// <param name="row"></param>
695 /// <returns></returns>
634 private static InventoryFolderBase buildFolder(DataRow row) 696 private static InventoryFolderBase buildFolder(DataRow row)
635 { 697 {
636 InventoryFolderBase folder = new InventoryFolderBase(); 698 InventoryFolderBase folder = new InventoryFolderBase();
@@ -643,6 +705,11 @@ namespace OpenSim.Data.SQLite
643 return folder; 705 return folder;
644 } 706 }
645 707
708 /// <summary>
709 ///
710 /// </summary>
711 /// <param name="row"></param>
712 /// <param name="folder"></param>
646 private static void fillFolderRow(DataRow row, InventoryFolderBase folder) 713 private static void fillFolderRow(DataRow row, InventoryFolderBase folder)
647 { 714 {
648 row["UUID"] = Util.ToRawUuidString(folder.ID); 715 row["UUID"] = Util.ToRawUuidString(folder.ID);
@@ -653,6 +720,11 @@ namespace OpenSim.Data.SQLite
653 row["version"] = folder.Version; 720 row["version"] = folder.Version;
654 } 721 }
655 722
723 /// <summary>
724 ///
725 /// </summary>
726 /// <param name="row"></param>
727 /// <param name="folder"></param>
656 private static void moveFolderRow(DataRow row, InventoryFolderBase folder) 728 private static void moveFolderRow(DataRow row, InventoryFolderBase folder)
657 { 729 {
658 row["UUID"] = Util.ToRawUuidString(folder.ID); 730 row["UUID"] = Util.ToRawUuidString(folder.ID);
@@ -665,6 +737,10 @@ namespace OpenSim.Data.SQLite
665 * 737 *
666 **********************************************************************/ 738 **********************************************************************/
667 739
740 /// <summary>
741 ///
742 /// </summary>
743 /// <param name="conn"></param>
668 private static void InitDB(SqliteConnection conn) 744 private static void InitDB(SqliteConnection conn)
669 { 745 {
670 string createInventoryItems = defineTable(createInventoryItemsTable()); 746 string createInventoryItems = defineTable(createInventoryItemsTable());
@@ -677,6 +753,12 @@ namespace OpenSim.Data.SQLite
677 scmd.ExecuteNonQuery(); 753 scmd.ExecuteNonQuery();
678 } 754 }
679 755
756 /// <summary>
757 ///
758 /// </summary>
759 /// <param name="conn"></param>
760 /// <param name="m"></param>
761 /// <returns></returns>
680 private static bool TestTables(SqliteConnection conn, Migration m) 762 private static bool TestTables(SqliteConnection conn, Migration m)
681 { 763 {
682 SqliteCommand invItemsSelectCmd = new SqliteCommand(invItemsSelect, conn); 764 SqliteCommand invItemsSelectCmd = new SqliteCommand(invItemsSelect, conn);