lib/lutaml/xmi/parsers/xml.rb in lutaml-xmi-0.2.2 vs lib/lutaml/xmi/parsers/xml.rb in lutaml-xmi-0.2.3
- old
+ new
@@ -128,11 +128,11 @@
def serialize_model_associations(klass)
xmi_id = klass["xmi:id"]
main_model.xpath(%(//element[@xmi:idref="#{xmi_id}"]/links/*)).map do |link|
link_member_name = link.attributes["start"].value == xmi_id ? "end" : "start"
linke_owner_name = link_member_name == "start" ? "end" : "start"
- member_end, member_end_type, member_end_cardinality, member_end_attribute_name = serialize_member_type(xmi_id, link, link_member_name)
+ member_end, member_end_type, member_end_cardinality, member_end_attribute_name, member_end_xmi_id = serialize_member_type(xmi_id, link, link_member_name)
owner_end, owner_end_cardinality, owner_end_attribute_name = serialize_owned_type(xmi_id, link, linke_owner_name)
if member_end && ((member_end_type != 'aggregation') || (member_end_type == 'aggregation' && member_end_attribute_name))
doc_node_name = link_member_name == "start" ? "source" : "target"
definition_node = main_model.xpath(%(//connector[@xmi:idref="#{link['xmi:id']}"]/#{doc_node_name}/documentation)).first
definition = definition_node.attributes['value']&.value if definition_node
@@ -140,11 +140,13 @@
xmi_id: link["xmi:id"],
member_end: member_end,
member_end_type: member_end_type,
member_end_cardinality: member_end_cardinality,
member_end_attribute_name: member_end_attribute_name,
+ member_end_xmi_id: member_end_xmi_id,
owner_end: owner_end,
+ owner_end_xmi_id: xmi_id,
definition: definition
}
end
end.uniq
end
@@ -243,11 +245,11 @@
member_end_cardinality = { "min" => cardinality_min_value(assoc), "max" => cardinality_max_value(assoc) }
member_end_attribute_name = assoc.attributes["name"]&.value
end
end
- [member_end, "aggregation", member_end_cardinality, member_end_attribute_name]
+ [member_end, "aggregation", member_end_cardinality, member_end_attribute_name, xmi_id]
end
def generalization_association(owner_xmi_id, link)
if link.attributes["start"].value == owner_xmi_id
xmi_id = link.attributes["end"].value
@@ -263,11 +265,11 @@
if member_end_node
assoc = member_end_node.parent
member_end_cardinality = { "min" => cardinality_min_value(assoc), "max" => cardinality_max_value(assoc) }
end
- [member_end, member_end_type, member_end_cardinality, nil]
+ [member_end, member_end_type, member_end_cardinality, nil, xmi_id]
end
def class_element_metadata(klass)
main_model.xpath(%(//element[@xmi:idref="#{klass['xmi:id']}"]))
end
@@ -279,9 +281,10 @@
{
# TODO: xmi_id
# xmi_id: klass['xmi:id'],
name: attribute["name"],
type: lookup_entity_name(type["xmi:idref"]) || type["xmi:idref"],
+ xmi_id: type["xmi:idref"],
is_derived: attribute["isDerived"],
cardinality: { "min" => cardinality_min_value(attribute), "max" => cardinality_max_value(attribute) },
definition: lookup_attribute_definition(attribute),
}
end