activefacts 0.8.15 → 0.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/examples/CQL/Metamodel.cql +46 -40
- data/lib/activefacts/cql.rb +1 -0
- data/lib/activefacts/cql/CQLParser.treetop +1 -1
- data/lib/activefacts/cql/compiler.rb +21 -0
- data/lib/activefacts/cql/compiler/clause.rb +1 -1
- data/lib/activefacts/cql/compiler/constraint.rb +10 -11
- data/lib/activefacts/cql/compiler/entity_type.rb +9 -9
- data/lib/activefacts/cql/compiler/expression.rb +4 -4
- data/lib/activefacts/cql/compiler/fact.rb +5 -7
- data/lib/activefacts/cql/compiler/fact_type.rb +3 -1
- data/lib/activefacts/cql/compiler/shared.rb +9 -4
- data/lib/activefacts/cql/compiler/value_type.rb +2 -2
- data/lib/activefacts/cql/parser.rb +9 -7
- data/lib/activefacts/generate/ordered.rb +2 -4
- data/lib/activefacts/input/orm.rb +17 -17
- data/lib/activefacts/persistence/reference.rb +1 -1
- data/lib/activefacts/persistence/tables.rb +10 -0
- data/lib/activefacts/version.rb +1 -1
- data/lib/activefacts/vocabulary/extensions.rb +4 -4
- data/lib/activefacts/vocabulary/metamodel.rb +29 -75
- data/spec/cql_symbol_tables_spec.rb +1 -1
- data/spec/cqldump_spec.rb +12 -12
- metadata +5 -5
data/examples/CQL/Metamodel.cql
CHANGED
|
@@ -6,22 +6,16 @@ vocabulary Metamodel;
|
|
|
6
6
|
Adjective is written as String(64);
|
|
7
7
|
Agent Name is written as String;
|
|
8
8
|
Assimilation is written as String restricted to {'partitioned', 'separate'};
|
|
9
|
-
Constraint Id is written as Auto Counter;
|
|
10
|
-
Context Note Id is written as Auto Counter;
|
|
11
9
|
Context Note Kind is written as String restricted to {'as_opposed_to', 'because', 'so_that', 'to_avoid'};
|
|
12
10
|
Date is written as Date;
|
|
13
11
|
Denominator is written as Unsigned Integer(32);
|
|
14
12
|
Discussion is written as String;
|
|
15
|
-
Disjunction Id is written as Auto Counter;
|
|
16
13
|
Display Role Names Setting is written as String restricted to {'false', 'true'};
|
|
17
14
|
Enforcement Code is written as String(16);
|
|
18
15
|
Ephemera URL is written as String;
|
|
19
16
|
Exponent is written as Signed Integer(16);
|
|
20
|
-
Fact Id is written as Auto Counter;
|
|
21
|
-
Fact Type Id is written as Auto Counter;
|
|
22
17
|
Frequency is written as Unsigned Integer(32);
|
|
23
|
-
|
|
24
|
-
Join Id is written as Auto Counter;
|
|
18
|
+
Guid is written as Guid;
|
|
25
19
|
Length is written as Unsigned Integer(32);
|
|
26
20
|
Literal is written as String;
|
|
27
21
|
Name is written as String(64);
|
|
@@ -30,14 +24,11 @@ Offset is written as Decimal;
|
|
|
30
24
|
Ordinal is written as Unsigned Integer(16);
|
|
31
25
|
Pronoun is written as String(20) restricted to {'feminine', 'masculine', 'neuter', 'personal'};
|
|
32
26
|
Ring Type is written as String;
|
|
33
|
-
Role Sequence Id is written as Auto Counter;
|
|
34
27
|
Rotation Setting is written as String restricted to {'left', 'right'};
|
|
35
28
|
Scale is written as Unsigned Integer(32);
|
|
36
|
-
Shape Id is written as Auto Counter;
|
|
37
29
|
Subscript is written as Unsigned Integer(16);
|
|
38
30
|
Text is written as String(256);
|
|
39
31
|
Transaction Timing is written as String restricted to {'assert', 'commit'};
|
|
40
|
-
Unit Id is written as Auto Counter;
|
|
41
32
|
X is written as Signed Integer(32);
|
|
42
33
|
Y is written as Signed Integer(32);
|
|
43
34
|
|
|
@@ -46,25 +37,31 @@ Y is written as Signed Integer(32);
|
|
|
46
37
|
*/
|
|
47
38
|
Agent is identified by its Name;
|
|
48
39
|
|
|
40
|
+
Alternative Set is identified by Guid where
|
|
41
|
+
Alternative Set has one Guid,
|
|
42
|
+
Guid is of at most one Alternative Set;
|
|
43
|
+
|
|
49
44
|
Coefficient is identified by Numerator and Denominator and Coefficient is precise where
|
|
50
45
|
Coefficient has one Numerator,
|
|
51
46
|
Coefficient has one Denominator,
|
|
52
47
|
Coefficient is precise;
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
Concept is identified by Guid where
|
|
50
|
+
Concept has one Guid,
|
|
51
|
+
Guid is of at most one Concept;
|
|
52
|
+
|
|
53
|
+
Constraint is a kind of Concept [partitioned];
|
|
55
54
|
Name is of Constraint,
|
|
56
55
|
Constraint is called at most one Name;
|
|
57
56
|
|
|
58
|
-
Context Note is
|
|
59
|
-
|
|
60
|
-
Context Note applies to at most one
|
|
57
|
+
Context Note is a kind of Concept [partitioned];
|
|
58
|
+
Concept has Context Note,
|
|
59
|
+
Context Note applies to at most one Concept;
|
|
61
60
|
Context Note has one Context Note Kind,
|
|
62
61
|
Context Note Kind is of Context Note;
|
|
63
62
|
Context Note has one Discussion,
|
|
64
63
|
Discussion is for Context Note;
|
|
65
64
|
|
|
66
|
-
Disjunction is identified by its Id;
|
|
67
|
-
|
|
68
65
|
Enforcement is identified by Constraint where
|
|
69
66
|
Constraint requires at most one Enforcement,
|
|
70
67
|
Enforcement applies to one Constraint;
|
|
@@ -72,20 +69,18 @@ Enforcement notifies at most one Agent;
|
|
|
72
69
|
Enforcement has one Enforcement Code,
|
|
73
70
|
Enforcement Code is of Enforcement;
|
|
74
71
|
|
|
75
|
-
Fact is
|
|
72
|
+
Fact is a kind of Concept [partitioned];
|
|
76
73
|
|
|
77
|
-
Fact Type is
|
|
74
|
+
Fact Type is a kind of Concept [partitioned];
|
|
78
75
|
Fact is of one Fact Type;
|
|
79
|
-
Fact Type has Context Note,
|
|
80
|
-
Context Note applies to at most one Fact Type;
|
|
81
76
|
|
|
82
77
|
Implicit Fact Type is a kind of Fact Type;
|
|
83
78
|
|
|
84
|
-
Instance is
|
|
79
|
+
Instance is a kind of Concept [partitioned];
|
|
85
80
|
Instance objectifies at most one Fact,
|
|
86
81
|
Fact is objectified as at most one Instance;
|
|
87
82
|
|
|
88
|
-
Join is
|
|
83
|
+
Join is a kind of Concept [partitioned];
|
|
89
84
|
|
|
90
85
|
Join Node is identified by Join and Ordinal where
|
|
91
86
|
Join includes Join Node,
|
|
@@ -116,8 +111,11 @@ Reading has one Text;
|
|
|
116
111
|
Ring Constraint is a kind of Constraint;
|
|
117
112
|
Ring Constraint is of one Ring Type;
|
|
118
113
|
|
|
119
|
-
Role is where
|
|
120
|
-
|
|
114
|
+
Role is a kind of Concept identified by Fact Type and Ordinal [partitioned] where
|
|
115
|
+
Role belongs to one Fact Type,
|
|
116
|
+
Fact Type contains Role,
|
|
117
|
+
Role fills one Ordinal,
|
|
118
|
+
Ordinal applies to Role;
|
|
121
119
|
Implicit Fact Type is implied by one Role (as Implying Role),
|
|
122
120
|
Implying Role implies at most one Implicit Fact Type;
|
|
123
121
|
Ring Constraint has at most one other-Role,
|
|
@@ -128,7 +126,9 @@ Role is of Ring Constraint,
|
|
|
128
126
|
Role has at most one role-Name,
|
|
129
127
|
role-Name is name of at least one Role;
|
|
130
128
|
|
|
131
|
-
Role Sequence is identified by
|
|
129
|
+
Role Sequence is identified by Guid where
|
|
130
|
+
Role Sequence has one Guid,
|
|
131
|
+
Guid is of at most one Role Sequence;
|
|
132
132
|
Presence Constraint covers one Role Sequence;
|
|
133
133
|
Reading is in one Role Sequence,
|
|
134
134
|
Role Sequence is for Reading;
|
|
@@ -143,7 +143,9 @@ Role Value is of one Role;
|
|
|
143
143
|
|
|
144
144
|
Set Constraint is a kind of Constraint;
|
|
145
145
|
|
|
146
|
-
Shape is identified by
|
|
146
|
+
Shape is identified by Guid where
|
|
147
|
+
Shape has one Guid,
|
|
148
|
+
Guid is of at most one Shape;
|
|
147
149
|
Shape is at at most one Position;
|
|
148
150
|
Shape is expanded;
|
|
149
151
|
|
|
@@ -151,7 +153,7 @@ Subset Constraint is a kind of Set Constraint;
|
|
|
151
153
|
Subset Constraint covers one subset-Role Sequence;
|
|
152
154
|
Subset Constraint covers one superset-Role Sequence;
|
|
153
155
|
|
|
154
|
-
Unit is
|
|
156
|
+
Unit is a kind of Concept [partitioned];
|
|
155
157
|
Ephemera URL provides Unit coefficient,
|
|
156
158
|
Unit uses coefficient from at most one Ephemera URL;
|
|
157
159
|
Name is of at most one Unit,
|
|
@@ -230,8 +232,8 @@ Join Role is independent where
|
|
|
230
232
|
Join Step is identified by input-Join Role and output-Join Role where
|
|
231
233
|
Join Step has one input-Join Role,
|
|
232
234
|
Join Step has one output-Join Role;
|
|
233
|
-
Join Step falls under at most one
|
|
234
|
-
|
|
235
|
+
Join Step falls under at most one Alternative Set,
|
|
236
|
+
Alternative Set covers at least one Join Step;
|
|
235
237
|
Join Step traverses one Fact Type,
|
|
236
238
|
Fact Type directs Join Step;
|
|
237
239
|
Join Step involves incidental-Join Role,
|
|
@@ -242,15 +244,12 @@ Join Step is outer;
|
|
|
242
244
|
Model Note Shape is a kind of Shape;
|
|
243
245
|
Model Note Shape is for one Context Note;
|
|
244
246
|
|
|
245
|
-
Object Type is identified by Vocabulary and Name where
|
|
247
|
+
Object Type is a kind of Concept identified by Vocabulary and Name [partitioned] where
|
|
246
248
|
Object Type belongs to one Vocabulary,
|
|
247
|
-
Vocabulary contains Object Type,
|
|
248
249
|
Object Type is called one Name;
|
|
249
250
|
Instance is of one Object Type;
|
|
250
251
|
Join Node is for one Object Type,
|
|
251
252
|
Object Type is referenced in Join Node;
|
|
252
|
-
Object Type has Context Note,
|
|
253
|
-
Context Note applies to at most one Object Type;
|
|
254
253
|
Object Type uses at most one Pronoun;
|
|
255
254
|
Object Type plays Role,
|
|
256
255
|
Role is played by one Object Type;
|
|
@@ -265,7 +264,7 @@ Objectified Fact Type Name Shape is a kind of Shape identified by Fact Type Shap
|
|
|
265
264
|
Objectified Fact Type Name Shape is for one Fact Type Shape,
|
|
266
265
|
Fact Type Shape has at most one Objectified Fact Type Name Shape;
|
|
267
266
|
|
|
268
|
-
Population is identified by Vocabulary and Name where
|
|
267
|
+
Population is a kind of Concept identified by Vocabulary and Name [partitioned] where
|
|
269
268
|
Vocabulary includes Population,
|
|
270
269
|
Population belongs to at most one Vocabulary,
|
|
271
270
|
Population has one Name,
|
|
@@ -335,7 +334,7 @@ Value Type is of at most one Unit;
|
|
|
335
334
|
Value Type has at most one Value Constraint,
|
|
336
335
|
Value Constraint constrains at most one Value Type;
|
|
337
336
|
Value Type has at most one auto-- assigned Transaction Timing;
|
|
338
|
-
Value Type is subtype of at most one super-Value Type (as Supertype) [acyclic],
|
|
337
|
+
Value Type is subtype of at most one super-Value Type (as Supertype) [acyclic, transitive],
|
|
339
338
|
Supertype is supertype of Value Type;
|
|
340
339
|
|
|
341
340
|
Allowed Range is where
|
|
@@ -366,14 +365,21 @@ Type Inheritance provides identification;
|
|
|
366
365
|
/*
|
|
367
366
|
* Constraints:
|
|
368
367
|
*/
|
|
368
|
+
for each Concept exactly one of these holds:
|
|
369
|
+
Concept is an Instance,
|
|
370
|
+
Concept is a Fact,
|
|
371
|
+
Concept is an Object Type,
|
|
372
|
+
Concept is a Role,
|
|
373
|
+
Concept is a Fact Type,
|
|
374
|
+
Concept is a Constraint,
|
|
375
|
+
Concept is a Population,
|
|
376
|
+
Concept is an Unit,
|
|
377
|
+
Concept is a Join,
|
|
378
|
+
Concept is a Context Note;
|
|
369
379
|
for each Constraint exactly one of these holds:
|
|
370
380
|
Constraint is a Presence Constraint,
|
|
371
381
|
Constraint is a Set Constraint,
|
|
372
382
|
Constraint is a Ring Constraint;
|
|
373
|
-
for each Context Note exactly one of these holds:
|
|
374
|
-
Context Note applies to Object Type,
|
|
375
|
-
Context Note applies to Fact Type,
|
|
376
|
-
Context Note applies to Constraint;
|
|
377
383
|
either Object Type is an Entity Type or Object Type is a Value Type but not both;
|
|
378
384
|
for each Role Sequence exactly one of these holds:
|
|
379
385
|
Role Sequence is for Reading,
|
|
@@ -404,7 +410,7 @@ Role Value is of Instance that is of Object Type
|
|
|
404
410
|
Role Value is of Role that is played by Object Type;
|
|
405
411
|
Role Value fulfils Fact that is of Fact Type
|
|
406
412
|
if and only if
|
|
407
|
-
Role Value is of Role
|
|
413
|
+
Role Value is of Role that belongs to Fact Type;
|
|
408
414
|
Entity Type is implied by objectification
|
|
409
415
|
only if Entity Type nests Fact Type;
|
|
410
416
|
Presence Constraint is preferred identifier
|
data/lib/activefacts/cql.rb
CHANGED
|
@@ -66,6 +66,27 @@ module ActiveFacts
|
|
|
66
66
|
vocabulary
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
def compile_import file, aliases
|
|
70
|
+
saved_index = @index
|
|
71
|
+
saved_block = @block
|
|
72
|
+
old_filename = @filename
|
|
73
|
+
@filename = file+'.cql'
|
|
74
|
+
|
|
75
|
+
File.open(@filename) do |f|
|
|
76
|
+
ok = parse_all(f.read, nil, &@block)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
rescue => e
|
|
80
|
+
ne = StandardError.new("In #{@filename} #{e.message.strip}")
|
|
81
|
+
ne.set_backtrace(e.backtrace)
|
|
82
|
+
raise ne
|
|
83
|
+
ensure
|
|
84
|
+
@block = saved_block
|
|
85
|
+
@index = saved_index
|
|
86
|
+
@filename = old_filename
|
|
87
|
+
nil
|
|
88
|
+
end
|
|
89
|
+
|
|
69
90
|
def compile_definition ast
|
|
70
91
|
ast.compile
|
|
71
92
|
end
|
|
@@ -523,7 +523,7 @@ module ActiveFacts
|
|
|
523
523
|
debug :matching, "Making new fact type for #{@phrases.inspect}" do
|
|
524
524
|
@phrases.each do |phrase|
|
|
525
525
|
next unless phrase.respond_to?(:player)
|
|
526
|
-
phrase.role = vocabulary.constellation.Role(fact_type, fact_type.all_role.size, :object_type => phrase.player)
|
|
526
|
+
phrase.role = vocabulary.constellation.Role(fact_type, fact_type.all_role.size, :object_type => phrase.player, :guid => :new)
|
|
527
527
|
phrase.role.role_name = phrase.role_name if phrase.role_name && phrase.role_name.is_a?(String)
|
|
528
528
|
end
|
|
529
529
|
end
|
|
@@ -28,16 +28,10 @@ module ActiveFacts
|
|
|
28
28
|
:context_note_kind => @context_kind,
|
|
29
29
|
:discussion => @discussion
|
|
30
30
|
)
|
|
31
|
-
|
|
32
|
-
when ActiveFacts::Metamodel::ObjectType
|
|
33
|
-
context_note.object_type = target
|
|
34
|
-
when ActiveFacts::Metamodel::Constraint
|
|
35
|
-
context_note.constraint = target
|
|
36
|
-
when ActiveFacts::Metamodel::FactType
|
|
37
|
-
context_note.fact_type = target
|
|
38
|
-
end
|
|
31
|
+
context_note.concept = target
|
|
39
32
|
if @agreed_date || @agreed_agents
|
|
40
|
-
agreement = constellation.Agreement(context_note
|
|
33
|
+
agreement = constellation.Agreement(context_note)
|
|
34
|
+
agreement.date = @agreed_date if @agreed_date
|
|
41
35
|
@agreed_agents.each do |agent|
|
|
42
36
|
constellation.ContextAgreedBy(agreement, agent)
|
|
43
37
|
end
|
|
@@ -426,7 +420,12 @@ module ActiveFacts
|
|
|
426
420
|
|
|
427
421
|
class RingConstraint < Constraint
|
|
428
422
|
Types = %w{acyclic intransitive symmetric asymmetric transitive antisymmetric irreflexive reflexive}
|
|
429
|
-
Pairs = {
|
|
423
|
+
Pairs = {
|
|
424
|
+
:intransitive => [:acyclic, :asymmetric, :symmetric],
|
|
425
|
+
:transitive => [:acyclic],
|
|
426
|
+
:acyclic => [:transitive],
|
|
427
|
+
:irreflexive => [:symmetric]
|
|
428
|
+
}
|
|
430
429
|
|
|
431
430
|
def initialize role_sequence, qualifiers
|
|
432
431
|
super nil, nil
|
|
@@ -464,7 +463,7 @@ module ActiveFacts
|
|
|
464
463
|
# Ensure that the keys in Pairs follow others:
|
|
465
464
|
@rings = @rings.partition{|rc| !Pairs.keys.include?(rc.downcase.to_sym) }.flatten
|
|
466
465
|
|
|
467
|
-
if @rings.size > 1 and !Pairs[@rings[-1].to_sym].include?(@rings[0].to_sym)
|
|
466
|
+
if @rings.size > 1 and !(p = Pairs[@rings[-1].to_sym]) and !p.include?(@rings[0].to_sym)
|
|
468
467
|
raise "incompatible ring constraint types (#{@rings*", "})"
|
|
469
468
|
end
|
|
470
469
|
ring_type = @rings.map{|c| c.capitalize}*""
|
|
@@ -28,7 +28,7 @@ module ActiveFacts
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def compile
|
|
31
|
-
@entity_type = @constellation.EntityType(@vocabulary, @name)
|
|
31
|
+
@entity_type = @constellation.EntityType(@vocabulary, @name, :guid => :new)
|
|
32
32
|
@entity_type.is_independent = true if (@pragmas.include? 'independent')
|
|
33
33
|
|
|
34
34
|
# REVISIT: CQL needs a way to indicate whether subtype migration can occur.
|
|
@@ -214,7 +214,7 @@ module ActiveFacts
|
|
|
214
214
|
|
|
215
215
|
def add_supertype(supertype_name, not_identifying)
|
|
216
216
|
debug :supertype, "Adding supertype #{supertype_name}" do
|
|
217
|
-
supertype = @constellation.EntityType(@vocabulary, supertype_name)
|
|
217
|
+
supertype = @constellation.EntityType(@vocabulary, supertype_name, :guid => :new)
|
|
218
218
|
|
|
219
219
|
# Did we already know about this supertype?
|
|
220
220
|
return if @entity_type.all_type_inheritance_as_subtype.detect{|ti| ti.supertype == supertype}
|
|
@@ -222,15 +222,15 @@ module ActiveFacts
|
|
|
222
222
|
# By default, the first supertype identifies this entity type
|
|
223
223
|
is_identifying_supertype = !not_identifying && @entity_type.all_type_inheritance_as_subtype.size == 0
|
|
224
224
|
|
|
225
|
-
inheritance_fact = @constellation.TypeInheritance(@entity_type, supertype, :
|
|
225
|
+
inheritance_fact = @constellation.TypeInheritance(@entity_type, supertype, :guid => :new)
|
|
226
226
|
|
|
227
227
|
assimilations = @pragmas.select { |p| ['absorbed', 'separate', 'partitioned'].include? p}
|
|
228
228
|
raise "Conflicting assimilation pragmas #{assimilations*', '}" if assimilations.size > 1
|
|
229
229
|
inheritance_fact.assimilation = assimilations[0]
|
|
230
230
|
|
|
231
231
|
# Create a reading:
|
|
232
|
-
sub_role = @constellation.Role(inheritance_fact, 0, :object_type => @entity_type)
|
|
233
|
-
super_role = @constellation.Role(inheritance_fact, 1, :object_type => supertype)
|
|
232
|
+
sub_role = @constellation.Role(inheritance_fact, 0, :object_type => @entity_type, :guid => :new)
|
|
233
|
+
super_role = @constellation.Role(inheritance_fact, 1, :object_type => supertype, :guid => :new)
|
|
234
234
|
|
|
235
235
|
rs = @constellation.RoleSequence(:new)
|
|
236
236
|
@constellation.RoleRef(rs, 0, :role => sub_role)
|
|
@@ -279,8 +279,8 @@ module ActiveFacts
|
|
|
279
279
|
# Find or Create an appropriate ValueType called '#{vt_name}', of the supertype '#{mode}'
|
|
280
280
|
unless vt = @constellation.ObjectType[[@vocabulary.identifying_role_values, vt_name]] or
|
|
281
281
|
vt = @constellation.ObjectType[[@vocabulary.identifying_role_values, vt_name = "#{name} #{mode}"]]
|
|
282
|
-
base_vt = @constellation.ValueType(@vocabulary, mode)
|
|
283
|
-
vt = @constellation.ValueType(@vocabulary, vt_name, :supertype => base_vt)
|
|
282
|
+
base_vt = @constellation.ValueType(@vocabulary, mode, :guid => :new)
|
|
283
|
+
vt = @constellation.ValueType(@vocabulary, vt_name, :supertype => base_vt, :guid => :new)
|
|
284
284
|
if parameters
|
|
285
285
|
length, scale = *parameters
|
|
286
286
|
vt.length = length if length
|
|
@@ -313,8 +313,8 @@ module ActiveFacts
|
|
|
313
313
|
unless fact_type
|
|
314
314
|
fact_type = @constellation.FactType(:new)
|
|
315
315
|
fact_types << fact_type
|
|
316
|
-
entity_role = @constellation.Role(fact_type, 0, :object_type => @entity_type)
|
|
317
|
-
identifying_role = @constellation.Role(fact_type, 1, :object_type => identifying_type)
|
|
316
|
+
entity_role = @constellation.Role(fact_type, 0, :object_type => @entity_type, :guid => :new)
|
|
317
|
+
identifying_role = @constellation.Role(fact_type, 1, :object_type => identifying_type, :guid => :new)
|
|
318
318
|
end
|
|
319
319
|
@identification[0].role = identifying_role
|
|
320
320
|
|
|
@@ -87,7 +87,7 @@ module ActiveFacts
|
|
|
87
87
|
def result_value_type(context, name)
|
|
88
88
|
vocabulary = context.vocabulary
|
|
89
89
|
constellation = vocabulary.constellation
|
|
90
|
-
constellation.ValueType(vocabulary, name)
|
|
90
|
+
constellation.ValueType(vocabulary, name, :guid => :new)
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def is_naked_object_type
|
|
@@ -180,7 +180,7 @@ module ActiveFacts
|
|
|
180
180
|
raise "REVISIT: The player is the projected expression"
|
|
181
181
|
end
|
|
182
182
|
v = context.vocabulary
|
|
183
|
-
@player = v.constellation.ValueType(v, 'Boolean')
|
|
183
|
+
@player = v.constellation.ValueType(v, 'Boolean', :guid => :new)
|
|
184
184
|
end
|
|
185
185
|
end
|
|
186
186
|
|
|
@@ -308,7 +308,7 @@ module ActiveFacts
|
|
|
308
308
|
# REVISIT: Calculate the units of the result from the units in @divisor
|
|
309
309
|
# REVISIT: Do we want integer division?
|
|
310
310
|
v = context.vocabulary
|
|
311
|
-
@player = v.constellation.ValueType(v, 'Real')
|
|
311
|
+
@player = v.constellation.ValueType(v, 'Real', :guid => :new)
|
|
312
312
|
end
|
|
313
313
|
end
|
|
314
314
|
|
|
@@ -396,7 +396,7 @@ module ActiveFacts
|
|
|
396
396
|
when TrueClass, FalseClass; 'Boolean'
|
|
397
397
|
end
|
|
398
398
|
v = context.vocabulary
|
|
399
|
-
@player = v.constellation.ValueType(v, player_name)
|
|
399
|
+
@player = v.constellation.ValueType(v, player_name, :guid => :new)
|
|
400
400
|
end
|
|
401
401
|
end
|
|
402
402
|
|
|
@@ -9,7 +9,7 @@ module ActiveFacts
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def compile
|
|
12
|
-
@population = @constellation.Population(@vocabulary, @population_name)
|
|
12
|
+
@population = @constellation.Population(@vocabulary, @population_name, :guid => :new)
|
|
13
13
|
|
|
14
14
|
@context = CompilationContext.new(@vocabulary)
|
|
15
15
|
@context.bind @clauses
|
|
@@ -276,12 +276,10 @@ module ActiveFacts
|
|
|
276
276
|
#}
|
|
277
277
|
debug :instance, "This #{object_type.name} value already exists" if instance
|
|
278
278
|
unless instance
|
|
279
|
-
instance = @constellation.Instance(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
:value => [literal.to_s, is_a_string, nil]
|
|
284
|
-
)
|
|
279
|
+
instance = @constellation.Instance(:new)
|
|
280
|
+
instance.object_type = object_type
|
|
281
|
+
instance.population = @population
|
|
282
|
+
instance.value = [literal.to_s, is_a_string, nil]
|
|
285
283
|
@bound_facts << instance
|
|
286
284
|
end
|
|
287
285
|
instance
|
|
@@ -140,7 +140,7 @@ module ActiveFacts
|
|
|
140
140
|
end
|
|
141
141
|
e = @constellation.EntityType[[@vocabulary, @name]]
|
|
142
142
|
raise "You can't objectify #{@name}, it already exists" if e
|
|
143
|
-
e = @constellation.EntityType(@vocabulary, @name, :fact_type => @fact_type)
|
|
143
|
+
e = @constellation.EntityType(@vocabulary, @name, :fact_type => @fact_type, :guid => :new)
|
|
144
144
|
e.create_implicit_fact_types
|
|
145
145
|
if @pragmas
|
|
146
146
|
e.is_independent = true if @pragmas.delete('independent')
|
|
@@ -192,6 +192,8 @@ module ActiveFacts
|
|
|
192
192
|
# REVISIT: If we have conditions, we must match all given clauses exactly (no side-effects)
|
|
193
193
|
@existing_clauses = @clauses.
|
|
194
194
|
select{ |clause| clause.match_existing_fact_type @context }.
|
|
195
|
+
# subtyping match is not allowed for fact type extension:
|
|
196
|
+
reject{ |clause| clause.side_effects.role_side_effects.detect{|se| se.common_supertype } }.
|
|
195
197
|
sort_by{ |clause| clause.side_effects.cost }
|
|
196
198
|
fact_types = @existing_clauses.map{ |clause| clause.fact_type }.uniq.compact
|
|
197
199
|
|
|
@@ -64,7 +64,7 @@ module ActiveFacts
|
|
|
64
64
|
player ||= @player_by_role_name[name]
|
|
65
65
|
|
|
66
66
|
if !player && @allowed_forward_terms.include?(name)
|
|
67
|
-
player = constellation.EntityType(@vocabulary, name)
|
|
67
|
+
player = constellation.EntityType(@vocabulary, name, :guid => :new)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
player
|
|
@@ -111,13 +111,18 @@ module ActiveFacts
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
class Import < Definition
|
|
114
|
-
def initialize name,
|
|
114
|
+
def initialize parser, name, alias_hash
|
|
115
|
+
@parser = parser
|
|
115
116
|
@name = name
|
|
116
|
-
@
|
|
117
|
+
@alias_hash = alias_hash
|
|
117
118
|
end
|
|
118
119
|
|
|
119
120
|
def to_s
|
|
120
|
-
"#{@vocabulary.to_s} imports #{
|
|
121
|
+
"#{@vocabulary.to_s} imports #{@alias_hash.map{|k,v| "#{k} as #{v}" }*', '};"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def compile
|
|
125
|
+
@parser.compile_import(@name, @alias_hash)
|
|
121
126
|
end
|
|
122
127
|
end
|
|
123
128
|
|
|
@@ -103,13 +103,13 @@ module ActiveFacts
|
|
|
103
103
|
base_type = nil
|
|
104
104
|
if (@base_type_name != @name)
|
|
105
105
|
unless base_type = @constellation.ValueType[[@vocabulary.identifying_role_values, @constellation.Name(@base_type_name)]]
|
|
106
|
-
base_type = @constellation.ValueType(@vocabulary, @base_type_name)
|
|
106
|
+
base_type = @constellation.ValueType(@vocabulary, @base_type_name, :guid => :new)
|
|
107
107
|
return base_type if @base_type_name == @name
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
# Create and initialise the ValueType:
|
|
112
|
-
vt = @constellation.ValueType(@vocabulary, @name)
|
|
112
|
+
vt = @constellation.ValueType(@vocabulary, @name, :guid => :new)
|
|
113
113
|
vt.is_independent = true if (@pragmas.include? 'independent')
|
|
114
114
|
vt.supertype = base_type if base_type
|
|
115
115
|
vt.length = length if length
|
|
@@ -164,11 +164,12 @@ module ActiveFacts
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
class InputProxy
|
|
167
|
-
attr_reader :context
|
|
167
|
+
attr_reader :context, :parser
|
|
168
168
|
|
|
169
|
-
def initialize(input, context)
|
|
169
|
+
def initialize(input, context, parser)
|
|
170
170
|
@input = input
|
|
171
171
|
@context = context
|
|
172
|
+
@parser = parser
|
|
172
173
|
end
|
|
173
174
|
|
|
174
175
|
def length
|
|
@@ -206,7 +207,7 @@ module ActiveFacts
|
|
|
206
207
|
end
|
|
207
208
|
|
|
208
209
|
def parse(input, options = {})
|
|
209
|
-
input = InputProxy.new(input, context) unless input.respond_to?(:context)
|
|
210
|
+
input = InputProxy.new(input, context, self) unless input.respond_to?(:context)
|
|
210
211
|
super(input, options)
|
|
211
212
|
end
|
|
212
213
|
|
|
@@ -214,18 +215,19 @@ module ActiveFacts
|
|
|
214
215
|
self.root = rule_name if rule_name
|
|
215
216
|
|
|
216
217
|
@index = 0 # Byte offset to start next parse
|
|
218
|
+
@block = block
|
|
217
219
|
self.consume_all_input = false
|
|
218
220
|
nodes = []
|
|
219
221
|
begin
|
|
220
|
-
node = parse(InputProxy.new(input, context), :index => @index)
|
|
222
|
+
node = parse(InputProxy.new(input, context, self), :index => @index)
|
|
221
223
|
return nil unless node
|
|
222
|
-
if block
|
|
223
|
-
block.call(node)
|
|
224
|
+
if @block
|
|
225
|
+
@block.call(node)
|
|
224
226
|
else
|
|
225
227
|
nodes << node
|
|
226
228
|
end
|
|
227
229
|
end until self.index == @input_length
|
|
228
|
-
block ? true : nodes
|
|
230
|
+
@block ? true : nodes
|
|
229
231
|
end
|
|
230
232
|
end
|
|
231
233
|
|
|
@@ -51,7 +51,7 @@ module ActiveFacts
|
|
|
51
51
|
when ActiveFacts::Metamodel::PresenceConstraint
|
|
52
52
|
fact_types = c.role_sequence.all_role_ref.map{|rr| rr.role.fact_type}.uniq # All fact types spanned by this constraint
|
|
53
53
|
if fact_types.size == 1 # There's only one, save it:
|
|
54
|
-
# debug "Single-fact constraint on #{fact_types[0].
|
|
54
|
+
# debug "Single-fact constraint on #{fact_types[0].guid}: #{c.name}"
|
|
55
55
|
(@presence_constraints_by_fact[fact_types[0]] ||= []) << c
|
|
56
56
|
end
|
|
57
57
|
when ActiveFacts::Metamodel::RingConstraint
|
|
@@ -348,7 +348,7 @@ module ActiveFacts
|
|
|
348
348
|
|
|
349
349
|
# debug "for fact type #{fact_type.to_s}, considering\n\t#{fact_constraints.map(&:to_s)*",\n\t"}"
|
|
350
350
|
# debug "#{fact_type.name} has readings:\n\t#{fact_type.readings.map(&:name)*"\n\t"}"
|
|
351
|
-
# debug "Dumping #{fact_type.
|
|
351
|
+
# debug "Dumping #{fact_type.guid} as a fact type"
|
|
352
352
|
|
|
353
353
|
# Fact types that aren't nested have no names
|
|
354
354
|
name = fact_type.entity_type && fact_type.entity_type.name
|
|
@@ -501,8 +501,6 @@ module ActiveFacts
|
|
|
501
501
|
!c.role_sequence.all_role_ref.detect{|rr| rr.join_role } &&
|
|
502
502
|
c.max_frequency == 1 && # Uniqueness
|
|
503
503
|
fact_types[0].all_role.size == c.role_sequence.all_role_ref.size
|
|
504
|
-
# debugger if !$constraint_id || c.constraint_id.object_id == $foo
|
|
505
|
-
# $constraint_id ||= 1
|
|
506
504
|
next
|
|
507
505
|
end
|
|
508
506
|
|
|
@@ -63,8 +63,8 @@ module ActiveFacts
|
|
|
63
63
|
"DateAndTimeTemporal" => "Date Time",
|
|
64
64
|
"TrueOrFalseLogical" => "Boolean",
|
|
65
65
|
"YesOrNoLogical" => "Boolean",
|
|
66
|
-
"RowIdOther" => "
|
|
67
|
-
"ObjectIdOther" => "
|
|
66
|
+
"RowIdOther" => "Guid",
|
|
67
|
+
"ObjectIdOther" => "Guid"
|
|
68
68
|
}
|
|
69
69
|
RESERVED_WORDS = %w{
|
|
70
70
|
and but each each either false if maybe no none not one or some that true where
|
|
@@ -155,7 +155,7 @@ module ActiveFacts
|
|
|
155
155
|
entity_types <<
|
|
156
156
|
@by_id[id] =
|
|
157
157
|
entity_type =
|
|
158
|
-
@constellation.EntityType(@vocabulary, name)
|
|
158
|
+
@constellation.EntityType(@vocabulary, name, :guid => :new)
|
|
159
159
|
independent = x['IsIndependent']
|
|
160
160
|
entity_type.is_independent = true if independent && independent == 'true'
|
|
161
161
|
personal = x['IsPersonal']
|
|
@@ -216,14 +216,14 @@ module ActiveFacts
|
|
|
216
216
|
supertype_name = x_supertype['Name']
|
|
217
217
|
raise "Supertype of #{name} is post-defined but recursiving processing failed" unless supertype
|
|
218
218
|
raise "Supertype #{supertype_name} of #{name} is not a value type" unless supertype.kind_of? ActiveFacts::Metamodel::ValueType
|
|
219
|
-
value_super_type = @constellation.ValueType(@vocabulary, supertype_name)
|
|
219
|
+
value_super_type = @constellation.ValueType(@vocabulary, supertype_name, :guid => :new)
|
|
220
220
|
else
|
|
221
221
|
# REVISIT: Need to handle standard types better here:
|
|
222
|
-
value_super_type = type_name != name ? @constellation.ValueType(@vocabulary, type_name) : nil
|
|
222
|
+
value_super_type = type_name != name ? @constellation.ValueType(@vocabulary, type_name, :guid => :new) : nil
|
|
223
223
|
end
|
|
224
224
|
|
|
225
225
|
@by_id[id] =
|
|
226
|
-
vt = @constellation.ValueType(@vocabulary, name)
|
|
226
|
+
vt = @constellation.ValueType(@vocabulary, name, :guid => :new)
|
|
227
227
|
vt.supertype = value_super_type
|
|
228
228
|
vt.length = length if length
|
|
229
229
|
vt.scale = scale if scale && scale != 0
|
|
@@ -316,7 +316,7 @@ module ActiveFacts
|
|
|
316
316
|
next if subtype.kind_of? ActiveFacts::Metamodel::ValueType or
|
|
317
317
|
supertype.kind_of? ActiveFacts::Metamodel::ValueType
|
|
318
318
|
|
|
319
|
-
inheritance_fact = @constellation.TypeInheritance(subtype, supertype, :
|
|
319
|
+
inheritance_fact = @constellation.TypeInheritance(subtype, supertype, :guid => :new)
|
|
320
320
|
if x["IsPrimary"] == "true" or # Old way
|
|
321
321
|
x["PreferredIdentificationPath"] == "true" # Newer
|
|
322
322
|
debug :orm, "#{supertype.name} is primary supertype of #{subtype.name}"
|
|
@@ -328,8 +328,8 @@ module ActiveFacts
|
|
|
328
328
|
facts << @by_id[id] = inheritance_fact
|
|
329
329
|
|
|
330
330
|
# Create the new Roles so we can find constraints on them:
|
|
331
|
-
subtype_role = @by_id[subtype_role_id] = @constellation.Role(inheritance_fact, 0, :object_type => subtype)
|
|
332
|
-
supertype_role = @by_id[supertype_role_id] = @constellation.Role(inheritance_fact, 1, :object_type => supertype)
|
|
331
|
+
subtype_role = @by_id[subtype_role_id] = @constellation.Role(inheritance_fact, 0, :object_type => subtype, :guid => :new)
|
|
332
|
+
supertype_role = @by_id[supertype_role_id] = @constellation.Role(inheritance_fact, 1, :object_type => supertype, :guid => :new)
|
|
333
333
|
|
|
334
334
|
# Create readings, so constraints can be verbalised for example:
|
|
335
335
|
rs = @constellation.RoleSequence(:new)
|
|
@@ -368,10 +368,10 @@ module ActiveFacts
|
|
|
368
368
|
next if x.xpath("orm:DerivationRule").size > 0
|
|
369
369
|
throw "Nested fact #{fact_id} not found" if !fact_type
|
|
370
370
|
|
|
371
|
-
debug :orm, "NestedType #{name} is #{id}, nests #{fact_type.
|
|
371
|
+
debug :orm, "NestedType #{name} is #{id}, nests #{fact_type.guid}"
|
|
372
372
|
@nested_types <<
|
|
373
373
|
@by_id[id] =
|
|
374
|
-
nested_type = @constellation.EntityType(@vocabulary, name)
|
|
374
|
+
nested_type = @constellation.EntityType(@vocabulary, name, :guid => :new)
|
|
375
375
|
independent = x['IsIndependent']
|
|
376
376
|
nested_type.is_independent = true if independent && independent == 'true' && !is_implied
|
|
377
377
|
nested_type.is_implied_by_objectification = is_implied
|
|
@@ -443,11 +443,11 @@ module ActiveFacts
|
|
|
443
443
|
debug :orm, "#{@vocabulary.name}, RoleName=#{x['Name'].inspect} played by object_type=#{object_type.name}"
|
|
444
444
|
throw "Role is played by #{object_type.class} not ObjectType" if !(@constellation.vocabulary.object_type(:ObjectType) === object_type)
|
|
445
445
|
|
|
446
|
-
debug :orm, "Creating role #{name} nr#{fact_type.all_role.size} of #{fact_type.
|
|
446
|
+
debug :orm, "Creating role #{name} nr#{fact_type.all_role.size} of #{fact_type.guid} played by #{object_type.name}"
|
|
447
447
|
|
|
448
|
-
role = @by_id[id] = @constellation.Role(fact_type, fact_type.all_role.size, :object_type => object_type)
|
|
448
|
+
role = @by_id[id] = @constellation.Role(fact_type, fact_type.all_role.size, :object_type => object_type, :guid => :new)
|
|
449
449
|
role.role_name = name if name && name != object_type.name
|
|
450
|
-
debug :orm, "Fact #{fact_name} (id #{fact_type.
|
|
450
|
+
debug :orm, "Fact #{fact_name} (id #{fact_type.guid.object_id}) role #{x['Name']} is played by #{object_type.name}, role is #{role.object_id}"
|
|
451
451
|
|
|
452
452
|
x_vr = x.xpath("orm:ValueRestriction/orm:RoleValueConstraint")
|
|
453
453
|
x_vr.each{|vr|
|
|
@@ -1190,7 +1190,7 @@ module ActiveFacts
|
|
|
1190
1190
|
|
|
1191
1191
|
def read_instances
|
|
1192
1192
|
debug :orm, "Reading sample data" do
|
|
1193
|
-
population = @constellation.Population(@vocabulary, "sample")
|
|
1193
|
+
population = @constellation.Population(@vocabulary, "sample", :guid => :new)
|
|
1194
1194
|
|
|
1195
1195
|
# Value instances first, then entities then facts:
|
|
1196
1196
|
|
|
@@ -1436,9 +1436,9 @@ module ActiveFacts
|
|
|
1436
1436
|
position = convert_position(xr_shape['AbsoluteBounds'])
|
|
1437
1437
|
case xr_shape.name
|
|
1438
1438
|
when 'ObjectifiedFactTypeNameShape'
|
|
1439
|
-
@constellation.ObjectifiedFactTypeNameShape(shape, :
|
|
1439
|
+
@constellation.ObjectifiedFactTypeNameShape(shape, :guid => :new, :diagram => diagram, :position => position, :is_expanded => false)
|
|
1440
1440
|
when 'ReadingShape'
|
|
1441
|
-
@constellation.ReadingShape(shape, :
|
|
1441
|
+
@constellation.ReadingShape(shape, :guid => :new, :fact_type_shape=>shape, :diagram => diagram, :position => position, :is_expanded => false, :reading => fact_type.preferred_reading)
|
|
1442
1442
|
when 'RoleNameShape'
|
|
1443
1443
|
role = @by_id[xr_shape.xpath("ormDiagram:Subject")[0]['ref']]
|
|
1444
1444
|
role_display = role_display_for_role(shape, x_role_display, role)
|
|
@@ -203,7 +203,7 @@ module ActiveFacts
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
module Metamodel #:nodoc:
|
|
206
|
-
class ObjectType
|
|
206
|
+
class ObjectType < Concept
|
|
207
207
|
# Say whether the independence of this object is still under consideration
|
|
208
208
|
# This is used in detecting dependency cycles, such as occurs in the Metamodel
|
|
209
209
|
attr_accessor :tentative #:nodoc:
|
|
@@ -158,12 +158,22 @@ module ActiveFacts
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
class Vocabulary
|
|
161
|
+
@@relational_transforms = []
|
|
162
|
+
|
|
161
163
|
# return an Array of ObjectTypes that will have their own tables
|
|
162
164
|
def tables
|
|
163
165
|
decide_tables if !@tables
|
|
166
|
+
@@relational_transforms.each{|tr| tr.call(self)}
|
|
164
167
|
@tables
|
|
165
168
|
end
|
|
166
169
|
|
|
170
|
+
def self.relational_transform &block
|
|
171
|
+
# Add this block to the additional transformations which wil be applied
|
|
172
|
+
# to the relational schema after the initial absorption.
|
|
173
|
+
# For example, to perform injection of surrogate keys to replace composite keys...
|
|
174
|
+
@@relational_transforms << block
|
|
175
|
+
end
|
|
176
|
+
|
|
167
177
|
def decide_tables #:nodoc:
|
|
168
178
|
# Strategy:
|
|
169
179
|
# 1) Populate references for all ObjectTypes
|
data/lib/activefacts/version.rb
CHANGED
|
@@ -44,8 +44,8 @@ module ActiveFacts
|
|
|
44
44
|
# NORMA doesn't create an implicit fact type here, rather the fact type has an implicit extra role, so looks like a binary
|
|
45
45
|
# We only do it when the unary fact type is not objectified
|
|
46
46
|
implicit_fact_type = @constellation.ImplicitFactType(:new, :implying_role => role)
|
|
47
|
-
entity_type = @entity_type || @constellation.ImplicitBooleanValueType(role.object_type.vocabulary, "_ImplicitBooleanValueType")
|
|
48
|
-
phantom_role = @constellation.Role(implicit_fact_type, 0, :object_type => entity_type)
|
|
47
|
+
entity_type = @entity_type || @constellation.ImplicitBooleanValueType(role.object_type.vocabulary, "_ImplicitBooleanValueType", :guid => :new)
|
|
48
|
+
phantom_role = @constellation.Role(implicit_fact_type, 0, :object_type => entity_type, :guid => :new)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def reading_preferably_starting_with_role role
|
|
@@ -372,7 +372,7 @@ module ActiveFacts
|
|
|
372
372
|
fact_type.all_role.each do |role|
|
|
373
373
|
next if role.implicit_fact_type # Already exists
|
|
374
374
|
implicit_fact_type = @constellation.ImplicitFactType(:new, :implying_role => role)
|
|
375
|
-
phantom_role = @constellation.Role(implicit_fact_type, 0, :object_type => self)
|
|
375
|
+
phantom_role = @constellation.Role(implicit_fact_type, 0, :object_type => self, :guid => :new)
|
|
376
376
|
# We could create a copy of the visible external role here, but there's no need yet...
|
|
377
377
|
# Nor is there a need for a presence constraint, readings, etc.
|
|
378
378
|
end
|
|
@@ -644,7 +644,7 @@ module ActiveFacts
|
|
|
644
644
|
class Join
|
|
645
645
|
def show
|
|
646
646
|
steps_shown = {}
|
|
647
|
-
debug :join, "Displaying full contents of Join #{
|
|
647
|
+
debug :join, "Displaying full contents of Join #{guid}" do
|
|
648
648
|
all_join_node.sort_by{|jn| jn.ordinal}.each do |join_node|
|
|
649
649
|
debug :join, "#{join_node.describe}" do
|
|
650
650
|
join_node.all_join_step.
|
|
@@ -16,14 +16,6 @@ module ActiveFacts
|
|
|
16
16
|
restrict 'partitioned', 'separate'
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
class ConstraintId < AutoCounter
|
|
20
|
-
value_type
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
class ContextNoteId < AutoCounter
|
|
24
|
-
value_type
|
|
25
|
-
end
|
|
26
|
-
|
|
27
19
|
class ContextNoteKind < String
|
|
28
20
|
value_type
|
|
29
21
|
restrict 'as_opposed_to', 'because', 'so_that', 'to_avoid'
|
|
@@ -41,10 +33,6 @@ module ActiveFacts
|
|
|
41
33
|
value_type
|
|
42
34
|
end
|
|
43
35
|
|
|
44
|
-
class DisjunctionId < AutoCounter
|
|
45
|
-
value_type
|
|
46
|
-
end
|
|
47
|
-
|
|
48
36
|
class DisplayRoleNamesSetting < String
|
|
49
37
|
value_type
|
|
50
38
|
restrict 'false', 'true'
|
|
@@ -62,23 +50,11 @@ module ActiveFacts
|
|
|
62
50
|
value_type :length => 16
|
|
63
51
|
end
|
|
64
52
|
|
|
65
|
-
class FactId < AutoCounter
|
|
66
|
-
value_type
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
class FactTypeId < AutoCounter
|
|
70
|
-
value_type
|
|
71
|
-
end
|
|
72
|
-
|
|
73
53
|
class Frequency < UnsignedInteger
|
|
74
54
|
value_type :length => 32
|
|
75
55
|
end
|
|
76
56
|
|
|
77
|
-
class
|
|
78
|
-
value_type
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
class JoinId < AutoCounter
|
|
57
|
+
class Guid < ::Guid
|
|
82
58
|
value_type
|
|
83
59
|
end
|
|
84
60
|
|
|
@@ -115,10 +91,6 @@ module ActiveFacts
|
|
|
115
91
|
value_type
|
|
116
92
|
end
|
|
117
93
|
|
|
118
|
-
class RoleSequenceId < AutoCounter
|
|
119
|
-
value_type
|
|
120
|
-
end
|
|
121
|
-
|
|
122
94
|
class RotationSetting < String
|
|
123
95
|
value_type
|
|
124
96
|
restrict 'left', 'right'
|
|
@@ -128,10 +100,6 @@ module ActiveFacts
|
|
|
128
100
|
value_type :length => 32
|
|
129
101
|
end
|
|
130
102
|
|
|
131
|
-
class ShapeId < AutoCounter
|
|
132
|
-
value_type
|
|
133
|
-
end
|
|
134
|
-
|
|
135
103
|
class Subscript < UnsignedInteger
|
|
136
104
|
value_type :length => 16
|
|
137
105
|
end
|
|
@@ -145,10 +113,6 @@ module ActiveFacts
|
|
|
145
113
|
restrict 'assert', 'commit'
|
|
146
114
|
end
|
|
147
115
|
|
|
148
|
-
class UnitId < AutoCounter
|
|
149
|
-
value_type
|
|
150
|
-
end
|
|
151
|
-
|
|
152
116
|
class X < SignedInteger
|
|
153
117
|
value_type :length => 32
|
|
154
118
|
end
|
|
@@ -162,6 +126,11 @@ module ActiveFacts
|
|
|
162
126
|
one_to_one :agent_name, :mandatory => true # See AgentName.agent
|
|
163
127
|
end
|
|
164
128
|
|
|
129
|
+
class AlternativeSet
|
|
130
|
+
identified_by :guid
|
|
131
|
+
one_to_one :guid, :mandatory => true # See Guid.alternative_set
|
|
132
|
+
end
|
|
133
|
+
|
|
165
134
|
class Coefficient
|
|
166
135
|
identified_by :numerator, :denominator, :is_precise
|
|
167
136
|
has_one :denominator, :mandatory => true # See Denominator.all_coefficient
|
|
@@ -169,26 +138,20 @@ module ActiveFacts
|
|
|
169
138
|
has_one :numerator, :mandatory => true # See Numerator.all_coefficient
|
|
170
139
|
end
|
|
171
140
|
|
|
172
|
-
class
|
|
173
|
-
identified_by :
|
|
174
|
-
one_to_one :
|
|
141
|
+
class Concept
|
|
142
|
+
identified_by :guid
|
|
143
|
+
one_to_one :guid, :mandatory => true # See Guid.concept
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
class Constraint < Concept
|
|
175
147
|
has_one :name # See Name.all_constraint
|
|
176
148
|
has_one :vocabulary # See Vocabulary.all_constraint
|
|
177
149
|
end
|
|
178
150
|
|
|
179
|
-
class ContextNote
|
|
180
|
-
|
|
181
|
-
has_one :constraint # See Constraint.all_context_note
|
|
182
|
-
one_to_one :context_note_id, :mandatory => true # See ContextNoteId.context_note
|
|
151
|
+
class ContextNote < Concept
|
|
152
|
+
has_one :concept # See Concept.all_context_note
|
|
183
153
|
has_one :context_note_kind, :mandatory => true # See ContextNoteKind.all_context_note
|
|
184
154
|
has_one :discussion, :mandatory => true # See Discussion.all_context_note
|
|
185
|
-
has_one :fact_type # See FactType.all_context_note
|
|
186
|
-
has_one :object_type # See ObjectType.all_context_note
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
class Disjunction
|
|
190
|
-
identified_by :disjunction_id
|
|
191
|
-
one_to_one :disjunction_id, :mandatory => true # See DisjunctionId.disjunction
|
|
192
155
|
end
|
|
193
156
|
|
|
194
157
|
class Enforcement
|
|
@@ -198,33 +161,25 @@ module ActiveFacts
|
|
|
198
161
|
has_one :enforcement_code, :mandatory => true # See EnforcementCode.all_enforcement
|
|
199
162
|
end
|
|
200
163
|
|
|
201
|
-
class Fact
|
|
202
|
-
identified_by :fact_id
|
|
203
|
-
one_to_one :fact_id, :mandatory => true # See FactId.fact
|
|
164
|
+
class Fact < Concept
|
|
204
165
|
has_one :fact_type, :mandatory => true # See FactType.all_fact
|
|
205
166
|
has_one :population, :mandatory => true # See Population.all_fact
|
|
206
167
|
end
|
|
207
168
|
|
|
208
|
-
class FactType
|
|
209
|
-
identified_by :fact_type_id
|
|
210
|
-
one_to_one :fact_type_id, :mandatory => true # See FactTypeId.fact_type
|
|
169
|
+
class FactType < Concept
|
|
211
170
|
end
|
|
212
171
|
|
|
213
172
|
class ImplicitFactType < FactType
|
|
214
173
|
end
|
|
215
174
|
|
|
216
|
-
class Instance
|
|
217
|
-
identified_by :instance_id
|
|
175
|
+
class Instance < Concept
|
|
218
176
|
one_to_one :fact # See Fact.instance
|
|
219
|
-
one_to_one :instance_id, :mandatory => true # See InstanceId.instance
|
|
220
177
|
has_one :object_type, :mandatory => true # See ObjectType.all_instance
|
|
221
178
|
has_one :population, :mandatory => true # See Population.all_instance
|
|
222
179
|
has_one :value # See Value.all_instance
|
|
223
180
|
end
|
|
224
181
|
|
|
225
|
-
class Join
|
|
226
|
-
identified_by :join_id
|
|
227
|
-
one_to_one :join_id, :mandatory => true # See JoinId.join
|
|
182
|
+
class Join < Concept
|
|
228
183
|
end
|
|
229
184
|
|
|
230
185
|
class JoinNode
|
|
@@ -265,19 +220,19 @@ module ActiveFacts
|
|
|
265
220
|
has_one :role # See Role.all_ring_constraint
|
|
266
221
|
end
|
|
267
222
|
|
|
268
|
-
class Role
|
|
223
|
+
class Role < Concept
|
|
269
224
|
identified_by :fact_type, :ordinal
|
|
270
225
|
has_one :fact_type, :mandatory => true # See FactType.all_role
|
|
271
|
-
has_one :ordinal, :mandatory => true # See Ordinal.all_role
|
|
272
226
|
one_to_one :implicit_fact_type, :counterpart => :implying_role # See ImplicitFactType.implying_role
|
|
273
227
|
has_one :object_type, :mandatory => true # See ObjectType.all_role
|
|
228
|
+
has_one :ordinal, :mandatory => true # See Ordinal.all_role
|
|
274
229
|
has_one :role_name, :class => Name # See Name.all_role_as_role_name
|
|
275
230
|
end
|
|
276
231
|
|
|
277
232
|
class RoleSequence
|
|
278
|
-
identified_by :
|
|
233
|
+
identified_by :guid
|
|
234
|
+
one_to_one :guid, :mandatory => true # See Guid.role_sequence
|
|
279
235
|
maybe :has_unused_dependency_to_force_table_in_norma
|
|
280
|
-
one_to_one :role_sequence_id, :mandatory => true # See RoleSequenceId.role_sequence
|
|
281
236
|
end
|
|
282
237
|
|
|
283
238
|
class RoleValue
|
|
@@ -292,11 +247,11 @@ module ActiveFacts
|
|
|
292
247
|
end
|
|
293
248
|
|
|
294
249
|
class Shape
|
|
295
|
-
identified_by :
|
|
250
|
+
identified_by :guid
|
|
296
251
|
has_one :diagram, :mandatory => true # See Diagram.all_shape
|
|
252
|
+
one_to_one :guid, :mandatory => true # See Guid.shape
|
|
297
253
|
maybe :is_expanded
|
|
298
254
|
has_one :position # See Position.all_shape
|
|
299
|
-
one_to_one :shape_id, :mandatory => true # See ShapeId.shape
|
|
300
255
|
end
|
|
301
256
|
|
|
302
257
|
class SubsetConstraint < SetConstraint
|
|
@@ -304,15 +259,13 @@ module ActiveFacts
|
|
|
304
259
|
has_one :superset_role_sequence, :class => RoleSequence, :mandatory => true # See RoleSequence.all_subset_constraint_as_superset_role_sequence
|
|
305
260
|
end
|
|
306
261
|
|
|
307
|
-
class Unit
|
|
308
|
-
identified_by :unit_id
|
|
262
|
+
class Unit < Concept
|
|
309
263
|
has_one :coefficient # See Coefficient.all_unit
|
|
310
264
|
has_one :ephemera_url, :class => EphemeraURL # See EphemeraURL.all_unit
|
|
311
265
|
maybe :is_fundamental
|
|
312
266
|
one_to_one :name, :mandatory => true # See Name.unit
|
|
313
267
|
has_one :offset # See Offset.all_unit
|
|
314
268
|
one_to_one :plural_name, :class => Name # See Name.unit_as_plural_name
|
|
315
|
-
one_to_one :unit_id, :mandatory => true # See UnitId.unit
|
|
316
269
|
has_one :vocabulary, :mandatory => true # See Vocabulary.all_unit
|
|
317
270
|
end
|
|
318
271
|
|
|
@@ -389,7 +342,7 @@ module ActiveFacts
|
|
|
389
342
|
|
|
390
343
|
class JoinStep
|
|
391
344
|
identified_by :input_join_role, :output_join_role
|
|
392
|
-
has_one :
|
|
345
|
+
has_one :alternative_set # See AlternativeSet.all_join_step
|
|
393
346
|
has_one :fact_type, :mandatory => true # See FactType.all_join_step
|
|
394
347
|
has_one :input_join_role, :class => JoinRole, :mandatory => true # See JoinRole.all_join_step_as_input_join_role
|
|
395
348
|
maybe :is_anti
|
|
@@ -401,7 +354,7 @@ module ActiveFacts
|
|
|
401
354
|
has_one :context_note, :mandatory => true # See ContextNote.all_model_note_shape
|
|
402
355
|
end
|
|
403
356
|
|
|
404
|
-
class ObjectType
|
|
357
|
+
class ObjectType < Concept
|
|
405
358
|
identified_by :vocabulary, :name
|
|
406
359
|
maybe :is_independent
|
|
407
360
|
has_one :name, :mandatory => true # See Name.all_object_type
|
|
@@ -410,6 +363,7 @@ module ActiveFacts
|
|
|
410
363
|
end
|
|
411
364
|
|
|
412
365
|
class ObjectTypeShape < Shape
|
|
366
|
+
maybe :has_expanded_reference_mode
|
|
413
367
|
has_one :object_type, :mandatory => true # See ObjectType.all_object_type_shape
|
|
414
368
|
end
|
|
415
369
|
|
|
@@ -418,7 +372,7 @@ module ActiveFacts
|
|
|
418
372
|
one_to_one :fact_type_shape, :mandatory => true # See FactTypeShape.objectified_fact_type_name_shape
|
|
419
373
|
end
|
|
420
374
|
|
|
421
|
-
class Population
|
|
375
|
+
class Population < Concept
|
|
422
376
|
identified_by :vocabulary, :name
|
|
423
377
|
has_one :name, :mandatory => true # See Name.all_population
|
|
424
378
|
has_one :vocabulary # See Vocabulary.all_population
|
|
@@ -102,7 +102,7 @@ describe "CQL Symbol table" do
|
|
|
102
102
|
it "should define #{description}" do
|
|
103
103
|
if result
|
|
104
104
|
# Predefine an entity type, some cases use it:
|
|
105
|
-
@constellation.EntityType(@vocabulary.identifying_role_values, "Person")
|
|
105
|
+
@constellation.EntityType(@vocabulary.identifying_role_values, "Person", :guid => :new)
|
|
106
106
|
|
|
107
107
|
player, bound = @symbols.bind(*args)
|
|
108
108
|
player.should_not be_nil
|
data/spec/cqldump_spec.rb
CHANGED
|
@@ -15,8 +15,8 @@ describe "CQL Dumper" do
|
|
|
15
15
|
before :each do
|
|
16
16
|
@constellation = ActiveFacts::API::Constellation.new(ActiveFacts::Metamodel)
|
|
17
17
|
@vocabulary = @constellation.Vocabulary("TestVocab")
|
|
18
|
-
@string_type = @constellation.ValueType(@vocabulary, "String")
|
|
19
|
-
@integer_type = @constellation.ValueType(@vocabulary, "Integer")
|
|
18
|
+
@string_type = @constellation.ValueType(@vocabulary, "String", :guid => :new)
|
|
19
|
+
@integer_type = @constellation.ValueType(@vocabulary, "Integer", :guid => :new)
|
|
20
20
|
@dumper = ActiveFacts::Generate::CQL.new(@constellation)
|
|
21
21
|
end
|
|
22
22
|
|
|
@@ -28,7 +28,7 @@ describe "CQL Dumper" do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should dump a String ValueType" do
|
|
31
|
-
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20)
|
|
31
|
+
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20, :guid => :new)
|
|
32
32
|
vt.supertype = @string_type
|
|
33
33
|
vt.length = 20
|
|
34
34
|
#p vt.class.roles.keys.sort_by{|s| s.to_s}
|
|
@@ -45,7 +45,7 @@ END
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it "should dump an Integer ValueType" do
|
|
48
|
-
vt = @constellation.ValueType(@vocabulary, "Count", :supertype => @integer_type, :length => 32)
|
|
48
|
+
vt = @constellation.ValueType(@vocabulary, "Count", :supertype => @integer_type, :length => 32, :guid => :new)
|
|
49
49
|
cql.should == <<END
|
|
50
50
|
vocabulary TestVocab;
|
|
51
51
|
|
|
@@ -58,8 +58,8 @@ END
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def value_type(name, datatype = "String", length = 0, scale = 0)
|
|
61
|
-
dt = @constellation.ValueType(@vocabulary, datatype)
|
|
62
|
-
vt = @constellation.ValueType(@vocabulary, name, :supertype => dt)
|
|
61
|
+
dt = @constellation.ValueType(@vocabulary, datatype, :guid => :new)
|
|
62
|
+
vt = @constellation.ValueType(@vocabulary, name, :supertype => dt, :guid => :new)
|
|
63
63
|
vt.length = length if length != 0
|
|
64
64
|
vt.scale = scale if scale != 0
|
|
65
65
|
vt
|
|
@@ -68,8 +68,8 @@ END
|
|
|
68
68
|
def one_to_many(one, many, reading)
|
|
69
69
|
# Join them with a fact type:
|
|
70
70
|
ft = @constellation.FactType(:new)
|
|
71
|
-
role0 = @constellation.Role(ft, 0, :object_type => one)
|
|
72
|
-
role1 = @constellation.Role(ft, 1, :object_type => many)
|
|
71
|
+
role0 = @constellation.Role(ft, 0, :object_type => one, :guid => :new)
|
|
72
|
+
role1 = @constellation.Role(ft, 1, :object_type => many, :guid => :new)
|
|
73
73
|
|
|
74
74
|
# Make a role sequence:
|
|
75
75
|
rs = @constellation.RoleSequence(:new)
|
|
@@ -90,8 +90,8 @@ END
|
|
|
90
90
|
def one_to_one(first, second, reading)
|
|
91
91
|
# Join them with a fact type:
|
|
92
92
|
ft = @constellation.FactType(:new)
|
|
93
|
-
role0 = @constellation.Role(ft, 0, :object_type => first)
|
|
94
|
-
role1 = @constellation.Role(ft, 1, :object_type => second)
|
|
93
|
+
role0 = @constellation.Role(ft, 0, :object_type => first, :guid => :new)
|
|
94
|
+
role1 = @constellation.Role(ft, 1, :object_type => second, :guid => :new)
|
|
95
95
|
|
|
96
96
|
# Make a role sequence for the reading
|
|
97
97
|
rs = @constellation.RoleSequence(:new)
|
|
@@ -141,8 +141,8 @@ END
|
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "should dump an named EntityType" do
|
|
144
|
-
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20)
|
|
145
|
-
et = @constellation.EntityType(@vocabulary, "Company")
|
|
144
|
+
vt = @constellation.ValueType(@vocabulary, "Name", :supertype => @string_type, :length => 20, :guid => :new)
|
|
145
|
+
et = @constellation.EntityType(@vocabulary, "Company", :guid => :new)
|
|
146
146
|
|
|
147
147
|
ft = one_to_one(et, vt, "{0} is called {1}")
|
|
148
148
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activefacts
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.16
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activefacts-api
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.9.
|
|
21
|
+
version: 0.9.3
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ~>
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.9.
|
|
29
|
+
version: 0.9.3
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: treetop
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -459,7 +459,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
459
459
|
version: '0'
|
|
460
460
|
segments:
|
|
461
461
|
- 0
|
|
462
|
-
hash:
|
|
462
|
+
hash: 3445837228112835093
|
|
463
463
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
464
464
|
none: false
|
|
465
465
|
requirements:
|