lutaml-xmi 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 629f979aa19a9752da8b4c75d763fc4b7cb2bb7e8c94ecf99080f6b69cc7cb91
4
- data.tar.gz: 3d43008c0fdf0cba05f2266129aaa6e2f1e3d3ca21ecde1e0226d1dd9f6e3b09
3
+ metadata.gz: 5f4a8a80a350203d62586a60fb8b4c4021251953dc7cf6840b79433b164149e4
4
+ data.tar.gz: aac4b122d79b8d83dac436363dbd062ff5286b330c2bd106db5f1ab952e0f06b
5
5
  SHA512:
6
- metadata.gz: 35c6eaef31f0041dca19d776f6dde6150aafa50cfd7bc24c0fbab21deb5d7bd9193ba87df698ebda194c2ad58c58c6daf1880a2a09d3b961786cb786b7601b0e
7
- data.tar.gz: 70294ad01b275265d8106690cb34ee82694546f1746bbb9cae24d2b14041f2194d09025c2eea932be994b529300566519b8dd85fb9ff65d859f2e66bcfb2f9ca
6
+ metadata.gz: 6dcb83373821cf4d5859180ecebe65e24c75e903f0d44a8b97d87c67ded4ef0eb51894a6cc43dc64d2b3d6bbd0a6abcadee207d8d5c2457e076f4189e4f39f52
7
+ data.tar.gz: 74fa008e8ce12702db9a66afc9ce1aaf7e34b05fea9def10e09898fc750ea99b119218765c55bcfd0ec75a78b09aea94602837478247ec32d9f1842e32fa3f67
@@ -91,13 +91,15 @@ module Lutaml
91
91
  xmi_id = klass["xmi:id"]
92
92
  main_model.xpath(%(//element[@xmi:idref="#{xmi_id}"]/links/*)).map do |link|
93
93
  member_end, member_end_type, member_end_cardinality, member_end_attribute_name = serialize_member_type(xmi_id, link)
94
- {
95
- xmi_id: link["xmi:id"],
96
- member_end: member_end,
97
- member_end_type: member_end_type,
98
- member_end_cardinality: member_end_cardinality,
99
- member_end_attribute_name: member_end_attribute_name,
100
- }
94
+ if member_end && member_end != klass["name"]
95
+ {
96
+ xmi_id: link["xmi:id"],
97
+ member_end: member_end,
98
+ member_end_type: member_end_type,
99
+ member_end_cardinality: member_end_cardinality,
100
+ member_end_attribute_name: member_end_attribute_name,
101
+ }
102
+ end
101
103
  end
102
104
  end
103
105
 
@@ -111,6 +113,7 @@ module Lutaml
111
113
  end
112
114
 
113
115
  def serialize_member_type(owned_xmi_id, link)
116
+ return if link.name == 'NoteLink'
114
117
  return generalization_association(owned_xmi_id, link) if link.name == "Generalization"
115
118
 
116
119
  xmi_id = link.attributes["start"].value
@@ -135,11 +138,12 @@ module Lutaml
135
138
  if link.attributes["start"].value == owned_xmi_id
136
139
  xmi_id = link.attributes["end"].value
137
140
  member_end_type = "inheritance"
141
+ member_end = lookup_entity_name(xmi_id) || connector_target_name(xmi_id)
138
142
  else
139
143
  xmi_id = link.attributes["start"].value
140
144
  member_end_type = "generalization"
145
+ member_end = lookup_entity_name(xmi_id) || connector_source_name(xmi_id)
141
146
  end
142
- member_end = lookup_entity_name(xmi_id)
143
147
 
144
148
  member_end_node = main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first
145
149
  if member_end_node
@@ -203,7 +207,7 @@ module Lutaml
203
207
  end
204
208
 
205
209
  def lookup_entity_name(xmi_id)
206
- xmi_cache[xmi_id] ||= model_node_name_by_xmi_id(xmi_id) || connector_source_name(xmi_id)
210
+ xmi_cache[xmi_id] ||= model_node_name_by_xmi_id(xmi_id)
207
211
  xmi_cache[xmi_id]
208
212
  end
209
213
 
@@ -214,6 +218,13 @@ module Lutaml
214
218
  node.attributes["name"]&.value
215
219
  end
216
220
 
221
+ def connector_target_name(xmi_id)
222
+ node = main_model.xpath(%(//target[@xmi:idref="#{xmi_id}"]/model)).first
223
+ return unless node
224
+
225
+ node.attributes["name"]&.value
226
+ end
227
+
217
228
  def model_node_name_by_xmi_id(xmi_id)
218
229
  node = main_model.xpath(%(//*[@xmi:id="#{xmi_id}"])).first
219
230
  return unless node
@@ -1,5 +1,5 @@
1
1
  module Lutaml
2
2
  module XMI
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
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.1.2
4
+ version: 0.1.3
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-04-14 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie