lib/activefacts/input/orm.rb in activefacts-0.8.9 vs lib/activefacts/input/orm.rb in activefacts-0.8.10

- old
+ new

@@ -175,10 +175,12 @@ x_value_types.each{|x| id = x['id'] name = (x['Name'] || "").gsub(/\s+/,' ').gsub(/-/,'_').strip name = nil if name.size == 0 + next if x['IsImplicitBooleanValue'] + cdt = x.xpath('orm:ConceptualDataType')[0] scale = cdt['Scale'] scale = scale != "" && scale.to_i length = cdt['Length'] length = length != "" && length.to_i @@ -242,10 +244,11 @@ id = x['id'] name = x['Name'] || x['_Name'] name = "<unnamed>" if !name name = "" if !name || name.size == 0 # Note that the new metamodel doesn't have a name for a facttype unless it's objectified + next if x.xpath("orm:DerivationRule").size > 0 debug :orm, "FactType #{name || id}" facts << @by_id[id] = fact_type = @constellation.FactType(:new) } end @@ -282,12 +285,11 @@ throw "For Subtype fact #{name}, the supertype #{supertype_id} was not found" if !supertype throw "For Subtype fact #{name}, the subtype #{subtype_id} was not found" if !subtype debug :orm, "#{subtype.name} is a subtype of #{supertype.name}" - inheritance_fact = @constellation.TypeInheritance(subtype, supertype) - inheritance_fact.fact_type_id = :new + inheritance_fact = @constellation.TypeInheritance(subtype, supertype, :fact_type_id => :new) if x["IsPrimary"] == "true" or # Old way x["PreferredIdentificationPath"] == "true" # Newer debug :orm, "#{supertype.name} is primary supertype of #{subtype.name}" inheritance_fact.provides_identification = true end @@ -295,12 +297,12 @@ mapping_choice = mapping ? mapping.parent['AbsorptionChoice'] : 'Absorbed' inheritance_fact.assimilation = mapping_choice.downcase.sub(/partition/, 'partitioned') if mapping_choice != 'Absorbed' facts << @by_id[id] = inheritance_fact # Create the new Roles so we can find constraints on them: - subtype_role = @by_id[subtype_role_id] = @constellation.Role(inheritance_fact, 0, :concept => subtype) - supertype_role = @by_id[supertype_role_id] = @constellation.Role(inheritance_fact, 1, :concept => supertype) + subtype_role = @by_id[subtype_role_id] = @constellation.Role(inheritance_fact, 0, :object_type => subtype) + supertype_role = @by_id[supertype_role_id] = @constellation.Role(inheritance_fact, 1, :object_type => supertype) # Create readings, so constraints can be verbalised for example: rs = @constellation.RoleSequence(:new) @constellation.RoleRef(rs, 0, :role => subtype_role) @constellation.RoleRef(rs, 1, :role => supertype_role) @@ -308,11 +310,11 @@ @constellation.Reading(inheritance_fact, 1, :role_sequence => rs, :text => "{0} is a subtype of {1}") rs2 = @constellation.RoleSequence(:new) @constellation.RoleRef(rs2, 0, :role => supertype_role) @constellation.RoleRef(rs2, 1, :role => subtype_role) - n = 'aeiouh'.include?(subtype_role.concept.name.downcase[0]) ? 1 : 0 + n = 'aeiouh'.include?(subtype_role.object_type.name.downcase[0]) ? 1 : 0 @constellation.Reading(inheritance_fact, 2+n, :role_sequence => rs2, :text => "{0} is a {1}") @constellation.Reading(inheritance_fact, 3-n, :role_sequence => rs2, :text => "{0} is an {1}") } end end @@ -332,10 +334,11 @@ x_fact_type = x.xpath('orm:NestedPredicate')[0] is_implied = x_fact_type['IsImplied'] == "true" fact_id = x_fact_type['ref'] fact_type = @by_id[fact_id] + next if x.xpath("orm:DerivationRule").size > 0 throw "Nested fact #{fact_id} not found" if !fact_type #if is_implied # puts "Implied type #{name} (#{id}) nests #{fact_type ? fact_type.fact_type_id : "unknown"}" # @by_id[id] = fact_type @@ -343,10 +346,12 @@ begin debug :orm, "NestedType #{name} is #{id}, nests #{fact_type.fact_type_id}" @nested_types << @by_id[id] = nested_type = @constellation.EntityType(@vocabulary, name) + independent = x['IsIndependent'] + nested_type.is_independent = true if independent && independent == 'true' && !is_implied nested_type.fact_type = fact_type end } end end @@ -362,10 +367,11 @@ def read_roles debug :orm, "Reading roles and readings" do @x_facts.each{|x| id = x['id'] + next if x.xpath("orm:DerivationRule").size > 0 fact_type = @by_id[id] fact_name = x['Name'] || x['_Name'] || '' #fact_name.gsub!(/\s/,'') fact_name = nil if fact_name == '' @@ -383,13 +389,12 @@ id = x['id'] rp = x.xpath('orm:RolePlayer')[0] raise "Invalid ORM file; fact has missing player (RolePlayer id=#{id})" unless rp ref = rp['ref'] - # Find the concept that plays the role: - concept = @by_id[ref] - throw "RolePlayer for '#{name}' #{ref} was not found" if !concept + # Find the object_type that plays the role: + object_type = @by_id[ref] # Skip implicit roles added by NORMA to make unaries into binaries. # This would make constraints over the deleted roles impossible, # so as a SPECIAL CASE we index the unary role by the id of the # implicit role. That means care is needed when handling unary FTs. @@ -404,23 +409,23 @@ # The role name of the ignored role is the one that applies: role_name = x['Name'] other_role.role_name = role_name if role_name && role_name != '' - concept.retract # Delete our object for the implicit boolean ValueType @by_id.delete(ref) # and de-index it from our list next end + throw "RolePlayer for '#{name}' #{ref} was not found" if !object_type - debug :orm, "#{@vocabulary.name}, RoleName=#{x['Name'].inspect} played by concept=#{concept.name}" - throw "Role is played by #{concept.class} not Concept" if !(@constellation.vocabulary.concept(:Concept) === concept) + debug :orm, "#{@vocabulary.name}, RoleName=#{x['Name'].inspect} played by object_type=#{object_type.name}" + throw "Role is played by #{object_type.class} not ObjectType" if !(@constellation.vocabulary.object_type(:ObjectType) === object_type) - debug :orm, "Creating role #{name} nr#{fact_type.all_role.size} of #{fact_type.fact_type_id} played by #{concept.name}" + debug :orm, "Creating role #{name} nr#{fact_type.all_role.size} of #{fact_type.fact_type_id} played by #{object_type.name}" - role = @by_id[id] = @constellation.Role(fact_type, fact_type.all_role.size, :concept => concept) - role.role_name = name if name && name != concept.name - debug :orm, "Fact #{fact_name} (id #{fact_type.fact_type_id.object_id}) role #{x['Name']} is played by #{concept.name}, role is #{role.object_id}" + role = @by_id[id] = @constellation.Role(fact_type, fact_type.all_role.size, :object_type => object_type) + role.role_name = name if name && name != object_type.name + debug :orm, "Fact #{fact_name} (id #{fact_type.fact_type_id.object_id}) role #{x['Name']} is played by #{object_type.name}, role is #{role.object_id}" x_vr = x.xpath("orm:ValueRestriction/orm:RoleValueConstraint") x_vr.each{|vr| x_ranges = vr.xpath("orm:ValueRanges/orm:ValueRange") next if x_ranges.size == 0 @@ -429,11 +434,11 @@ v_range = value_range(x_range) ar = @constellation.AllowedRange(role.role_value_constraint, v_range) } } - debug :orm, "Adding Role #{role.role_name || role.concept.name} to #{fact_type.describe}" + debug :orm, "Adding Role #{role.role_name || role.object_type.name} to #{fact_type.describe}" #fact_type.add_role(role) debug :orm, "Role #{role} is #{id}" } end @@ -480,11 +485,11 @@ text.gsub!(role_with_adjectives_re) { # REVISIT: Don't want to strip all spaces here any more: #puts "text=#{text.inspect}, la=#{$1.inspect}, ta=#{$2.inspect}" if $1 || $2 la = ($1||'').gsub(/\s+/,' ').sub(/-/,'').strip ta = ($2||'').gsub(/\s+/,' ').sub(/-/,'').strip - #puts "Setting leading adj #{la.inspect} from #{text.inspect} for #{role_ref.role.concept.name}" if la != "" + #puts "Setting leading adj #{la.inspect} from #{text.inspect} for #{role_ref.role.object_type.name}" if la != "" # REVISIT: Dunno what's up here, but removing the "if" test makes this chuck exceptions: role_ref.leading_adjective = la if la != "" role_ref.trailing_adjective = ta if ta != "" #puts "Reading '#{text}' has role #{i} adjectives '#{la}' '#{ta}'" if la != "" || ta != "" @@ -500,11 +505,11 @@ case w when /[A-Za-z]/ if RESERVED_WORDS.include?(w) $stderr.puts "Masking reserved word '#{w}' in reading '#{text}'" next "_#{w}" - elsif @constellation.Concept[[[@vocabulary.name], w]] + elsif @constellation.ObjectType[[[@vocabulary.name], w]] $stderr.puts "Masking object type name '#{w}' in reading '#{text}'" next "_#{w}" elsif all_role_refs.detect{|rr| rr.role.role_name == w} $stderr.puts "Masking role name '#{w}' in reading '#{text}'" next "_#{w}" @@ -517,21 +522,21 @@ else elided << w next '' end end - $stderr.puts "Elided illegal characters '#{elided}' from reading" unless elided.empty? + $stderr.puts "Elided illegal characters '#{elided}' from reading #{text.inspect}" unless elided.empty? text end def get_role_sequence(role_array) - # puts "Getting RoleSequence [#{role_array.map{|r| "#{r.concept.name} (role #{r.object_id})" }*", "}]" + # puts "Getting RoleSequence [#{role_array.map{|r| "#{r.object_type.name} (role #{r.object_id})" }*", "}]" # Look for an existing RoleSequence # REVISIT: This searches all role sequences. Perhaps we could narrow it down first instead? role_sequence = @constellation.RoleSequence.values.detect{|c| - #puts "Checking RoleSequence [#{c.all_role_ref.map{|rr| rr.role.concept.name}*", "}]" + #puts "Checking RoleSequence [#{c.all_role_ref.map{|rr| rr.role.object_type.name}*", "}]" role_array == c.all_role_ref.sort_by{|rr| rr.ordinal}.map{|rr| rr.role } } # puts "Found matching RoleSequence!" if role_sequence return role_sequence if role_sequence @@ -556,16 +561,19 @@ x_object = @x_by_id[x_player['ref']] x_nests = nil if (x_object.name.to_s == 'ObjectifiedType') x_nests = x_object.xpath('orm:NestedPredicate')[0] implied = x_nests['IsImplied'] + # x_fact is the fact of which the role player is an objectification, not the fact this role belongs to x_fact = @x_by_id[x_nests['ref']] end # This might have been a role of an ImpliedFact, which makes it safe to ignore. next if 'ImpliedFact' == x_role.parent.parent.name + next if x_role.parent.parent.xpath('orm:DerivationRule').size > 0 + # Talk about why this wasn't found - this shouldn't happen. if (!x_nests || !implied) #puts "="*60 puts "Skipping #{why}, #{x_role.name} #{id} not found" @@ -627,11 +635,11 @@ # Create a simply-mandatory PresenceConstraint for each mandatory constraint name = x["Name"] || '' name = nil if name.size == 0 #puts "Residual Mandatory #{name}: #{role_sequence.to_s}" - if (players = role_sequence.all_role_ref.map{|rr| rr.role.concept}).uniq.size > 1 + if (players = role_sequence.all_role_ref.map{|rr| rr.role.object_type}).uniq.size > 1 join_over, = *ActiveFacts::Metamodel.join_roles_over(role_sequence.all_role_ref.map{|rr| rr.role}, :proximate) raise "Mandatory join constraint #{name} has incompatible players #{players.map{|o| o.name}.inspect}" unless join_over if players.detect{|p| p != join_over} debug :join, "subtyping join simple mandatory constraint #{name} over #{join_over.name}" players.each_with_index do |player, i| @@ -664,11 +672,11 @@ name = nil if name.size == 0 uc_id = x["id"] x_pi = x.xpath("orm:PreferredIdentifierFor")[0] pi = x_pi ? @by_id[eref = x_pi['ref']] : nil - # Skip uniqueness constraints on implied concepts + # Skip uniqueness constraints on implied object_types next if x_pi && !pi # Get the RoleSequence: x_roles = x.xpath("orm:RoleSequence/orm:Role") next if x_roles.size == 0 @@ -678,11 +686,11 @@ # Check for a join if (fact_types = role_sequence.all_role_ref.map{|rr| rr.role.fact_type}).uniq.size > 1 join_over, = *ActiveFacts::Metamodel.join_roles_over(role_sequence.all_role_ref.map{|rr| rr.role}, :counterpart) - players = role_sequence.all_role_ref.map{|rr| rr.role.concept.name}.uniq + players = role_sequence.all_role_ref.map{|rr| rr.role.object_type.name}.uniq raise "Uniqueness join constraint #{name} has incompatible players #{players.inspect}" unless join_over subtyping = players.size > 1 ? 'subtyping ' : '' # REVISIT: Create the Join, the JoinNode for join_over, and steps from each role_ref to join_over debug :join, "#{subtyping}join uniqueness constraint over #{join_over.name} in #{fact_types.map(&:default_reading)*', '}" end @@ -722,11 +730,11 @@ is_supertype_constraint = (rr = role_sequence.all_role_ref.single) && (role = rr.role) && (fact_type = role.fact_type) && fact_type.is_a?(ActiveFacts::Metamodel::TypeInheritance) && - role.concept == fact_type.supertype && + role.object_type == fact_type.supertype && fact_type.provides_identification pc = @constellation.PresenceConstraint(:new) pc.vocabulary = @vocabulary pc.name = name @@ -745,14 +753,14 @@ } end end def subtype_join_step(join, ti) - subtype_node = join.all_join_node.detect{|jn| jn.concept == ti.subtype } || - @constellation.JoinNode(join, join.all_join_node.size, :concept => ti.subtype) - supertype_node = join.all_join_node.detect{|jn| jn.concept == ti.supertype } || - @constellation.JoinNode(join, join.all_join_node.size, :concept => ti.supertype) + subtype_node = join.all_join_node.detect{|jn| jn.object_type == ti.subtype } || + @constellation.JoinNode(join, join.all_join_node.size, :object_type => ti.subtype) + supertype_node = join.all_join_node.detect{|jn| jn.object_type == ti.supertype } || + @constellation.JoinNode(join, join.all_join_node.size, :object_type => ti.supertype) rs = @constellation.RoleSequence(:new) @constellation.RoleRef(rs, 0, :role => ti.subtype_role) sub_jr = @constellation.JoinRole(subtype_node, ti.subtype_role) @constellation.RoleRef(rs, 1, :role => ti.supertype_role) sup_jr = @constellation.JoinRole(supertype_node, ti.supertype_role) @@ -791,23 +799,26 @@ # Supertyping joins may be needed to reach them. end_points = [] # An array of the common supertype for matching role_refs across the sequences end_joins = [] # An array of booleans indicating whether any role_sequence requires a subtyping join role_sequences[0].all_role_ref.size.times do |i| role_refs = role_sequences.map{|rs| rs.all_role_ref.detect{|rr| rr.ordinal == i}} - next if (fact_types = role_refs.map{|rr| rr.role.fact_type}).uniq.size == 1 - if (players = role_refs.map{|rr| rr.role.concept}).uniq.size == 1 + if (fact_types = role_refs.map{|rr| rr.role.fact_type}).uniq.size == 1 + raise "In #{constraint_type} #{name}, there is a faulty join" + next + end + if (players = role_refs.map{|rr| rr.role.object_type}).uniq.size == 1 end_point = players[0] end_joins[i] = false else # Can the players be joined using a subtyping join? common_supertypes = players[1..-1]. inject(players[0].supertypes_transitive) do |remaining, player| remaining & player.supertypes_transitive end end_point = common_supertypes[0] - raise "constrained roles of #{constraint_type} constraint #{name} are incompatible (#{names*', '})" if common_supertypes.size == 0 + raise "constrained roles of #{constraint_type} constraint #{name} are incompatible (#{players.map(&:name)*', '})" if common_supertypes.size == 0 end_joins[i] = true end end_points[i] = end_point end @@ -847,11 +858,11 @@ # There may be one join per role sequence: role_sequences.zip(sequence_join_over||[], sequence_joined_roles||[]).map do |role_sequence, join_over, joined_roles| # Skip if there's no join here (sequence join nor end-point subset join) role_refs = role_sequence.all_role_ref_in_order - if !join_over and !role_refs.detect{|rr| rr.role.concept != end_points[rr.ordinal]} + if !join_over and !role_refs.detect{|rr| rr.role.object_type != end_points[rr.ordinal]} # No sequence join nor end_point join here next end # A RoleSequence for the actual join end-points @@ -864,52 +875,53 @@ # Each role_ref is to an object joined via joined_role to join_node (or which will be the join_node) # Create a join node for the actual end-point (supertype of the constrained roles) end_point = end_points[i] + raise "In #{constraint_type} #{name}, there is a faulty join" unless end_point debug :join, "Join Node #{join.all_join_node.size} is for #{end_point.name}" - end_node = @constellation.JoinNode(join, join.all_join_node.size, :concept => end_point) + end_node = @constellation.JoinNode(join, join.all_join_node.size, :object_type => end_point) # We're going to rewrite the constraint to constrain the supertype roles, but assume they're the same: role_node = end_node end_role = role_ref.role # Create subtyping join steps at the end-point, if needed: projecting_jr = nil constrained_join_role = nil - if (subtype = role_ref.role.concept) != end_point + if (subtype = role_ref.role.object_type) != end_point debug :join, "Making subtyping join steps from #{subtype.name} to #{end_point.name}" do # There may be more than one supertyping level. Make the steps: subtyping_steps = subtype_join_steps(join, subtype, end_point) js = subtyping_steps[0] constrained_join_role = subtyping_steps[-1].input_join_role # Replace the constrained role and node with the supertype ones: - end_node = join.all_join_node.detect{|jn| jn.concept == end_point } + end_node = join.all_join_node.detect{|jn| jn.object_type == end_point } projecting_jr = js.output_join_role - end_role = js.fact_type.all_role.detect{|r| r.concept == end_point } - role_node = join.all_join_node.detect{|jn| jn.concept == role_ref.role.concept } + end_role = js.fact_type.all_role.detect{|r| r.object_type == end_point } + role_node = join.all_join_node.detect{|jn| jn.object_type == role_ref.role.object_type } end end - raise "Internal error: making illegal reference to join node" if end_role.concept != end_node.concept + raise "Internal error: making illegal reference to join node" if end_role.object_type != end_node.object_type rr = @constellation.RoleRef(replacement_rs, replacement_rs.all_role_ref.size, :role => end_role) projecting_jr ||= (constrained_join_role = @constellation.JoinRole(end_node, end_role)) projecting_jr.role_ref = rr # Project this RoleRef if join_over if !join_node # Create the JoinNode when processing the first role debug :join, "Join Node #{join.all_join_node.size} is over #{join_over.name}" - join_node = @constellation.JoinNode(join, join.all_join_node.size, :concept => join_over) + join_node = @constellation.JoinNode(join, join.all_join_node.size, :object_type => join_over) end debug :join, "Making join step from #{end_point.name} to #{join_over.name}" do rs = @constellation.RoleSequence(:new) # Detect the fact type over which we're joining (may involve objectification) - raise "Internal error: making illegal reference to join node" if role_ref.role.concept != role_node.concept + raise "Internal error: making illegal reference to join node" if role_ref.role.object_type != role_node.object_type @constellation.RoleRef(rs, 0, :role => role_ref.role) role_jr = @constellation.JoinRole(role_node, role_ref.role) - raise "Internal error: making illegal reference to join node" if joined_role.concept != join_node.concept + raise "Internal error: making illegal reference to join node" if joined_role.object_type != join_node.object_type @constellation.RoleRef(rs, 1, :role => joined_role) join_jr = @constellation.JoinRole(join_node, joined_role) js = @constellation.JoinStep(role_jr, join_jr, :fact_type => joined_role.fact_type) debug :join, "New join step #{js.describe}" @@ -917,17 +929,17 @@ else debug :join, "Need join step for non-join_over role #{end_point.name} #{role_ref.describe} in #{role_ref.role.fact_type.default_reading}" if (roles = role_ref.role.fact_type.all_role.to_a).size > 1 # Here we have an end join (step already created) but no sequence join if join_node - raise "Internal error: making illegal join step" if role_ref.role.concept != role_node.concept + raise "Internal error: making illegal join step" if role_ref.role.object_type != role_node.object_type join_jr = @constellation.JoinRole(join_node, join_role) role_jr = @constellation.JoinRole(role_node, role_ref.role) js = @constellation.JoinStep(join_jr, role_jr, :fact_type => role_ref.role.fact_type) roles -= [join_role, role_ref.role] roles.each do |incidental_role| - jn = @constellation.JoinNode(join, join.all_join_node.size, :concept => incidental_role.concept) + jn = @constellation.JoinNode(join, join.all_join_node.size, :object_type => incidental_role.object_type) jr = @constellation.JoinRole(jn, incidental_role, :join_step => js) end else if role_sequence.all_role_ref.size > 1 join_node = role_node @@ -939,11 +951,11 @@ role_jr = @constellation.JoinRole(role_node, role_ref.role) js = nil role_ref.role.fact_type.all_role.each do |role| next if role == role_jr.role next if role_sequence.all_role_ref.detect{|rr| rr.role == role} - jn = @constellation.JoinNode(join, join.all_join_node.size, :concept => role.concept) + jn = @constellation.JoinNode(join, join.all_join_node.size, :object_type => role.object_type) jr = @constellation.JoinRole(jn, role) if js jr.join_step = js # Incidental role else js = @constellation.JoinStep(role_jr, jr, :fact_type => role_ref.role.fact_type) @@ -992,10 +1004,12 @@ mc_rs = @mandatory_constraint_rs_by_id[mc_id] @mandatory_constraint_rs_by_id.delete(mc_id) @mandatory_constraints_by_rs.delete(mc_rs) end + next if role_sequences.compact.size != role_sequences.size # Role sequence missing; includes a derived fact type role + make_joins('exclusion', name+(x_mandatory ? '/'+x_mandatory['Name'] : ''), role_sequences) ec = @constellation.SetExclusionConstraint(:new) ec.vocabulary = @vocabulary ec.name = name @@ -1024,10 +1038,11 @@ x_role_refs , # .map{|xr| @x_by_id[xr['ref']] }, "equality constraint #{name}" ) } + next if role_sequences.compact.size != role_sequences.size # Role sequence missing; includes a derived fact type role make_joins('equality', name, role_sequences) ec = @constellation.SetEqualityConstraint(:new) ec.vocabulary = @vocabulary ec.name = name @@ -1053,10 +1068,11 @@ map_roles( x_role_refs , # .map{|xr| @x_by_id[xr['ref']] }, "equality constraint #{name}" ) } + next if role_sequences.compact.size != role_sequences.size # Role sequence missing; includes a derived fact type role make_joins('subset', name, role_sequences) ec = @constellation.SubsetConstraint(:new) ec.vocabulary = @vocabulary ec.name = name @@ -1079,13 +1095,14 @@ from, to = *x.xpath("orm:RoleSequence/orm:Role"). map do |xr| @by_id[xr['ref']] end - if from.concept != to.concept + next unless from && to # Roles missing; covers a derived fact type + if from.object_type != to.object_type join_over, = *ActiveFacts::Metamodel.join_roles_over([from, to], :counterpart) - raise "Ring constraint has incompatible players #{from.concept.name}, #{to.concept.name}" if !join_over + raise "Ring constraint has incompatible players #{from.object_type.name}, #{to.object_type.name}" if !join_over debug :join, "join ring constraint over #{join_over.name}" end rc = @constellation.RingConstraint(:new) rc.vocabulary = @vocabulary rc.name = name @@ -1109,10 +1126,11 @@ max_frequency = nil if max_frequency == 0 x_roles = x_frequency_constraint.xpath("orm:RoleSequence/orm:Role") role = @by_id[x_roles[0]["ref"]] role_sequence = @constellation.RoleSequence(:new) role_ref = @constellation.RoleRef(role_sequence, 0, :role => role) + next unless role # Role missing; belongs to a derived fact type debug :orm, "FrequencyConstraint(min #{min_frequency.inspect} max #{max_frequency.inspect} over #{role.fact_type.describe(role)} #{id} role ref = #{x_roles[0]["ref"]}" @by_id[id] = @constellation.PresenceConstraint( :new, :vocabulary => @vocabulary, :name => name = x_frequency_constraint["Name"] || '', @@ -1144,11 +1162,11 @@ #vtname.gsub!(/\s/,'') vtname = nil if vtname.size == 0 vt = @by_id[vt_id] throw "ValueType #{vtname} not found" unless vt - i = @constellation.Instance(:new, :population => population, :concept => vt, :value => [v.text, is_a_string(v.text), nil]) + i = @constellation.Instance(:new, :population => population, :object_type => vt, :value => [v.text, is_a_string(v.text), nil]) @by_id[id] = i # show_xmlobj(v) } end @@ -1173,11 +1191,11 @@ last_et = et = @by_id[et_id] last_et_id = et_id throw "EntityType #{etname} not found" unless et end - instance = @constellation.Instance(:new, :population => population, :concept => et, :value => nil) + instance = @constellation.Instance(:new, :population => population, :object_type => et, :value => nil) @by_id[id] = instance debug :orm, "Made new EntityType #{etname}" } end @@ -1210,11 +1228,11 @@ identifying_fact_types. each do |ft| debug :orm, "For FactType #{ft}" do fact = @constellation.Fact(:new, :population => population, :fact_type => ft) fact_roles = ft.all_role.map do |role| - if role.concept == et + if role.object_type == et object = instance else object = role_instances[role] debug :orm, "instance for role #{role} is #{object}" end @@ -1297,11 +1315,11 @@ when 'ModelNoteShape' # REVISIT: Add model notes when 'ObjectTypeShape' shape = @constellation.ObjectTypeShape( :new, :diagram => diagram, :position => position, :is_expanded => is_expanded, - :concept => subject, + :object_type => subject, :has_expanded_reference_mode => false # REVISIT ) else raise "Unknown shape #{x_shape.name}" end @@ -1348,12 +1366,12 @@ :rotation_setting => rotation_setting, :fact_type => fact_type ) # Create RoleDisplay objects if necessary x_role_display = x_shape.xpath("ormDiagram:RoleDisplayOrder/ormDiagram:Role") - # print "Fact type '#{fact_type.preferred_reading.expand}' (#{fact_type.all_role.map{|r|r.concept.name}*' '})" + # print "Fact type '#{fact_type.preferred_reading.expand}' (#{fact_type.all_role.map{|r|r.object_type.name}*' '})" if x_role_display.size > 0 - debug :orm, " has roleDisplay (#{x_role_display.map{|rd| @by_id[rd['ref']].concept.name}*','})'" + debug :orm, " has roleDisplay (#{x_role_display.map{|rd| @by_id[rd['ref']].object_type.name}*','})'" x_role_display.each_with_index do |rd, ordinal| role_display = @constellation.RoleDisplay(shape, ordinal, :role => @by_id[rd['ref']]) end else # Decide whether to create all RoleDisplay objects for this fact type, which is in role order