File: database-orm.ads

package info (click to toggle)
gnat-gps 18-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,716 kB
  • sloc: ada: 362,679; python: 31,031; xml: 9,597; makefile: 1,030; ansic: 917; sh: 264; java: 17
file content (1376 lines) | stat: -rw-r--r-- 54,228 bytes parent folder | download
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
pragma Warnings (Off);
with Ada.Calendar; use Ada.Calendar;
with Ada.Finalization; use Ada.Finalization;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Database; use Database;
with GNAT.Calendar; use GNAT.Calendar;
with GNAT.Strings; use GNAT.Strings;
with GNATCOLL.SQL; use GNATCOLL.SQL;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.SQL.Orm; use GNATCOLL.SQL.Orm;
with GNATCOLL.SQL.Orm.Impl; use GNATCOLL.SQL.Orm.Impl;
with GNATCOLL.SQL.Sessions; use GNATCOLL.SQL.Sessions;
with GNATCOLL.SQL_Fields; use GNATCOLL.SQL_Fields;
with GNATCOLL.Tribooleans; use GNATCOLL.Tribooleans;
with System.Address_Image;
pragma Warnings (On);
pragma Style_Checks (Off);

package Database.Orm is
   package DBA renames Database;
   subtype Related_Depth is Integer range 0 .. 3;

   -----------
   -- Types --
   -----------
   --  Detached_* elements extract the value from the list and store them
    --  locally. As a result, they remain valid even if the list is modified,
    --  but require more memory to store.
    --
    --  Other elements are only valid while the list from which they are
    --  created is not modified(see Element below). As soon as you iterate the
    --  list this element becomes invalid.
    --
    --  Direct lists are stored in memory, and can be traversed in any order.
    --  Forward lists can only be iterated forward. With some database backends
    --  this is much more efficient since only the current element needs to be
    --  stored in memory(and retrieved from the server).

   type Entity is new Orm_Element with null record;
   type Entity_DDR is new Detached_Data (7) with private;
   type Detached_Entity is  --  Get() returns a Entity_DDR
   new Sessions.Detached_Element with private;
   type Detached_Entity_Access is access all Detached_Entity'Class;
   No_Detached_Entity : constant Detached_Entity;
   No_Entity : constant Entity;

   type Entity_Message is new Orm_Element with null record;
   type Entity_Message_DDR is new Detached_Data (5) with private;
   type Detached_Entity_Message is  --  Get() returns a Entity_Message_DDR
   new Sessions.Detached_Element with private;
   type Detached_Entity_Message_Access is access all Detached_Entity_Message'Class;
   No_Detached_Entity_Message : constant Detached_Entity_Message;
   No_Entity_Message : constant Entity_Message;

   type Message is new Orm_Element with null record;
   type Message_DDR is new Detached_Data (5) with private;
   type Detached_Message is  --  Get() returns a Message_DDR
   new Sessions.Detached_Element with private;
   type Detached_Message_Access is access all Detached_Message'Class;
   No_Detached_Message : constant Detached_Message;
   No_Message : constant Message;

   type Message_Property is new Orm_Element with null record;
   type Message_Property_DDR is new Detached_Data (5) with private;
   type Detached_Message_Property is  --  Get() returns a Message_Property_DDR
   new Sessions.Detached_Element with private;
   type Detached_Message_Property_Access is access all Detached_Message_Property'Class;
   No_Detached_Message_Property : constant Detached_Message_Property;
   No_Message_Property : constant Message_Property;

   type Property is new Orm_Element with null record;
   type Property_DDR is new Detached_Data (3) with private;
   type Detached_Property is  --  Get() returns a Property_DDR
   new Sessions.Detached_Element with private;
   type Detached_Property_Access is access all Detached_Property'Class;
   No_Detached_Property : constant Detached_Property;
   No_Property : constant Property;

   type Resource_Tree is new Orm_Element with null record;
   type Resource_Tree_DDR is new Detached_Data (5) with private;
   type Detached_Resource_Tree is  --  Get() returns a Resource_Tree_DDR
   new Sessions.Detached_Element with private;
   type Detached_Resource_Tree_Access is access all Detached_Resource_Tree'Class;
   No_Detached_Resource_Tree : constant Detached_Resource_Tree;
   No_Resource_Tree : constant Resource_Tree;

   type Resource is new Orm_Element with null record;
   type Resource_DDR is new Detached_Data (4) with private;
   type Detached_Resource is  --  Get() returns a Resource_DDR
   new Sessions.Detached_Element with private;
   type Detached_Resource_Access is access all Detached_Resource'Class;
   No_Detached_Resource : constant Detached_Resource;
   No_Resource : constant Resource;

   type Resource_Message is new Orm_Element with null record;
   type Resource_Message_DDR is new Detached_Data (8) with private;
   type Detached_Resource_Message is  --  Get() returns a Resource_Message_DDR
   new Sessions.Detached_Element with private;
   type Detached_Resource_Message_Access is access all Detached_Resource_Message'Class;
   No_Detached_Resource_Message : constant Detached_Resource_Message;
   No_Resource_Message : constant Resource_Message;

   type Rule is new Orm_Element with null record;
   type Rule_DDR is new Detached_Data (6) with private;
   type Detached_Rule is  --  Get() returns a Rule_DDR
   new Sessions.Detached_Element with private;
   type Detached_Rule_Access is access all Detached_Rule'Class;
   No_Detached_Rule : constant Detached_Rule;
   No_Rule : constant Rule;

   type Tool is new Orm_Element with null record;
   type Tool_DDR is new Detached_Data (2) with private;
   type Detached_Tool is  --  Get() returns a Tool_DDR
   new Sessions.Detached_Element with private;
   type Detached_Tool_Access is access all Detached_Tool'Class;
   No_Detached_Tool : constant Detached_Tool;
   No_Tool : constant Tool;


   ------------------------------
   -- Elements: Resource_Trees --
   ------------------------------

   function "=" (Op1 : Resource_Tree; Op2 : Resource_Tree) return Boolean;
   function "="
     (Op1 : Detached_Resource_Tree;
      Op2 : Detached_Resource_Tree)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Child_Id (Self : Resource_Tree) return Integer;
   function Child_Id (Self : Detached_Resource_Tree) return Integer;
   procedure Set_Child_Id (Self : Detached_Resource_Tree; Value : Integer);
   function Child_Id (Self : Resource_Tree) return Resource'Class;
   function Child_Id
     (Self : Detached_Resource_Tree)
     return Detached_Resource'Class;
   procedure Set_Child_Id
     (Self  : Detached_Resource_Tree;
      Value : Detached_Resource'Class);
   --  Resources as a child

   function Id (Self : Resource_Tree) return Integer;
   function Id (Self : Detached_Resource_Tree) return Integer;
   --  Auto-generated id

   function Parent_Id (Self : Resource_Tree) return Integer;
   function Parent_Id (Self : Detached_Resource_Tree) return Integer;
   procedure Set_Parent_Id (Self : Detached_Resource_Tree; Value : Integer);
   function Parent_Id (Self : Resource_Tree) return Resource'Class;
   function Parent_Id
     (Self : Detached_Resource_Tree)
     return Detached_Resource'Class;
   procedure Set_Parent_Id
     (Self  : Detached_Resource_Tree;
      Value : Detached_Resource'Class);
   --  Resource as a parent

   function Detach
     (Self : Resource_Tree'Class)
     return Detached_Resource_Tree'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Resource_Tree'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Resource_Tree return Detached_Resource_Tree'Class;

   ---------------------
   -- Elements: Rules --
   ---------------------

   function "=" (Op1 : Rule; Op2 : Rule) return Boolean;
   function "=" (Op1 : Detached_Rule; Op2 : Detached_Rule) return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Id (Self : Rule) return Integer;
   function Id (Self : Detached_Rule) return Integer;

   function Identifier (Self : Rule) return String;
   function Identifier (Self : Detached_Rule) return String;
   procedure Set_Identifier (Self : Detached_Rule; Value : String);
   --  Rule's unique identifier

   function Kind (Self : Rule) return Integer;
   function Kind (Self : Detached_Rule) return Integer;
   procedure Set_Kind (Self : Detached_Rule; Value : Integer);
   --  Whether it is a rule or a metric. 0 for rule, 1 for metric

   function Name (Self : Rule) return String;
   function Name (Self : Detached_Rule) return String;
   procedure Set_Name (Self : Detached_Rule; Value : String);
   --  Rule's name

   function Tool_Id (Self : Rule) return Integer;
   function Tool_Id (Self : Detached_Rule) return Integer;
   procedure Set_Tool_Id (Self : Detached_Rule; Value : Integer);
   function Tool_Id (Self : Rule) return Tool'Class;
   function Tool_Id (Self : Detached_Rule) return Detached_Tool'Class;
   procedure Set_Tool_Id (Self : Detached_Rule; Value : Detached_Tool'Class);
   --  Rule's related tool

   function Detach (Self : Rule'Class) return Detached_Rule'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Rule'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Rule return Detached_Rule'Class;

   ----------------------------------
   -- Elements: Resources_Messages --
   ----------------------------------

   function "=" (Op1 : Resource_Message; Op2 : Resource_Message) return Boolean;
   function "="
     (Op1 : Detached_Resource_Message;
      Op2 : Detached_Resource_Message)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Col_Begin (Self : Resource_Message) return Integer;
   function Col_Begin (Self : Detached_Resource_Message) return Integer;
   procedure Set_Col_Begin (Self : Detached_Resource_Message; Value : Integer);
   --  Line's column begin

   function Col_End (Self : Resource_Message) return Integer;
   function Col_End (Self : Detached_Resource_Message) return Integer;
   procedure Set_Col_End (Self : Detached_Resource_Message; Value : Integer);
   --  Line's column end

   function Id (Self : Resource_Message) return Integer;
   function Id (Self : Detached_Resource_Message) return Integer;
   --  Auto-generated id

   function Line (Self : Resource_Message) return Integer;
   function Line (Self : Detached_Resource_Message) return Integer;
   procedure Set_Line (Self : Detached_Resource_Message; Value : Integer);
   --  Corresponding line for message - zero means not associated to a line

   function Message_Id (Self : Resource_Message) return Integer;
   function Message_Id (Self : Detached_Resource_Message) return Integer;
   procedure Set_Message_Id (Self : Detached_Resource_Message; Value : Integer);
   function Message_Id (Self : Resource_Message) return Message'Class;
   function Message_Id
     (Self : Detached_Resource_Message)
     return Detached_Message'Class;
   procedure Set_Message_Id
     (Self  : Detached_Resource_Message;
      Value : Detached_Message'Class);
   --  the associated message

   function Resource_Id (Self : Resource_Message) return Integer;
   function Resource_Id (Self : Detached_Resource_Message) return Integer;
   procedure Set_Resource_Id (Self : Detached_Resource_Message; Value : Integer);
   function Resource_Id (Self : Resource_Message) return Resource'Class;
   function Resource_Id
     (Self : Detached_Resource_Message)
     return Detached_Resource'Class;
   procedure Set_Resource_Id
     (Self  : Detached_Resource_Message;
      Value : Detached_Resource'Class);
   --  Corresponding resource for message

   function Detach
     (Self : Resource_Message'Class)
     return Detached_Resource_Message'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Resource_Message'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Resource_Message return Detached_Resource_Message'Class;

   ------------------------
   -- Elements: Messages --
   ------------------------

   function "=" (Op1 : Message; Op2 : Message) return Boolean;
   function "=" (Op1 : Detached_Message; Op2 : Detached_Message) return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Data (Self : Message) return String;
   function Data (Self : Detached_Message) return String;
   procedure Set_Data (Self : Detached_Message; Value : String);
   --  Value associated with the message, possibly a numeric value for metrics

   function Id (Self : Message) return Integer;
   function Id (Self : Detached_Message) return Integer;
   --  Auto-generated id

   function Ranking (Self : Message) return Integer;
   function Ranking (Self : Detached_Message) return Integer;
   procedure Set_Ranking (Self : Detached_Message; Value : Integer);
   --  Values : 0-Annotation, 1-Unspecified, 2-Info, 3-Low, 4-Medium, 5-High

   function Rule_Id (Self : Message) return Integer;
   function Rule_Id (Self : Detached_Message) return Integer;
   procedure Set_Rule_Id (Self : Detached_Message; Value : Integer);
   function Rule_Id (Self : Message) return Rule'Class;
   function Rule_Id (Self : Detached_Message) return Detached_Rule'Class;
   procedure Set_Rule_Id (Self : Detached_Message; Value : Detached_Rule'Class);
   --  Messages' associated rule

   function Detach (Self : Message'Class) return Detached_Message'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Message'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Message return Detached_Message'Class;

   ------------------------
   -- Elements: Entities --
   ------------------------

   function "=" (Op1 : Entity; Op2 : Entity) return Boolean;
   function "=" (Op1 : Detached_Entity; Op2 : Detached_Entity) return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Col_Begin (Self : Entity) return Integer;
   function Col_Begin (Self : Detached_Entity) return Integer;
   procedure Set_Col_Begin (Self : Detached_Entity; Value : Integer);
   --  Entitie's column begin

   function Col_End (Self : Entity) return Integer;
   function Col_End (Self : Detached_Entity) return Integer;
   procedure Set_Col_End (Self : Detached_Entity; Value : Integer);
   --  Entitie's column end

   function Id (Self : Entity) return Integer;
   function Id (Self : Detached_Entity) return Integer;
   --  Auto-generated id

   function Line (Self : Entity) return Integer;
   function Line (Self : Detached_Entity) return Integer;
   procedure Set_Line (Self : Detached_Entity; Value : Integer);
   --  Entitie's line begin

   function Name (Self : Entity) return String;
   function Name (Self : Detached_Entity) return String;
   procedure Set_Name (Self : Detached_Entity; Value : String);
   --  Entitie's name

   function Resource_Id (Self : Entity) return Integer;
   function Resource_Id (Self : Detached_Entity) return Integer;
   procedure Set_Resource_Id (Self : Detached_Entity; Value : Integer);
   function Resource_Id (Self : Entity) return Resource'Class;
   function Resource_Id (Self : Detached_Entity) return Detached_Resource'Class;
   procedure Set_Resource_Id
     (Self  : Detached_Entity;
      Value : Detached_Resource'Class);
   --  Entitie's associated ressource

   function Detach (Self : Entity'Class) return Detached_Entity'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Entity'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Entity return Detached_Entity'Class;

   -----------------------------------
   -- Elements: Messages_Properties --
   -----------------------------------

   function "=" (Op1 : Message_Property; Op2 : Message_Property) return Boolean;
   function "="
     (Op1 : Detached_Message_Property;
      Op2 : Detached_Message_Property)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Id (Self : Message_Property) return Integer;
   function Id (Self : Detached_Message_Property) return Integer;
   --  Auto-generated id

   function Message_Id (Self : Message_Property) return Integer;
   function Message_Id (Self : Detached_Message_Property) return Integer;
   procedure Set_Message_Id (Self : Detached_Message_Property; Value : Integer);
   function Message_Id (Self : Message_Property) return Message'Class;
   function Message_Id
     (Self : Detached_Message_Property)
     return Detached_Message'Class;
   procedure Set_Message_Id
     (Self  : Detached_Message_Property;
      Value : Detached_Message'Class);
   --  Message's id

   function Property_Id (Self : Message_Property) return Integer;
   function Property_Id (Self : Detached_Message_Property) return Integer;
   procedure Set_Property_Id (Self : Detached_Message_Property; Value : Integer);
   function Property_Id (Self : Message_Property) return Property'Class;
   function Property_Id
     (Self : Detached_Message_Property)
     return Detached_Property'Class;
   procedure Set_Property_Id
     (Self  : Detached_Message_Property;
      Value : Detached_Property'Class);
   --  Propertie's id

   function Detach
     (Self : Message_Property'Class)
     return Detached_Message_Property'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Message_Property'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Message_Property return Detached_Message_Property'Class;

   ---------------------------------
   -- Elements: Entities_Messages --
   ---------------------------------

   function "=" (Op1 : Entity_Message; Op2 : Entity_Message) return Boolean;
   function "="
     (Op1 : Detached_Entity_Message;
      Op2 : Detached_Entity_Message)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Entity_Id (Self : Entity_Message) return Integer;
   function Entity_Id (Self : Detached_Entity_Message) return Integer;
   procedure Set_Entity_Id (Self : Detached_Entity_Message; Value : Integer);
   function Entity_Id (Self : Entity_Message) return Entity'Class;
   function Entity_Id
     (Self : Detached_Entity_Message)
     return Detached_Entity'Class;
   procedure Set_Entity_Id
     (Self  : Detached_Entity_Message;
      Value : Detached_Entity'Class);
   --  Entitie's id

   function Id (Self : Entity_Message) return Integer;
   function Id (Self : Detached_Entity_Message) return Integer;
   --  Auto-generated id

   function Message_Id (Self : Entity_Message) return Integer;
   function Message_Id (Self : Detached_Entity_Message) return Integer;
   procedure Set_Message_Id (Self : Detached_Entity_Message; Value : Integer);
   function Message_Id (Self : Entity_Message) return Message'Class;
   function Message_Id
     (Self : Detached_Entity_Message)
     return Detached_Message'Class;
   procedure Set_Message_Id
     (Self  : Detached_Entity_Message;
      Value : Detached_Message'Class);
   --  Message's id

   function Detach
     (Self : Entity_Message'Class)
     return Detached_Entity_Message'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Entity_Message'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Entity_Message return Detached_Entity_Message'Class;

   ---------------------
   -- Elements: Tools --
   ---------------------

   function "=" (Op1 : Tool; Op2 : Tool) return Boolean;
   function "=" (Op1 : Detached_Tool; Op2 : Detached_Tool) return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Id (Self : Tool) return Integer;
   function Id (Self : Detached_Tool) return Integer;
   --  Auto-generated id

   function Name (Self : Tool) return String;
   function Name (Self : Detached_Tool) return String;
   procedure Set_Name (Self : Detached_Tool; Value : String);
   --  Tool's name

   function Detach (Self : Tool'Class) return Detached_Tool'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Tool'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Tool return Detached_Tool'Class;

   --------------------------
   -- Elements: Properties --
   --------------------------

   function "=" (Op1 : Property; Op2 : Property) return Boolean;
   function "="
     (Op1 : Detached_Property;
      Op2 : Detached_Property)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Id (Self : Property) return Integer;
   function Id (Self : Detached_Property) return Integer;
   --  Auto-generated id

   function Identifier (Self : Property) return String;
   function Identifier (Self : Detached_Property) return String;
   procedure Set_Identifier (Self : Detached_Property; Value : String);
   --  Propertie's unique identifier

   function Name (Self : Property) return String;
   function Name (Self : Detached_Property) return String;
   procedure Set_Name (Self : Detached_Property; Value : String);
   --  Propertie's name

   function Detach (Self : Property'Class) return Detached_Property'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Property'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Property return Detached_Property'Class;

   -------------------------
   -- Elements: Resources --
   -------------------------

   function "=" (Op1 : Resource; Op2 : Resource) return Boolean;
   function "="
     (Op1 : Detached_Resource;
      Op2 : Detached_Resource)
     return Boolean;
   --  Compares two elements using only the primary keys. All other fields are
   --  ignored

   function Id (Self : Resource) return Integer;
   function Id (Self : Detached_Resource) return Integer;
   --  Auto-generated id

   function Kind (Self : Resource) return Integer;
   function Kind (Self : Detached_Resource) return Integer;
   procedure Set_Kind (Self : Detached_Resource; Value : Integer);
   --  Resource's kind: project, directory or file

   function Name (Self : Resource) return String;
   function Name (Self : Detached_Resource) return String;
   procedure Set_Name (Self : Detached_Resource; Value : String);
   --  Resource's name

   function Timestamp (Self : Resource) return Ada.Calendar.Time;
   function Timestamp (Self : Detached_Resource) return Ada.Calendar.Time;
   procedure Set_Timestamp (Self : Detached_Resource; Value : Ada.Calendar.Time);
   --  Resource's timestamp

   function Detach (Self : Resource'Class) return Detached_Resource'Class;

   function From_Cache
     (Session : Session_Type;
      Id      : Integer)
     return Detached_Resource'Class;
   --  Check whether there is already an element with this primary key. If
   --  not, the returned value will be a null element (test with Is_Null)

   function New_Resource return Detached_Resource'Class;

   --------------------------------------
   -- Managers(Implementation Details) --
   --------------------------------------

   procedure Internal_Query_Entities
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Entities_Messages
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Messages
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Messages_Properties
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Properties
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Resource_Trees
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Resources
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Resources_Messages
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Rules
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   procedure Internal_Query_Tools
     (Fields    : in out SQL_Field_List;
      From      : out SQL_Table_List;
      Criteria  : in out Sql_Criteria;
      Depth     : Natural;
      Follow_LJ : Boolean;
      Pk_Only   : Boolean := False);

   -------------------
   -- Manager Types --
   -------------------

   type I_Entities_Managers is abstract new Manager with null record;
   package I_Entities is new Generic_Managers
     (I_Entities_Managers, Entity, Related_Depth, DBA.Entities,
      Internal_Query_Entities);
   type Entities_Managers is new I_Entities.Manager with null record;
   subtype Entities_Stmt is I_Entities.ORM_Prepared_Statement;

   subtype Entity_List is I_Entities.List;
   subtype Direct_Entity_List is I_Entities.Direct_List;
   Empty_Entity_List : constant Entity_List := I_Entities.Empty_List;
   Empty_Direct_Entity_List : constant Direct_Entity_List :=
   I_Entities.Empty_Direct_List;

   type I_Entities_Messages_Managers is abstract new Manager with null record;
   package I_Entities_Messages is new Generic_Managers
     (I_Entities_Messages_Managers, Entity_Message, Related_Depth, DBA.Entities_Messages,
      Internal_Query_Entities_Messages);
   type Entities_Messages_Managers is new I_Entities_Messages.Manager with null record;
   subtype Entities_Messages_Stmt is I_Entities_Messages.ORM_Prepared_Statement;

   subtype Entity_Message_List is I_Entities_Messages.List;
   subtype Direct_Entity_Message_List is I_Entities_Messages.Direct_List;
   Empty_Entity_Message_List : constant Entity_Message_List := I_Entities_Messages.Empty_List;
   Empty_Direct_Entity_Message_List : constant Direct_Entity_Message_List :=
   I_Entities_Messages.Empty_Direct_List;

   type I_Messages_Managers is abstract new Manager with null record;
   package I_Messages is new Generic_Managers
     (I_Messages_Managers, Message, Related_Depth, DBA.Messages,
      Internal_Query_Messages);
   type Messages_Managers is new I_Messages.Manager with null record;
   subtype Messages_Stmt is I_Messages.ORM_Prepared_Statement;

   subtype Message_List is I_Messages.List;
   subtype Direct_Message_List is I_Messages.Direct_List;
   Empty_Message_List : constant Message_List := I_Messages.Empty_List;
   Empty_Direct_Message_List : constant Direct_Message_List :=
   I_Messages.Empty_Direct_List;

   type I_Messages_Properties_Managers is abstract new Manager with null record;
   package I_Messages_Properties is new Generic_Managers
     (I_Messages_Properties_Managers, Message_Property, Related_Depth, DBA.Messages_Properties,
      Internal_Query_Messages_Properties);
   type Messages_Properties_Managers is new I_Messages_Properties.Manager with null record;
   subtype Messages_Properties_Stmt is I_Messages_Properties.ORM_Prepared_Statement;

   subtype Message_Property_List is I_Messages_Properties.List;
   subtype Direct_Message_Property_List is I_Messages_Properties.Direct_List;
   Empty_Message_Property_List : constant Message_Property_List := I_Messages_Properties.Empty_List;
   Empty_Direct_Message_Property_List : constant Direct_Message_Property_List :=
   I_Messages_Properties.Empty_Direct_List;

   type I_Properties_Managers is abstract new Manager with null record;
   package I_Properties is new Generic_Managers
     (I_Properties_Managers, Property, Related_Depth, DBA.Properties,
      Internal_Query_Properties);
   type Properties_Managers is new I_Properties.Manager with null record;
   subtype Properties_Stmt is I_Properties.ORM_Prepared_Statement;

   subtype Property_List is I_Properties.List;
   subtype Direct_Property_List is I_Properties.Direct_List;
   Empty_Property_List : constant Property_List := I_Properties.Empty_List;
   Empty_Direct_Property_List : constant Direct_Property_List :=
   I_Properties.Empty_Direct_List;

   type I_Resource_Trees_Managers is abstract new Manager with null record;
   package I_Resource_Trees is new Generic_Managers
     (I_Resource_Trees_Managers, Resource_Tree, Related_Depth, DBA.Resource_Trees,
      Internal_Query_Resource_Trees);
   type Resource_Trees_Managers is new I_Resource_Trees.Manager with null record;
   subtype Resource_Trees_Stmt is I_Resource_Trees.ORM_Prepared_Statement;

   subtype Resource_Tree_List is I_Resource_Trees.List;
   subtype Direct_Resource_Tree_List is I_Resource_Trees.Direct_List;
   Empty_Resource_Tree_List : constant Resource_Tree_List := I_Resource_Trees.Empty_List;
   Empty_Direct_Resource_Tree_List : constant Direct_Resource_Tree_List :=
   I_Resource_Trees.Empty_Direct_List;

   type I_Resources_Managers is abstract new Manager with null record;
   package I_Resources is new Generic_Managers
     (I_Resources_Managers, Resource, Related_Depth, DBA.Resources,
      Internal_Query_Resources);
   type Resources_Managers is new I_Resources.Manager with null record;
   subtype Resources_Stmt is I_Resources.ORM_Prepared_Statement;

   subtype Resource_List is I_Resources.List;
   subtype Direct_Resource_List is I_Resources.Direct_List;
   Empty_Resource_List : constant Resource_List := I_Resources.Empty_List;
   Empty_Direct_Resource_List : constant Direct_Resource_List :=
   I_Resources.Empty_Direct_List;

   type I_Resources_Messages_Managers is abstract new Manager with null record;
   package I_Resources_Messages is new Generic_Managers
     (I_Resources_Messages_Managers, Resource_Message, Related_Depth, DBA.Resources_Messages,
      Internal_Query_Resources_Messages);
   type Resources_Messages_Managers is new I_Resources_Messages.Manager with null record;
   subtype Resources_Messages_Stmt is I_Resources_Messages.ORM_Prepared_Statement;

   subtype Resource_Message_List is I_Resources_Messages.List;
   subtype Direct_Resource_Message_List is I_Resources_Messages.Direct_List;
   Empty_Resource_Message_List : constant Resource_Message_List := I_Resources_Messages.Empty_List;
   Empty_Direct_Resource_Message_List : constant Direct_Resource_Message_List :=
   I_Resources_Messages.Empty_Direct_List;

   type I_Rules_Managers is abstract new Manager with null record;
   package I_Rules is new Generic_Managers
     (I_Rules_Managers, Rule, Related_Depth, DBA.Rules,
      Internal_Query_Rules);
   type Rules_Managers is new I_Rules.Manager with null record;
   subtype Rules_Stmt is I_Rules.ORM_Prepared_Statement;

   subtype Rule_List is I_Rules.List;
   subtype Direct_Rule_List is I_Rules.Direct_List;
   Empty_Rule_List : constant Rule_List := I_Rules.Empty_List;
   Empty_Direct_Rule_List : constant Direct_Rule_List :=
   I_Rules.Empty_Direct_List;

   type I_Tools_Managers is abstract new Manager with null record;
   package I_Tools is new Generic_Managers
     (I_Tools_Managers, Tool, Related_Depth, DBA.Tools,
      Internal_Query_Tools);
   type Tools_Managers is new I_Tools.Manager with null record;
   subtype Tools_Stmt is I_Tools.ORM_Prepared_Statement;

   subtype Tool_List is I_Tools.List;
   subtype Direct_Tool_List is I_Tools.Direct_List;
   Empty_Tool_List : constant Tool_List := I_Tools.Empty_List;
   Empty_Direct_Tool_List : constant Direct_Tool_List :=
   I_Tools.Empty_Direct_List;


   -----------------------------
   -- Manager: Resource_Trees --
   -----------------------------

   function Filter
     (Self      : Resource_Trees_Managers'Class;
      Id        : Integer := -1;
      Child_Id  : Integer := -1;
      Parent_Id : Integer := -1)
     return Resource_Trees_Managers;

   function Get_Resource_Tree
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Resource_Tree'Class;

   --------------------
   -- Manager: Rules --
   --------------------

   function Filter
     (Self       : Rules_Managers'Class;
      Id         : Integer := -1;
      Name       : String := No_Update;
      Identifier : String := No_Update;
      Kind       : Integer := -1;
      Tool_Id    : Integer := -1)
     return Rules_Managers;

   function Get_Rule
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Rule'Class;

   function Rule_Messages (Self : Rule'Class) return Messages_Managers;
   function Rule_Messages (Self : Detached_Rule'Class) return Messages_Managers;
   function Rule_Messages
     (Self : I_Rules_Managers'Class)
     return Messages_Managers;

   ---------------------------------
   -- Manager: Resources_Messages --
   ---------------------------------

   function Filter
     (Self        : Resources_Messages_Managers'Class;
      Id          : Integer := -1;
      Message_Id  : Integer := -1;
      Resource_Id : Integer := -1;
      Line        : Integer := -1;
      Col_Begin   : Integer := -1;
      Col_End     : Integer := -1)
     return Resources_Messages_Managers;

   function Get_Resource_Message
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Resource_Message'Class;

   -----------------------
   -- Manager: Messages --
   -----------------------

   function Get_Message
     (Self : Message'Class)
     return Resources_Messages_Managers;
   function Get_Message
     (Self : Detached_Message'Class)
     return Resources_Messages_Managers;
   function Get_Message
     (Self : I_Messages_Managers'Class)
     return Resources_Messages_Managers;

   function Filter
     (Self    : Messages_Managers'Class;
      Id      : Integer := -1;
      Rule_Id : Integer := -1;
      Data    : String := No_Update;
      Ranking : Integer := -1)
     return Messages_Managers;

   function Get_Message
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Message'Class;

   function Message_Entities
     (Self : Message'Class)
     return Entities_Messages_Managers;
   function Message_Entities
     (Self : Detached_Message'Class)
     return Entities_Messages_Managers;
   function Message_Entities
     (Self : I_Messages_Managers'Class)
     return Entities_Messages_Managers;

   function Message_Properties
     (Self : Message'Class)
     return Messages_Properties_Managers;
   function Message_Properties
     (Self : Detached_Message'Class)
     return Messages_Properties_Managers;
   function Message_Properties
     (Self : I_Messages_Managers'Class)
     return Messages_Properties_Managers;

   -----------------------
   -- Manager: Entities --
   -----------------------

   function Entity_Messages
     (Self : Entity'Class)
     return Entities_Messages_Managers;
   function Entity_Messages
     (Self : Detached_Entity'Class)
     return Entities_Messages_Managers;
   function Entity_Messages
     (Self : I_Entities_Managers'Class)
     return Entities_Messages_Managers;

   function Filter
     (Self        : Entities_Managers'Class;
      Id          : Integer := -1;
      Name        : String := No_Update;
      Line        : Integer := -1;
      Col_Begin   : Integer := -1;
      Col_End     : Integer := -1;
      Resource_Id : Integer := -1)
     return Entities_Managers;

   function Get_Entity
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Entity'Class;

   ----------------------------------
   -- Manager: Messages_Properties --
   ----------------------------------

   function Filter
     (Self        : Messages_Properties_Managers'Class;
      Id          : Integer := -1;
      Message_Id  : Integer := -1;
      Property_Id : Integer := -1)
     return Messages_Properties_Managers;

   function Get_Message_Property
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Message_Property'Class;

   --------------------------------
   -- Manager: Entities_Messages --
   --------------------------------

   function Filter
     (Self       : Entities_Messages_Managers'Class;
      Id         : Integer := -1;
      Entity_Id  : Integer := -1;
      Message_Id : Integer := -1)
     return Entities_Messages_Managers;

   function Get_Entity_Message
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Entity_Message'Class;

   --------------------
   -- Manager: Tools --
   --------------------

   function Filter
     (Self : Tools_Managers'Class;
      Id   : Integer := -1;
      Name : String := No_Update)
     return Tools_Managers;

   function Get_Tool
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Tool'Class;

   function Tool_Rules (Self : Tool'Class) return Rules_Managers;
   function Tool_Rules (Self : Detached_Tool'Class) return Rules_Managers;
   function Tool_Rules (Self : I_Tools_Managers'Class) return Rules_Managers;

   -------------------------
   -- Manager: Properties --
   -------------------------

   function Filter
     (Self       : Properties_Managers'Class;
      Id         : Integer := -1;
      Identifier : String := No_Update;
      Name       : String := No_Update)
     return Properties_Managers;

   function Get_Property
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Property'Class;

   function Property_Messages
     (Self : Property'Class)
     return Messages_Properties_Managers;
   function Property_Messages
     (Self : Detached_Property'Class)
     return Messages_Properties_Managers;
   function Property_Messages
     (Self : I_Properties_Managers'Class)
     return Messages_Properties_Managers;

   ------------------------
   -- Manager: Resources --
   ------------------------

   function Get_Resource
     (Self : Resource'Class)
     return Resources_Messages_Managers;
   function Get_Resource
     (Self : Detached_Resource'Class)
     return Resources_Messages_Managers;
   function Get_Resource
     (Self : I_Resources_Managers'Class)
     return Resources_Messages_Managers;
   function Get_Resource (Self : Resource'Class) return Entities_Managers;
   function Get_Resource
     (Self : Detached_Resource'Class)
     return Entities_Managers;
   function Get_Resource
     (Self : I_Resources_Managers'Class)
     return Entities_Managers;

   function Filter
     (Self      : Resources_Managers'Class;
      Id        : Integer := -1;
      Name      : String := No_Update;
      Kind      : Integer := -1;
      Timestamp : Ada.Calendar.Time := No_Time)
     return Resources_Managers;

   function Get_Resource
     (Session          : Session_Type;
      Id               : Integer;
      Depth            : Related_Depth := 0;
      Follow_Left_Join : Boolean := False)
     return Detached_Resource'Class;

   function Resource_Children
     (Self : Resource'Class)
     return Resource_Trees_Managers;
   function Resource_Children
     (Self : Detached_Resource'Class)
     return Resource_Trees_Managers;
   function Resource_Children
     (Self : I_Resources_Managers'Class)
     return Resource_Trees_Managers;

   function Resource_Parent
     (Self : Resource'Class)
     return Resource_Trees_Managers;
   function Resource_Parent
     (Self : Detached_Resource'Class)
     return Resource_Trees_Managers;
   function Resource_Parent
     (Self : I_Resources_Managers'Class)
     return Resource_Trees_Managers;

   --------------
   -- Managers --
   --------------

   All_Entities : constant Entities_Managers :=
     (I_Entities.All_Managers with null record);

   All_Entities_Messages : constant Entities_Messages_Managers :=
     (I_Entities_Messages.All_Managers with null record);

   All_Messages : constant Messages_Managers :=
     (I_Messages.All_Managers with null record);

   All_Messages_Properties : constant Messages_Properties_Managers :=
     (I_Messages_Properties.All_Managers with null record);

   All_Properties : constant Properties_Managers :=
     (I_Properties.All_Managers with null record);

   All_Resource_Trees : constant Resource_Trees_Managers :=
     (I_Resource_Trees.All_Managers with null record);

   All_Resources : constant Resources_Managers :=
     (I_Resources.All_Managers with null record);

   All_Resources_Messages : constant Resources_Messages_Managers :=
     (I_Resources_Messages.All_Managers with null record);

   All_Rules : constant Rules_Managers :=
     (I_Rules.All_Managers with null record);

   All_Tools : constant Tools_Managers :=
     (I_Tools.All_Managers with null record);


   --------------
   -- Internal --
   --------------

   overriding procedure Free (Self : in out Entity_Ddr);
   overriding procedure Free (Self : in out Entity_Message_Ddr);
   overriding procedure Free (Self : in out Message_Ddr);
   overriding procedure Free (Self : in out Message_Property_Ddr);
   overriding procedure Free (Self : in out Property_Ddr);
   overriding procedure Free (Self : in out Resource_Tree_Ddr);
   overriding procedure Free (Self : in out Resource_Ddr);
   overriding procedure Free (Self : in out Resource_Message_Ddr);
   overriding procedure Free (Self : in out Rule_Ddr);
   overriding procedure Free (Self : in out Tool_Ddr);

   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Entity;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Entity_Message;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Message;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Message_Property;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Property;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Resource_Tree;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Resource;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Resource_Message;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Rule;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);
   overriding procedure Insert_Or_Update
     (Self        : in out Detached_Tool;
      Pk_Modified : in out Boolean;
      Mask        : Dirty_Mask);

   overriding procedure Internal_Delete (Self : Detached_Entity);
   overriding procedure Internal_Delete (Self : Detached_Entity_Message);
   overriding procedure Internal_Delete (Self : Detached_Message);
   overriding procedure Internal_Delete (Self : Detached_Message_Property);
   overriding procedure Internal_Delete (Self : Detached_Property);
   overriding procedure Internal_Delete (Self : Detached_Resource_Tree);
   overriding procedure Internal_Delete (Self : Detached_Resource);
   overriding procedure Internal_Delete (Self : Detached_Resource_Message);
   overriding procedure Internal_Delete (Self : Detached_Rule);
   overriding procedure Internal_Delete (Self : Detached_Tool);

   overriding function Key (Self : Entity_Ddr) return Element_Key;
   overriding function Key (Self : Entity_Message_Ddr) return Element_Key;
   overriding function Key (Self : Message_Ddr) return Element_Key;
   overriding function Key (Self : Message_Property_Ddr) return Element_Key;
   overriding function Key (Self : Property_Ddr) return Element_Key;
   overriding function Key (Self : Resource_Tree_Ddr) return Element_Key;
   overriding function Key (Self : Resource_Ddr) return Element_Key;
   overriding function Key (Self : Resource_Message_Ddr) return Element_Key;
   overriding function Key (Self : Rule_Ddr) return Element_Key;
   overriding function Key (Self : Tool_Ddr) return Element_Key;

   overriding procedure On_Persist (Self : Detached_Entity);
   overriding procedure On_Persist (Self : Detached_Entity_Message);
   overriding procedure On_Persist (Self : Detached_Message);
   overriding procedure On_Persist (Self : Detached_Message_Property);
   overriding procedure On_Persist (Self : Detached_Resource_Tree);
   overriding procedure On_Persist (Self : Detached_Resource_Message);
   overriding procedure On_Persist (Self : Detached_Rule);

private

    type Entity_DDR is new Detached_Data (7) with record
       ORM_Col_Begin      : Integer := -1;
       ORM_Col_End        : Integer := -1;
       ORM_FK_Resource_Id : Detached_Resource_Access := null;
       ORM_Id             : Integer := -1;
       ORM_Line           : Integer := -1;
       ORM_Name           : Unbounded_String := Null_Unbounded_String;
       ORM_Resource_Id    : Integer := -1;
    end record;
    type Entity_Data is access all Entity_DDR;
    
    type Entity_Message_DDR is new Detached_Data (5) with record
       ORM_Entity_Id     : Integer := -1;
       ORM_FK_Entity_Id  : Detached_Entity_Access := null;
       ORM_FK_Message_Id : Detached_Message_Access := null;
       ORM_Id            : Integer := -1;
       ORM_Message_Id    : Integer := -1;
    end record;
    type Entity_Message_Data is access all Entity_Message_DDR;
    
    type Message_DDR is new Detached_Data (5) with record
       ORM_Data       : Unbounded_String := Null_Unbounded_String;
       ORM_FK_Rule_Id : Detached_Rule_Access := null;
       ORM_Id         : Integer := -1;
       ORM_Ranking    : Integer := 1;
       ORM_Rule_Id    : Integer := -1;
    end record;
    type Message_Data is access all Message_DDR;
    
    type Message_Property_DDR is new Detached_Data (5) with record
       ORM_FK_Message_Id  : Detached_Message_Access := null;
       ORM_FK_Property_Id : Detached_Property_Access := null;
       ORM_Id             : Integer := -1;
       ORM_Message_Id     : Integer := -1;
       ORM_Property_Id    : Integer := -1;
    end record;
    type Message_Property_Data is access all Message_Property_DDR;
    
    type Property_DDR is new Detached_Data (3) with record
       ORM_Id            : Integer := -1;
       ORM_Identifier    : Unbounded_String := Null_Unbounded_String;
       ORM_Name          : Unbounded_String := Null_Unbounded_String;
    end record;
    type Property_Data is access all Property_DDR;
    
    type Resource_Tree_DDR is new Detached_Data (5) with record
       ORM_Child_Id     : Integer := -1;
       ORM_FK_Child_Id  : Detached_Resource_Access := null;
       ORM_FK_Parent_Id : Detached_Resource_Access := null;
       ORM_Id           : Integer := -1;
       ORM_Parent_Id    : Integer := -1;
    end record;
    type Resource_Tree_Data is access all Resource_Tree_DDR;
    
    type Resource_DDR is new Detached_Data (4) with record
       ORM_Id           : Integer := -1;
       ORM_Kind         : Integer := -1;
       ORM_Name         : Unbounded_String := Null_Unbounded_String;
       ORM_Timestamp    : Ada.Calendar.Time := No_Time;
    end record;
    type Resource_Data is access all Resource_DDR;
    
    type Resource_Message_DDR is new Detached_Data (8) with record
       ORM_Col_Begin      : Integer := -1;
       ORM_Col_End        : Integer := -1;
       ORM_FK_Message_Id  : Detached_Message_Access := null;
       ORM_FK_Resource_Id : Detached_Resource_Access := null;
       ORM_Id             : Integer := -1;
       ORM_Line           : Integer := -1;
       ORM_Message_Id     : Integer := -1;
       ORM_Resource_Id    : Integer := -1;
    end record;
    type Resource_Message_Data is access all Resource_Message_DDR;
    
    type Rule_DDR is new Detached_Data (6) with record
       ORM_FK_Tool_Id    : Detached_Tool_Access := null;
       ORM_Id            : Integer := -1;
       ORM_Identifier    : Unbounded_String := Null_Unbounded_String;
       ORM_Kind          : Integer := 0;
       ORM_Name          : Unbounded_String := Null_Unbounded_String;
       ORM_Tool_Id       : Integer := -1;
    end record;
    type Rule_Data is access all Rule_DDR;
    
    type Tool_DDR is new Detached_Data (2) with record
       ORM_Id      : Integer := -1;
       ORM_Name    : Unbounded_String := Null_Unbounded_String;
    end record;
    type Tool_Data is access all Tool_DDR;
    

    type Detached_Entity
       is new Sessions.Detached_Element with null record;
    No_Entity : constant Entity :=(No_Orm_Element with null record);
    No_Detached_Entity : constant Detached_Entity :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Entity_Message
       is new Sessions.Detached_Element with null record;
    No_Entity_Message : constant Entity_Message :=(No_Orm_Element with null record);
    No_Detached_Entity_Message : constant Detached_Entity_Message :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Message
       is new Sessions.Detached_Element with null record;
    No_Message : constant Message :=(No_Orm_Element with null record);
    No_Detached_Message : constant Detached_Message :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Message_Property
       is new Sessions.Detached_Element with null record;
    No_Message_Property : constant Message_Property :=(No_Orm_Element with null record);
    No_Detached_Message_Property : constant Detached_Message_Property :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Property
       is new Sessions.Detached_Element with null record;
    No_Property : constant Property :=(No_Orm_Element with null record);
    No_Detached_Property : constant Detached_Property :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Resource_Tree
       is new Sessions.Detached_Element with null record;
    No_Resource_Tree : constant Resource_Tree :=(No_Orm_Element with null record);
    No_Detached_Resource_Tree : constant Detached_Resource_Tree :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Resource
       is new Sessions.Detached_Element with null record;
    No_Resource : constant Resource :=(No_Orm_Element with null record);
    No_Detached_Resource : constant Detached_Resource :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Resource_Message
       is new Sessions.Detached_Element with null record;
    No_Resource_Message : constant Resource_Message :=(No_Orm_Element with null record);
    No_Detached_Resource_Message : constant Detached_Resource_Message :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Rule
       is new Sessions.Detached_Element with null record;
    No_Rule : constant Rule :=(No_Orm_Element with null record);
    No_Detached_Rule : constant Detached_Rule :=
      (Sessions.Detached_Element with null record);
 
    type Detached_Tool
       is new Sessions.Detached_Element with null record;
    No_Tool : constant Tool :=(No_Orm_Element with null record);
    No_Detached_Tool : constant Detached_Tool :=
      (Sessions.Detached_Element with null record);
 
end Database.Orm;