-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFmxSQLStructuralMetamodelGenerator.class.st
More file actions
345 lines (298 loc) · 11 KB
/
FmxSQLStructuralMetamodelGenerator.class.st
File metadata and controls
345 lines (298 loc) · 11 KB
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
Class {
#name : #FmxSQLStructuralMetamodelGenerator,
#superclass : #FamixBasicInfrastructureGenerator,
#instVars : [
'uniqueConstraint',
'constraint',
'reference',
'type',
'structuralEntity',
'table',
'column',
'checkConstraint',
'notNullConstraint',
'tableReference',
'namespace',
'primaryKeyConstraint',
'columnReference',
'typeReference',
'foreignKeyConstraint',
'tQueryContainer',
'tColumnsContainer',
'tAbstractType',
'tColumn',
'tWithColumnReference',
'tWithTableReference',
'namespaceReference',
'tWithNamespaceReference',
'exclusionConstraint'
],
#category : #FAMIXNGSQLMetamodelGenerator
}
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> checkConstraintComment [
^ 'I represent a CHECK constraint as defined in SQL standard.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> columnComment [
^ 'I represent a Column in the relational model.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> columnReferenceComment [
^ 'I am reference to a column in a table of the model.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> columnsContainerComment [
^ 'I am an abstract super class for entities that contain columns. Two of my well-known subclasses are the table and the view.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> constraintComment [
^ 'I am an abstract superclass for constraints. A constraint restrict the possible values that can be stored in a column of a table.'
]
{ #category : #definition }
FmxSQLStructuralMetamodelGenerator >> defineClasses [
super defineClasses.
self defineStructuralEntities.
]
{ #category : #definition }
FmxSQLStructuralMetamodelGenerator >> defineHierarchy [
super defineHierarchy.
self
defineStructuralHierarchy;
defineStructuralReferencesHierarchy.
]
{ #category : #definition }
FmxSQLStructuralMetamodelGenerator >> defineProperties [
super defineProperties.
self defineStructuralReferenceProperties
]
{ #category : #definition }
FmxSQLStructuralMetamodelGenerator >> defineRelations [
super defineRelations.
self
defineStructuralEntitiesRelations;
defineStructuralTraitsRelations;
defineStructuralReferenceEntities.
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralEntities [
structuralEntity := builder
newClassNamed: #StructuralEntity
comment: self structuralEntityComment.
constraint := builder
newClassNamed: #Constraint
comment: self constraintComment.
constraint withTesting.
reference := builder
newClassNamed: #Reference
comment: self referenceComment.
"Concrete structural entities."
namespace := builder
newClassNamed: #Namespace
comment: self namespaceComment.
table := builder newClassNamed: #Table comment: self tableComment.
column := builder newClassNamed: #Column comment: self columnComment.
column withTesting.
type := builder newClassNamed: #Type comment: self typeComment.
checkConstraint := builder
newClassNamed: #CheckConstraint
comment: self checkConstraintComment.
checkConstraint withTesting.
exclusionConstraint := builder
newClassNamed: #ExclusionConstraint
comment: self exclusionConstraintComment.
exclusionConstraint withTesting.
primaryKeyConstraint := builder
newClassNamed: #PrimaryKeyConstraint
comment: self primaryKeyConstraintComment.
primaryKeyConstraint withTesting.
foreignKeyConstraint := builder
newClassNamed: #ForeignKeyConstraint
comment: self foreignKeyConstraintComment.
foreignKeyConstraint withTesting.
notNullConstraint := builder
newClassNamed: #NotNullConstraint
comment: self nullConstraintComment.
notNullConstraint withTesting.
uniqueConstraint := builder
newClassNamed: #UniqueConstraint
comment: self uniqueConstraintComment.
uniqueConstraint withTesting.
"Concrete reference entities."
tableReference := builder
newClassNamed: #TableReference
comment: self tableReferenceComment.
columnReference := builder
newClassNamed: #ColumnReference
comment: self columnReferenceComment.
columnReference withTesting.
typeReference := builder
newClassNamed: #TypeReference
comment: self typeReferenceComment.
namespaceReference := builder
newClassNamed: #NamespaceReference
comment: self namespaceReferenceComment.
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralEntitiesRelations [
"A column references a type."
(column property: #type) *- (type property: #columns).
"A Constraint is contained in a Table."
(table property: #constraints)
<>-* (constraint property: #table).
"A foreign key constraint references at least one column from another table."
(foreignKeyConstraint property: #outgoingForeignKeyColumnReferences)
-* (columnReference property: #foreignKeyConstraintSource) source.
"A table eventually has inheritance sub tables and zero or one inheritance super table."
self flag: #TODO. "Reify inheritance relation."
(table property: #superTable)
*- (table property: #subTables)
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralHierarchy [
"Abstract entities inheritance relations."
structuralEntity --|> namedEntity.
structuralEntity --|> #TNamespaceEntity.
constraint --|> structuralEntity.
constraint --|> tWithColumnReference.
"Concrete structural entities inheritance relations."
namespace --|> structuralEntity.
namespace --|> #TNamespace.
table --|> structuralEntity.
table --|> tColumnsContainer.
table --|> tAbstractType.
column --|> structuralEntity.
column --|> tColumn.
type --|> structuralEntity.
type --|> tAbstractType.
checkConstraint --|> constraint.
exclusionConstraint --|> constraint.
primaryKeyConstraint --|> constraint.
foreignKeyConstraint --|> constraint.
notNullConstraint --|> constraint.
uniqueConstraint --|> constraint.
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralReferenceEntities [
"A type reference references a type."
(typeReference property: #type) target
*- (type property: #references).
"A table reference references a table."
(tableReference property: #table) target
*- (table property: #references).
"A column reference references a column."
(columnReference property: #column) target
*- (column property: #references).
(namespaceReference property: #namespace) target
*- (namespace property: #references)
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralReferenceProperties [
columnReference
property: #isWildCardReference type: #Boolean
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralReferencesHierarchy [
reference --|> association.
reference --|> #TArgument.
tableReference --|> reference.
columnReference --|> reference.
typeReference --|> reference.
namespaceReference --|> reference
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralTraits [
tAbstractType := builder newTraitNamed: #AbstractType.
tColumn := builder newTraitNamed: #TColumn.
tColumnsContainer := builder
newTraitNamed: #ColumnsContainer
comment: self columnsContainerComment.
tQueryContainer := builder
newTraitNamed: #TQueryContainer
comment: self queryContainerComment.
tQueryContainer withTesting.
tWithColumnReference := builder newTraitNamed: #TWithColumnReference.
tWithTableReference := builder newTraitNamed: #TWithTableReference.
tWithNamespaceReference := builder newTraitNamed: #TWithNamespaceReference
]
{ #category : #'definition - structural' }
FmxSQLStructuralMetamodelGenerator >> defineStructuralTraitsRelations [
"A columns container contains columns."
(tColumnsContainer property: #columns)
<>-* (tColumn property: #columnsContainer).
(tWithColumnReference property: #outgoingColumnReferences)
-* (columnReference property: #source) source.
(tWithTableReference property: #outgoingTableReferences)
-* (tableReference property: #source) source.
(tWithNamespaceReference property: #outgoingNamespaceReference)
-* (namespaceReference property: #source)
]
{ #category : #definition }
FmxSQLStructuralMetamodelGenerator >> defineTraits [
super defineTraits.
self defineStructuralTraits
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> entityInNamespaceComment [
^ 'I am a trait that any entity which can be part of a namespace use.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> exclusionConstraintComment [
^ 'I represent an EXCLUSION constraint as defined in SQL standard.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> foreignKeyConstraintComment [
^ 'I represent a FOREIGN KEY constraint as defined in SQL standard.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> namespaceComment [
^ 'I am a namespace. I hold entities to define a name scope where name duplicates are forbidden.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> namespaceReferenceComment [
^ 'I model a reference made to a namespace from source code.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> nullConstraintComment [
^ 'I represent a NOT NULL constraint as defined in SQL standard.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> primaryKeyConstraintComment [
^ 'I represent a PRIMARY KEY constraint as defined in SQL standard.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> queryContainerComment [
^ 'I am an abstract super class for behavioural entities that can contain queries in their source code.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> referenceComment [
^ 'I am an abstract object that represent a reference made to another entity in the source code a behavioural entity.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> referenceContainerComment [
^ 'I am a trait for entities containing references (storedProcedure, Clause and Alias).'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> structuralEntityComment [
^ 'I am an abstract superclass for structural entities. A structural entity is an entity that defines how data are structured by the database.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> tableComment [
^ 'I represent a Table in the relational model.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> tableReferenceComment [
^ 'I am a reference to a table.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> typeComment [
^ 'I represent a Type in the database. I can be used for a column, a local variable, a parameter, etc...'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> typeReferenceComment [
^ 'I am reference to a type of the model.'
]
{ #category : #'comments - SQL' }
FmxSQLStructuralMetamodelGenerator >> uniqueConstraintComment [
^ 'I represent a UNIQUE constraint as defined in SQL standard.'
]