1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
module CPM.Repository.RepositoryDB where
import qualified Data.Time as Time
import qualified Database.CDBI.ER
import qualified Database.CDBI.Criteria
import qualified Database.CDBI.Connection
import qualified Database.CDBI.Description
data IndexEntry = IndexEntry IndexEntryID String String String String String String String String String
deriving (Eq,Show,Read)
data IndexEntryID = IndexEntryID Int
deriving (Eq,Show,Read)
sqliteDBFile :: String
sqliteDBFile = "REPOSITORY_CACHE.db"
indexEntry_CDBI_Description
:: Database.CDBI.Description.EntityDescription IndexEntry
indexEntry_CDBI_Description =
Database.CDBI.Description.ED "IndexEntry"
[Database.CDBI.Connection.SQLTypeInt
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString
,Database.CDBI.Connection.SQLTypeString]
(\(IndexEntry
(IndexEntryID key)
name
version
dependencies
compilerCompatibility
synopsis
category
sourceDirs
exportedModules
executableSpec) ->
[Database.CDBI.Connection.SQLInt key
,Database.CDBI.Connection.SQLString name
,Database.CDBI.Connection.SQLString version
,Database.CDBI.Description.sqlString dependencies
,Database.CDBI.Description.sqlString compilerCompatibility
,Database.CDBI.Description.sqlString synopsis
,Database.CDBI.Description.sqlString category
,Database.CDBI.Description.sqlString sourceDirs
,Database.CDBI.Description.sqlString exportedModules
,Database.CDBI.Description.sqlString executableSpec])
(\(IndexEntry
_
name
version
dependencies
compilerCompatibility
synopsis
category
sourceDirs
exportedModules
executableSpec) ->
[Database.CDBI.Connection.SQLNull
,Database.CDBI.Connection.SQLString name
,Database.CDBI.Connection.SQLString version
,Database.CDBI.Description.sqlString dependencies
,Database.CDBI.Description.sqlString compilerCompatibility
,Database.CDBI.Description.sqlString synopsis
,Database.CDBI.Description.sqlString category
,Database.CDBI.Description.sqlString sourceDirs
,Database.CDBI.Description.sqlString exportedModules
,Database.CDBI.Description.sqlString executableSpec])
(\[Database.CDBI.Connection.SQLInt key
,Database.CDBI.Connection.SQLString name
,Database.CDBI.Connection.SQLString version
,dependencies
,compilerCompatibility
,synopsis
,category
,sourceDirs
,exportedModules
,executableSpec] ->
IndexEntry (IndexEntryID key) name version
(Database.CDBI.Description.fromStringOrNull dependencies)
(Database.CDBI.Description.fromStringOrNull compilerCompatibility)
(Database.CDBI.Description.fromStringOrNull synopsis)
(Database.CDBI.Description.fromStringOrNull category)
(Database.CDBI.Description.fromStringOrNull sourceDirs)
(Database.CDBI.Description.fromStringOrNull exportedModules)
(Database.CDBI.Description.fromStringOrNull executableSpec))
indexEntryTable :: Database.CDBI.Description.Table
indexEntryTable = "IndexEntry"
indexEntryColumnKey :: Database.CDBI.Description.Column IndexEntryID
indexEntryColumnKey =
Database.CDBI.Description.Column "\"Key\"" "\"IndexEntry\".\"Key\""
indexEntryColumnName :: Database.CDBI.Description.Column String
indexEntryColumnName =
Database.CDBI.Description.Column "\"Name\"" "\"IndexEntry\".\"Name\""
indexEntryColumnVersion :: Database.CDBI.Description.Column String
indexEntryColumnVersion =
Database.CDBI.Description.Column "\"Version\"" "\"IndexEntry\".\"Version\""
indexEntryColumnDependencies :: Database.CDBI.Description.Column String
indexEntryColumnDependencies =
Database.CDBI.Description.Column "\"Dependencies\""
"\"IndexEntry\".\"Dependencies\""
indexEntryColumnCompilerCompatibility :: Database.CDBI.Description.Column String
indexEntryColumnCompilerCompatibility =
Database.CDBI.Description.Column "\"CompilerCompatibility\""
"\"IndexEntry\".\"CompilerCompatibility\""
indexEntryColumnSynopsis :: Database.CDBI.Description.Column String
indexEntryColumnSynopsis =
Database.CDBI.Description.Column "\"Synopsis\"" "\"IndexEntry\".\"Synopsis\""
indexEntryColumnCategory :: Database.CDBI.Description.Column String
indexEntryColumnCategory =
Database.CDBI.Description.Column "\"Category\"" "\"IndexEntry\".\"Category\""
indexEntryColumnSourceDirs :: Database.CDBI.Description.Column String
indexEntryColumnSourceDirs =
Database.CDBI.Description.Column "\"SourceDirs\""
"\"IndexEntry\".\"SourceDirs\""
indexEntryColumnExportedModules :: Database.CDBI.Description.Column String
indexEntryColumnExportedModules =
Database.CDBI.Description.Column "\"ExportedModules\""
"\"IndexEntry\".\"ExportedModules\""
indexEntryColumnExecutableSpec :: Database.CDBI.Description.Column String
indexEntryColumnExecutableSpec =
Database.CDBI.Description.Column "\"ExecutableSpec\""
"\"IndexEntry\".\"ExecutableSpec\""
indexEntryKeyColDesc :: Database.CDBI.Description.ColumnDescription IndexEntryID
indexEntryKeyColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Key\""
Database.CDBI.Connection.SQLTypeInt
(\(IndexEntryID key) -> Database.CDBI.Connection.SQLInt key)
(\(Database.CDBI.Connection.SQLInt key) -> IndexEntryID key)
indexEntryNameColDesc :: Database.CDBI.Description.ColumnDescription String
indexEntryNameColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Name\""
Database.CDBI.Connection.SQLTypeString
(\name -> Database.CDBI.Connection.SQLString name)
(\(Database.CDBI.Connection.SQLString name) -> name)
indexEntryVersionColDesc :: Database.CDBI.Description.ColumnDescription String
indexEntryVersionColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Version\""
Database.CDBI.Connection.SQLTypeString
(\version -> Database.CDBI.Connection.SQLString version)
(\(Database.CDBI.Connection.SQLString version) -> version)
indexEntryDependenciesColDesc
:: Database.CDBI.Description.ColumnDescription String
indexEntryDependenciesColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Dependencies\""
Database.CDBI.Connection.SQLTypeString
(\dependencies -> Database.CDBI.Description.sqlString dependencies)
(\dependencies -> Database.CDBI.Description.fromStringOrNull dependencies)
indexEntryCompilerCompatibilityColDesc
:: Database.CDBI.Description.ColumnDescription String
indexEntryCompilerCompatibilityColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"CompilerCompatibility\""
Database.CDBI.Connection.SQLTypeString
(\compilerCompatibility ->
Database.CDBI.Description.sqlString compilerCompatibility)
(\compilerCompatibility ->
Database.CDBI.Description.fromStringOrNull compilerCompatibility)
indexEntrySynopsisColDesc :: Database.CDBI.Description.ColumnDescription String
indexEntrySynopsisColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Synopsis\""
Database.CDBI.Connection.SQLTypeString
(\synopsis -> Database.CDBI.Description.sqlString synopsis)
(\synopsis -> Database.CDBI.Description.fromStringOrNull synopsis)
indexEntryCategoryColDesc :: Database.CDBI.Description.ColumnDescription String
indexEntryCategoryColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"Category\""
Database.CDBI.Connection.SQLTypeString
(\category -> Database.CDBI.Description.sqlString category)
(\category -> Database.CDBI.Description.fromStringOrNull category)
indexEntrySourceDirsColDesc
:: Database.CDBI.Description.ColumnDescription String
indexEntrySourceDirsColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"SourceDirs\""
Database.CDBI.Connection.SQLTypeString
(\sourceDirs -> Database.CDBI.Description.sqlString sourceDirs)
(\sourceDirs -> Database.CDBI.Description.fromStringOrNull sourceDirs)
indexEntryExportedModulesColDesc
:: Database.CDBI.Description.ColumnDescription String
indexEntryExportedModulesColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"ExportedModules\""
Database.CDBI.Connection.SQLTypeString
(\exportedModules -> Database.CDBI.Description.sqlString exportedModules)
(\exportedModules ->
Database.CDBI.Description.fromStringOrNull exportedModules)
indexEntryExecutableSpecColDesc
:: Database.CDBI.Description.ColumnDescription String
indexEntryExecutableSpecColDesc =
Database.CDBI.Description.ColDesc "\"IndexEntry\".\"ExecutableSpec\""
Database.CDBI.Connection.SQLTypeString
(\executableSpec -> Database.CDBI.Description.sqlString executableSpec)
(\executableSpec ->
Database.CDBI.Description.fromStringOrNull executableSpec)
indexEntryKey :: IndexEntry -> IndexEntryID
indexEntryKey (IndexEntry a _ _ _ _ _ _ _ _ _) = a
indexEntryName :: IndexEntry -> String
indexEntryName (IndexEntry _ a _ _ _ _ _ _ _ _) = a
indexEntryVersion :: IndexEntry -> String
indexEntryVersion (IndexEntry _ _ a _ _ _ _ _ _ _) = a
indexEntryDependencies :: IndexEntry -> String
indexEntryDependencies (IndexEntry _ _ _ a _ _ _ _ _ _) = a
indexEntryCompilerCompatibility :: IndexEntry -> String
indexEntryCompilerCompatibility (IndexEntry _ _ _ _ a _ _ _ _ _) = a
indexEntrySynopsis :: IndexEntry -> String
indexEntrySynopsis (IndexEntry _ _ _ _ _ a _ _ _ _) = a
indexEntryCategory :: IndexEntry -> String
indexEntryCategory (IndexEntry _ _ _ _ _ _ a _ _ _) = a
indexEntrySourceDirs :: IndexEntry -> String
indexEntrySourceDirs (IndexEntry _ _ _ _ _ _ _ a _ _) = a
indexEntryExportedModules :: IndexEntry -> String
indexEntryExportedModules (IndexEntry _ _ _ _ _ _ _ _ a _) = a
indexEntryExecutableSpec :: IndexEntry -> String
indexEntryExecutableSpec (IndexEntry _ _ _ _ _ _ _ _ _ a) = a
setIndexEntryKey :: IndexEntry -> IndexEntryID -> IndexEntry
setIndexEntryKey (IndexEntry _ b9 b8 b7 b6 b5 b4 b3 b2 b1) a =
IndexEntry a b9 b8 b7 b6 b5 b4 b3 b2 b1
setIndexEntryName :: IndexEntry -> String -> IndexEntry
setIndexEntryName (IndexEntry a2 _ b8 b7 b6 b5 b4 b3 b2 b1) a =
IndexEntry a2 a b8 b7 b6 b5 b4 b3 b2 b1
setIndexEntryVersion :: IndexEntry -> String -> IndexEntry
setIndexEntryVersion (IndexEntry a3 a2 _ b7 b6 b5 b4 b3 b2 b1) a =
IndexEntry a3 a2 a b7 b6 b5 b4 b3 b2 b1
setIndexEntryDependencies :: IndexEntry -> String -> IndexEntry
setIndexEntryDependencies (IndexEntry a4 a3 a2 _ b6 b5 b4 b3 b2 b1) a =
IndexEntry a4 a3 a2 a b6 b5 b4 b3 b2 b1
setIndexEntryCompilerCompatibility :: IndexEntry -> String -> IndexEntry
setIndexEntryCompilerCompatibility (IndexEntry a5 a4 a3 a2 _ b5 b4 b3 b2 b1) a =
IndexEntry a5 a4 a3 a2 a b5 b4 b3 b2 b1
setIndexEntrySynopsis :: IndexEntry -> String -> IndexEntry
setIndexEntrySynopsis (IndexEntry a6 a5 a4 a3 a2 _ b4 b3 b2 b1) a =
IndexEntry a6 a5 a4 a3 a2 a b4 b3 b2 b1
setIndexEntryCategory :: IndexEntry -> String -> IndexEntry
setIndexEntryCategory (IndexEntry a7 a6 a5 a4 a3 a2 _ b3 b2 b1) a =
IndexEntry a7 a6 a5 a4 a3 a2 a b3 b2 b1
setIndexEntrySourceDirs :: IndexEntry -> String -> IndexEntry
setIndexEntrySourceDirs (IndexEntry a8 a7 a6 a5 a4 a3 a2 _ b2 b1) a =
IndexEntry a8 a7 a6 a5 a4 a3 a2 a b2 b1
setIndexEntryExportedModules :: IndexEntry -> String -> IndexEntry
setIndexEntryExportedModules (IndexEntry a9 a8 a7 a6 a5 a4 a3 a2 _ b1) a =
IndexEntry a9 a8 a7 a6 a5 a4 a3 a2 a b1
setIndexEntryExecutableSpec :: IndexEntry -> String -> IndexEntry
setIndexEntryExecutableSpec (IndexEntry a10 a9 a8 a7 a6 a5 a4 a3 a2 _) a =
IndexEntry a10 a9 a8 a7 a6 a5 a4 a3 a2 a
indexEntryID :: IndexEntryID -> Database.CDBI.Criteria.Value IndexEntryID
indexEntryID (IndexEntryID key) = Database.CDBI.Criteria.idVal key
indexEntryKeyToInt :: IndexEntryID -> Int
indexEntryKeyToInt (IndexEntryID key) = key
showIndexEntryKey :: IndexEntry -> String
showIndexEntryKey entry =
Database.CDBI.ER.showDatabaseKey "IndexEntry" indexEntryKeyToInt
(indexEntryKey entry)
readIndexEntryKey :: String -> Maybe IndexEntryID
readIndexEntryKey = Database.CDBI.ER.readDatabaseKey "IndexEntry" IndexEntryID
queryAllIndexEntrys :: Database.CDBI.Connection.DBAction [IndexEntry]
queryAllIndexEntrys = Database.CDBI.ER.getAllEntries indexEntry_CDBI_Description
queryCondIndexEntry
:: (IndexEntry -> Bool) -> Database.CDBI.Connection.DBAction [IndexEntry]
queryCondIndexEntry =
Database.CDBI.ER.getCondEntries indexEntry_CDBI_Description
getIndexEntry :: IndexEntryID -> Database.CDBI.Connection.DBAction IndexEntry
getIndexEntry =
Database.CDBI.ER.getEntryWithKey indexEntry_CDBI_Description
indexEntryColumnKey
indexEntryID
newIndexEntry
:: String
-> String
-> String
-> String
-> String
-> String
-> String -> String -> String -> Database.CDBI.Connection.DBAction IndexEntry
newIndexEntry
name_p
version_p
dependencies_p
compilerCompatibility_p
synopsis_p
category_p
sourceDirs_p
exportedModules_p
executableSpec_p =
Database.CDBI.ER.insertNewEntry indexEntry_CDBI_Description setIndexEntryKey
IndexEntryID
(IndexEntry (IndexEntryID 0) name_p version_p dependencies_p
compilerCompatibility_p
synopsis_p
category_p
sourceDirs_p
exportedModules_p
executableSpec_p)
deleteIndexEntry :: IndexEntry -> Database.CDBI.Connection.DBAction ()
deleteIndexEntry =
Database.CDBI.ER.deleteEntry indexEntry_CDBI_Description indexEntryColumnKey
(indexEntryID . indexEntryKey)
updateIndexEntry :: IndexEntry -> Database.CDBI.Connection.DBAction ()
updateIndexEntry = Database.CDBI.ER.updateEntry indexEntry_CDBI_Description
createNewDB :: String -> IO ()
createNewDB dbfile =
do conn <- Database.CDBI.Connection.connectSQLite dbfile
Database.CDBI.Connection.writeConnection cstr conn
Database.CDBI.Connection.disconnect conn
where
cstr =
unlines
["create table 'IndexEntry'('Key' integer primary key ,'Name' string not null ,'Version' string not null ,'Dependencies' string ,'CompilerCompatibility' string ,'Synopsis' string ,'Category' string ,'SourceDirs' string ,'ExportedModules' string ,'ExecutableSpec' string);"]
saveDBTo :: String -> IO ()
saveDBTo dir =
do Database.CDBI.ER.saveDBTerms indexEntry_CDBI_Description sqliteDBFile dir
restoreDBFrom :: String -> IO ()
restoreDBFrom dir =
do Database.CDBI.ER.restoreDBTerms indexEntry_CDBI_Description sqliteDBFile
dir
runQ :: Database.CDBI.Connection.DBAction a -> IO a
runQ = Database.CDBI.ER.runQueryOnDB sqliteDBFile
runT
:: Database.CDBI.Connection.DBAction a
-> IO (Database.CDBI.Connection.SQLResult a)
runT = Database.CDBI.ER.runTransactionOnDB sqliteDBFile
runJustT :: Database.CDBI.Connection.DBAction a -> IO a
runJustT = Database.CDBI.ER.runJustTransactionOnDB sqliteDBFile
|