diff options
author | Jeff Ames | 2008-06-26 20:14:33 +0000 |
---|---|---|
committer | Jeff Ames | 2008-06-26 20:14:33 +0000 |
commit | 9fae975a53fbb852dfbaf811dca259ddd4f74f4c (patch) | |
tree | 7273987bd5c30c4fabca6fa68b43ce25304a703a /OpenSim/Data/SQLite/SQLiteRegionData.cs | |
parent | Update svn properties. Minor formatting cleanup. (diff) | |
download | opensim-SC_OLD-9fae975a53fbb852dfbaf811dca259ddd4f74f4c.zip opensim-SC_OLD-9fae975a53fbb852dfbaf811dca259ddd4f74f4c.tar.gz opensim-SC_OLD-9fae975a53fbb852dfbaf811dca259ddd4f74f4c.tar.bz2 opensim-SC_OLD-9fae975a53fbb852dfbaf811dca259ddd4f74f4c.tar.xz |
Apply patch from bug #1605 -- Documentation for Data/SQLite. Thanks kerunix_Flan!
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteRegionData.cs')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteRegionData.cs | 263 |
1 files changed, 245 insertions, 18 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index eb6f253..86f4370 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs | |||
@@ -40,6 +40,9 @@ using OpenSim.Region.Environment.Scenes; | |||
40 | 40 | ||
41 | namespace OpenSim.Data.SQLite | 41 | namespace OpenSim.Data.SQLite |
42 | { | 42 | { |
43 | /// <summary> | ||
44 | /// A RegionData Interface to the SQLite database | ||
45 | /// </summary> | ||
43 | public class SQLiteRegionData : IRegionDataStore | 46 | public class SQLiteRegionData : IRegionDataStore |
44 | { | 47 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -74,7 +77,15 @@ namespace OpenSim.Data.SQLite | |||
74 | * | 77 | * |
75 | **********************************************************************/ | 78 | **********************************************************************/ |
76 | 79 | ||
77 | // see IRegionDataStore | 80 | /// <summary> |
81 | /// See IRegionDataStore | ||
82 | /// <list type="bullet"> | ||
83 | /// <item>Initialises RegionData Interface</item> | ||
84 | /// <item>Loads and initialises a new SQLite connection and maintains it.</item> | ||
85 | /// </list> | ||
86 | /// </summary> | ||
87 | /// <param name="connectionString">the connection string</param> | ||
88 | /// <param name="persistPrimInventories">?</param> | ||
78 | public void Initialise(string connectionString, bool persistPrimInventories) | 89 | public void Initialise(string connectionString, bool persistPrimInventories) |
79 | { | 90 | { |
80 | m_connectionString = connectionString; | 91 | m_connectionString = connectionString; |
@@ -203,6 +214,11 @@ namespace OpenSim.Data.SQLite | |||
203 | } | 214 | } |
204 | } | 215 | } |
205 | 216 | ||
217 | /// <summary> | ||
218 | /// Adds an object into region storage | ||
219 | /// </summary> | ||
220 | /// <param name="obj">the object</param> | ||
221 | /// <param name="regionUUID">the region UUID</param> | ||
206 | public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) | 222 | public void StoreObject(SceneObjectGroup obj, LLUUID regionUUID) |
207 | { | 223 | { |
208 | lock (ds) | 224 | lock (ds) |
@@ -233,6 +249,11 @@ namespace OpenSim.Data.SQLite | |||
233 | // m_log.Info("[Dump of prims]: " + ds.GetXml()); | 249 | // m_log.Info("[Dump of prims]: " + ds.GetXml()); |
234 | } | 250 | } |
235 | 251 | ||
252 | /// <summary> | ||
253 | /// Removes an object from region storage | ||
254 | /// </summary> | ||
255 | /// <param name="obj">the object</param> | ||
256 | /// <param name="regionUUID">the region UUID</param> | ||
236 | public void RemoveObject(LLUUID obj, LLUUID regionUUID) | 257 | public void RemoveObject(LLUUID obj, LLUUID regionUUID) |
237 | { | 258 | { |
238 | m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); | 259 | m_log.InfoFormat("[REGION DB]: Removing obj: {0} from region: {1}", obj.UUID, regionUUID); |
@@ -271,6 +292,7 @@ namespace OpenSim.Data.SQLite | |||
271 | /// Remove all persisted items of the given prim. | 292 | /// Remove all persisted items of the given prim. |
272 | /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. | 293 | /// The caller must acquire the necessrary synchronization locks and commit or rollback changes. |
273 | /// </summary> | 294 | /// </summary> |
295 | /// <param name="uuid">The item UUID</param> | ||
274 | private void RemoveItems(LLUUID uuid) | 296 | private void RemoveItems(LLUUID uuid) |
275 | { | 297 | { |
276 | DataTable items = ds.Tables["primitems"]; | 298 | DataTable items = ds.Tables["primitems"]; |
@@ -287,7 +309,7 @@ namespace OpenSim.Data.SQLite | |||
287 | /// <summary> | 309 | /// <summary> |
288 | /// Load persisted objects from region storage. | 310 | /// Load persisted objects from region storage. |
289 | /// </summary> | 311 | /// </summary> |
290 | /// <param name="regionUUID"></param> | 312 | /// <param name="regionUUID">The region UUID</param> |
291 | /// <returns>List of loaded groups</returns> | 313 | /// <returns>List of loaded groups</returns> |
292 | public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) | 314 | public List<SceneObjectGroup> LoadObjects(LLUUID regionUUID) |
293 | { | 315 | { |
@@ -375,7 +397,7 @@ namespace OpenSim.Data.SQLite | |||
375 | /// <summary> | 397 | /// <summary> |
376 | /// Load in a prim's persisted inventory. | 398 | /// Load in a prim's persisted inventory. |
377 | /// </summary> | 399 | /// </summary> |
378 | /// <param name="prim"></param> | 400 | /// <param name="prim">the prim</param> |
379 | private void LoadItems(SceneObjectPart prim) | 401 | private void LoadItems(SceneObjectPart prim) |
380 | { | 402 | { |
381 | //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); | 403 | //m_log.DebugFormat("[DATASTORE]: Loading inventory for {0}, {1}", prim.Name, prim.UUID); |
@@ -405,6 +427,11 @@ namespace OpenSim.Data.SQLite | |||
405 | } | 427 | } |
406 | } | 428 | } |
407 | 429 | ||
430 | /// <summary> | ||
431 | /// Store a terrain revision in region storage | ||
432 | /// </summary> | ||
433 | /// <param name="ter">terrain heightfield</param> | ||
434 | /// <param name="regionID">region UUID</param> | ||
408 | public void StoreTerrain(double[,] ter, LLUUID regionID) | 435 | public void StoreTerrain(double[,] ter, LLUUID regionID) |
409 | { | 436 | { |
410 | lock (ds) | 437 | lock (ds) |
@@ -444,6 +471,11 @@ namespace OpenSim.Data.SQLite | |||
444 | } | 471 | } |
445 | } | 472 | } |
446 | 473 | ||
474 | /// <summary> | ||
475 | /// Load the latest terrain revision from region storage | ||
476 | /// </summary> | ||
477 | /// <param name="regionID">the region UUID</param> | ||
478 | /// <returns>Heightfield data</returns> | ||
447 | public double[,] LoadTerrain(LLUUID regionID) | 479 | public double[,] LoadTerrain(LLUUID regionID) |
448 | { | 480 | { |
449 | lock (ds) | 481 | lock (ds) |
@@ -488,6 +520,10 @@ namespace OpenSim.Data.SQLite | |||
488 | } | 520 | } |
489 | } | 521 | } |
490 | 522 | ||
523 | /// <summary> | ||
524 | /// | ||
525 | /// </summary> | ||
526 | /// <param name="globalID"></param> | ||
491 | public void RemoveLandObject(LLUUID globalID) | 527 | public void RemoveLandObject(LLUUID globalID) |
492 | { | 528 | { |
493 | lock (ds) | 529 | lock (ds) |
@@ -506,6 +542,10 @@ namespace OpenSim.Data.SQLite | |||
506 | } | 542 | } |
507 | } | 543 | } |
508 | 544 | ||
545 | /// <summary> | ||
546 | /// | ||
547 | /// </summary> | ||
548 | /// <param name="parcel"></param> | ||
509 | public void StoreLandObject(ILandObject parcel) | 549 | public void StoreLandObject(ILandObject parcel) |
510 | { | 550 | { |
511 | lock (ds) | 551 | lock (ds) |
@@ -543,6 +583,11 @@ namespace OpenSim.Data.SQLite | |||
543 | Commit(); | 583 | Commit(); |
544 | } | 584 | } |
545 | 585 | ||
586 | /// <summary> | ||
587 | /// | ||
588 | /// </summary> | ||
589 | /// <param name="regionUUID"></param> | ||
590 | /// <returns></returns> | ||
546 | public List<LandData> LoadLandObjects(LLUUID regionUUID) | 591 | public List<LandData> LoadLandObjects(LLUUID regionUUID) |
547 | { | 592 | { |
548 | List<LandData> landDataForRegion = new List<LandData>(); | 593 | List<LandData> landDataForRegion = new List<LandData>(); |
@@ -568,6 +613,9 @@ namespace OpenSim.Data.SQLite | |||
568 | return landDataForRegion; | 613 | return landDataForRegion; |
569 | } | 614 | } |
570 | 615 | ||
616 | /// <summary> | ||
617 | /// | ||
618 | /// </summary> | ||
571 | public void Commit() | 619 | public void Commit() |
572 | { | 620 | { |
573 | lock (ds) | 621 | lock (ds) |
@@ -587,6 +635,9 @@ namespace OpenSim.Data.SQLite | |||
587 | } | 635 | } |
588 | } | 636 | } |
589 | 637 | ||
638 | /// <summary> | ||
639 | /// See <see cref="Commit"/> | ||
640 | /// </summary> | ||
590 | public void Shutdown() | 641 | public void Shutdown() |
591 | { | 642 | { |
592 | Commit(); | 643 | Commit(); |
@@ -600,12 +651,22 @@ namespace OpenSim.Data.SQLite | |||
600 | * | 651 | * |
601 | **********************************************************************/ | 652 | **********************************************************************/ |
602 | 653 | ||
654 | /// <summary> | ||
655 | /// | ||
656 | /// </summary> | ||
657 | /// <param name="dt"></param> | ||
658 | /// <param name="name"></param> | ||
659 | /// <param name="type"></param> | ||
603 | private static void createCol(DataTable dt, string name, Type type) | 660 | private static void createCol(DataTable dt, string name, Type type) |
604 | { | 661 | { |
605 | DataColumn col = new DataColumn(name, type); | 662 | DataColumn col = new DataColumn(name, type); |
606 | dt.Columns.Add(col); | 663 | dt.Columns.Add(col); |
607 | } | 664 | } |
608 | 665 | ||
666 | /// <summary> | ||
667 | /// Creates the "terrain" table | ||
668 | /// </summary> | ||
669 | /// <returns>terrain table DataTable</returns> | ||
609 | private static DataTable createTerrainTable() | 670 | private static DataTable createTerrainTable() |
610 | { | 671 | { |
611 | DataTable terrain = new DataTable("terrain"); | 672 | DataTable terrain = new DataTable("terrain"); |
@@ -617,6 +678,10 @@ namespace OpenSim.Data.SQLite | |||
617 | return terrain; | 678 | return terrain; |
618 | } | 679 | } |
619 | 680 | ||
681 | /// <summary> | ||
682 | /// Creates the "prims" table | ||
683 | /// </summary> | ||
684 | /// <returns>prim table DataTable</returns> | ||
620 | private static DataTable createPrimTable() | 685 | private static DataTable createPrimTable() |
621 | { | 686 | { |
622 | DataTable prims = new DataTable("prims"); | 687 | DataTable prims = new DataTable("prims"); |
@@ -681,6 +746,10 @@ namespace OpenSim.Data.SQLite | |||
681 | return prims; | 746 | return prims; |
682 | } | 747 | } |
683 | 748 | ||
749 | /// <summary> | ||
750 | /// Creates "primshapes" table | ||
751 | /// </summary> | ||
752 | /// <returns>shape table DataTable</returns> | ||
684 | private static DataTable createShapeTable() | 753 | private static DataTable createShapeTable() |
685 | { | 754 | { |
686 | DataTable shapes = new DataTable("primshapes"); | 755 | DataTable shapes = new DataTable("primshapes"); |
@@ -723,6 +792,10 @@ namespace OpenSim.Data.SQLite | |||
723 | return shapes; | 792 | return shapes; |
724 | } | 793 | } |
725 | 794 | ||
795 | /// <summary> | ||
796 | /// creates "primitems" table | ||
797 | /// </summary> | ||
798 | /// <returns>item table DataTable</returns> | ||
726 | private static DataTable createItemsTable() | 799 | private static DataTable createItemsTable() |
727 | { | 800 | { |
728 | DataTable items = new DataTable("primitems"); | 801 | DataTable items = new DataTable("primitems"); |
@@ -756,6 +829,10 @@ namespace OpenSim.Data.SQLite | |||
756 | return items; | 829 | return items; |
757 | } | 830 | } |
758 | 831 | ||
832 | /// <summary> | ||
833 | /// Creates "land" table | ||
834 | /// </summary> | ||
835 | /// <returns>land table DataTable</returns> | ||
759 | private static DataTable createLandTable() | 836 | private static DataTable createLandTable() |
760 | { | 837 | { |
761 | DataTable land = new DataTable("land"); | 838 | DataTable land = new DataTable("land"); |
@@ -800,6 +877,10 @@ namespace OpenSim.Data.SQLite | |||
800 | return land; | 877 | return land; |
801 | } | 878 | } |
802 | 879 | ||
880 | /// <summary> | ||
881 | /// create "landaccesslist" table | ||
882 | /// </summary> | ||
883 | /// <returns>Landacceslist DataTable</returns> | ||
803 | private static DataTable createLandAccessListTable() | 884 | private static DataTable createLandAccessListTable() |
804 | { | 885 | { |
805 | DataTable landaccess = new DataTable("landaccesslist"); | 886 | DataTable landaccess = new DataTable("landaccesslist"); |
@@ -810,6 +891,10 @@ namespace OpenSim.Data.SQLite | |||
810 | return landaccess; | 891 | return landaccess; |
811 | } | 892 | } |
812 | 893 | ||
894 | /// <summary> | ||
895 | /// create "regionban" table | ||
896 | /// </summary> | ||
897 | /// <returns>regionban datatable</returns> | ||
813 | private static DataTable createRegionBanListTable() | 898 | private static DataTable createRegionBanListTable() |
814 | { | 899 | { |
815 | DataTable regionbanlist = new DataTable("regionban"); | 900 | DataTable regionbanlist = new DataTable("regionban"); |
@@ -829,6 +914,11 @@ namespace OpenSim.Data.SQLite | |||
829 | * | 914 | * |
830 | **********************************************************************/ | 915 | **********************************************************************/ |
831 | 916 | ||
917 | /// <summary> | ||
918 | /// | ||
919 | /// </summary> | ||
920 | /// <param name="row"></param> | ||
921 | /// <returns></returns> | ||
832 | private SceneObjectPart buildPrim(DataRow row) | 922 | private SceneObjectPart buildPrim(DataRow row) |
833 | { | 923 | { |
834 | // TODO: this doesn't work yet because something more | 924 | // TODO: this doesn't work yet because something more |
@@ -971,6 +1061,11 @@ namespace OpenSim.Data.SQLite | |||
971 | return taskItem; | 1061 | return taskItem; |
972 | } | 1062 | } |
973 | 1063 | ||
1064 | /// <summary> | ||
1065 | /// Build a Land Data from the persisted data. | ||
1066 | /// </summary> | ||
1067 | /// <param name="row"></param> | ||
1068 | /// <returns></returns> | ||
974 | private LandData buildLandData(DataRow row) | 1069 | private LandData buildLandData(DataRow row) |
975 | { | 1070 | { |
976 | LandData newData = new LandData(); | 1071 | LandData newData = new LandData(); |
@@ -1059,6 +1154,11 @@ namespace OpenSim.Data.SQLite | |||
1059 | return newData; | 1154 | return newData; |
1060 | } | 1155 | } |
1061 | 1156 | ||
1157 | /// <summary> | ||
1158 | /// Build a land access entry from the persisted data. | ||
1159 | /// </summary> | ||
1160 | /// <param name="row"></param> | ||
1161 | /// <returns></returns> | ||
1062 | private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) | 1162 | private static ParcelManager.ParcelAccessEntry buildLandAccessData(DataRow row) |
1063 | { | 1163 | { |
1064 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | 1164 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); |
@@ -1069,7 +1169,11 @@ namespace OpenSim.Data.SQLite | |||
1069 | } | 1169 | } |
1070 | 1170 | ||
1071 | 1171 | ||
1072 | 1172 | /// <summary> | |
1173 | /// Load a region banlist | ||
1174 | /// </summary> | ||
1175 | /// <param name="regionUUID">the region UUID</param> | ||
1176 | /// <returns>The banlist</returns> | ||
1073 | public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID) | 1177 | public List<RegionBanListItem> LoadRegionBanList(LLUUID regionUUID) |
1074 | { | 1178 | { |
1075 | List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>(); | 1179 | List<RegionBanListItem> regionbanlist = new List<RegionBanListItem>(); |
@@ -1096,6 +1200,10 @@ namespace OpenSim.Data.SQLite | |||
1096 | return regionbanlist; | 1200 | return regionbanlist; |
1097 | } | 1201 | } |
1098 | 1202 | ||
1203 | /// <summary> | ||
1204 | /// Add en entry into region banlist | ||
1205 | /// </summary> | ||
1206 | /// <param name="item"></param> | ||
1099 | public void AddToRegionBanlist(RegionBanListItem item) | 1207 | public void AddToRegionBanlist(RegionBanListItem item) |
1100 | { | 1208 | { |
1101 | lock (ds) | 1209 | lock (ds) |
@@ -1111,6 +1219,10 @@ namespace OpenSim.Data.SQLite | |||
1111 | } | 1219 | } |
1112 | } | 1220 | } |
1113 | 1221 | ||
1222 | /// <summary> | ||
1223 | /// remove an entry from the region banlist | ||
1224 | /// </summary> | ||
1225 | /// <param name="item"></param> | ||
1114 | public void RemoveFromRegionBanlist(RegionBanListItem item) | 1226 | public void RemoveFromRegionBanlist(RegionBanListItem item) |
1115 | { | 1227 | { |
1116 | lock (ds) | 1228 | lock (ds) |
@@ -1124,6 +1236,11 @@ namespace OpenSim.Data.SQLite | |||
1124 | } | 1236 | } |
1125 | } | 1237 | } |
1126 | 1238 | ||
1239 | /// <summary> | ||
1240 | /// | ||
1241 | /// </summary> | ||
1242 | /// <param name="val"></param> | ||
1243 | /// <returns></returns> | ||
1127 | private static Array serializeTerrain(double[,] val) | 1244 | private static Array serializeTerrain(double[,] val) |
1128 | { | 1245 | { |
1129 | MemoryStream str = new MemoryStream(65536*sizeof (double)); | 1246 | MemoryStream str = new MemoryStream(65536*sizeof (double)); |
@@ -1153,6 +1270,13 @@ namespace OpenSim.Data.SQLite | |||
1153 | // row["Heightfield"] = str.ToArray(); | 1270 | // row["Heightfield"] = str.ToArray(); |
1154 | // } | 1271 | // } |
1155 | 1272 | ||
1273 | /// <summary> | ||
1274 | /// | ||
1275 | /// </summary> | ||
1276 | /// <param name="row"></param> | ||
1277 | /// <param name="prim"></param> | ||
1278 | /// <param name="sceneGroupID"></param> | ||
1279 | /// <param name="regionUUID"></param> | ||
1156 | private static void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) | 1280 | private static void fillPrimRow(DataRow row, SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) |
1157 | { | 1281 | { |
1158 | row["UUID"] = Util.ToRawUuidString(prim.UUID); | 1282 | row["UUID"] = Util.ToRawUuidString(prim.UUID); |
@@ -1213,6 +1337,11 @@ namespace OpenSim.Data.SQLite | |||
1213 | row["SitTargetOrientZ"] = sitTargetOrient.Z; | 1337 | row["SitTargetOrientZ"] = sitTargetOrient.Z; |
1214 | } | 1338 | } |
1215 | 1339 | ||
1340 | /// <summary> | ||
1341 | /// | ||
1342 | /// </summary> | ||
1343 | /// <param name="row"></param> | ||
1344 | /// <param name="taskItem"></param> | ||
1216 | private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) | 1345 | private static void fillItemRow(DataRow row, TaskInventoryItem taskItem) |
1217 | { | 1346 | { |
1218 | row["itemID"] = taskItem.ItemID; | 1347 | row["itemID"] = taskItem.ItemID; |
@@ -1238,6 +1367,12 @@ namespace OpenSim.Data.SQLite | |||
1238 | row["flags"] = taskItem.Flags; | 1367 | row["flags"] = taskItem.Flags; |
1239 | } | 1368 | } |
1240 | 1369 | ||
1370 | /// <summary> | ||
1371 | /// | ||
1372 | /// </summary> | ||
1373 | /// <param name="row"></param> | ||
1374 | /// <param name="land"></param> | ||
1375 | /// <param name="regionUUID"></param> | ||
1241 | private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) | 1376 | private static void fillLandRow(DataRow row, LandData land, LLUUID regionUUID) |
1242 | { | 1377 | { |
1243 | row["UUID"] = Util.ToRawUuidString(land.globalID); | 1378 | row["UUID"] = Util.ToRawUuidString(land.globalID); |
@@ -1277,6 +1412,12 @@ namespace OpenSim.Data.SQLite | |||
1277 | row["AuthbuyerID"] = Util.ToRawUuidString(land.authBuyerID); | 1412 | row["AuthbuyerID"] = Util.ToRawUuidString(land.authBuyerID); |
1278 | } | 1413 | } |
1279 | 1414 | ||
1415 | /// <summary> | ||
1416 | /// | ||
1417 | /// </summary> | ||
1418 | /// <param name="row"></param> | ||
1419 | /// <param name="entry"></param> | ||
1420 | /// <param name="parcelID"></param> | ||
1280 | private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) | 1421 | private static void fillLandAccessRow(DataRow row, ParcelManager.ParcelAccessEntry entry, LLUUID parcelID) |
1281 | { | 1422 | { |
1282 | row["LandUUID"] = Util.ToRawUuidString(parcelID); | 1423 | row["LandUUID"] = Util.ToRawUuidString(parcelID); |
@@ -1284,6 +1425,11 @@ namespace OpenSim.Data.SQLite | |||
1284 | row["Flags"] = entry.Flags; | 1425 | row["Flags"] = entry.Flags; |
1285 | } | 1426 | } |
1286 | 1427 | ||
1428 | /// <summary> | ||
1429 | /// | ||
1430 | /// </summary> | ||
1431 | /// <param name="row"></param> | ||
1432 | /// <returns></returns> | ||
1287 | private PrimitiveBaseShape buildShape(DataRow row) | 1433 | private PrimitiveBaseShape buildShape(DataRow row) |
1288 | { | 1434 | { |
1289 | PrimitiveBaseShape s = new PrimitiveBaseShape(); | 1435 | PrimitiveBaseShape s = new PrimitiveBaseShape(); |
@@ -1334,6 +1480,11 @@ namespace OpenSim.Data.SQLite | |||
1334 | return s; | 1480 | return s; |
1335 | } | 1481 | } |
1336 | 1482 | ||
1483 | /// <summary> | ||
1484 | /// | ||
1485 | /// </summary> | ||
1486 | /// <param name="row"></param> | ||
1487 | /// <param name="prim"></param> | ||
1337 | private static void fillShapeRow(DataRow row, SceneObjectPart prim) | 1488 | private static void fillShapeRow(DataRow row, SceneObjectPart prim) |
1338 | { | 1489 | { |
1339 | PrimitiveBaseShape s = prim.Shape; | 1490 | PrimitiveBaseShape s = prim.Shape; |
@@ -1371,6 +1522,12 @@ namespace OpenSim.Data.SQLite | |||
1371 | row["ExtraParams"] = s.ExtraParams; | 1522 | row["ExtraParams"] = s.ExtraParams; |
1372 | } | 1523 | } |
1373 | 1524 | ||
1525 | /// <summary> | ||
1526 | /// | ||
1527 | /// </summary> | ||
1528 | /// <param name="prim"></param> | ||
1529 | /// <param name="sceneGroupID"></param> | ||
1530 | /// <param name="regionUUID"></param> | ||
1374 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) | 1531 | private void addPrim(SceneObjectPart prim, LLUUID sceneGroupID, LLUUID regionUUID) |
1375 | { | 1532 | { |
1376 | DataTable prims = ds.Tables["prims"]; | 1533 | DataTable prims = ds.Tables["prims"]; |
@@ -1401,7 +1558,11 @@ namespace OpenSim.Data.SQLite | |||
1401 | } | 1558 | } |
1402 | } | 1559 | } |
1403 | 1560 | ||
1404 | // see IRegionDatastore | 1561 | /// <summary> |
1562 | /// see IRegionDatastore | ||
1563 | /// </summary> | ||
1564 | /// <param name="primID"></param> | ||
1565 | /// <param name="items"></param> | ||
1405 | public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items) | 1566 | public void StorePrimInventory(LLUUID primID, ICollection<TaskInventoryItem> items) |
1406 | { | 1567 | { |
1407 | if (!persistPrimInventories) | 1568 | if (!persistPrimInventories) |
@@ -1444,17 +1605,23 @@ namespace OpenSim.Data.SQLite | |||
1444 | * | 1605 | * |
1445 | **********************************************************************/ | 1606 | **********************************************************************/ |
1446 | 1607 | ||
1608 | /// <summary> | ||
1609 | /// Create an insert command | ||
1610 | /// </summary> | ||
1611 | /// <param name="table">table name</param> | ||
1612 | /// <param name="dt">data table</param> | ||
1613 | /// <returns>the created command</returns> | ||
1614 | /// <remarks> | ||
1615 | /// This is subtle enough to deserve some commentary. | ||
1616 | /// Instead of doing *lots* and *lots of hardcoded strings | ||
1617 | /// for database definitions we'll use the fact that | ||
1618 | /// realistically all insert statements look like "insert | ||
1619 | /// into A(b, c) values(:b, :c) on the parameterized query | ||
1620 | /// front. If we just have a list of b, c, etc... we can | ||
1621 | /// generate these strings instead of typing them out. | ||
1622 | /// </remarks> | ||
1447 | private static SqliteCommand createInsertCommand(string table, DataTable dt) | 1623 | private static SqliteCommand createInsertCommand(string table, DataTable dt) |
1448 | { | 1624 | { |
1449 | /** | ||
1450 | * This is subtle enough to deserve some commentary. | ||
1451 | * Instead of doing *lots* and *lots of hardcoded strings | ||
1452 | * for database definitions we'll use the fact that | ||
1453 | * realistically all insert statements look like "insert | ||
1454 | * into A(b, c) values(:b, :c) on the parameterized query | ||
1455 | * front. If we just have a list of b, c, etc... we can | ||
1456 | * generate these strings instead of typing them out. | ||
1457 | */ | ||
1458 | string[] cols = new string[dt.Columns.Count]; | 1625 | string[] cols = new string[dt.Columns.Count]; |
1459 | for (int i = 0; i < dt.Columns.Count; i++) | 1626 | for (int i = 0; i < dt.Columns.Count; i++) |
1460 | { | 1627 | { |
@@ -1479,6 +1646,14 @@ namespace OpenSim.Data.SQLite | |||
1479 | return cmd; | 1646 | return cmd; |
1480 | } | 1647 | } |
1481 | 1648 | ||
1649 | |||
1650 | /// <summary> | ||
1651 | /// create an update command | ||
1652 | /// </summary> | ||
1653 | /// <param name="table">table name</param> | ||
1654 | /// <param name="pk"></param> | ||
1655 | /// <param name="dt"></param> | ||
1656 | /// <returns>the created command</returns> | ||
1482 | private static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) | 1657 | private static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) |
1483 | { | 1658 | { |
1484 | string sql = "update " + table + " set "; | 1659 | string sql = "update " + table + " set "; |
@@ -1506,7 +1681,11 @@ namespace OpenSim.Data.SQLite | |||
1506 | return cmd; | 1681 | return cmd; |
1507 | } | 1682 | } |
1508 | 1683 | ||
1509 | 1684 | /// <summary> | |
1685 | /// | ||
1686 | /// </summary> | ||
1687 | /// <param name="dt">Data Table</param> | ||
1688 | /// <returns></returns> | ||
1510 | private static string defineTable(DataTable dt) | 1689 | private static string defineTable(DataTable dt) |
1511 | { | 1690 | { |
1512 | string sql = "create table " + dt.TableName + "("; | 1691 | string sql = "create table " + dt.TableName + "("; |
@@ -1559,6 +1738,11 @@ namespace OpenSim.Data.SQLite | |||
1559 | return param; | 1738 | return param; |
1560 | } | 1739 | } |
1561 | 1740 | ||
1741 | /// <summary> | ||
1742 | /// | ||
1743 | /// </summary> | ||
1744 | /// <param name="da"></param> | ||
1745 | /// <param name="conn"></param> | ||
1562 | private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) | 1746 | private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) |
1563 | { | 1747 | { |
1564 | da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]); | 1748 | da.InsertCommand = createInsertCommand("prims", ds.Tables["prims"]); |
@@ -1573,6 +1757,11 @@ namespace OpenSim.Data.SQLite | |||
1573 | da.DeleteCommand = delete; | 1757 | da.DeleteCommand = delete; |
1574 | } | 1758 | } |
1575 | 1759 | ||
1760 | /// <summary> | ||
1761 | /// | ||
1762 | /// </summary> | ||
1763 | /// <param name="da"></param> | ||
1764 | /// <param name="conn"></param> | ||
1576 | private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) | 1765 | private void setupItemsCommands(SqliteDataAdapter da, SqliteConnection conn) |
1577 | { | 1766 | { |
1578 | da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]); | 1767 | da.InsertCommand = createInsertCommand("primitems", ds.Tables["primitems"]); |
@@ -1587,12 +1776,22 @@ namespace OpenSim.Data.SQLite | |||
1587 | da.DeleteCommand = delete; | 1776 | da.DeleteCommand = delete; |
1588 | } | 1777 | } |
1589 | 1778 | ||
1779 | /// <summary> | ||
1780 | /// | ||
1781 | /// </summary> | ||
1782 | /// <param name="da"></param> | ||
1783 | /// <param name="conn"></param> | ||
1590 | private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn) | 1784 | private void setupTerrainCommands(SqliteDataAdapter da, SqliteConnection conn) |
1591 | { | 1785 | { |
1592 | da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]); | 1786 | da.InsertCommand = createInsertCommand("terrain", ds.Tables["terrain"]); |
1593 | da.InsertCommand.Connection = conn; | 1787 | da.InsertCommand.Connection = conn; |
1594 | } | 1788 | } |
1595 | 1789 | ||
1790 | /// <summary> | ||
1791 | /// | ||
1792 | /// </summary> | ||
1793 | /// <param name="da"></param> | ||
1794 | /// <param name="conn"></param> | ||
1596 | private void setupLandCommands(SqliteDataAdapter da, SqliteConnection conn) | 1795 | private void setupLandCommands(SqliteDataAdapter da, SqliteConnection conn) |
1597 | { | 1796 | { |
1598 | da.InsertCommand = createInsertCommand("land", ds.Tables["land"]); | 1797 | da.InsertCommand = createInsertCommand("land", ds.Tables["land"]); |
@@ -1602,12 +1801,22 @@ namespace OpenSim.Data.SQLite | |||
1602 | da.UpdateCommand.Connection = conn; | 1801 | da.UpdateCommand.Connection = conn; |
1603 | } | 1802 | } |
1604 | 1803 | ||
1804 | /// <summary> | ||
1805 | /// | ||
1806 | /// </summary> | ||
1807 | /// <param name="da"></param> | ||
1808 | /// <param name="conn"></param> | ||
1605 | private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn) | 1809 | private void setupLandAccessCommands(SqliteDataAdapter da, SqliteConnection conn) |
1606 | { | 1810 | { |
1607 | da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); | 1811 | da.InsertCommand = createInsertCommand("landaccesslist", ds.Tables["landaccesslist"]); |
1608 | da.InsertCommand.Connection = conn; | 1812 | da.InsertCommand.Connection = conn; |
1609 | } | 1813 | } |
1610 | 1814 | ||
1815 | /// <summary> | ||
1816 | /// | ||
1817 | /// </summary> | ||
1818 | /// <param name="da"></param> | ||
1819 | /// <param name="conn"></param> | ||
1611 | private void setupRegionBanCommands(SqliteDataAdapter da, SqliteConnection conn) | 1820 | private void setupRegionBanCommands(SqliteDataAdapter da, SqliteConnection conn) |
1612 | { | 1821 | { |
1613 | da.InsertCommand = createInsertCommand("regionban", ds.Tables["regionban"]); | 1822 | da.InsertCommand = createInsertCommand("regionban", ds.Tables["regionban"]); |
@@ -1617,7 +1826,11 @@ namespace OpenSim.Data.SQLite | |||
1617 | da.UpdateCommand.Connection = conn; | 1826 | da.UpdateCommand.Connection = conn; |
1618 | } | 1827 | } |
1619 | 1828 | ||
1620 | 1829 | /// <summary> | |
1830 | /// | ||
1831 | /// </summary> | ||
1832 | /// <param name="da"></param> | ||
1833 | /// <param name="conn"></param> | ||
1621 | private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) | 1834 | private void setupShapeCommands(SqliteDataAdapter da, SqliteConnection conn) |
1622 | { | 1835 | { |
1623 | da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); | 1836 | da.InsertCommand = createInsertCommand("primshapes", ds.Tables["primshapes"]); |
@@ -1710,6 +1923,12 @@ namespace OpenSim.Data.SQLite | |||
1710 | // } | 1923 | // } |
1711 | // } | 1924 | // } |
1712 | 1925 | ||
1926 | /// <summary> | ||
1927 | /// | ||
1928 | /// </summary> | ||
1929 | /// <param name="conn"></param> | ||
1930 | /// <param name="m"></param> | ||
1931 | /// <returns></returns> | ||
1713 | private bool TestTables(SqliteConnection conn, Migration m) | 1932 | private bool TestTables(SqliteConnection conn, Migration m) |
1714 | { | 1933 | { |
1715 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); | 1934 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); |
@@ -1822,6 +2041,11 @@ namespace OpenSim.Data.SQLite | |||
1822 | * | 2041 | * |
1823 | **********************************************************************/ | 2042 | **********************************************************************/ |
1824 | 2043 | ||
2044 | /// <summary> | ||
2045 | /// Type conversion function | ||
2046 | /// </summary> | ||
2047 | /// <param name="type"></param> | ||
2048 | /// <returns></returns> | ||
1825 | private static DbType dbtypeFromType(Type type) | 2049 | private static DbType dbtypeFromType(Type type) |
1826 | { | 2050 | { |
1827 | if (type == typeof (String)) | 2051 | if (type == typeof (String)) |
@@ -1854,8 +2078,11 @@ namespace OpenSim.Data.SQLite | |||
1854 | } | 2078 | } |
1855 | } | 2079 | } |
1856 | 2080 | ||
1857 | // this is something we'll need to implement for each db | 2081 | /// <summary> |
1858 | // slightly differently. | 2082 | /// </summary> |
2083 | /// <param name="type">a Type</param> | ||
2084 | /// <returns>an sqliteType</returns> | ||
2085 | /// <remarks>this is something we'll need to implement for each db slightly differently.</remarks> | ||
1859 | private static string sqliteType(Type type) | 2086 | private static string sqliteType(Type type) |
1860 | { | 2087 | { |
1861 | if (type == typeof (String)) | 2088 | if (type == typeof (String)) |