Class: ActiveFacts::Generate::Helpers::OrderedDumper
- Inherits:
-
Object
- Object
- ActiveFacts::Generate::Helpers::OrderedDumper
- Defined in:
- lib/activefacts/generate/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.
- #build_indices ⇒ Object
- #constraint_banner ⇒ Object
- #constraint_dump(c) ⇒ Object
- #constraint_end ⇒ Object
- #constraint_sort_key(c) ⇒ Object
- #constraints_dump(except = {}) ⇒ 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(vocabulary) ⇒ Object
Constructor Details
#initialize(vocabulary, *options) ⇒ OrderedDumper
Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary.
14 15 16 17 18 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 14 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
580 581 582 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 580 def append_ring_to_reading(reading, ring) debug "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.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 249 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; debug "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 |
#build_indices ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 46 def build_indices @presence_constraints_by_fact = Hash.new{ |h, k| h[k] = [] } @ring_constraints_by_fact = Hash.new{ |h, k| h[k] = [] } @vocabulary.all_constraint.each { |c| case c when ActiveFacts::Metamodel::PresenceConstraint fact_types = c.role_sequence.all_role_ref.map{|rr| rr.role.fact_type}.uniq # All fact types spanned by this constraint if fact_types.size == 1 # There's only one, save it: # debug "Single-fact constraint on #{fact_types[0].concept.guid}: #{c.name}" (@presence_constraints_by_fact[fact_types[0]] ||= []) << c end when ActiveFacts::Metamodel::RingConstraint (@ring_constraints_by_fact[c.role.fact_type] ||= []) << c else # debug "Found unhandled constraint #{c.class} #{c.name}" end } @constraints_used = {} end |
#constraint_banner ⇒ Object
596 597 598 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 596 def debug "Should override constraint_banner" end |
#constraint_dump(c) ⇒ Object
604 605 606 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 604 def constraint_dump(c) debug "Should override constraint_dump" end |
#constraint_end ⇒ Object
600 601 602 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 600 def constraint_end debug "Should override constraint_end" end |
#constraint_sort_key(c) ⇒ Object
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 489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 455 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(except = {}) ⇒ Object
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 501 def constraints_dump(except = {}) heading = false @vocabulary.all_constraint.reject{|c| except[c]}.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
556 557 558 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 556 def data_type_dump(o) debug "Should override data_type_dump" end |
#derivation_precursors_complete(fact_type) ⇒ Object
319 320 321 322 323 324 325 326 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 319 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| !@fact_types_dumped[js.fact_type] } return false if query.all_variable.detect{|jn| !@object_types_dumped[jn.object_type] } true end |
#describe_fact_type(fact_type, highlight = nil) ⇒ Object
230 231 232 233 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 230 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
241 242 243 244 245 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 241 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
235 236 237 238 239 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 235 def describe_roles(roles, highlight = nil) "("+ roles.map{|role| role.object_type.name + (role == highlight ? "*" : "")}*", "+ ")" end |
#entity_type_banner ⇒ Object
564 565 566 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 564 def debug "Should override entity_type_banner" end |
#entity_type_group_end ⇒ Object
568 569 570 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 568 def entity_type_group_end debug "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!)
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 142 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 @object_types_dumped[o] # Already done # Can we do this yet? if (o != panic and # We don't *have* to do it (panic mode) (p = @precursors[o]) and # There might be... p.size > 0) # precursors - still blocked skipped_this_pass += 1 next end 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 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". raise "Unresolvable cycle of forward references: " + (bad = sorted.select{|o| EntityType === o && !@object_types_dumped[o]}).map{|o| o.name }.inspect + ":\n\t" + bad.map{|o| o.name + ": " + @precursors[o].map{|p| p.name}.uniq.inspect } * "\n\t" + "\n" 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| !@object_types_dumped[o] }. sort_by{|o| f = @followers[o] || []; o.supertypes.detect{|s| !@object_types_dumped[s] } ? 0 : -f.size }[0] # debug "Panic mode, selected #{panic.name} next" end end break if skipped_this_pass == 0 # All done. end end |
#fact_instances_dump ⇒ Object
421 422 423 424 425 426 427 428 429 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 421 def fact_instances_dump @vocabulary.fact_types.each{|f| # Dump the instances: f.facts.each{|i| raise "REVISIT: Not dumping fact instances" debug "\t\t"+i.to_s } } end |
#fact_type_banner ⇒ Object
584 585 586 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 584 def debug "Should override fact_type_banner" end |
#fact_type_dump(fact_type, name) ⇒ Object
592 593 594 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 592 def fact_type_dump(fact_type, name) debug "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.
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 341 def fact_type_dump_with_dependents(fact_type) @fact_types_dumped[fact_type] = true # debug "Trying to dump FT again" if @fact_types_dumped[fact_type] return if skip_fact_type(fact_type) if (et = fact_type.entity_type) && (pi = et.preferred_identifier) && pi.role_sequence.all_role_ref.detect{|rr| rr.role.fact_type != fact_type } # debug "Dumping objectified FT #{et.name} as an entity, non-fact PI" entity_type_dump(et) released_fact_types_dump(et) return end fact_constraints = @presence_constraints_by_fact[fact_type] # debug "for fact type #{fact_type.to_s}, considering\n\t#{fact_constraints.map(&:to_s)*",\n\t"}" # debug "#{fact_type.name} has readings:\n\t#{fact_type.readings.map(&:name)*"\n\t"}" # debug "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 @fact_types_dumped[fact_type] = true @object_types_dumped[fact_type.entity_type] = true if fact_type.entity_type end |
#fact_type_end ⇒ Object
588 589 590 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 588 def fact_type_end debug "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).
434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 434 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.
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 409 410 411 412 413 414 415 416 417 418 419 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 373 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_types_dumped[fact_type] 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_types_dumped[fact_type] # debug "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 # unused = constraints - @constraints_used.keys # debug "residual constraints are\n\t#{unused.map(&:to_s)*",\n\t"}" @constraints_used end |
#generate(out = $>) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 31 def generate(out = $>) @out = out vocabulary_start(@vocabulary) build_indices @object_types_dumped = {} @fact_types_dumped = {} units_dump() value_types_dump() entity_types_dump() fact_types_dump() constraints_dump(@constraints_used) vocabulary_end end |
#identified_by(o, pi) ⇒ Object
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 215 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. = pi.role_sequence.all_role_ref.sort_by{|role_ref| role_ref.ordinal} # 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
572 573 574 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 572 def non_subtype_dump(o, pi) debug "Should override non_subtype_dump" end |
#print(*a) ⇒ Object
27 28 29 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 27 def print(*a) @out.print *a end |
#puts(*a) ⇒ Object
23 24 25 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 23 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:
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 296 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_types_dumped[fact_type] && !fact_type.is_a?(ActiveFacts::Metamodel::LinkFactType) && !fact_type.all_role.detect{|r| !@object_types_dumped[r.object_type] } && !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
449 450 451 452 453 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 449 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
20 21 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 20 def set_option(option) end |
#skip_fact_type(f) ⇒ Object
328 329 330 331 332 333 334 335 336 337 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 328 def skip_fact_type(f) return true if f.is_a?(ActiveFacts::Metamodel::TypeInheritance) return false if f.entity_type && !@object_types_dumped[f.entity_type] # 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| !@constraints_used[c] } end |
#subtype_dump(o, supertypes, pi = nil) ⇒ Object
576 577 578 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 576 def subtype_dump(o, supertypes, pi = nil) debug "Should override subtype_dump" end |
#unit_dump(unit) ⇒ Object
545 546 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 545 def unit_dump unit end |
#units_banner ⇒ Object
539 540 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 539 def end |
#units_dump ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 67 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
542 543 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 542 def units_end end |
#value_type_banner ⇒ Object
548 549 550 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 548 def debug "Should override value_type_banner" end |
#value_type_chain_dump(o) ⇒ Object
Ensure that supertype gets dumped first
132 133 134 135 136 137 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 132 def value_type_chain_dump(o) return if @value_type_dumped[o] value_type_chain_dump(o.supertype) if (o.supertype && !@value_type_dumped[o.supertype]) value_type_fork(o) @value_type_dumped[o] = true end |
#value_type_dump(o, super_type_name, facets) ⇒ Object
560 561 562 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 560 def value_type_dump(o, super_type_name, facets) debug "Should override value_type_dump" end |
#value_type_end ⇒ Object
552 553 554 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 552 def value_type_end debug "Should override value_type_end" end |
#value_type_fork(o) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 96 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
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 116 def value_types_dump = false @value_type_dumped = {} @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 } value_type_end if end |
#vocabulary_end ⇒ Object
535 536 537 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 535 def vocabulary_end debug "Should override vocabulary_end" end |
#vocabulary_start(vocabulary) ⇒ Object
531 532 533 |
# File 'lib/activefacts/generate/helpers/ordered.rb', line 531 def vocabulary_start(vocabulary) debug "Should override vocabulary_start" end |