lutaml-xmi 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lutaml/xmi/parsers/xml.rb +19 -13
- data/lib/lutaml/xmi/version.rb +1 -1
- data/spec/lutaml/parsers/xmi_spec.rb +0 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00fbd8ecac2e908005b2e8721296f5ad95c49bd164b32bc9954e8bf94d82ad18
|
4
|
+
data.tar.gz: 14e0bffadfb34e0980fba6d535576b3fff50b663c2f26f3174b1ab908a1883d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 432706c232ea18b66169dad9ce3a5f25612824563cde18484b3e83bab07804a503b7c145e62c67d0516e0b3ea83f38e6ed7fda461ee88b5d4a0a9a153142a300
|
7
|
+
data.tar.gz: 40d9499f0866b91bd5b04a8d2e47b0b894c82f6a129893f8b0d1f57e15ac37981d9a12c87b14f5f2acb0bbd6e4dd797ed910d28379f159bafed63e187947857d
|
@@ -127,10 +127,13 @@ module Lutaml
|
|
127
127
|
def serialize_model_associations(klass)
|
128
128
|
xmi_id = klass["xmi:id"]
|
129
129
|
main_model.xpath(%(//element[@xmi:idref="#{xmi_id}"]/links/*)).map do |link|
|
130
|
-
|
131
|
-
|
130
|
+
link_member_name = link.attributes["start"].value == xmi_id ? "end" : "start"
|
131
|
+
linke_owner_name = link_member_name == "start" ? "end" : "start"
|
132
|
+
member_end, member_end_type, member_end_cardinality, member_end_attribute_name = serialize_member_type(xmi_id, link, link_member_name)
|
133
|
+
owner_end, owner_end_cardinality, owner_end_attribute_name = serialize_owned_type(xmi_id, link, linke_owner_name)
|
132
134
|
if member_end && ((member_end_type != 'aggregation') || (member_end_type == 'aggregation' && member_end_attribute_name))
|
133
|
-
|
135
|
+
doc_node_name = link_member_name == "start" ? "source" : "target"
|
136
|
+
definition_node = main_model.xpath(%(//connector[@xmi:idref="#{link['xmi:id']}"]/#{doc_node_name}/documentation)).first
|
134
137
|
definition = definition_node.attributes['value']&.value if definition_node
|
135
138
|
{
|
136
139
|
xmi_id: link["xmi:id"],
|
@@ -138,6 +141,7 @@ module Lutaml
|
|
138
141
|
member_end_type: member_end_type,
|
139
142
|
member_end_cardinality: member_end_cardinality,
|
140
143
|
member_end_attribute_name: member_end_attribute_name,
|
144
|
+
owner_end: owner_end,
|
141
145
|
definition: definition
|
142
146
|
}
|
143
147
|
end
|
@@ -167,11 +171,12 @@ module Lutaml
|
|
167
171
|
end
|
168
172
|
end
|
169
173
|
|
170
|
-
def serialize_owned_type(
|
174
|
+
def serialize_owned_type(owner_xmi_id, link, linke_owner_name)
|
171
175
|
return if link.name == 'NoteLink'
|
172
|
-
return generalization_association(
|
176
|
+
return generalization_association(owner_xmi_id, link) if link.name == "Generalization"
|
173
177
|
|
174
|
-
xmi_id = link.attributes[
|
178
|
+
xmi_id = link.attributes[linke_owner_name].value
|
179
|
+
owner_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
|
175
180
|
|
176
181
|
if link.name == "Association"
|
177
182
|
assoc_connector = main_model.xpath(%(//connector[@xmi:idref="#{link['xmi:id']}"]/source)).first
|
@@ -197,18 +202,19 @@ module Lutaml
|
|
197
202
|
end
|
198
203
|
end
|
199
204
|
|
200
|
-
[owned_cardinality, owned_attribute_name]
|
205
|
+
[owner_end, owned_cardinality, owned_attribute_name]
|
201
206
|
end
|
202
207
|
|
203
|
-
def serialize_member_type(
|
208
|
+
def serialize_member_type(owner_xmi_id, link, link_member_name)
|
204
209
|
return if link.name == 'NoteLink'
|
205
|
-
return generalization_association(
|
210
|
+
return generalization_association(owner_xmi_id, link) if link.name == "Generalization"
|
206
211
|
|
207
|
-
xmi_id = link.attributes[
|
212
|
+
xmi_id = link.attributes[link_member_name].value
|
208
213
|
member_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
|
209
214
|
|
210
215
|
if link.name == "Association"
|
211
|
-
|
216
|
+
connector_type = link_member_name == "start" ? "source" : "target"
|
217
|
+
assoc_connector = main_model.xpath(%(//connector[@xmi:idref="#{link['xmi:id']}"]/#{connector_type})).first
|
212
218
|
if assoc_connector
|
213
219
|
connector_type = assoc_connector.children.find { |node| node.name == 'type' }
|
214
220
|
if connector_type && connector_type.attributes['multiplicity']
|
@@ -234,8 +240,8 @@ module Lutaml
|
|
234
240
|
[member_end, "aggregation", member_end_cardinality, member_end_attribute_name]
|
235
241
|
end
|
236
242
|
|
237
|
-
def generalization_association(
|
238
|
-
if link.attributes["start"].value ==
|
243
|
+
def generalization_association(owner_xmi_id, link)
|
244
|
+
if link.attributes["start"].value == owner_xmi_id
|
239
245
|
xmi_id = link.attributes["end"].value
|
240
246
|
member_end_type = "inheritance"
|
241
247
|
member_end = lookup_entity_name(xmi_id) || connector_target_name(xmi_id)
|
data/lib/lutaml/xmi/version.rb
CHANGED
@@ -88,7 +88,6 @@ RSpec.describe Lutaml::XMI::Parsers::XML do
|
|
88
88
|
end
|
89
89
|
let(:expected_association_names) do
|
90
90
|
%w[
|
91
|
-
TemporalGeometricPrimitive
|
92
91
|
Primitive
|
93
92
|
TemporalGeometry
|
94
93
|
Interval
|
@@ -133,11 +132,6 @@ RSpec.describe Lutaml::XMI::Parsers::XML do
|
|
133
132
|
inheritance = klass.associations.find { |entity| entity.member_end == 'TemporalGeometry' }
|
134
133
|
expect(inheritance.member_end_type).to eq('inheritance')
|
135
134
|
expect(inheritance.member_end_cardinality).to eq({"min"=>"C", "max"=>"*"})
|
136
|
-
|
137
|
-
aggregation = klass.associations.find { |entity| entity.member_end == 'TemporalGeometricPrimitive' }
|
138
|
-
expect(aggregation.member_end_attribute_name).to eq('element')
|
139
|
-
expect(aggregation.member_end_type).to eq('aggregation')
|
140
|
-
expect(aggregation.member_end_cardinality).to eq({"min"=>"C", "max"=>"*"})
|
141
135
|
end
|
142
136
|
|
143
137
|
it "correctly parses diagrams for package" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml-xmi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|