aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Storage/OpenSim.DataStore.Sqlite')
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs213
1 files changed, 0 insertions, 213 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs
deleted file mode 100644
index 5c17620..0000000
--- a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs
+++ /dev/null
@@ -1,213 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using OpenSim.Region.Environment.Scenes;
6using OpenSim.Region.Environment.LandManagement;
7using OpenSim.Region.Environment;
8using OpenSim.Region.Interfaces;
9using OpenSim.Framework.Console;
10using libsecondlife;
11
12using System.Data;
13// Yes, this won't compile on MS, need to deal with that later
14using Mono.Data.SqliteClient;
15using Primitive = OpenSim.Region.Environment.Scenes.Primitive;
16
17namespace OpenSim.DataStore.SqliteStorage
18{
19
20 public class SqliteDataStore : IRegionDataStore
21 {
22 private const string primSelect = "select * from prims";
23 private const string shapeSelect = "select * from primshapes";
24
25 private DataSet ds;
26 private SqliteDataAdapter primDa;
27 private SqliteDataAdapter shapeDa;
28
29 public void Initialise(string dbfile, string dbname)
30 {
31 // for us, dbfile will be the connect string
32 MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + dbfile);
33 SqliteConnection conn = new SqliteConnection(dbfile);
34
35 SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
36 primDa = new SqliteDataAdapter(primSelectCmd);
37 // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);
38
39 SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn);
40 shapeDa = new SqliteDataAdapter(shapeSelectCmd);
41 // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);
42
43 ds = new DataSet();
44
45 // We fill the data set, now we've got copies in memory for the information
46 // TODO: see if the linkage actually holds.
47 // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
48 primDa.Fill(ds, "prims");
49 ds.AcceptChanges();
50
51 DataTable prims = ds.Tables["prims"];
52 prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] };
53 setupPrimCommands(primDa, conn);
54
55 // shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema");
56 shapeDa.Fill(ds, "primshapes");
57
58 return;
59 }
60
61 private SqliteParameter createSqliteParameter(string name, DbType type)
62 {
63 SqliteParameter param = new SqliteParameter();
64 param.ParameterName = ":" + name;
65 param.DbType = type;
66 param.SourceColumn = name;
67 param.SourceVersion = DataRowVersion.Current;
68 return param;
69 }
70
71 private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn)
72 {
73 SqliteParameter UUID = createSqliteParameter("UUID", DbType.String);
74 SqliteParameter Name = createSqliteParameter("Name", DbType.String);
75 SqliteParameter CreationDate = createSqliteParameter("CreationDate", DbType.Int32);
76 SqliteParameter PositionX = createSqliteParameter("PositionX", DbType.Double);
77 SqliteParameter PositionY = createSqliteParameter("PositionY", DbType.Double);
78 SqliteParameter PositionZ = createSqliteParameter("PositionZ", DbType.Double);
79
80
81 SqliteCommand delete = new SqliteCommand("delete from prims where UUID = :UUID");
82 delete.Connection = conn;
83
84 SqliteCommand insert =
85 new SqliteCommand("insert into prims(" +
86 "UUID, CreationDate, Name, PositionX, PositionY, PositionZ" +
87 ") values(:UUID, :CreationDate, :Name, :PositionX, :PositionY, :PositionZ)");
88 insert.Connection = conn;
89
90 SqliteCommand update =
91 new SqliteCommand("update prims set " +
92 "UUID = :UUID, CreationDate = :CreationDate, Name = :Name, PositionX = :PositionX, " +
93 "PositionY = :PositionY, PositionZ = :PositionZ where UUID = :UUID");
94 update.Connection = conn;
95
96 delete.Parameters.Add(UUID);
97
98 insert.Parameters.Add(UUID);
99 insert.Parameters.Add(Name);
100 insert.Parameters.Add(CreationDate);
101 insert.Parameters.Add(PositionX);
102 insert.Parameters.Add(PositionY);
103 insert.Parameters.Add(PositionZ);
104
105 update.Parameters.Add(UUID);
106 update.Parameters.Add(Name);
107 update.Parameters.Add(CreationDate);
108 update.Parameters.Add(PositionX);
109 update.Parameters.Add(PositionY);
110 update.Parameters.Add(PositionZ);
111
112 da.DeleteCommand = delete;
113 da.InsertCommand = insert;
114 da.UpdateCommand = update;
115 }
116
117 private void StoreSceneObject(SceneObject obj)
118 {
119
120 }
121
122 public void StoreObject(AllNewSceneObjectPart2 obj)
123 {
124 // TODO: Serializing code
125 DataTable prims = ds.Tables["prims"];
126 DataTable shapes = ds.Tables["shapes"];
127
128
129
130 }
131
132 private void fillPrimRow(DataRow row, Primitive prim)
133 {
134 row["UUID"] = prim.UUID;
135 row["CreationDate"] = prim.CreationDate;
136 row["Name"] = prim.Name;
137 row["PositionX"] = prim.Pos.X;
138 row["PositionY"] = prim.Pos.Y;
139 row["PositionZ"] = prim.Pos.Z;
140 }
141
142 private void addPrim(Primitive prim)
143 {
144 DataTable prims = ds.Tables["prims"];
145 DataTable shapes = ds.Tables["shapes"];
146
147 DataRow row = prims.Rows.Find(prim.UUID);
148 if (row == null) {
149 row = prims.NewRow();
150 fillPrimRow(row, prim);
151 prims.Rows.Add(row);
152 } else {
153 fillPrimRow(row, prim);
154 }
155 }
156
157 public void StoreObject(SceneObject obj)
158 {
159 foreach (Primitive prim in obj.Children.Values)
160 {
161 addPrim(prim);
162 }
163
164 MainLog.Instance.Verbose("Attempting to do update....");
165 primDa.Update(ds, "prims");
166 MainLog.Instance.Verbose("Dump of prims:", ds.GetXml());
167 }
168
169 public void RemoveObject(LLUUID obj)
170 {
171 // TODO: remove code
172 }
173
174 public List<SceneObject> LoadObjects()
175 {
176 List<SceneObject> retvals = new List<SceneObject>();
177
178 MainLog.Instance.Verbose("DATASTORE", "Sqlite - LoadObjects found " + " objects");
179
180 return retvals;
181 }
182
183 public void StoreTerrain(double[,] ter)
184 {
185
186 }
187
188 public double[,] LoadTerrain()
189 {
190 return null;
191 }
192
193 public void RemoveLandObject(uint id)
194 {
195
196 }
197
198 public void StoreParcel(Land parcel)
199 {
200
201 }
202
203 public List<Land> LoadLandObjects()
204 {
205 return new List<Land>();
206 }
207
208 public void Shutdown()
209 {
210 // TODO: DataSet commit
211 }
212 }
213}