activefacts-generators 1.8.3 → 1.9.0

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.
@@ -82,8 +82,8 @@ module ActiveFacts
82
82
  /^Signed ?Small ?Integer$/,
83
83
  /^Unsigned ?Tiny ?Integer$/
84
84
  s = case
85
- when length == nil
86
- 'int'
85
+ when length == nil
86
+ 'int'
87
87
  when length <= 8
88
88
  'tinyint'
89
89
  when length <= 16
@@ -168,7 +168,7 @@ module ActiveFacts
168
168
  "(" + length.to_s + (scale ? ", #{scale}" : "") + ")"
169
169
  end
170
170
  }"
171
- # Emit IDENTITY for auto-assigned columns, unless it's assigned at assert:
171
+ # Emit IDENTITY for auto-assigned columns, unless it's assigned at assert:
172
172
  identity = column == identity_column && column.references[-1].to.transaction_phase != 'assert' ? " IDENTITY" : ""
173
173
  null = (column.is_mandatory ? "NOT " : "") + "NULL"
174
174
  check = check_clause(name, constraints)
@@ -21,47 +21,47 @@ module ActiveFacts
21
21
 
22
22
  public
23
23
  def generate(out = $>)
24
- constellation = @vocabulary.constellation
25
- object_types = constellation.ObjectType.values
26
- fact_types = constellation.FactType.values
24
+ constellation = @vocabulary.constellation
25
+ object_types = constellation.ObjectType.values
26
+ fact_types = constellation.FactType.values
27
27
 
28
- # All metamodel object types:
29
- object_count = 0
30
- populated_object_type_count = 0
31
- fact_types_processed = {}
32
- fact_count = 0
33
- role_played_count = 0
34
- constellation.vocabulary.object_type.map do |object_type_name, object_type|
35
- objects = constellation.send(object_type_name)
36
- next unless objects.size > 0
37
- puts "\t#{object_type_name}: #{objects.size} instances (which play #{object_type.all_role.size} roles)"
38
- populated_object_type_count += 1
39
- object_count += objects.size
28
+ # All metamodel object types:
29
+ object_count = 0
30
+ populated_object_type_count = 0
31
+ fact_types_processed = {}
32
+ fact_count = 0
33
+ role_played_count = 0
34
+ constellation.vocabulary.object_type.map do |object_type_name, object_type|
35
+ objects = constellation.send(object_type_name)
36
+ next unless objects.size > 0
37
+ puts "\t#{object_type_name}: #{objects.size} instances (which play #{object_type.all_role.size} roles)"
38
+ populated_object_type_count += 1
39
+ object_count += objects.size
40
40
 
41
- #puts "#{object_type_name} has #{object_type.all_role.size} roles"
42
- object_type.all_role.each do |name, role|
43
- next unless role.unique
44
- next if fact_types_processed[role.fact_type]
45
- next if role.fact_type.is_a?(ActiveFacts::API::TypeInheritanceFactType)
46
- role_population_count =
47
- objects.values.inject(0) do |count, object|
48
- count += 1 if object.send(role.name) != nil
49
- count
50
- end
51
- puts "\t\t#{object_type_name}.#{role.name} has #{role_population_count} instances" if role_population_count > 0
52
- fact_count += role_population_count
53
- role_played_count += role_population_count*role.fact_type.all_role.size
41
+ #puts "#{object_type_name} has #{object_type.all_role.size} roles"
42
+ object_type.all_role.each do |name, role|
43
+ next unless role.unique
44
+ next if fact_types_processed[role.fact_type]
45
+ next if role.fact_type.is_a?(ActiveFacts::API::TypeInheritanceFactType)
46
+ role_population_count =
47
+ objects.values.inject(0) do |count, object|
48
+ count += 1 if object.send(role.name) != nil
49
+ count
50
+ end
51
+ puts "\t\t#{object_type_name}.#{role.name} has #{role_population_count} instances" if role_population_count > 0
52
+ fact_count += role_population_count
53
+ role_played_count += role_population_count*role.fact_type.all_role.size
54
54
 
55
- fact_types_processed[role.fact_type] = true
56
- end
55
+ fact_types_processed[role.fact_type] = true
56
+ end
57
57
 
58
- end
59
- puts "#{@vocabulary.name} has"
60
- puts "\t#{object_types.size} object types"
61
- puts "\t#{fact_types.size} fact types"
62
- puts "\tcompiles to #{object_count} objects in total, of #{populated_object_type_count} metamodel types"
63
- puts "\tcompiles to #{fact_count} facts in total, of #{fact_types_processed.size} metamodel fact types"
64
- puts "\tcompiles to #{role_played_count} role instances in total"
58
+ end
59
+ puts "#{@vocabulary.name} has"
60
+ puts "\t#{object_types.size} object types"
61
+ puts "\t#{fact_types.size} fact types"
62
+ puts "\tcompiles to #{object_count} objects in total, of #{populated_object_type_count} metamodel types"
63
+ puts "\tcompiles to #{fact_count} facts in total, of #{fact_types_processed.size} metamodel fact types"
64
+ puts "\tcompiles to #{role_played_count} role instances in total"
65
65
  end
66
66
  end
67
67
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # ActiveFacts Schema Transform
3
- # Transform a loaded ActiveFacts vocabulary to suit ActiveRecord
2
+ # ActiveFacts Schema Transform
3
+ # Transform a loaded ActiveFacts vocabulary to suit ActiveRecord
4
4
  #
5
5
  # Copyright (c) 2009 Clifford Heath. Read the LICENSE file.
6
6
  #
@@ -12,230 +12,230 @@ module ActiveFacts
12
12
 
13
13
  module ObjectType
14
14
 
15
- def dv_add_surrogate type_name = 'Auto Counter', suffix = 'ID'
16
- # Find or assert the surrogate value type
17
- auto_counter = vocabulary.valid_value_type_name(type_name) ||
18
- constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => :new)
19
-
20
- # Create a subtype to identify this entity type:
21
- vt_name = self.name + ' '+suffix
22
- my_id = @vocabulary.valid_value_type_name(vt_name) ||
23
- constellation.ValueType(:vocabulary => vocabulary, :name => vt_name, :concept => :new, :supertype => auto_counter)
24
-
25
- # Create a fact type
26
- identifying_fact_type = constellation.FactType(:concept => :new)
27
- my_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 0, :object_type => self)
28
- self.injected_surrogate_role = my_role
29
- id_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 1, :object_type => my_id)
30
-
31
- # Create a reading (which needs a RoleSequence)
32
- reading = constellation.Reading(
33
- :fact_type => identifying_fact_type,
34
- :ordinal => 0,
35
- :role_sequence => [:new],
36
- :text => "{0} has {1}"
37
- )
38
- constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 0, :role => my_role)
39
- constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 1, :role => id_role)
40
-
41
- # Create two uniqueness constraints for the one-to-one. Each needs a RoleSequence (two RoleRefs)
42
- one_id = constellation.PresenceConstraint(
43
- :concept => :new,
44
- :vocabulary => vocabulary,
45
- :name => self.name+'HasOne'+suffix,
46
- :role_sequence => [:new],
47
- :is_mandatory => true,
48
- :min_frequency => 1,
49
- :max_frequency => 1,
50
- :is_preferred_identifier => false
51
- )
52
- @constellation.RoleRef(:role_sequence => one_id.role_sequence, :ordinal => 0, :role => my_role)
53
-
54
- one_me = constellation.PresenceConstraint(
55
- :concept => :new,
56
- :vocabulary => vocabulary,
57
- :name => self.name+suffix+'IsOfOne'+self.name,
58
- :role_sequence => [:new],
59
- :is_mandatory => false,
60
- :min_frequency => 0,
61
- :max_frequency => 1,
62
- :is_preferred_identifier => true
63
- )
64
- @constellation.RoleRef(:role_sequence => one_me.role_sequence, :ordinal => 0, :role => id_role)
65
- end
15
+ def dv_add_surrogate type_name = 'Auto Counter', suffix = 'ID'
16
+ # Find or assert the surrogate value type
17
+ auto_counter = vocabulary.valid_value_type_name(type_name) ||
18
+ constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => :new)
19
+
20
+ # Create a subtype to identify this entity type:
21
+ vt_name = self.name + ' '+suffix
22
+ my_id = @vocabulary.valid_value_type_name(vt_name) ||
23
+ constellation.ValueType(:vocabulary => vocabulary, :name => vt_name, :concept => :new, :supertype => auto_counter)
24
+
25
+ # Create a fact type
26
+ identifying_fact_type = constellation.FactType(:concept => :new)
27
+ my_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 0, :object_type => self)
28
+ self.injected_surrogate_role = my_role
29
+ id_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 1, :object_type => my_id)
30
+
31
+ # Create a reading (which needs a RoleSequence)
32
+ reading = constellation.Reading(
33
+ :fact_type => identifying_fact_type,
34
+ :ordinal => 0,
35
+ :role_sequence => [:new],
36
+ :text => "{0} has {1}"
37
+ )
38
+ constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 0, :role => my_role)
39
+ constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 1, :role => id_role)
40
+
41
+ # Create two uniqueness constraints for the one-to-one. Each needs a RoleSequence (two RoleRefs)
42
+ one_id = constellation.PresenceConstraint(
43
+ :concept => :new,
44
+ :vocabulary => vocabulary,
45
+ :name => self.name+'HasOne'+suffix,
46
+ :role_sequence => [:new],
47
+ :is_mandatory => true,
48
+ :min_frequency => 1,
49
+ :max_frequency => 1,
50
+ :is_preferred_identifier => false
51
+ )
52
+ @constellation.RoleRef(:role_sequence => one_id.role_sequence, :ordinal => 0, :role => my_role)
53
+
54
+ one_me = constellation.PresenceConstraint(
55
+ :concept => :new,
56
+ :vocabulary => vocabulary,
57
+ :name => self.name+suffix+'IsOfOne'+self.name,
58
+ :role_sequence => [:new],
59
+ :is_mandatory => false,
60
+ :min_frequency => 0,
61
+ :max_frequency => 1,
62
+ :is_preferred_identifier => true
63
+ )
64
+ @constellation.RoleRef(:role_sequence => one_me.role_sequence, :ordinal => 0, :role => id_role)
65
+ end
66
66
  end
67
67
 
68
68
  module ValueType
69
- def dv_needs_surrogate
70
- !is_auto_assigned
71
- end
72
-
73
- def dv_inject_surrogate
74
- trace :transform_surrogate, "Adding surrogate ID to Value Type #{name}"
75
- add_surrogate('Auto Counter', 'ID')
76
- end
69
+ def dv_needs_surrogate
70
+ !is_auto_assigned
71
+ end
72
+
73
+ def dv_inject_surrogate
74
+ trace :transform_surrogate, "Adding surrogate ID to Value Type #{name}"
75
+ add_surrogate('Auto Counter', 'ID')
76
+ end
77
77
  end
78
78
 
79
79
  module EntityType
80
- def dv_identifying_refs_from
81
- pi = preferred_identifier
82
- rrs = pi.role_sequence.all_role_ref
83
-
84
- # REVISIT: This is actually a ref to us, not from
85
- # if absorbed_via
86
- # return [absorbed_via]
87
- # end
88
-
89
- rrs.map do |rr|
90
- r = references_from.detect{|ref| rr.role == ref.to_role }
91
- unless r
92
- debugger
93
- raise "failed to find #{name} identifying reference for #{rr.role.object_type.name} in #{references_from.inspect}"
94
- end
95
- r
96
- end
97
- end
98
-
99
- def dv_needs_surrogate
100
-
101
- # A recursive proc to replace any reference to an Entity Type by its identifying references:
102
- trace :transform_surrogate_expansion, "Expanding key for #{name}"
103
- substitute_identifying_refs = proc do |object|
104
- if ref = object.absorbed_via
105
- # This shouldn't be necessary, but see the absorbed_via comment above.
106
- absorbed_into = ref.from
107
- trace :transform_surrogate_expansion, "recursing to handle absorption of #{object.name} into #{absorbed_into.name}"
108
- [substitute_identifying_refs.call(absorbed_into)]
109
- else
110
- irf = object.dv_identifying_refs_from
111
- trace :transform_surrogate_expansion, "Iterating for #{object.name} over #{irf.inspect}" do
112
- irf.each_with_index do |ref, i|
113
- next if ref.is_unary
114
- next if ref.to_role.object_type.kind_of?(ActiveFacts::Metamodel::ValueType)
115
- recurse_to = ref.to_role.object_type
116
-
117
- trace :transform_surrogate_expansion, "#{i}: recursing to expand #{recurse_to.name} key in #{ref}" do
118
- irf[i] = substitute_identifying_refs.call(recurse_to)
119
- end
120
- end
121
- end
122
- irf
123
- end
124
- end
125
- irf = substitute_identifying_refs.call(self)
126
-
127
- trace :transform_surrogate, "Does #{name} need a surrogate? it's identified by #{irf.inspect}" do
128
-
129
- pk_fks = dv_identifying_refs_from.map do |ref|
130
- ref.to && ref.to.is_table ? ref.to : nil
131
- end
132
-
133
- irf.flatten!
134
-
135
- # Multi-part identifiers are only allowed if:
136
- # * each part is a foreign key (i.e. it's a join table),
137
- # * there are no other columns (that might require updating) and
138
- # * the object is not the target of a foreign key:
139
- if irf.size >= 2
140
- if pk_fks.include?(nil)
141
- trace :transform_surrogate, "#{self.name} needs a surrogate because its multi-part key contains a non-table"
142
- return true
143
- elsif references_to.size != 0
144
- trace :transform_surrogate, "#{self.name} is a join table between #{pk_fks.map(&:name).inspect} but is also an FK target"
145
- return true
146
- elsif (references_from-dv_identifying_refs_from).size > 0
147
- # There are other attributes to worry about
148
- return true
149
- else
150
- trace :transform_surrogate, "#{self.name} is a join table between #{pk_fks.map(&:name).inspect}"
151
- return false
152
- end
153
- return true
154
- end
155
-
156
- # Single-part key. It must be an Auto Counter, or we will add a surrogate
157
-
158
- identifying_type = irf[0].to
159
- if identifying_type.dv_needs_surrogate
160
- trace :transform_surrogate, "#{self.name} needs a surrogate because #{irf[0].to.name} is not an AutoCounter, but #{identifying_type.supertypes_transitive.map(&:name).inspect}"
161
- return true
162
- end
163
-
164
- false
165
- end
166
- end
167
-
168
- def dv_inject_surrogate
169
- trace :transform_surrogate, "Injecting a surrogate key into #{self.name}"
170
-
171
- # Disable the preferred identifier:
172
- pi = preferred_identifier
173
- trace :transform_surrogate, "pi for #{name} was '#{pi.describe}'"
174
- pi.is_preferred_identifier = false
175
- @preferred_identifier = nil # Kill the cache
176
-
177
- dv_add_surrogate
178
-
179
- trace :transform_surrogate, "pi for #{name} is now '#{preferred_identifier.describe}'"
180
- end
181
-
182
- def dv_add_surrogate type_name = 'Auto Counter', suffix = 'ID'
183
- # Find or assert the surrogate value type
184
- auto_counter = vocabulary.valid_value_type_name(type_name) ||
185
- constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => :new)
186
-
187
- # Create a subtype to identify this entity type:
188
- vt_name = self.name + ' '+suffix
189
- my_id = @vocabulary.valid_value_type_name(vt_name) ||
190
- constellation.ValueType(:vocabulary => vocabulary, :name => vt_name, :concept => :new, :supertype => auto_counter)
191
-
192
- # Create a fact type
193
- identifying_fact_type = constellation.FactType(:concept => :new)
194
- my_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 0, :object_type => self)
195
- @injected_surrogate_role = my_role
196
- id_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 1, :object_type => my_id)
197
-
198
- # Create a reading (which needs a RoleSequence)
199
- reading = constellation.Reading(
200
- :fact_type => identifying_fact_type,
201
- :ordinal => 0,
202
- :role_sequence => [:new],
203
- :text => "{0} has {1}"
204
- )
205
- constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 0, :role => my_role)
206
- constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 1, :role => id_role)
207
-
208
- # Create two uniqueness constraints for the one-to-one. Each needs a RoleSequence (two RoleRefs)
209
- one_id = constellation.PresenceConstraint(
210
- :concept => :new,
211
- :vocabulary => vocabulary,
212
- :name => self.name+'HasOne'+suffix,
213
- :role_sequence => [:new],
214
- :is_mandatory => true,
215
- :min_frequency => 1,
216
- :max_frequency => 1,
217
- :is_preferred_identifier => false
218
- )
219
- @constellation.RoleRef(:role_sequence => one_id.role_sequence, :ordinal => 0, :role => my_role)
220
-
221
- one_me = constellation.PresenceConstraint(
222
- :concept => :new,
223
- :vocabulary => vocabulary,
224
- :name => self.name+suffix+'IsOfOne'+self.name,
225
- :role_sequence => [:new],
226
- :is_mandatory => false,
227
- :min_frequency => 0,
228
- :max_frequency => 1,
229
- :is_preferred_identifier => true
230
- )
231
- @constellation.RoleRef(:role_sequence => one_me.role_sequence, :ordinal => 0, :role => id_role)
232
-
233
- return my_id
234
- end
80
+ def dv_identifying_refs_from
81
+ pi = preferred_identifier
82
+ rrs = pi.role_sequence.all_role_ref
83
+
84
+ # REVISIT: This is actually a ref to us, not from
85
+ # if absorbed_via
86
+ # return [absorbed_via]
87
+ # end
88
+
89
+ rrs.map do |rr|
90
+ r = references_from.detect{|ref| rr.role == ref.to_role }
91
+ unless r
92
+ debugger
93
+ raise "failed to find #{name} identifying reference for #{rr.role.object_type.name} in #{references_from.inspect}"
94
+ end
95
+ r
96
+ end
97
+ end
98
+
99
+ def dv_needs_surrogate
100
+
101
+ # A recursive proc to replace any reference to an Entity Type by its identifying references:
102
+ trace :transform_surrogate_expansion, "Expanding key for #{name}"
103
+ substitute_identifying_refs = proc do |object|
104
+ if ref = object.absorbed_via
105
+ # This shouldn't be necessary, but see the absorbed_via comment above.
106
+ absorbed_into = ref.from
107
+ trace :transform_surrogate_expansion, "recursing to handle absorption of #{object.name} into #{absorbed_into.name}"
108
+ [substitute_identifying_refs.call(absorbed_into)]
109
+ else
110
+ irf = object.dv_identifying_refs_from
111
+ trace :transform_surrogate_expansion, "Iterating for #{object.name} over #{irf.inspect}" do
112
+ irf.each_with_index do |ref, i|
113
+ next if ref.is_unary
114
+ next if ref.to_role.object_type.kind_of?(ActiveFacts::Metamodel::ValueType)
115
+ recurse_to = ref.to_role.object_type
116
+
117
+ trace :transform_surrogate_expansion, "#{i}: recursing to expand #{recurse_to.name} key in #{ref}" do
118
+ irf[i] = substitute_identifying_refs.call(recurse_to)
119
+ end
120
+ end
121
+ end
122
+ irf
123
+ end
124
+ end
125
+ irf = substitute_identifying_refs.call(self)
126
+
127
+ trace :transform_surrogate, "Does #{name} need a surrogate? it's identified by #{irf.inspect}" do
128
+
129
+ pk_fks = dv_identifying_refs_from.map do |ref|
130
+ ref.to && ref.to.is_table ? ref.to : nil
131
+ end
132
+
133
+ irf.flatten!
134
+
135
+ # Multi-part identifiers are only allowed if:
136
+ # * each part is a foreign key (i.e. it's a join table),
137
+ # * there are no other columns (that might require updating) and
138
+ # * the object is not the target of a foreign key:
139
+ if irf.size >= 2
140
+ if pk_fks.include?(nil)
141
+ trace :transform_surrogate, "#{self.name} needs a surrogate because its multi-part key contains a non-table"
142
+ return true
143
+ elsif references_to.size != 0
144
+ trace :transform_surrogate, "#{self.name} is a join table between #{pk_fks.map(&:name).inspect} but is also an FK target"
145
+ return true
146
+ elsif (references_from-dv_identifying_refs_from).size > 0
147
+ # There are other attributes to worry about
148
+ return true
149
+ else
150
+ trace :transform_surrogate, "#{self.name} is a join table between #{pk_fks.map(&:name).inspect}"
151
+ return false
152
+ end
153
+ return true
154
+ end
155
+
156
+ # Single-part key. It must be an Auto Counter, or we will add a surrogate
157
+
158
+ identifying_type = irf[0].to
159
+ if identifying_type.dv_needs_surrogate
160
+ trace :transform_surrogate, "#{self.name} needs a surrogate because #{irf[0].to.name} is not an AutoCounter, but #{identifying_type.supertypes_transitive.map(&:name).inspect}"
161
+ return true
162
+ end
163
+
164
+ false
165
+ end
166
+ end
167
+
168
+ def dv_inject_surrogate
169
+ trace :transform_surrogate, "Injecting a surrogate key into #{self.name}"
170
+
171
+ # Disable the preferred identifier:
172
+ pi = preferred_identifier
173
+ trace :transform_surrogate, "pi for #{name} was '#{pi.describe}'"
174
+ pi.is_preferred_identifier = false
175
+ @preferred_identifier = nil # Kill the cache
176
+
177
+ dv_add_surrogate
178
+
179
+ trace :transform_surrogate, "pi for #{name} is now '#{preferred_identifier.describe}'"
180
+ end
181
+
182
+ def dv_add_surrogate type_name = 'Auto Counter', suffix = 'ID'
183
+ # Find or assert the surrogate value type
184
+ auto_counter = vocabulary.valid_value_type_name(type_name) ||
185
+ constellation.ValueType(:vocabulary => vocabulary, :name => type_name, :concept => :new)
186
+
187
+ # Create a subtype to identify this entity type:
188
+ vt_name = self.name + ' '+suffix
189
+ my_id = @vocabulary.valid_value_type_name(vt_name) ||
190
+ constellation.ValueType(:vocabulary => vocabulary, :name => vt_name, :concept => :new, :supertype => auto_counter)
191
+
192
+ # Create a fact type
193
+ identifying_fact_type = constellation.FactType(:concept => :new)
194
+ my_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 0, :object_type => self)
195
+ @injected_surrogate_role = my_role
196
+ id_role = constellation.Role(:concept => :new, :fact_type => identifying_fact_type, :ordinal => 1, :object_type => my_id)
197
+
198
+ # Create a reading (which needs a RoleSequence)
199
+ reading = constellation.Reading(
200
+ :fact_type => identifying_fact_type,
201
+ :ordinal => 0,
202
+ :role_sequence => [:new],
203
+ :text => "{0} has {1}"
204
+ )
205
+ constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 0, :role => my_role)
206
+ constellation.RoleRef(:role_sequence => reading.role_sequence, :ordinal => 1, :role => id_role)
207
+
208
+ # Create two uniqueness constraints for the one-to-one. Each needs a RoleSequence (two RoleRefs)
209
+ one_id = constellation.PresenceConstraint(
210
+ :concept => :new,
211
+ :vocabulary => vocabulary,
212
+ :name => self.name+'HasOne'+suffix,
213
+ :role_sequence => [:new],
214
+ :is_mandatory => true,
215
+ :min_frequency => 1,
216
+ :max_frequency => 1,
217
+ :is_preferred_identifier => false
218
+ )
219
+ @constellation.RoleRef(:role_sequence => one_id.role_sequence, :ordinal => 0, :role => my_role)
220
+
221
+ one_me = constellation.PresenceConstraint(
222
+ :concept => :new,
223
+ :vocabulary => vocabulary,
224
+ :name => self.name+suffix+'IsOfOne'+self.name,
225
+ :role_sequence => [:new],
226
+ :is_mandatory => false,
227
+ :min_frequency => 0,
228
+ :max_frequency => 1,
229
+ :is_preferred_identifier => true
230
+ )
231
+ @constellation.RoleRef(:role_sequence => one_me.role_sequence, :ordinal => 0, :role => id_role)
232
+
233
+ return my_id
234
+ end
235
235
 
236
236
  end
237
237
 
238
- include ActiveFacts::TraitInjector # Must be last in this module, after all submodules have been defined
238
+ include ActiveFacts::TraitInjector # Must be last in this module, after all submodules have been defined
239
239
  end
240
240
  end
241
241
  end