activefacts 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Rakefile +2 -2
- data/bin/afgen +1 -1
- data/bin/cql +118 -27
- data/examples/CQL/Insurance.cql +2 -2
- data/examples/CQL/Metamodel.cql +3 -3
- data/examples/CQL/SchoolActivities.cql +1 -1
- data/examples/CQL/Warehousing.cql +5 -4
- data/lib/activefacts/cql.rb +1 -1
- data/lib/activefacts/cql/Language/English.treetop +2 -1
- data/lib/activefacts/cql/compiler.rb +6 -6
- data/lib/activefacts/cql/compiler/clause.rb +69 -46
- data/lib/activefacts/cql/compiler/constraint.rb +14 -14
- data/lib/activefacts/cql/compiler/entity_type.rb +24 -24
- data/lib/activefacts/cql/compiler/fact.rb +40 -27
- data/lib/activefacts/cql/compiler/fact_type.rb +16 -16
- data/lib/activefacts/cql/compiler/query.rb +12 -12
- data/lib/activefacts/cql/compiler/shared.rb +9 -0
- data/lib/activefacts/cql/compiler/value_type.rb +4 -4
- data/lib/activefacts/cql/parser.rb +9 -9
- data/lib/activefacts/generate/cql.rb +41 -20
- data/lib/activefacts/generate/helpers/oo.rb +33 -70
- data/lib/activefacts/generate/helpers/ordered.rb +61 -87
- data/lib/activefacts/generate/ruby.rb +12 -72
- data/lib/activefacts/generate/transform/surrogate.rb +13 -13
- data/lib/activefacts/input/orm.rb +72 -71
- data/lib/activefacts/persistence/columns.rb +66 -31
- data/lib/activefacts/persistence/foreignkey.rb +6 -6
- data/lib/activefacts/persistence/index.rb +12 -12
- data/lib/activefacts/persistence/object_type.rb +15 -12
- data/lib/activefacts/persistence/reference.rb +20 -18
- data/lib/activefacts/persistence/tables.rb +40 -36
- data/lib/activefacts/support.rb +69 -123
- data/lib/activefacts/version.rb +2 -2
- data/lib/activefacts/vocabulary/extensions.rb +42 -39
- data/lib/activefacts/vocabulary/metamodel.rb +11 -1
- data/lib/activefacts/vocabulary/verbaliser.rb +28 -28
- data/spec/cql/contractions_spec.rb +1 -1
- data/spec/cql/entity_type_spec.rb +1 -1
- data/spec/cql/fact_type_matching_spec.rb +3 -3
- data/spec/cql/role_matching_spec.rb +4 -4
- data/spec/cql/samples_spec.rb +2 -2
- data/spec/cql_cql_spec.rb +1 -1
- data/spec/helpers/array_matcher.rb +1 -1
- data/spec/norma_ruby_sql_spec.rb +2 -2
- data/spec/norma_tables_spec.rb +3 -2
- metadata +47 -68
@@ -6,13 +6,15 @@
|
|
6
6
|
#
|
7
7
|
require 'activefacts/vocabulary'
|
8
8
|
require 'activefacts/generate/helpers/ordered'
|
9
|
+
require 'activefacts/generate/traits/oo'
|
9
10
|
|
10
11
|
module ActiveFacts
|
11
12
|
module Generate
|
13
|
+
|
12
14
|
module Helpers
|
13
15
|
# Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary.
|
14
16
|
class OO < OrderedDumper #:nodoc:
|
15
|
-
def constraints_dump
|
17
|
+
def constraints_dump
|
16
18
|
# Stub, not needed.
|
17
19
|
end
|
18
20
|
|
@@ -23,7 +25,7 @@ module ActiveFacts
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def entity_type_dump(o)
|
26
|
-
|
28
|
+
o.ordered_dumped!
|
27
29
|
pi = o.preferred_identifier
|
28
30
|
|
29
31
|
supers = o.supertypes
|
@@ -34,7 +36,7 @@ module ActiveFacts
|
|
34
36
|
else
|
35
37
|
non_subtype_dump(o, pi)
|
36
38
|
end
|
37
|
-
|
39
|
+
pi.ordered_dumped! if pi
|
38
40
|
end
|
39
41
|
|
40
42
|
# Dump the roles for an object type (excluding the roles of a fact type which is objectified)
|
@@ -45,27 +47,29 @@ module ActiveFacts
|
|
45
47
|
!role.fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType)
|
46
48
|
}.
|
47
49
|
sort_by{|role|
|
48
|
-
|
50
|
+
other_role = role.fact_type.all_role.select{|r2| r2 != role}[0] || role
|
51
|
+
other_role.preferred_role_name(o) + ':' + role.preferred_role_name(other_role.object_type)
|
49
52
|
}.each{|role|
|
50
53
|
role_dump(role)
|
51
54
|
}
|
52
55
|
end
|
53
56
|
|
54
57
|
def role_dump(role)
|
55
|
-
return if role.fact_type.entity_type
|
56
|
-
|
57
58
|
fact_type = role.fact_type
|
58
59
|
if fact_type.all_role.size == 1
|
59
|
-
unary_dump(role, preferred_role_name
|
60
|
+
unary_dump(role, role.preferred_role_name)
|
60
61
|
return
|
61
|
-
|
62
|
+
end
|
63
|
+
return if role.fact_type.entity_type
|
64
|
+
|
65
|
+
if fact_type.all_role.size != 2
|
62
66
|
# Shouldn't come here, except perhaps for an invalid model
|
63
67
|
return # ternaries and higher are always objectified
|
64
68
|
end
|
65
69
|
|
66
70
|
# REVISIT: TypeInheritance
|
67
71
|
if fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance)
|
68
|
-
#
|
72
|
+
# trace "Ignoring role #{role} in #{fact_type}, subtype fact type"
|
69
73
|
# REVISIT: What about secondary subtypes?
|
70
74
|
# REVISIT: What about dumping the relational mapping when using separate tables?
|
71
75
|
return
|
@@ -74,68 +78,31 @@ module ActiveFacts
|
|
74
78
|
return unless role.is_functional
|
75
79
|
|
76
80
|
other_role = fact_type.all_role.select{|r| r != role}[0]
|
77
|
-
other_role_name = preferred_role_name
|
81
|
+
other_role_name = other_role.preferred_role_name
|
78
82
|
other_player = other_role.object_type
|
79
83
|
|
80
84
|
# It's a one_to_one if there's a uniqueness constraint on the other role:
|
81
85
|
one_to_one = other_role.is_functional
|
82
86
|
return if one_to_one &&
|
83
|
-
|
87
|
+
!other_role.object_type.ordered_dumped
|
84
88
|
|
85
89
|
# Find role name:
|
86
|
-
role_method = preferred_role_name
|
90
|
+
role_method = role.preferred_role_name
|
87
91
|
other_role_method = one_to_one ? role_method : "all_"+role_method
|
88
92
|
# puts "---"+role.role_name if role.role_name
|
89
|
-
if other_role_name != other_player.
|
90
|
-
|
93
|
+
if other_role_name != other_player.oo_default_role_name and
|
94
|
+
role_method == role.object_type.oo_default_role_name
|
95
|
+
# debugger
|
91
96
|
other_role_method += "_as_#{other_role_name}"
|
92
97
|
end
|
93
98
|
|
94
99
|
role_name = role_method
|
95
|
-
role_name = nil if role_name == role.object_type.
|
96
|
-
|
97
|
-
binary_dump(role, other_role_name, other_player, role.is_mandatory, one_to_one, nil, role_name, other_role_method)
|
98
|
-
end
|
99
|
-
|
100
|
-
def preferred_role_name(role, is_for = nil, &b)
|
101
|
-
b ||= proc {|names| names.map(&:downcase)*'_' } # Make snake_case by default
|
102
|
-
return b.call([]) if role.fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance)
|
103
|
-
|
104
|
-
if is_for && role.fact_type.entity_type == is_for && role.fact_type.all_role.size == 1
|
105
|
-
return b.call(role.object_type.name.gsub(/[- ]/,'_').split(/_/))
|
106
|
-
end
|
107
|
-
|
108
|
-
# debug "Looking for preferred_role_name of #{describe_fact_type(role.fact_type, role)}"
|
109
|
-
reading = role.fact_type.preferred_reading
|
110
|
-
preferred_role_ref = reading.role_sequence.all_role_ref.detect{|reading_rr|
|
111
|
-
reading_rr.role == role
|
112
|
-
}
|
113
|
-
|
114
|
-
# Unaries are a hack, with only one role for what is effectively a binary:
|
115
|
-
if (role.fact_type.all_role.size == 1)
|
116
|
-
return b.call(
|
117
|
-
( (role.role_name && role.role_name.snakecase) ||
|
118
|
-
reading.text.gsub(/ *\{0\} */,'').gsub(/[- ]/,'_')
|
119
|
-
).split(/_/)
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
# debug "\tleading_adjective=#{(p=preferred_role_ref).leading_adjective}, role_name=#{role.role_name}, role player=#{role.object_type.name}, trailing_adjective=#{p.trailing_adjective}"
|
124
|
-
role_words = []
|
125
|
-
role_name = role.role_name
|
126
|
-
role_name = nil if role_name == ""
|
100
|
+
role_name = nil if role_name == role.object_type.oo_default_role_name
|
127
101
|
|
128
|
-
|
129
|
-
|
130
|
-
role_words << la.gsub(/[- ]/,'_') if la && la != "" and !role.role_name
|
102
|
+
b = role.ruby_role_definition
|
103
|
+
puts b
|
131
104
|
|
132
|
-
|
133
|
-
# REVISIT: Same when trailing_adjective is a suffix of the role_name
|
134
|
-
ta = preferred_role_ref.trailing_adjective
|
135
|
-
role_words << ta.gsub(/[- ]/,'_') if ta && ta != "" and !role_name
|
136
|
-
n = role_words.map{|w| w.gsub(/([a-z])([A-Z]+)/,'\1_\2').downcase}*"_"
|
137
|
-
# debug "\tresult=#{n}"
|
138
|
-
return b.call(n.gsub(' ','_').split(/_/))
|
105
|
+
# binary_dump(role, other_role_name, other_player, role.is_mandatory, one_to_one, nil, role_name, other_role_method)
|
139
106
|
end
|
140
107
|
|
141
108
|
def skip_fact_type(f)
|
@@ -147,19 +114,15 @@ module ActiveFacts
|
|
147
114
|
# An objectified fact type has internal roles that are always "has_one":
|
148
115
|
def fact_roles_dump(fact_type)
|
149
116
|
fact_type.all_role.sort_by{|role|
|
150
|
-
preferred_role_name(
|
117
|
+
role.preferred_role_name(fact_type.entity_type)
|
151
118
|
}.each{|role|
|
152
|
-
role_name = preferred_role_name(
|
153
|
-
one_to_one = role.
|
154
|
-
|
155
|
-
|
156
|
-
pc.max_frequency == 1
|
157
|
-
}
|
158
|
-
}
|
159
|
-
as = role_name != role.object_type.name.gsub(/ /,'_').snakecase ? "_as_#{role_name}" : ""
|
119
|
+
role_name = role.preferred_role_name(fact_type.entity_type)
|
120
|
+
one_to_one = role.is_unique
|
121
|
+
as = role_name != role.object_type.oo_default_role_name ? "_as_#{role_name}" : ""
|
122
|
+
# debugger if as != ''
|
160
123
|
raise "Fact #{fact_type.describe} type is not objectified" unless fact_type.entity_type
|
161
124
|
other_role_method = (one_to_one ? "" : "all_") +
|
162
|
-
fact_type.entity_type.
|
125
|
+
fact_type.entity_type.oo_default_role_name +
|
163
126
|
as
|
164
127
|
binary_dump(role, role_name, role.object_type, true, one_to_one, nil, nil, other_role_method)
|
165
128
|
}
|
@@ -172,7 +135,7 @@ module ActiveFacts
|
|
172
135
|
end
|
173
136
|
|
174
137
|
def append_ring_to_reading(reading, ring)
|
175
|
-
# REVISIT:
|
138
|
+
# REVISIT: trace "Should override append_ring_to_reading"
|
176
139
|
end
|
177
140
|
|
178
141
|
def fact_type_banner
|
@@ -182,15 +145,15 @@ module ActiveFacts
|
|
182
145
|
end
|
183
146
|
|
184
147
|
def constraint_banner
|
185
|
-
#
|
148
|
+
# trace "Should override constraint_banner"
|
186
149
|
end
|
187
150
|
|
188
151
|
def constraint_end
|
189
|
-
#
|
152
|
+
# trace "Should override constraint_end"
|
190
153
|
end
|
191
154
|
|
192
155
|
def constraint_dump(c)
|
193
|
-
#
|
156
|
+
# trace "Should override constraint_dump"
|
194
157
|
end
|
195
158
|
|
196
159
|
end
|
@@ -5,6 +5,8 @@
|
|
5
5
|
# Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
|
6
6
|
#
|
7
7
|
require 'activefacts/api'
|
8
|
+
require 'activefacts/generate/helpers/inject'
|
9
|
+
require 'activefacts/generate/traits/ordered'
|
8
10
|
|
9
11
|
module ActiveFacts
|
10
12
|
module Generate #:nodoc:
|
@@ -30,40 +32,15 @@ module ActiveFacts
|
|
30
32
|
|
31
33
|
def generate(out = $>)
|
32
34
|
@out = out
|
33
|
-
vocabulary_start
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
value_types_dump()
|
40
|
-
entity_types_dump()
|
41
|
-
fact_types_dump()
|
42
|
-
constraints_dump(@constraints_used)
|
35
|
+
vocabulary_start
|
36
|
+
units_dump
|
37
|
+
value_types_dump
|
38
|
+
entity_types_dump
|
39
|
+
fact_types_dump
|
40
|
+
constraints_dump
|
43
41
|
vocabulary_end
|
44
42
|
end
|
45
43
|
|
46
|
-
def build_indices
|
47
|
-
@presence_constraints_by_fact = Hash.new{ |h, k| h[k] = [] }
|
48
|
-
@ring_constraints_by_fact = Hash.new{ |h, k| h[k] = [] }
|
49
|
-
|
50
|
-
@vocabulary.all_constraint.each { |c|
|
51
|
-
case c
|
52
|
-
when ActiveFacts::Metamodel::PresenceConstraint
|
53
|
-
fact_types = c.role_sequence.all_role_ref.map{|rr| rr.role.fact_type}.uniq # All fact types spanned by this constraint
|
54
|
-
if fact_types.size == 1 # There's only one, save it:
|
55
|
-
# debug "Single-fact constraint on #{fact_types[0].concept.guid}: #{c.name}"
|
56
|
-
(@presence_constraints_by_fact[fact_types[0]] ||= []) << c
|
57
|
-
end
|
58
|
-
when ActiveFacts::Metamodel::RingConstraint
|
59
|
-
(@ring_constraints_by_fact[c.role.fact_type] ||= []) << c
|
60
|
-
else
|
61
|
-
# debug "Found unhandled constraint #{c.class} #{c.name}"
|
62
|
-
end
|
63
|
-
}
|
64
|
-
@constraints_used = {}
|
65
|
-
end
|
66
|
-
|
67
44
|
def units_dump
|
68
45
|
done_banner = false
|
69
46
|
units = @vocabulary.all_unit.to_a.sort_by{|u| u.name.gsub(/ /,'')}
|
@@ -115,7 +92,6 @@ module ActiveFacts
|
|
115
92
|
|
116
93
|
def value_types_dump
|
117
94
|
done_banner = false
|
118
|
-
@value_type_dumped = {}
|
119
95
|
@vocabulary.all_object_type.sort_by{|o| o.name.gsub(/ /,'')}.each{|o|
|
120
96
|
next unless o.is_a?(ActiveFacts::Metamodel::ValueType)
|
121
97
|
|
@@ -123,17 +99,18 @@ module ActiveFacts
|
|
123
99
|
done_banner = true
|
124
100
|
|
125
101
|
value_type_chain_dump(o)
|
126
|
-
@object_types_dumped[o] = true
|
102
|
+
# @object_types_dumped[o] = true
|
103
|
+
o.ordered_dumped!
|
127
104
|
}
|
128
105
|
value_type_end if done_banner
|
129
106
|
end
|
130
107
|
|
131
108
|
# Ensure that supertype gets dumped first
|
132
109
|
def value_type_chain_dump(o)
|
133
|
-
return if
|
134
|
-
value_type_chain_dump(o.supertype) if (o.supertype &&
|
110
|
+
return if o.ordered_dumped
|
111
|
+
value_type_chain_dump(o.supertype) if (o.supertype && !o.supertype.ordered_dumped)
|
135
112
|
value_type_fork(o)
|
136
|
-
|
113
|
+
o.ordered_dumped!
|
137
114
|
end
|
138
115
|
|
139
116
|
# Try to dump entity types in order of name, but we need
|
@@ -152,11 +129,11 @@ module ActiveFacts
|
|
152
129
|
count_this_pass = 0
|
153
130
|
skipped_this_pass = 0
|
154
131
|
sorted.each{|o|
|
155
|
-
|
132
|
+
next if o.ordered_dumped # Already done
|
156
133
|
|
157
134
|
# Can we do this yet?
|
158
135
|
if (o != panic and # We don't *have* to do it (panic mode)
|
159
|
-
(p = @precursors[o]) and
|
136
|
+
(p = @precursors[o]) and # There might be...
|
160
137
|
p.size > 0) # precursors - still blocked
|
161
138
|
skipped_this_pass += 1
|
162
139
|
next
|
@@ -188,7 +165,7 @@ module ActiveFacts
|
|
188
165
|
if panic # We were already panicing... what to do now?
|
189
166
|
# This won't happen again unless the above code is changed to decide it can't dump "panic".
|
190
167
|
raise "Unresolvable cycle of forward references: " +
|
191
|
-
(bad = sorted.select{|o| EntityType === o &&
|
168
|
+
(bad = sorted.select{|o| EntityType === o && !o.ordered_dumped}).map{|o| o.name }.inspect +
|
192
169
|
":\n\t" + bad.map{|o|
|
193
170
|
o.name +
|
194
171
|
": " +
|
@@ -198,12 +175,12 @@ module ActiveFacts
|
|
198
175
|
# Find the object that has the most followers and no fwd-ref'd supertypes:
|
199
176
|
# This selection might be better if we allow PI roles to be fwd-ref'd...
|
200
177
|
panic = sorted.
|
201
|
-
select{|o|
|
178
|
+
select{|o| o.ordered_dumped }.
|
202
179
|
sort_by{|o|
|
203
180
|
f = @followers[o] || [];
|
204
|
-
o.supertypes.detect{|s|
|
181
|
+
o.supertypes.detect{|s| !s.ordered_dumped } ? 0 : -f.size
|
205
182
|
}[0]
|
206
|
-
#
|
183
|
+
# trace "Panic mode, selected #{panic.name} next"
|
207
184
|
end
|
208
185
|
end
|
209
186
|
|
@@ -276,7 +253,7 @@ module ActiveFacts
|
|
276
253
|
subtyping = o.all_type_inheritance_as_supertype
|
277
254
|
next a if subtyping.size == 0
|
278
255
|
subtyping.each{|ti|
|
279
|
-
# debug ti.class.roles.verbalise;
|
256
|
+
# debug ti.class.roles.verbalise; trace "all_type_inheritance_as_supertype"; exit
|
280
257
|
s = ti.subtype
|
281
258
|
(precursor[s] ||= []) << o
|
282
259
|
(follower[o] ||= []) << s
|
@@ -299,9 +276,9 @@ module ActiveFacts
|
|
299
276
|
progress = false
|
300
277
|
roles.map(&:fact_type).uniq.select{|fact_type|
|
301
278
|
# The fact type hasn't already been dumped but all its role players have
|
302
|
-
|
279
|
+
!fact_type.ordered_dumped &&
|
303
280
|
!fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) &&
|
304
|
-
!fact_type.all_role.detect{|r|
|
281
|
+
!fact_type.all_role.detect{|r| !r.object_type.ordered_dumped } &&
|
305
282
|
!fact_type.entity_type &&
|
306
283
|
derivation_precursors_complete(fact_type)
|
307
284
|
# REVISIT: A derived fact type must not be dumped before its dependent fact types have
|
@@ -320,43 +297,39 @@ module ActiveFacts
|
|
320
297
|
pr = fact_type.preferred_reading
|
321
298
|
return true unless jr = pr.role_sequence.all_role_ref.to_a[0].play
|
322
299
|
query = jr.variable.query
|
323
|
-
return false if query.all_step.detect{|js|
|
324
|
-
return false if query.all_variable.detect{|jn|
|
300
|
+
return false if query.all_step.detect{|js| !js.fact_type.ordered_dumped }
|
301
|
+
return false if query.all_variable.detect{|jn| !jn.object_type.ordered_dumped }
|
325
302
|
true
|
326
303
|
end
|
327
304
|
|
328
305
|
def skip_fact_type(f)
|
329
306
|
return true if f.is_a?(ActiveFacts::Metamodel::TypeInheritance)
|
330
|
-
return false if f.entity_type &&
|
307
|
+
return false if f.entity_type && !f.entity_type.ordered_dumped
|
331
308
|
|
332
309
|
# REVISIT: There might be constraints we have to merge into the nested entity or subtype.
|
333
310
|
# These will come up as un-handled constraints:
|
334
311
|
# Dump this fact type only if it contains a presence constraint we've missed:
|
335
312
|
pcs = @presence_constraints_by_fact[f]
|
336
|
-
pcs && pcs.size > 0 && !pcs.detect{|c|
|
313
|
+
pcs && pcs.size > 0 && !pcs.detect{|c| !c.ordered_dumped }
|
337
314
|
end
|
338
315
|
|
339
316
|
# Dump one fact type.
|
340
317
|
# Include as many as possible internal constraints in the fact type readings.
|
341
318
|
def fact_type_dump_with_dependents(fact_type)
|
342
|
-
|
343
|
-
# debug "Trying to dump FT again" if @fact_types_dumped[fact_type]
|
319
|
+
fact_type.ordered_dumped!
|
344
320
|
return if skip_fact_type(fact_type)
|
345
321
|
|
346
322
|
if (et = fact_type.entity_type) &&
|
347
323
|
(pi = et.preferred_identifier) &&
|
348
324
|
pi.role_sequence.all_role_ref.detect{|rr| rr.role.fact_type != fact_type }
|
349
|
-
#
|
325
|
+
# trace "Dumping objectified FT #{et.name} as an entity, non-fact PI"
|
350
326
|
entity_type_dump(et)
|
351
327
|
released_fact_types_dump(et)
|
352
328
|
return
|
353
329
|
end
|
354
330
|
|
355
|
-
|
356
|
-
|
357
|
-
# debug "for fact type #{fact_type.to_s}, considering\n\t#{fact_constraints.map(&:to_s)*",\n\t"}"
|
358
|
-
# debug "#{fact_type.name} has readings:\n\t#{fact_type.readings.map(&:name)*"\n\t"}"
|
359
|
-
# debug "Dumping #{fact_type.concept.guid} as a fact type"
|
331
|
+
# trace "#{fact_type.name} has readings:\n\t#{fact_type.readings.map(&:name)*"\n\t"}"
|
332
|
+
# trace "Dumping #{fact_type.concept.guid} as a fact type"
|
360
333
|
|
361
334
|
# Fact types that aren't nested have no names
|
362
335
|
name = fact_type.entity_type && fact_type.entity_type.name
|
@@ -365,8 +338,9 @@ module ActiveFacts
|
|
365
338
|
|
366
339
|
# REVISIT: Go through the residual constraints and re-process appropriate readings to show them
|
367
340
|
|
368
|
-
|
369
|
-
|
341
|
+
#CJH: Necessary?
|
342
|
+
fact_type.ordered_dumped!
|
343
|
+
fact_type.entity_type.ordered_dumped! if fact_type.entity_type
|
370
344
|
end
|
371
345
|
|
372
346
|
# Dump fact types.
|
@@ -383,7 +357,7 @@ module ActiveFacts
|
|
383
357
|
fact_type = fact_collection[fact_id] and
|
384
358
|
!fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) and
|
385
359
|
!fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) and
|
386
|
-
|
360
|
+
!fact_type.ordered_dumped and
|
387
361
|
!skip_fact_type(fact_type) and
|
388
362
|
!fact_type.all_role.detect{|r| r.object_type.is_a?(ActiveFacts::Metamodel::EntityType) }
|
389
363
|
}.sort_by{|fact_id|
|
@@ -404,18 +378,14 @@ module ActiveFacts
|
|
404
378
|
}.sort_by{|fact_type|
|
405
379
|
fact_type_key(fact_type)
|
406
380
|
}.each{|fact_type|
|
407
|
-
next if
|
408
|
-
#
|
381
|
+
next if fact_type.ordered_dumped
|
382
|
+
# trace "Not dumped #{fact_type.verbalise}(#{fact_type.all_role.map{|r| r.object_type.name}*", "})"
|
409
383
|
fact_type_banner unless done_banner
|
410
384
|
done_banner = true
|
411
385
|
fact_type_dump_with_dependents(fact_type)
|
412
386
|
}
|
413
387
|
|
414
388
|
fact_type_end if done_banner
|
415
|
-
# unused = constraints - @constraints_used.keys
|
416
|
-
# debug "residual constraints are\n\t#{unused.map(&:to_s)*",\n\t"}"
|
417
|
-
|
418
|
-
@constraints_used
|
419
389
|
end
|
420
390
|
|
421
391
|
def fact_instances_dump
|
@@ -423,7 +393,7 @@ module ActiveFacts
|
|
423
393
|
# Dump the instances:
|
424
394
|
f.facts.each{|i|
|
425
395
|
raise "REVISIT: Not dumping fact instances"
|
426
|
-
|
396
|
+
trace "\t\t"+i.to_s
|
427
397
|
}
|
428
398
|
}
|
429
399
|
end
|
@@ -498,9 +468,13 @@ module ActiveFacts
|
|
498
468
|
end
|
499
469
|
end
|
500
470
|
|
501
|
-
def constraints_dump
|
471
|
+
def constraints_dump
|
502
472
|
heading = false
|
503
|
-
@vocabulary.
|
473
|
+
@vocabulary.
|
474
|
+
all_constraint.
|
475
|
+
reject{|c| c.ordered_dumped}.
|
476
|
+
sort_by{ |c| constraint_sort_key(c) }.
|
477
|
+
each do |c|
|
504
478
|
# Skip some PresenceConstraints:
|
505
479
|
if c.is_a?(ActiveFacts::Metamodel::PresenceConstraint)
|
506
480
|
# Skip uniqueness constraints that cover all roles of a fact type, they're implicit
|
@@ -528,12 +502,12 @@ module ActiveFacts
|
|
528
502
|
constraint_end if heading
|
529
503
|
end
|
530
504
|
|
531
|
-
def vocabulary_start
|
532
|
-
|
505
|
+
def vocabulary_start
|
506
|
+
trace "Should override vocabulary_start"
|
533
507
|
end
|
534
508
|
|
535
509
|
def vocabulary_end
|
536
|
-
|
510
|
+
trace "Should override vocabulary_end"
|
537
511
|
end
|
538
512
|
|
539
513
|
def units_banner
|
@@ -546,63 +520,63 @@ module ActiveFacts
|
|
546
520
|
end
|
547
521
|
|
548
522
|
def value_type_banner
|
549
|
-
|
523
|
+
trace "Should override value_type_banner"
|
550
524
|
end
|
551
525
|
|
552
526
|
def value_type_end
|
553
|
-
|
527
|
+
trace "Should override value_type_end"
|
554
528
|
end
|
555
529
|
|
556
530
|
def data_type_dump(o)
|
557
|
-
|
531
|
+
trace "Should override data_type_dump"
|
558
532
|
end
|
559
533
|
|
560
534
|
def value_type_dump(o, super_type_name, facets)
|
561
|
-
|
535
|
+
trace "Should override value_type_dump"
|
562
536
|
end
|
563
537
|
|
564
538
|
def entity_type_banner
|
565
|
-
|
539
|
+
trace "Should override entity_type_banner"
|
566
540
|
end
|
567
541
|
|
568
542
|
def entity_type_group_end
|
569
|
-
|
543
|
+
trace "Should override entity_type_group_end"
|
570
544
|
end
|
571
545
|
|
572
546
|
def non_subtype_dump(o, pi)
|
573
|
-
|
547
|
+
trace "Should override non_subtype_dump"
|
574
548
|
end
|
575
549
|
|
576
550
|
def subtype_dump(o, supertypes, pi = nil)
|
577
|
-
|
551
|
+
trace "Should override subtype_dump"
|
578
552
|
end
|
579
553
|
|
580
554
|
def append_ring_to_reading(reading, ring)
|
581
|
-
|
555
|
+
trace "Should override append_ring_to_reading"
|
582
556
|
end
|
583
557
|
|
584
558
|
def fact_type_banner
|
585
|
-
|
559
|
+
trace "Should override fact_type_banner"
|
586
560
|
end
|
587
561
|
|
588
562
|
def fact_type_end
|
589
|
-
|
563
|
+
trace "Should override fact_type_end"
|
590
564
|
end
|
591
565
|
|
592
566
|
def fact_type_dump(fact_type, name)
|
593
|
-
|
567
|
+
trace "Should override fact_type_dump"
|
594
568
|
end
|
595
569
|
|
596
570
|
def constraint_banner
|
597
|
-
|
571
|
+
trace "Should override constraint_banner"
|
598
572
|
end
|
599
573
|
|
600
574
|
def constraint_end
|
601
|
-
|
575
|
+
trace "Should override constraint_end"
|
602
576
|
end
|
603
577
|
|
604
578
|
def constraint_dump(c)
|
605
|
-
|
579
|
+
trace "Should override constraint_dump"
|
606
580
|
end
|
607
581
|
|
608
582
|
end
|