Class: ActiveFacts::Generators::Helpers::OrderedDumper
- Inherits:
-
Object
- Object
- ActiveFacts::Generators::Helpers::OrderedDumper
- Defined in:
- lib/activefacts/generators/helpers/ordered.rb
Overview
:nodoc:
Instance Method Summary collapse
- #append_ring_to_reading(reading, ring) ⇒ Object
-
#build_entity_dependencies ⇒ Object
This returns an array of two hash tables each keyed by an EntityType.
- #constraint_banner ⇒ Object
- #constraint_dump(c) ⇒ Object
- #constraint_end ⇒ Object
- #constraint_sort_key(c) ⇒ Object
- #constraints_dump ⇒ Object
- #data_type_dump(o) ⇒ Object
- #derivation_precursors_complete(fact_type) ⇒ Object
- #describe_fact_type(fact_type, highlight = nil) ⇒ Object
- #describe_role_sequence(role_sequence) ⇒ Object
- #describe_roles(roles, highlight = nil) ⇒ Object
- #entity_type_banner ⇒ Object
- #entity_type_group_end ⇒ Object
-
#entity_types_dump ⇒ Object
Try to dump entity types in order of name, but we need to dump ETs before they’re referenced in preferred ids if possible (it’s not always, there may be loops!).
- #fact_instances_dump ⇒ Object
- #fact_type_banner ⇒ Object
- #fact_type_dump(fact_type, name) ⇒ Object
-
#fact_type_dump_with_dependents(fact_type) ⇒ Object
Dump one fact type.
- #fact_type_end ⇒ Object
-
#fact_type_key(fact_type) ⇒ Object
Arrange for objectified fact types to appear in order of name, after other fact types.
-
#fact_types_dump ⇒ Object
Dump fact types.
- #generate(out = $>) ⇒ Object
- #identified_by(o, pi) ⇒ Object
-
#initialize(vocabulary, *options) ⇒ OrderedDumper
constructor
Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary.
- #non_subtype_dump(o, pi) ⇒ Object
- #print(*a) ⇒ Object
- #puts(*a) ⇒ Object
-
#released_fact_types_dump(o) ⇒ Object
Dump all fact types for which all precursors (of which “o” is one) have been emitted:.
- #role_ref_key(role_ref) ⇒ Object
- #set_option(option) ⇒ Object
- #skip_fact_type(f) ⇒ Object
- #subtype_dump(o, supertypes, pi = nil) ⇒ Object
- #unit_dump(unit) ⇒ Object
- #units_banner ⇒ Object
- #units_dump ⇒ Object
- #units_end ⇒ Object
- #value_type_banner ⇒ Object
-
#value_type_chain_dump(o) ⇒ Object
Ensure that supertype gets dumped first.
- #value_type_dump(o, super_type_name, facets) ⇒ Object
- #value_type_end ⇒ Object
- #value_type_fork(o) ⇒ Object
- #value_types_dump ⇒ Object
- #vocabulary_end ⇒ Object
- #vocabulary_start ⇒ Object
Constructor Details
#initialize(vocabulary, *options) ⇒ OrderedDumper
Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary.
16 17 18 19 20 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 16 def initialize(vocabulary, *) @vocabulary = vocabulary @vocabulary = @vocabulary.Vocabulary.values[0] if ActiveFacts::API::Constellation === @vocabulary .each{|option| set_option(option) } end |
Instance Method Details
#append_ring_to_reading(reading, ring) ⇒ Object
573 574 575 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 573 def append_ring_to_reading(reading, ring) trace "Should override append_ring_to_reading" end |
#build_entity_dependencies ⇒ Object
This returns an array of two hash tables each keyed by an EntityType. The values of each hash entry are the precursors and followers (respectively) of that entity.
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 244 def build_entity_dependencies @vocabulary.all_object_type.inject([{},{}]) { |a, o| if o.is_a?(ActiveFacts::Metamodel::EntityType) precursor = a[0] follower = a[1] blocked = false pi = o.preferred_identifier if pi pi.role_sequence.all_role_ref.each{|rr| role = rr.role player = role.object_type # REVISIT: If we decide to emit value types on demand, need to remove this: next unless player.is_a?(ActiveFacts::Metamodel::EntityType) # player is a precursor of o (precursor[o] ||= []) << player if (player != o) (follower[player] ||= []) << o if (player != o) } end if o.fact_type o.fact_type.all_role.each do |role| next unless role.object_type.is_a?(ActiveFacts::Metamodel::EntityType) (precursor[o] ||= []) << role.object_type (follower[role.object_type] ||= []) << o end end # Supertypes are precursors too: subtyping = o.all_type_inheritance_as_supertype next a if subtyping.size == 0 subtyping.each{|ti| # debug ti.class.roles.verbalise; trace "all_type_inheritance_as_supertype"; exit s = ti.subtype (precursor[s] ||= []) << o (follower[o] ||= []) << s } # REVISIT: Need to use this to order ValueTypes after their supertypes # else # o.all_value_type_as_supertype.each { |s| # (precursor[s] ||= []) << o # (follower[o] ||= []) << s # } end a } end |
#constraint_banner ⇒ Object
589 590 591 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 589 def trace "Should override constraint_banner" end |
#constraint_dump(c) ⇒ Object
597 598 599 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 597 def constraint_dump(c) trace "Should override constraint_dump" end |
#constraint_end ⇒ Object
593 594 595 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 593 def constraint_end trace "Should override constraint_end" end |
#constraint_sort_key(c) ⇒ Object
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 444 def constraint_sort_key(c) case c when ActiveFacts::Metamodel::RingConstraint [ 1, c.ring_type, c.role.object_type.name, c.other_role.object_type.name, c.name||"" ] when ActiveFacts::Metamodel::SetExclusionConstraint [ 2+(c.is_mandatory ? 0 : 1), c.all_set_comparison_roles.map{|scrs| scrs.role_sequence.all_role_ref.map{|rr| role_ref_key(rr) } }, c.name||"" ] when ActiveFacts::Metamodel::SetEqualityConstraint [ 4, c.all_set_comparison_roles.map{|scrs| scrs.role_sequence.all_role_ref.map{|rr| role_ref_key(rr) } }, c.name||"" ] when ActiveFacts::Metamodel::SubsetConstraint [ 5, [c.superset_role_sequence, c.subset_role_sequence].map{|rs| rs.all_role_ref.map{|rr| role_ref_key(rr) } }, c.name||"" ] when ActiveFacts::Metamodel::PresenceConstraint [ 6, c.role_sequence.all_role_ref.map{|rr| role_ref_key(rr) }, c.name||"" ] end end |
#constraints_dump ⇒ Object
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 490 def constraints_dump heading = false @vocabulary. all_constraint. reject{|c| c.ordered_dumped}. sort_by{ |c| constraint_sort_key(c) }. each do |c| # Skip some PresenceConstraints: if c.is_a?(ActiveFacts::Metamodel::PresenceConstraint) # Skip uniqueness constraints that cover all roles of a fact type, they're implicit fact_types = c.role_sequence.all_role_ref.map{|rr| rr.role.fact_type}.uniq if fact_types.size == 1 && !c.role_sequence.all_role_ref.detect{|rr| rr.play } && c.max_frequency == 1 && # Uniqueness fact_types[0].all_role.size == c.role_sequence.all_role_ref.size next end # Skip internal PresenceConstraints over TypeInheritances: next if c.role_sequence.all_role_ref.size == 1 && fact_types[0].is_a?(ActiveFacts::Metamodel::TypeInheritance) end unless heading heading = true # Skip presence constraints on value types: # next if ActiveFacts::PresenceConstraint === c && # ActiveFacts::ValueType === c.object_type constraint_dump(c) end constraint_end if heading end |
#data_type_dump(o) ⇒ Object
549 550 551 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 549 def data_type_dump(o) trace "Should override data_type_dump" end |
#derivation_precursors_complete(fact_type) ⇒ Object
314 315 316 317 318 319 320 321 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 314 def derivation_precursors_complete(fact_type) pr = fact_type.preferred_reading return true unless jr = pr.role_sequence.all_role_ref.to_a[0].play query = jr.variable.query return false if query.all_step.detect{|js| !js.fact_type.ordered_dumped } return false if query.all_variable.detect{|jn| !jn.object_type.ordered_dumped } true end |
#describe_fact_type(fact_type, highlight = nil) ⇒ Object
225 226 227 228 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 225 def describe_fact_type(fact_type, highlight = nil) (fact_type.entity_type ? fact_type.entity_type.name : "")+ describe_roles(fact_type.all_role, highlight) end |
#describe_role_sequence(role_sequence) ⇒ Object
236 237 238 239 240 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 236 def describe_role_sequence(role_sequence) "("+ role_sequence.all_role_ref.map{|role_ref| role_ref.role.object_type.name }*", "+ ")" end |
#describe_roles(roles, highlight = nil) ⇒ Object
230 231 232 233 234 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 230 def describe_roles(roles, highlight = nil) "("+ roles.map{|role| role.object_type.name + (role == highlight ? "*" : "")}*", "+ ")" end |
#entity_type_banner ⇒ Object
557 558 559 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 557 def trace "Should override entity_type_banner" end |
#entity_type_group_end ⇒ Object
561 562 563 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 561 def entity_type_group_end trace "Should override entity_type_group_end" end |
#entity_types_dump ⇒ Object
Try to dump entity types in order of name, but we need to dump ETs before they’re referenced in preferred ids if possible (it’s not always, there may be loops!)
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 119 def entity_types_dump # Build hash tables of precursors and followers to use: @precursors, @followers = *build_entity_dependencies = false sorted = @vocabulary.all_object_type.select{|o| o.is_a?(ActiveFacts::Metamodel::EntityType) # and !o.fact_type }.sort_by{|o| o.name.gsub(/ /,'')} panic = nil while true do count_this_pass = 0 skipped_this_pass = 0 sorted.each{|o| next if o.ordered_dumped # Already done trace :ordered, "Panicing to dump #{panic.name}" if panic # Can we do this yet? remaining_precursors = Array(@precursors[o])-[o] if (o != panic and # We don't *have* to do it (panic mode) remaining_precursors.size > 0) # precursors - still blocked trace :ordered, "Can't dump #{o.name} despite panic for #{panic.name}, it still needs #{remaining_precursors.map(&:name)*', '}" if panic skipped_this_pass += 1 next end trace :ordered, "Dumping #{o.name} in panic mode, even though it still needs #{remaining_precursors.map(&:name)*', '}" if panic unless = true # We're going to emit o - remove it from precursors of others: (@followers[o]||[]).each{|f| @precursors[f] -= [o] } count_this_pass += 1 panic = nil if (o.fact_type) fact_type_dump_with_dependents(o.fact_type) released_fact_types_dump(o) else entity_type_dump(o) released_fact_types_dump(o) end entity_type_group_end } # Check that we made progress if there's any to make: if count_this_pass == 0 && skipped_this_pass > 0 =begin if panic # We were already panicing... what to do now? # This won't happen again unless the above code is changed to decide it can't dump "panic". bad = sorted.select do |o| o.is_a?(ActiveFacts::Metamodel::EntityType) && !o.ordered_dumped && (Array(@precursors[o])-[o]).size > 0 && (Array(@followers[o])-[o]).size > 0 end raise "Unresolvable cycle of forward references: " + bad.map { |o| o.name }*', ' + ":\n\t" + ( bad.map do |o| o.name + " depends on " + (@precursors[o].uniq.map{|p| p.name}.sort*', ') end ) * "\n\t" + "\n" =end # else # Find the object that has the most followers and no fwd-ref'd supertypes: # This selection might be better if we allow PI roles to be fwd-ref'd... panic = sorted. select{|o| !o.ordered_dumped }. sort_by{|o| f = (@followers[o] || []) - [o]; o.supertypes.detect{|s| !s.ordered_dumped } ? 0 : -f.size }[0] trace :ordered, "Panic mode, selected #{panic.name} next" # end end break if skipped_this_pass == 0 # All done. end end |
#fact_instances_dump ⇒ Object
410 411 412 413 414 415 416 417 418 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 410 def fact_instances_dump @vocabulary.fact_types.each{|f| # Dump the instances: f.facts.each{|i| raise "REVISIT: Not dumping fact instances" trace "\t\t"+i.to_s } } end |
#fact_type_banner ⇒ Object
577 578 579 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 577 def trace "Should override fact_type_banner" end |
#fact_type_dump(fact_type, name) ⇒ Object
585 586 587 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 585 def fact_type_dump(fact_type, name) trace "Should override fact_type_dump" end |
#fact_type_dump_with_dependents(fact_type) ⇒ Object
Dump one fact type. Include as many as possible internal constraints in the fact type readings.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 336 def fact_type_dump_with_dependents(fact_type) fact_type.ordered_dumped! return if skip_fact_type(fact_type) if (et = fact_type.entity_type) && fact_type.all_role.size > 1 && (pi = et.preferred_identifier) && pi.role_sequence.all_role_ref.detect{|rr| rr.role.fact_type != fact_type } # trace "Dumping objectified FT #{et.name} as an entity, non-fact PI" entity_type_dump(et) released_fact_types_dump(et) return end # trace "#{fact_type.name} has readings:\n\t#{fact_type.readings.map(&:name)*"\n\t"}" # trace "Dumping #{fact_type.concept.guid} as a fact type" # Fact types that aren't nested have no names name = fact_type.entity_type && fact_type.entity_type.name fact_type_dump(fact_type, name) # REVISIT: Go through the residual constraints and re-process appropriate readings to show them #CJH: Necessary? fact_type.ordered_dumped! fact_type.entity_type.ordered_dumped! if fact_type.entity_type end |
#fact_type_end ⇒ Object
581 582 583 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 581 def fact_type_end trace "Should override fact_type_end" end |
#fact_type_key(fact_type) ⇒ Object
Arrange for objectified fact types to appear in order of name, after other fact types. Facts are ordered alphabetically by the names of their role players, then by preferred_reading (subtyping fact types have no preferred_reading).
423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 423 def fact_type_key(fact_type) role_names = if (pr = fact_type.preferred_reading) pr.role_sequence. all_role_ref. sort_by{|role_ref| role_ref.ordinal}. map{|role_ref| [ role_ref.leading_adjective, role_ref.role.object_type.name, role_ref.trailing_adjective ].compact*"-" } + [pr.text] else fact_type.all_role.map{|role| role.object_type.name } end (fact_type.entity_type ? [fact_type.entity_type.name] : [""]) + role_names end |
#fact_types_dump ⇒ Object
Dump fact types.
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 366 def fact_types_dump # REVISIT: Uniqueness on the LHS of a binary can be coded using "distinct" # The only fact types that can be remaining are those involving only value types, # since we dumped every fact type as soon as all relevant entities were dumped. # Iterate over all fact types of all value types, looking for these strays. = false fact_collection = @vocabulary.constellation.FactType fact_collection.keys.select{|fact_id| fact_type = fact_collection[fact_id] and !fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) and !fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) and !fact_type.ordered_dumped and !skip_fact_type(fact_type) and !fact_type.all_role.detect{|r| r.object_type.is_a?(ActiveFacts::Metamodel::EntityType) } }.sort_by{|fact_id| fact_type = fact_collection[fact_id] fact_type_key(fact_type) }.each{|fact_id| fact_type = fact_collection[fact_id] unless = true fact_type_dump_with_dependents(fact_type) } # REVISIT: Find out why some fact types are missed during entity dumping: @vocabulary.constellation.FactType.values.select{|fact_type| !fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) && !fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) }.sort_by{|fact_type| fact_type_key(fact_type) }.each{|fact_type| next if fact_type.ordered_dumped # trace "Not dumped #{fact_type.verbalise}(#{fact_type.all_role.map{|r| r.object_type.name}*", "})" unless = true fact_type_dump_with_dependents(fact_type) } fact_type_end if end |
#generate(out = $>) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 33 def generate(out = $>) @out = out vocabulary_start units_dump value_types_dump entity_types_dump fact_types_dump constraints_dump vocabulary_end end |
#identified_by(o, pi) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 208 def identified_by(o, pi) # Different adjectives might be used for different readings. # Here, we must find the role_ref containing the adjectives that we need for each identifier, # which will be attached to the uniqueness constraint on this object in the binary FT that # attaches that identifying role. = (o.fact_type && o.fact_type.all_role.size == 1 ? o.fact_type.preferred_reading : pi). role_sequence.all_role_ref_in_order # We need to get the adjectives for the roles from the identifying fact's preferred readings: = ([o.fact_type]+.map{|rr| rr.role.fact_type }).compact.uniq identification = identified_by_roles_and_facts(o, , ) identification end |
#non_subtype_dump(o, pi) ⇒ Object
565 566 567 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 565 def non_subtype_dump(o, pi) trace "Should override non_subtype_dump" end |
#print(*a) ⇒ Object
29 30 31 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 29 def print(*a) @out.print *a end |
#puts(*a) ⇒ Object
25 26 27 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 25 def puts(*a) @out.puts *a end |
#released_fact_types_dump(o) ⇒ Object
Dump all fact types for which all precursors (of which “o” is one) have been emitted:
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 291 def released_fact_types_dump(o) roles = o.all_role begin progress = false roles.map(&:fact_type).uniq.select{|fact_type| # The fact type hasn't already been dumped but all its role players have !fact_type.ordered_dumped && !fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) && !fact_type.all_role.detect{|r| !r.object_type.ordered_dumped } && !fact_type.entity_type && derivation_precursors_complete(fact_type) # REVISIT: A derived fact type must not be dumped before its dependent fact types have }.sort_by{|fact_type| fact_type_key(fact_type) }.each{|fact_type| fact_type_dump_with_dependents(fact_type) # Objectified Fact Types may release additional fact types roles += fact_type.entity_type.all_role.sort_by{|role| role.ordinal} if fact_type.entity_type progress = true } end while progress end |
#role_ref_key(role_ref) ⇒ Object
438 439 440 441 442 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 438 def role_ref_key(role_ref) [ role_ref.leading_adjective, role_ref.role.object_type.name, role_ref.trailing_adjective ].compact*"-" + " in " + role_ref.role.fact_type.preferred_reading. end |
#set_option(option) ⇒ Object
22 23 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 22 def set_option(option) end |
#skip_fact_type(f) ⇒ Object
323 324 325 326 327 328 329 330 331 332 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 323 def skip_fact_type(f) return true if f.is_a?(ActiveFacts::Metamodel::TypeInheritance) return false if f.entity_type && !f.entity_type.ordered_dumped # REVISIT: There might be constraints we have to merge into the nested entity or subtype. # These will come up as un-handled constraints: # Dump this fact type only if it contains a presence constraint we've missed: pcs = @presence_constraints_by_fact[f] pcs && pcs.size > 0 && !pcs.detect{|c| !c.ordered_dumped } end |
#subtype_dump(o, supertypes, pi = nil) ⇒ Object
569 570 571 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 569 def subtype_dump(o, supertypes, pi = nil) trace "Should override subtype_dump" end |
#unit_dump(unit) ⇒ Object
538 539 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 538 def unit_dump unit end |
#units_banner ⇒ Object
532 533 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 532 def end |
#units_dump ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 44 def units_dump = false units = @vocabulary.all_unit.to_a.sort_by{|u| u.name.gsub(/ /,'')} while units.size > 0 i = 0 while i < units.size unit = units[i] i += 1 # Skip this one if the precursors haven't yet been dumped: next if unit.all_derivation_as_derived_unit.detect{|d| units.include?(d.base_unit) } # Even if we skip, we're done with this unit units.delete(unit) i -= 1 # Skip value-type derived units next if unit.name =~ /\^/ if ! = true end unit_dump(unit) end end units_end if end |
#units_end ⇒ Object
535 536 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 535 def units_end end |
#value_type_banner ⇒ Object
541 542 543 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 541 def trace "Should override value_type_banner" end |
#value_type_chain_dump(o) ⇒ Object
Ensure that supertype gets dumped first
109 110 111 112 113 114 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 109 def value_type_chain_dump(o) return if o.ordered_dumped value_type_chain_dump(o.supertype) if (o.supertype && !o.supertype.ordered_dumped) value_type_fork(o) o.ordered_dumped! end |
#value_type_dump(o, super_type_name, facets) ⇒ Object
553 554 555 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 553 def value_type_dump(o, super_type_name, facets) trace "Should override value_type_dump" end |
#value_type_end ⇒ Object
545 546 547 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 545 def value_type_end trace "Should override value_type_end" end |
#value_type_fork(o) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 73 def value_type_fork(o) if o.name == "_ImplicitBooleanValueType" # do nothing elsif !o.supertype # No supertype, i.e. a base type o.all_role.size == 0 && # No roles !o.is_independent && # not independent !o.value_constraint && # No value constraints o.concept.all_context_note_as_relevant_concept.size == 0 && # No context notes o.all_instance.size == 0 # No instances data_type_dump(o) else super_type_name = o.supertype ? o.supertype.name : o.name length = (l = o.length) && l > 0 ? "#{l}" : nil scale = (s = o.scale) && s > 0 ? "#{s}" : nil facets = { :length => length, :scale => scale } value_type_dump(o, super_type_name, facets) end end |
#value_types_dump ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 93 def value_types_dump = false @vocabulary.all_object_type.sort_by{|o| o.name.gsub(/ /,'')}.each{|o| next unless o.is_a?(ActiveFacts::Metamodel::ValueType) unless = true value_type_chain_dump(o) # @object_types_dumped[o] = true o.ordered_dumped! } value_type_end if end |
#vocabulary_end ⇒ Object
528 529 530 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 528 def vocabulary_end trace "Should override vocabulary_end" end |
#vocabulary_start ⇒ Object
524 525 526 |
# File 'lib/activefacts/generators/helpers/ordered.rb', line 524 def vocabulary_start trace "Should override vocabulary_start" end |