lutaml 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -6
- data/.rubocop.yml +1 -0
- data/LUTAML.adoc +372 -0
- data/Makefile +2 -0
- data/bin/console +5 -0
- data/bin/folder_yaml2lutaml.sh +6 -0
- data/bin/plantuml2lutaml +59 -0
- data/bin/yaml2lutaml +144 -0
- data/exe/lutaml-sysml +20 -0
- data/exe/lutaml-wsd2uml +59 -0
- data/exe/lutaml-yaml2uml +144 -0
- data/lib/lutaml/express/README.adoc +55 -0
- data/lib/lutaml/express/parsers/exp.rb +21 -0
- data/lib/lutaml/express/version.rb +7 -0
- data/lib/lutaml/express.rb +9 -0
- data/lib/lutaml/lutaml_path/document_wrapper.rb +7 -3
- data/lib/lutaml/parser.rb +7 -0
- data/lib/lutaml/sysml/README.md +40 -0
- data/lib/lutaml/sysml/allocate.rb +8 -0
- data/lib/lutaml/sysml/allocated.rb +7 -0
- data/lib/lutaml/sysml/binding_connector.rb +7 -0
- data/lib/lutaml/sysml/block.rb +27 -0
- data/lib/lutaml/sysml/constraint_block.rb +12 -0
- data/lib/lutaml/sysml/copy.rb +6 -0
- data/lib/lutaml/sysml/derive_requirement.rb +7 -0
- data/lib/lutaml/sysml/nested_connector_end.rb +11 -0
- data/lib/lutaml/sysml/refine.rb +7 -0
- data/lib/lutaml/sysml/requirement.rb +34 -0
- data/lib/lutaml/sysml/requirement_related.rb +7 -0
- data/lib/lutaml/sysml/satisfy.rb +7 -0
- data/lib/lutaml/sysml/test_case.rb +22 -0
- data/lib/lutaml/sysml/trace.rb +7 -0
- data/lib/lutaml/sysml/verify.rb +6 -0
- data/lib/lutaml/sysml/version.rb +5 -0
- data/lib/lutaml/sysml/xmi_file.rb +417 -0
- data/lib/lutaml/sysml.rb +10 -0
- data/lib/lutaml/uml/README.adoc +44 -0
- data/lib/lutaml/uml/abstraction.rb +11 -0
- data/lib/lutaml/uml/activity.rb +11 -0
- data/lib/lutaml/uml/actor.rb +19 -0
- data/lib/lutaml/uml/association.rb +43 -0
- data/lib/lutaml/uml/behavior.rb +11 -0
- data/lib/lutaml/uml/class.rb +83 -0
- data/lib/lutaml/uml/classifier.rb +11 -0
- data/lib/lutaml/uml/connector.rb +21 -0
- data/lib/lutaml/uml/constraint.rb +12 -0
- data/lib/lutaml/uml/constructor_end.rb +16 -0
- data/lib/lutaml/uml/data_type.rb +75 -0
- data/lib/lutaml/uml/dependency.rb +21 -0
- data/lib/lutaml/uml/diagram.rb +8 -0
- data/lib/lutaml/uml/document.rb +81 -0
- data/lib/lutaml/uml/enum.rb +45 -0
- data/lib/lutaml/uml/event.rb +12 -0
- data/lib/lutaml/uml/final_state.rb +11 -0
- data/lib/lutaml/uml/formatter/base.rb +67 -0
- data/lib/lutaml/uml/formatter/graphviz.rb +334 -0
- data/lib/lutaml/uml/formatter.rb +21 -0
- data/lib/lutaml/uml/has_attributes.rb +14 -0
- data/lib/lutaml/uml/has_members.rb +30 -0
- data/lib/lutaml/uml/instance.rb +17 -0
- data/lib/lutaml/uml/model.rb +13 -0
- data/lib/lutaml/uml/node/base.rb +21 -0
- data/lib/lutaml/uml/node/class_node.rb +57 -0
- data/lib/lutaml/uml/node/class_relationship.rb +14 -0
- data/lib/lutaml/uml/node/document.rb +18 -0
- data/lib/lutaml/uml/node/field.rb +34 -0
- data/lib/lutaml/uml/node/has_name.rb +15 -0
- data/lib/lutaml/uml/node/has_type.rb +15 -0
- data/lib/lutaml/uml/node/method.rb +29 -0
- data/lib/lutaml/uml/node/method_argument.rb +16 -0
- data/lib/lutaml/uml/node/relationship.rb +28 -0
- data/lib/lutaml/uml/opaque_behavior.rb +11 -0
- data/lib/lutaml/uml/operation.rb +31 -0
- data/lib/lutaml/uml/package.rb +53 -0
- data/lib/lutaml/uml/parsers/attribute.rb +70 -0
- data/lib/lutaml/uml/parsers/dsl.rb +413 -0
- data/lib/lutaml/uml/parsers/dsl_preprocessor.rb +59 -0
- data/lib/lutaml/uml/parsers/dsl_transform.rb +27 -0
- data/lib/lutaml/uml/parsers/yaml.rb +46 -0
- data/lib/lutaml/uml/port.rb +8 -0
- data/lib/lutaml/uml/primitive_type.rb +14 -0
- data/lib/lutaml/uml/property.rb +27 -0
- data/lib/lutaml/uml/pseudostate.rb +11 -0
- data/lib/lutaml/uml/realization.rb +11 -0
- data/lib/lutaml/uml/region.rb +12 -0
- data/lib/lutaml/uml/serializers/association.rb +58 -0
- data/lib/lutaml/uml/serializers/base.rb +16 -0
- data/lib/lutaml/uml/serializers/class.rb +29 -0
- data/lib/lutaml/uml/serializers/top_element_attribute.rb +14 -0
- data/lib/lutaml/uml/serializers/yaml_view.rb +18 -0
- data/lib/lutaml/uml/state.rb +12 -0
- data/lib/lutaml/uml/state_machine.rb +12 -0
- data/lib/lutaml/uml/top_element.rb +58 -0
- data/lib/lutaml/uml/top_element_attribute.rb +39 -0
- data/lib/lutaml/uml/transition.rb +12 -0
- data/lib/lutaml/uml/trigger.rb +12 -0
- data/lib/lutaml/uml/value.rb +31 -0
- data/lib/lutaml/uml/version.rb +7 -0
- data/lib/lutaml/uml/vertex.rb +11 -0
- data/lib/lutaml/uml.rb +13 -0
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/README.adoc +24 -0
- data/lib/lutaml/xmi/parsers/xml.rb +600 -0
- data/lib/lutaml/xmi/version.rb +5 -0
- data/lib/lutaml/xmi.rb +7 -0
- data/lib/lutaml/xml/lutaml_path/document_wrapper.rb +45 -0
- data/lib/lutaml/xml/mapper.rb +448 -0
- data/lib/lutaml/xml/parsers/xml.rb +57 -0
- data/lib/lutaml/xml.rb +9 -0
- data/lutaml.gemspec +8 -3
- metadata +192 -16
@@ -0,0 +1,417 @@
|
|
1
|
+
module Lutaml::SysMl
|
2
|
+
|
3
|
+
class XmiFile
|
4
|
+
|
5
|
+
attr_accessor :package_list, :model_list, :class_list, :activity_list, :property_list, :port_list, :datatype_list, :instance_list,
|
6
|
+
:realization_list, :abstraction_list, :association_list , :connector_list, :connectorend_list, :constraint_list, :block_list , :constraintblock_list,
|
7
|
+
:requirement_list, :testcase_list, :binding_connector_list, :nested_connectorend_list, :derive_requirement_list,
|
8
|
+
:refine_requirement_list, :trace_requirement_list, :copy_requirement_list, :verify_requirement_list, :satisfy_requirement_list ,
|
9
|
+
:allocate_requirement_list, :element_hash
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@package_list = []
|
13
|
+
@model_list = []
|
14
|
+
@class_list = []
|
15
|
+
@activity_list = []
|
16
|
+
@property_list = []
|
17
|
+
@port_list = []
|
18
|
+
@datatype_list = []
|
19
|
+
@instance_list = []
|
20
|
+
@realization_list = []
|
21
|
+
@abstraction_list = []
|
22
|
+
@association_list = []
|
23
|
+
@connector_list = []
|
24
|
+
@connectorend_list = []
|
25
|
+
@constraint_list = []
|
26
|
+
|
27
|
+
@block_list = []
|
28
|
+
@constraintblock_list = []
|
29
|
+
@requirement_list = []
|
30
|
+
@testcase_list = []
|
31
|
+
@binding_connector_list = []
|
32
|
+
@nested_connectorend_list = []
|
33
|
+
@derive_requirement_list = []
|
34
|
+
@refine_requirement_list = []
|
35
|
+
@trace_requirement_list = []
|
36
|
+
@copy_requirement_list = []
|
37
|
+
@verify_requirement_list = []
|
38
|
+
@satisfy_requirement_list = []
|
39
|
+
@allocate_requirement_list = []
|
40
|
+
|
41
|
+
@element_hash = Hash.new
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse (filename)
|
45
|
+
xmifile = File.new(filename, "r")
|
46
|
+
inxml = Nokogiri::XML(xmifile)
|
47
|
+
|
48
|
+
xmi_elements = inxml.xpath('//xmi:XMI')
|
49
|
+
if xmi_elements.size == 0
|
50
|
+
puts "ERROR : File contains no 'xmi:XMI' XML elements : #{filename}, may not be XMI file."
|
51
|
+
xmifile.close
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
55
|
+
#setup xmi namespace
|
56
|
+
xmiNS = inxml.root.namespace_definitions.find{|ns| ns.prefix=="xmi"}
|
57
|
+
|
58
|
+
## Step 1: Find UML and SysML Core Objects in XMI file and create as instance of metamodel
|
59
|
+
|
60
|
+
for xml_node in inxml.xpath('//*' )
|
61
|
+
element_new = nil
|
62
|
+
|
63
|
+
if xml_node.name.to_s == 'packagedElement' and xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Package'
|
64
|
+
element_new = Lutaml::Uml::Package.new
|
65
|
+
package_list.push element_new
|
66
|
+
end
|
67
|
+
|
68
|
+
if xml_node.name.to_s == 'Model'
|
69
|
+
element_new = Lutaml::Uml::Model.new
|
70
|
+
model_list.push element_new
|
71
|
+
element_new.viewpoint = xml_node['viewpoint']
|
72
|
+
element_new.href = xml_node['href']
|
73
|
+
end
|
74
|
+
|
75
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Class'
|
76
|
+
element_new = Lutaml::Uml::Class.new
|
77
|
+
if xml_node['isAbstract'] != nil
|
78
|
+
element_new.is_abstract = xml_node['isAbstract'] == 'true'
|
79
|
+
end
|
80
|
+
class_list.push element_new
|
81
|
+
end
|
82
|
+
|
83
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Activity'
|
84
|
+
element_new = Lutaml::Uml::Activity.new
|
85
|
+
activity_list.push element_new
|
86
|
+
end
|
87
|
+
|
88
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Property'
|
89
|
+
element_new = Lutaml::Uml::Property.new
|
90
|
+
property_list.push element_new
|
91
|
+
end
|
92
|
+
|
93
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s== 'uml:InstanceSpecification'
|
94
|
+
element_new = Lutaml::Uml::Instance.new
|
95
|
+
instance_list.push element_new
|
96
|
+
end
|
97
|
+
|
98
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:DataType'
|
99
|
+
element_new = Lutaml::Uml::DataType.new
|
100
|
+
datatype_list.push element_new
|
101
|
+
end
|
102
|
+
|
103
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Port'
|
104
|
+
element_new = Lutaml::Uml::Port.new
|
105
|
+
port_list.push element_new
|
106
|
+
end
|
107
|
+
|
108
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Connector'
|
109
|
+
element_new = Lutaml::Uml::Connector.new
|
110
|
+
connector_list.push element_new
|
111
|
+
end
|
112
|
+
|
113
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:ConnectorEnd'
|
114
|
+
element_new = Lutaml::Uml::ConnectorEnd.new
|
115
|
+
connectorend_list.push element_new
|
116
|
+
end
|
117
|
+
|
118
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Constraint'
|
119
|
+
element_new = Lutaml::Uml::Constraint.new
|
120
|
+
constraint_list.push element_new
|
121
|
+
end
|
122
|
+
|
123
|
+
if xml_node.name.to_s == 'Block'
|
124
|
+
element_new = SYSML::Block.new
|
125
|
+
block_list.push element_new
|
126
|
+
end
|
127
|
+
|
128
|
+
if xml_node.name.to_s == 'Template'
|
129
|
+
element_new = SYSML::Block.new
|
130
|
+
block_list.push element_new
|
131
|
+
end
|
132
|
+
|
133
|
+
if xml_node.name.to_s == 'ConstraintBlock'
|
134
|
+
element_new = SYSML::ConstraintBlock.new
|
135
|
+
constraintblock_list.push element_new
|
136
|
+
end
|
137
|
+
|
138
|
+
if xml_node.name.to_s.index('Requirement') or xml_node.name.to_s == 'designConstraint'
|
139
|
+
if xml_node.name.to_s != 'RequirementRelated'
|
140
|
+
element_new = SYSML::Requirement.new
|
141
|
+
requirement_list.push element_new
|
142
|
+
element_new.id = xml_node.attribute_with_ns('id',xmiNS.href).to_s.strip
|
143
|
+
element_new.text = xml_node['Text']
|
144
|
+
if xml_node.name != 'Requirement'
|
145
|
+
element_new.stereotype.push xml_node.name
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
if xml_node.name.to_s == 'TestCase'
|
151
|
+
element_new = SYSML::TestCase.new
|
152
|
+
testcase_list.push element_new
|
153
|
+
end
|
154
|
+
|
155
|
+
if xml_node.name.to_s == 'BindingConnector'
|
156
|
+
element_new = SYSML::BindingConnector.new
|
157
|
+
binding_connector_list.push element_new
|
158
|
+
end
|
159
|
+
|
160
|
+
if xml_node.name.to_s == 'NestedConnectorEnd'
|
161
|
+
element_new = SYSML::NestedConnectorEnd.new
|
162
|
+
nested_connectorend_list.push element_new
|
163
|
+
end
|
164
|
+
|
165
|
+
if xml_node.name.to_s == 'DeriveReqt'
|
166
|
+
element_new = SYSML::DeriveRequirement.new
|
167
|
+
derive_requirement_list.push element_new
|
168
|
+
end
|
169
|
+
if xml_node.name.to_s == 'refine'
|
170
|
+
element_new = SYSML::Refine.new
|
171
|
+
refine_requirement_list.push element_new
|
172
|
+
end
|
173
|
+
if xml_node.name.to_s == 'trace'
|
174
|
+
element_new = SYSML::Trace.new
|
175
|
+
trace_requirement_list.push element_new
|
176
|
+
end
|
177
|
+
if xml_node.name.to_s == 'Copy'
|
178
|
+
element_new = SYSML::Copy.new
|
179
|
+
copy_requirement_list.push element_new
|
180
|
+
end
|
181
|
+
if xml_node.name.to_s == 'Verify'
|
182
|
+
element_new = SYSML::Verify.new
|
183
|
+
verify_requirement_list.push element_new
|
184
|
+
end
|
185
|
+
if xml_node.name.to_s == 'Allocate'
|
186
|
+
element_new = SYSML::Allocate.new
|
187
|
+
allocate_requirement_list.push element_new
|
188
|
+
end
|
189
|
+
|
190
|
+
if xml_node.name.to_s == 'Satisfy'
|
191
|
+
element_new = SYSML::Satisfy.new
|
192
|
+
satisfy_requirement_list.push element_new
|
193
|
+
end
|
194
|
+
|
195
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Abstraction'
|
196
|
+
element_new = Lutaml::Uml::Abstraction.new
|
197
|
+
abstraction_list.push element_new
|
198
|
+
end
|
199
|
+
|
200
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Realization'
|
201
|
+
element_new = Lutaml::Uml::Realization.new
|
202
|
+
realization_list.push element_new
|
203
|
+
end
|
204
|
+
|
205
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Association'
|
206
|
+
element_new = Lutaml::Uml::Association.new
|
207
|
+
association_list.push element_new
|
208
|
+
end
|
209
|
+
|
210
|
+
if element_new != nil
|
211
|
+
new_xmi_id_node = xml_node.attribute_with_ns('id',xmiNS.href)
|
212
|
+
new_xmi_uuid_node = xml_node.attribute_with_ns('uuid',xmiNS.href)
|
213
|
+
new_name_node = xml_node['name']
|
214
|
+
new_href_node = xml_node['href']
|
215
|
+
|
216
|
+
if new_xmi_id_node != nil
|
217
|
+
element_new.xmi_id = new_xmi_id_node.to_s
|
218
|
+
element_hash[element_new.xmi_id] = element_new
|
219
|
+
end
|
220
|
+
|
221
|
+
if new_xmi_uuid_node != nil
|
222
|
+
element_new.xmi_uuid = new_xmi_uuid_node.to_s
|
223
|
+
end
|
224
|
+
|
225
|
+
if new_name_node != nil
|
226
|
+
element_new.name = xml_node['name'].strip
|
227
|
+
end
|
228
|
+
|
229
|
+
if new_href_node != nil
|
230
|
+
element_new.href = new_href_node.to_s
|
231
|
+
if new_xmi_id_node == nil
|
232
|
+
element_hash[element_new.href] = element_new
|
233
|
+
end
|
234
|
+
if xml_node.at('xmi:Extension/referenceExtension') != nil
|
235
|
+
element_new.name = xml_node.at('xmi:Extension/referenceExtension')['referentPath']
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
if (xml_node.parent != nil and
|
240
|
+
xml_node.parent.attribute_with_ns('id',xmiNS.href) != nil and
|
241
|
+
element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s] != nil)
|
242
|
+
|
243
|
+
parent = element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s]
|
244
|
+
element_new.namespace = parent
|
245
|
+
if parent.kind_of? Lutaml::Uml::Package
|
246
|
+
parent.contents.push element_new
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
for xml_node in inxml.xpath('//*')
|
253
|
+
|
254
|
+
if (xml_node.attribute_with_ns('id',xmiNS.href) != nil and
|
255
|
+
element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s] != nil)
|
256
|
+
|
257
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
258
|
+
end
|
259
|
+
|
260
|
+
if xml_node.name.to_s == 'nestedClassifier' and xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Class'
|
261
|
+
owning_class_xmi_id = xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s
|
262
|
+
owned_class_xmi_id = xml_node.attribute_with_ns('id',xmiNS.href).to_s
|
263
|
+
owning_class = element_hash[owning_class_xmi_id]
|
264
|
+
owned_class = element_hash[owned_class_xmi_id]
|
265
|
+
owning_class.nested_classifier.push owned_class
|
266
|
+
end
|
267
|
+
|
268
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Realization'
|
269
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
270
|
+
supplier_xmi_id = xml_node.at('supplier')['idref']
|
271
|
+
client_xmi_id = xml_node.at('client')['idref']
|
272
|
+
this_thing.supplier.push element_hash[supplier_xmi_id]
|
273
|
+
this_thing.client.push element_hash[client_xmi_id]
|
274
|
+
end
|
275
|
+
|
276
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Abstraction'
|
277
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
278
|
+
supplier_xmi_id = xml_node.at('supplier')['idref']
|
279
|
+
client_xmi_id = xml_node.at('client')['idref']
|
280
|
+
this_thing.supplier.push element_hash[supplier_xmi_id]
|
281
|
+
this_thing.client.push element_hash[client_xmi_id]
|
282
|
+
end
|
283
|
+
|
284
|
+
if xml_node.name.to_s == 'Block'
|
285
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
286
|
+
base_class_xmi_id = xml_node['base_Class']
|
287
|
+
this_thing.base_class = element_hash[base_class_xmi_id]
|
288
|
+
end
|
289
|
+
|
290
|
+
if xml_node.name.to_s == 'Template'
|
291
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
292
|
+
base_class_xmi_id = xml_node['base_Class']
|
293
|
+
this_thing.base_class = element_hash[base_class_xmi_id]
|
294
|
+
this_thing.base_class.stereotype.push 'Template'
|
295
|
+
end
|
296
|
+
|
297
|
+
if xml_node.name.to_s == 'ConstraintBlock'
|
298
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
299
|
+
base_class_xmi_id = xml_node['base_Class']
|
300
|
+
this_thing.base_class = element_hash[base_class_xmi_id]
|
301
|
+
end
|
302
|
+
|
303
|
+
if xml_node.name.to_s.index('Requirement') or xml_node.name.to_s == 'designConstraint'
|
304
|
+
if xml_node.name.to_s != 'RequirementRelated'
|
305
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
306
|
+
base_class_xmi_id = xml_node['base_Class']
|
307
|
+
this_thing.base_class = element_hash[base_class_xmi_id]
|
308
|
+
this_thing.refined_by = element_hash[xml_node['RefinedBy']]
|
309
|
+
this_thing.derived_from = element_hash[xml_node['DerivedFrom']]
|
310
|
+
this_thing.traced_to = element_hash[xml_node['TracedTo']]
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
if xml_node.name.to_s == 'TestCase'
|
315
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
316
|
+
this_thing.base_behavior = element_hash[xml_node['base_Behavior']]
|
317
|
+
this_thing.verifies = element_hash[xml_node['Verifies']]
|
318
|
+
end
|
319
|
+
|
320
|
+
if xml_node.name.to_s == 'BindingConnector'
|
321
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
322
|
+
base_connector_xmi_id = xml_node['base_Connector']
|
323
|
+
this_thing.base_connector = element_hash[base_connector_xmi_id]
|
324
|
+
end
|
325
|
+
|
326
|
+
if xml_node.name.to_s == 'NestedConnectorEnd'
|
327
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
328
|
+
base_connectorend_xmi_id = xml_node['base_ConnectorEnd']
|
329
|
+
this_thing.base_connectorend = element_hash[base_connectorend_xmi_id]
|
330
|
+
if xml_node['propertyPath'] != nil
|
331
|
+
this_thing.property_path.push element_hash[xml_node['propertyPath']]
|
332
|
+
else
|
333
|
+
for prop_path in xml_node.xpath('./propertyPath')
|
334
|
+
#to deal with href = '#xmi:id' i.e. local references
|
335
|
+
href_parts = prop_path['href'].split('#')
|
336
|
+
if href_parts[0].size == 0
|
337
|
+
prop = element_hash[href_parts[1]]
|
338
|
+
else
|
339
|
+
prop = element_hash[prop_path['href']]
|
340
|
+
end
|
341
|
+
this_thing.property_path.push prop
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
if xml_node.name.to_s == 'Satisfy'
|
347
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
348
|
+
base_realization_xmi_id = xml_node['base_Realization']
|
349
|
+
this_thing.base_realization = element_hash[base_realization_xmi_id]
|
350
|
+
end
|
351
|
+
|
352
|
+
if ['DeriveReqt', 'refine', 'trace', 'Copy', 'Verify', 'Allocate', ''].include? xml_node.name.to_s
|
353
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
354
|
+
base_abstraction_xmi_id = xml_node['base_Abstraction']
|
355
|
+
this_thing.base_abstraction = element_hash[base_abstraction_xmi_id]
|
356
|
+
end
|
357
|
+
|
358
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Association'
|
359
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
360
|
+
member_end_list = xml_node.xpath('./memberEnd')
|
361
|
+
for item in member_end_list
|
362
|
+
this_thing.member_end.push element_hash[item['idref']]
|
363
|
+
end
|
364
|
+
owned_end_list = xml_node.xpath('./ownedEnd')
|
365
|
+
for item in owned_end_list
|
366
|
+
this_thing.owned_end.push element_hash[item.attribute_with_ns('id',xmiNS.href).to_s]
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Property' or xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Port'
|
371
|
+
if not ['definingFeature', 'partWithPort', 'propertyPath', 'role'].include? xml_node.name.to_s
|
372
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
373
|
+
if xml_node['association'] != nil
|
374
|
+
this_thing.association = element_hash[xml_node['association']]
|
375
|
+
end
|
376
|
+
if xml_node['aggregation'] != nil
|
377
|
+
this_thing.aggregation = xml_node['aggregation']
|
378
|
+
end
|
379
|
+
if xml_node['visibility'] != nil
|
380
|
+
this_thing.visibility = xml_node['visibility']
|
381
|
+
end
|
382
|
+
|
383
|
+
if xml_node.at('lowerValue') != nil
|
384
|
+
|
385
|
+
if xml_node.at('lowerValue')['value'] != nil
|
386
|
+
this_thing.lowerValue = xml_node.at('lowerValue')['value']
|
387
|
+
else
|
388
|
+
this_thing.lowerValue = '0'
|
389
|
+
end
|
390
|
+
end
|
391
|
+
if xml_node.at('upperValue') != nil
|
392
|
+
this_thing.upperValue = xml_node.at('upperValue')['value']
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:Connector'
|
398
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
399
|
+
connector_end_list = xml_node.xpath('./end')
|
400
|
+
for end_xml_node in connector_end_list
|
401
|
+
this_thing.connector_end.push element_hash[end_xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
405
|
+
if xml_node.attribute_with_ns('type',xmiNS.href).to_s == 'uml:ConnectorEnd'
|
406
|
+
this_thing = element_hash[xml_node.attribute_with_ns('id',xmiNS.href).to_s]
|
407
|
+
this_thing.connector = element_hash[xml_node.parent.attribute_with_ns('id',xmiNS.href).to_s]
|
408
|
+
this_thing.role = element_hash[xml_node['role']]
|
409
|
+
if this_thing.role == nil
|
410
|
+
this_thing.role = element_hash[xml_node.at('role')['href']]
|
411
|
+
end
|
412
|
+
this_thing.part_with_port = element_hash[xml_node['part_with_port']]
|
413
|
+
end
|
414
|
+
end
|
415
|
+
end
|
416
|
+
end
|
417
|
+
end
|
data/lib/lutaml/sysml.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Lutaml::Uml
|
2
|
+
|
3
|
+
image:https://badge.fury.io/rb/lutaml-uml.svg["Gem Version", link="https://badge.fury.io/rb/lutaml-uml"]
|
4
|
+
|
5
|
+
image:https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml/badge.svg["macos", link="https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml"]
|
6
|
+
image:https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml/badge.svg["ubuntu", link="https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml"]
|
7
|
+
image:https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml/badge.svg["windows", link="https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml"]
|
8
|
+
|
9
|
+
Lutaml is a language for specifying UML class diagrams and a tool for converting it into various different formats.
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
### Bundler: `gem "lutaml-uml"`
|
14
|
+
|
15
|
+
### RubyGems: `gem install lutaml-uml`
|
16
|
+
|
17
|
+
## Language
|
18
|
+
|
19
|
+
See link:LUTAML.adoc[LUTAML.adoc]
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Converter executables are available:
|
24
|
+
|
25
|
+
* PlantUML WSD to LutaML UML: `lutaml-wsd2uml`
|
26
|
+
* LutaML YAML to LutaML UML: `lutaml-yaml2uml`
|
27
|
+
|
28
|
+
EXAMPLE: `lutaml-wsd2uml mn/metanorma-model-standoc/models/StandardDoc_Blocks_New.wsd`
|
29
|
+
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml-uml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
|
40
|
+
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Lutaml::Uml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## Behaviour metamodel
|
5
|
+
##
|
6
|
+
|
7
|
+
module Lutaml
|
8
|
+
module Uml
|
9
|
+
class Actor < Classifier
|
10
|
+
def initialize
|
11
|
+
@name = nil
|
12
|
+
@xmi_id = nil
|
13
|
+
@stereotype = []
|
14
|
+
@generalization = []
|
15
|
+
@namespace = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lutaml
|
4
|
+
module Uml
|
5
|
+
class Association < TopElement
|
6
|
+
include HasMembers
|
7
|
+
|
8
|
+
attr_accessor :owner_end,
|
9
|
+
:owner_end_attribute_name,
|
10
|
+
:owner_end_cardinality,
|
11
|
+
:owner_end_type,
|
12
|
+
:owner_end_xmi_id,
|
13
|
+
:member_end,
|
14
|
+
:member_end_attribute_name,
|
15
|
+
:member_end_xmi_id,
|
16
|
+
:member_end_cardinality,
|
17
|
+
:member_end_type,
|
18
|
+
:static,
|
19
|
+
:action
|
20
|
+
|
21
|
+
# TODO: move to Parslet::Transform
|
22
|
+
def members=(value)
|
23
|
+
value.group_by { |member| member.keys.first }
|
24
|
+
.each do |(type, group)|
|
25
|
+
if %w[owner_end member_end].include?(type)
|
26
|
+
group.each do |member|
|
27
|
+
member.each_pair do |key, member_value|
|
28
|
+
public_send("#{associtaion_type(key)}=", member_value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
next
|
32
|
+
end
|
33
|
+
attribute_value = group.map(&:values).flatten
|
34
|
+
if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash)
|
35
|
+
next public_send("#{associtaion_type(type)}=", attribute_value.first)
|
36
|
+
end
|
37
|
+
|
38
|
+
public_send("#{associtaion_type(type)}=", attribute_value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "lutaml/uml/classifier"
|
4
|
+
|
5
|
+
require "lutaml/uml/has_members"
|
6
|
+
require "lutaml/uml/association"
|
7
|
+
require "lutaml/uml/constraint"
|
8
|
+
require "lutaml/uml/data_type"
|
9
|
+
require "lutaml/uml/operation"
|
10
|
+
require "lutaml/uml/top_element_attribute"
|
11
|
+
|
12
|
+
module Lutaml
|
13
|
+
module Uml
|
14
|
+
class Class < Classifier
|
15
|
+
include HasMembers
|
16
|
+
|
17
|
+
attr_accessor :nested_classifier,
|
18
|
+
:is_abstract,
|
19
|
+
:type,
|
20
|
+
:package
|
21
|
+
|
22
|
+
attr_reader :associations,
|
23
|
+
:attributes,
|
24
|
+
:members,
|
25
|
+
:modifier,
|
26
|
+
:constraints,
|
27
|
+
:operations,
|
28
|
+
:data_types
|
29
|
+
|
30
|
+
def initialize(attributes = {})
|
31
|
+
@nested_classifier = []
|
32
|
+
@stereotype = []
|
33
|
+
@generalization = []
|
34
|
+
@is_abstract = false
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def modifier=(value)
|
39
|
+
@modifier = value.to_s # TODO: Validate?
|
40
|
+
end
|
41
|
+
|
42
|
+
def attributes=(value)
|
43
|
+
@attributes = value.to_a.map do |attr|
|
44
|
+
TopElementAttribute.new(attr)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def associations=(value)
|
49
|
+
@associations = value.to_a.map do |attr|
|
50
|
+
Association.new(attr.to_h.merge(owner_end: name))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def constraints=(value)
|
55
|
+
@constraints = value.to_a.map do |attr|
|
56
|
+
Constraint.new(attr)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def operations=(value)
|
61
|
+
@operations = value.to_a.map do |attr|
|
62
|
+
Operation.new(attr)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def data_types=(value)
|
67
|
+
@data_types = value.to_a.map do |attr|
|
68
|
+
DataType.new(attr)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def methods
|
73
|
+
# @members&.select { |member| member.class == Method }
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
|
77
|
+
def relationships
|
78
|
+
# @members&.select { |member| member.class == ClassRelationship }
|
79
|
+
[]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## Behaviour metamodel
|
5
|
+
##
|
6
|
+
module Lutaml
|
7
|
+
module Uml
|
8
|
+
class Connector < TopElement
|
9
|
+
attr_accessor :kind, :connector_end
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@name = nil
|
13
|
+
@xmi_id = nil
|
14
|
+
@xmi_uuid = nil
|
15
|
+
@connector_end = []
|
16
|
+
@namespace = nil
|
17
|
+
@kind = nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|