lutaml 0.9.39 → 0.9.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +7 -1
- data/docs/lutaml-express.adoc +35 -0
- data/docs/lutaml-sysml.adoc +10 -0
- data/docs/lutaml-uml.adoc +111 -0
- data/docs/lutaml-xmi.adoc +33 -0
- data/exe/lutaml-yaml2uml +1 -1
- data/lib/lutaml/command_line.rb +1 -1
- data/lib/lutaml/converter/dsl_to_uml.rb +235 -0
- data/lib/lutaml/converter/xmi_hash_to_uml.rb +196 -0
- data/lib/lutaml/express.rb +0 -1
- data/lib/lutaml/formatter/base.rb +7 -7
- data/lib/lutaml/formatter/graphviz.rb +19 -8
- data/lib/lutaml/formatter.rb +0 -2
- data/lib/lutaml/parser.rb +1 -1
- data/lib/lutaml/sysml/allocate.rb +1 -1
- data/lib/lutaml/sysml/allocated.rb +1 -1
- data/lib/lutaml/sysml/binding_connector.rb +1 -1
- data/lib/lutaml/sysml/block.rb +1 -1
- data/lib/lutaml/sysml/constraint_block.rb +1 -1
- data/lib/lutaml/sysml/copy.rb +1 -1
- data/lib/lutaml/sysml/derive_requirement.rb +1 -1
- data/lib/lutaml/sysml/nested_connector_end.rb +1 -1
- data/lib/lutaml/sysml/refine.rb +1 -1
- data/lib/lutaml/sysml/requirement_related.rb +1 -1
- data/lib/lutaml/sysml/satisfy.rb +1 -1
- data/lib/lutaml/sysml/test_case.rb +1 -1
- data/lib/lutaml/sysml/trace.rb +1 -1
- data/lib/lutaml/sysml/verify.rb +1 -1
- data/lib/lutaml/sysml/xmi_file.rb +1 -1
- data/lib/lutaml/sysml.rb +0 -1
- data/lib/lutaml/uml/action.rb +15 -0
- data/lib/lutaml/uml/actor.rb +0 -8
- data/lib/lutaml/uml/association.rb +25 -34
- data/lib/lutaml/uml/cardinality.rb +10 -0
- data/lib/lutaml/uml/class.rb +43 -68
- data/lib/lutaml/uml/classifier.rb +5 -3
- data/lib/lutaml/uml/connector.rb +5 -8
- data/lib/lutaml/uml/connector_end.rb +20 -0
- data/lib/lutaml/uml/constraint.rb +11 -1
- data/lib/lutaml/uml/data_type.rb +48 -64
- data/lib/lutaml/uml/dependency.rb +5 -8
- data/lib/lutaml/uml/document.rb +46 -73
- data/lib/lutaml/uml/enum.rb +12 -35
- data/lib/lutaml/uml/event.rb +0 -1
- data/lib/lutaml/uml/fidelity.rb +10 -0
- data/lib/lutaml/uml/group.rb +17 -0
- data/lib/lutaml/uml/instance.rb +5 -7
- data/lib/lutaml/uml/model.rb +3 -3
- data/lib/lutaml/uml/namespace.rb +10 -0
- data/lib/lutaml/uml/node/base.rb +1 -1
- data/lib/lutaml/uml/operation.rb +6 -22
- data/lib/lutaml/uml/package.rb +23 -44
- data/lib/lutaml/uml/parsers/dsl.rb +5 -2
- data/lib/lutaml/uml/parsers/yaml.rb +2 -28
- data/lib/lutaml/uml/primitive_type.rb +3 -4
- data/lib/lutaml/uml/property.rb +15 -17
- data/lib/lutaml/uml/region.rb +0 -1
- data/lib/lutaml/uml/state.rb +9 -1
- data/lib/lutaml/uml/state_machine.rb +0 -1
- data/lib/lutaml/uml/top_element.rb +61 -39
- data/lib/lutaml/uml/top_element_attribute.rb +33 -22
- data/lib/lutaml/uml/transition.rb +11 -1
- data/lib/lutaml/uml/trigger.rb +5 -1
- data/lib/lutaml/uml/value.rb +18 -14
- data/lib/lutaml/uml.rb +40 -2
- data/lib/lutaml/version.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/enum_drop.rb +1 -1
- data/lib/lutaml/xmi/liquid_drops/klass_drop.rb +2 -1
- data/lib/lutaml/xmi/parsers/xmi_base.rb +20 -2
- data/lib/lutaml/xmi/parsers/xml.rb +5 -4
- metadata +15 -19
- data/lib/lutaml/express/README.adoc +0 -55
- data/lib/lutaml/express/version.rb +0 -7
- data/lib/lutaml/sysml/README.md +0 -40
- data/lib/lutaml/sysml/version.rb +0 -5
- data/lib/lutaml/uml/README.adoc +0 -44
- data/lib/lutaml/uml/constructor_end.rb +0 -16
- data/lib/lutaml/uml/formatter/base.rb +0 -67
- data/lib/lutaml/uml/formatter/graphviz.rb +0 -332
- data/lib/lutaml/uml/formatter.rb +0 -21
- data/lib/lutaml/uml/serializers/association.rb +0 -58
- data/lib/lutaml/uml/serializers/base.rb +0 -16
- data/lib/lutaml/uml/serializers/class.rb +0 -29
- data/lib/lutaml/uml/serializers/top_element_attribute.rb +0 -14
- data/lib/lutaml/uml/serializers/yaml_view.rb +0 -18
- data/lib/lutaml/uml/version.rb +0 -7
- data/lib/lutaml/xmi/README.adoc +0 -24
- /data/{LUTAML.adoc → docs/lutaml_syntax.adoc} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f621771edf0e06706b47f6ae904a914c7b70e7e1aa59deb7014b0b11e78ff44
|
4
|
+
data.tar.gz: e73b37317621f4e795637cb720c4e909f7531a92935ae5d199e06559e97092bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3742c1252a487c8a8345d24c43667be8125b764c0d035c15700fa66ac3ee938055f5b5a2d2bf83888480cae399b208c6677408d7d55174ba43ff53b16987f17
|
7
|
+
data.tar.gz: 6e92157660f166291385ee44e55c6e37178494e98aad23e19722d486611458da06bc253c16a9bdf3f16a423a38359d9589a8eab85bcc5d89e4ef4a1170806f82
|
data/README.adoc
CHANGED
@@ -26,7 +26,7 @@ Directly:
|
|
26
26
|
$ gem install lutaml
|
27
27
|
----
|
28
28
|
|
29
|
-
==
|
29
|
+
== Usages
|
30
30
|
|
31
31
|
=== Parsing
|
32
32
|
|
@@ -100,6 +100,12 @@ $ lutaml -o assets -t png test.lutaml
|
|
100
100
|
|
101
101
|
For additional info refer to `lutaml --help output`.
|
102
102
|
|
103
|
+
== Other Usages
|
104
|
+
|
105
|
+
* link:docs/lutaml-uml.adoc[Usage with Lutaml::Uml]
|
106
|
+
* link:docs/lutaml-express.adoc[Usage with Lutaml::Express]
|
107
|
+
* link:docs/lutaml-xmi.adoc[Usage with Lutaml::XMI]
|
108
|
+
// * link:docs/lutaml-sysml.adoc[Usage with Lutaml::Sysml]
|
103
109
|
|
104
110
|
== Copyright and license
|
105
111
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
= Lutaml::Express
|
2
|
+
|
3
|
+
Lutaml::Express provides functionality to parse and manipulate EXPRESS files,
|
4
|
+
enabling seamless integration with the Lutaml framework.
|
5
|
+
|
6
|
+
== Usages
|
7
|
+
|
8
|
+
The parser `Lutaml::Express::Parsers::Exp` is used to parse EXPRESS schema file
|
9
|
+
`.exp` into `Expressir::Model::Repository` model.
|
10
|
+
|
11
|
+
=== Examples
|
12
|
+
|
13
|
+
.EXPRESS schema file parsing
|
14
|
+
[example]
|
15
|
+
====
|
16
|
+
|
17
|
+
When using the `Lutaml::Express::Parsers::Exp` parser, you can parse an EXPRESS
|
18
|
+
schema file as follows:
|
19
|
+
|
20
|
+
[source,ruby]
|
21
|
+
----
|
22
|
+
require "lutaml"
|
23
|
+
|
24
|
+
Lutaml::Express::Parsers::Exp.parse(File.new("path/to/example.exp"))
|
25
|
+
# => returns Expressir::Model::Repository model
|
26
|
+
----
|
27
|
+
|
28
|
+
|
29
|
+
`Expressir::Model::Repository` is a Lutaml model that can be further processed
|
30
|
+
or converted to other formats.
|
31
|
+
|
32
|
+
Please refer to https://github.com/lutaml/expressir[expressir] or
|
33
|
+
https://github.com/lutaml/lutaml-model[lutaml-model] for more details.
|
34
|
+
|
35
|
+
====
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= Lutaml::Sysml
|
2
|
+
|
3
|
+
Lutaml::Sysml extends Lutaml::Uml by adding concepts relevant to systems
|
4
|
+
engineering, supporting a Model-Based Systems Engineering (MBSE) approach
|
5
|
+
throughout the entire system lifecycle.
|
6
|
+
|
7
|
+
== Usage
|
8
|
+
|
9
|
+
Lutaml::Sysml provides specialized diagram types and elements for systems engineering modeling.
|
10
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
= Lutaml::Uml
|
2
|
+
|
3
|
+
Lutaml::Uml is a language for specifying UML class diagrams and a tool for
|
4
|
+
converting it into various different formats.
|
5
|
+
|
6
|
+
== Language
|
7
|
+
|
8
|
+
See link:lutaml_syntax.adoc[LutaML syntax]
|
9
|
+
|
10
|
+
== Usages
|
11
|
+
|
12
|
+
Converter executables are available:
|
13
|
+
|
14
|
+
* PlantUML WSD or PUML to LutaML UML: `lutaml-wsd2uml`
|
15
|
+
* LutaML YAML to LutaML UML: `lutaml-yaml2uml`
|
16
|
+
|
17
|
+
=== Examples
|
18
|
+
|
19
|
+
.PlantUML to LutaML UML
|
20
|
+
[example]
|
21
|
+
====
|
22
|
+
|
23
|
+
Given the following PlantUML PUML file `example.puml`:
|
24
|
+
|
25
|
+
[source,plantuml]
|
26
|
+
----
|
27
|
+
@startuml
|
28
|
+
Alice -> Bob: Authentication Request
|
29
|
+
Bob --> Alice: Authentication Response
|
30
|
+
@enduml
|
31
|
+
----
|
32
|
+
|
33
|
+
Running the command:
|
34
|
+
|
35
|
+
```
|
36
|
+
lutaml-wsd2uml example.puml
|
37
|
+
```
|
38
|
+
|
39
|
+
The following results will be produced:
|
40
|
+
|
41
|
+
[source,lutaml]
|
42
|
+
----
|
43
|
+
diagram plantuml-simple.puml {
|
44
|
+
association {
|
45
|
+
owner Alice
|
46
|
+
member Request
|
47
|
+
member_type direct
|
48
|
+
}
|
49
|
+
association {
|
50
|
+
owner Bob
|
51
|
+
member Response
|
52
|
+
member_type direct
|
53
|
+
}
|
54
|
+
}
|
55
|
+
----
|
56
|
+
====
|
57
|
+
|
58
|
+
.LutaML YAML to LutaML UML
|
59
|
+
[example]
|
60
|
+
====
|
61
|
+
|
62
|
+
Given the following LutaML YAML file `Address.yml`:
|
63
|
+
|
64
|
+
[source,yaml]
|
65
|
+
----
|
66
|
+
name: Address
|
67
|
+
modelType: class
|
68
|
+
relations:
|
69
|
+
- target: AddressComponent
|
70
|
+
relationship:
|
71
|
+
source:
|
72
|
+
type: aggregation
|
73
|
+
attributes:
|
74
|
+
address:
|
75
|
+
cardinality:
|
76
|
+
min: 1
|
77
|
+
max: "*"
|
78
|
+
target:
|
79
|
+
type: direct
|
80
|
+
attributes:
|
81
|
+
addressComponent:
|
82
|
+
cardinality:
|
83
|
+
min: 1
|
84
|
+
max: "*"
|
85
|
+
action:
|
86
|
+
verb: comprises
|
87
|
+
direction: target
|
88
|
+
----
|
89
|
+
|
90
|
+
Running the command:
|
91
|
+
|
92
|
+
```
|
93
|
+
lutaml-yaml2uml Address.yml
|
94
|
+
```
|
95
|
+
|
96
|
+
The following results will be produced:
|
97
|
+
|
98
|
+
[source,lutaml]
|
99
|
+
----
|
100
|
+
diagram Address {
|
101
|
+
title ''
|
102
|
+
caption ''
|
103
|
+
association {
|
104
|
+
owner_type aggregation
|
105
|
+
owner
|
106
|
+
member_type direct
|
107
|
+
member AddressComponent
|
108
|
+
}
|
109
|
+
}
|
110
|
+
----
|
111
|
+
====
|
@@ -0,0 +1,33 @@
|
|
1
|
+
= Lutaml::XMI
|
2
|
+
|
3
|
+
Lutaml::XMI provides functionality to parse and manipulate
|
4
|
+
Enterprise Architecture XMI files.
|
5
|
+
|
6
|
+
== Usages
|
7
|
+
|
8
|
+
The parser `Lutaml::XMI::Parsers::XML` is used to parse XMI files into
|
9
|
+
`Lutaml::Uml::Document` model.
|
10
|
+
|
11
|
+
=== Examples
|
12
|
+
|
13
|
+
.Parsing XMI file
|
14
|
+
[example]
|
15
|
+
====
|
16
|
+
|
17
|
+
When using the `Lutaml::XMI::Parsers::XML` parser, you can parse an XMI
|
18
|
+
file as follows:
|
19
|
+
|
20
|
+
[source,ruby]
|
21
|
+
----
|
22
|
+
require "lutaml"
|
23
|
+
|
24
|
+
Lutaml::XMI::Parsers::XML.parse(File.new("path/to/example.xmi"))
|
25
|
+
# => returns Lutaml::Uml::Document model
|
26
|
+
----
|
27
|
+
|
28
|
+
`Lutaml::Uml::Document` model is a Lutaml model that can be further processed or
|
29
|
+
converted to other formats.
|
30
|
+
|
31
|
+
Please refer to https://github.com/lutaml/lutaml-model[lutaml-model] for more details.
|
32
|
+
|
33
|
+
====
|
data/exe/lutaml-yaml2uml
CHANGED
@@ -84,7 +84,7 @@ view_yaml["relations"]&.each do |values|
|
|
84
84
|
process_association(values["source"], values, encountered_relations)
|
85
85
|
end
|
86
86
|
|
87
|
-
view_yaml["imports"]
|
87
|
+
view_yaml["imports"]&.each_key do |entry| # rubocop:disable Metrics/BlockLength
|
88
88
|
import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml")))
|
89
89
|
import_name = import["name"] || File.basename(entry)
|
90
90
|
# Class notation
|
data/lib/lutaml/command_line.rb
CHANGED
@@ -52,7 +52,7 @@ module Lutaml
|
|
52
52
|
|
53
53
|
def formatter=(value)
|
54
54
|
value = value.to_s.strip.downcase.to_sym
|
55
|
-
value = Lutaml::
|
55
|
+
value = Lutaml::Formatter.find_by(name: value)
|
56
56
|
raise Error, "Formatter not found: #{value}" if value.nil?
|
57
57
|
|
58
58
|
@formatter = value
|
@@ -0,0 +1,235 @@
|
|
1
|
+
module Lutaml
|
2
|
+
module Converter
|
3
|
+
module DslToUml
|
4
|
+
def create_uml_document(hash)
|
5
|
+
::Lutaml::Uml::Document.new.tap do |model|
|
6
|
+
set_uml_model(model, hash)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_uml_package(hash)
|
11
|
+
::Lutaml::Uml::Package.new.tap do |model|
|
12
|
+
set_uml_model(model, hash)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_uml_class(hash)
|
17
|
+
::Lutaml::Uml::Class.new.tap do |model|
|
18
|
+
set_uml_model(model, hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_uml_enum(hash)
|
23
|
+
::Lutaml::Uml::Enum.new.tap do |model|
|
24
|
+
set_uml_model(model, hash)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_uml_data_type(hash)
|
29
|
+
::Lutaml::Uml::DataType.new.tap do |model|
|
30
|
+
set_uml_model(model, hash)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_uml_diagram(hash)
|
35
|
+
::Lutaml::Uml::Diagram.new.tap do |model|
|
36
|
+
set_uml_model(model, hash)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_uml_attribute(hash) # rubocop:disable Metrics/AbcSize
|
41
|
+
::Lutaml::Uml::TopElementAttribute.new.tap do |model|
|
42
|
+
set_uml_model(model, hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_uml_cardinality(hash)
|
47
|
+
::Lutaml::Uml::Cardinality.new.tap do |cardinality|
|
48
|
+
cardinality.min = hash[:min]
|
49
|
+
cardinality.max = hash[:max]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_uml_association(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
54
|
+
::Lutaml::Uml::Association.new.tap do |model|
|
55
|
+
member_end_cardinality = hash.delete(:member_end_cardinality)
|
56
|
+
if member_end_cardinality
|
57
|
+
model.member_end_cardinality = create_uml_cardinality(
|
58
|
+
member_end_cardinality,
|
59
|
+
)
|
60
|
+
end
|
61
|
+
owner_end_cardinality = hash.delete(:owner_end_cardinality)
|
62
|
+
if owner_end_cardinality
|
63
|
+
model.owner_end_cardinality = create_uml_cardinality(
|
64
|
+
owner_end_cardinality,
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
set_uml_model(model, hash)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_uml_operation(hash)
|
73
|
+
::Lutaml::Uml::Operation.new.tap do |model|
|
74
|
+
set_uml_model(model, hash)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def create_uml_constraint(hash)
|
79
|
+
::Lutaml::Uml::Constraint.new.tap do |model|
|
80
|
+
set_uml_model(model, hash)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_uml_value(hash)
|
85
|
+
::Lutaml::Uml::Value.new.tap do |model|
|
86
|
+
set_uml_model(model, hash)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_uml_model(model, hash)
|
91
|
+
hash = create_uml_members(model, hash)
|
92
|
+
set_model_attribute(model, hash)
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_model_attribute(model, hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
96
|
+
hash.each do |key, value|
|
97
|
+
if key == :definition
|
98
|
+
value = value.to_s.gsub(/\\}/, "}").gsub(/\\{/, "{")
|
99
|
+
.split("\n").map(&:strip).join("\n")
|
100
|
+
end
|
101
|
+
|
102
|
+
if model.respond_to?("#{key}=")
|
103
|
+
if model.class.attributes[key.to_sym].options[:collection]
|
104
|
+
values = model.send(key.to_sym).to_a
|
105
|
+
values << value
|
106
|
+
model.send("#{key}=", values)
|
107
|
+
else
|
108
|
+
model.send("#{key}=", value)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_uml_members(model, hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
115
|
+
members = hash.delete(:members)
|
116
|
+
members.to_a.each do |member_hash|
|
117
|
+
member_hash.each do
|
118
|
+
create_uml_packages(model, member_hash)
|
119
|
+
create_uml_classes(model, member_hash)
|
120
|
+
create_uml_enums(model, member_hash)
|
121
|
+
create_uml_data_types(model, member_hash)
|
122
|
+
create_uml_diagrams(model, member_hash)
|
123
|
+
create_uml_attributes(model, member_hash)
|
124
|
+
create_uml_associations(model, member_hash)
|
125
|
+
create_uml_operations(model, member_hash)
|
126
|
+
create_uml_constraints(model, member_hash)
|
127
|
+
create_uml_values(model, member_hash)
|
128
|
+
set_model_attribute(model, member_hash)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
hash
|
132
|
+
end
|
133
|
+
|
134
|
+
def create_uml_packages(model, hash)
|
135
|
+
packages = hash.delete(:packages)
|
136
|
+
return [] if packages.nil?
|
137
|
+
|
138
|
+
attr = create_uml_package(packages)
|
139
|
+
model.packages = [] if model.packages.nil?
|
140
|
+
model.packages << attr
|
141
|
+
hash
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_uml_classes(model, hash)
|
145
|
+
classes = hash.delete(:classes)
|
146
|
+
return [] if classes.nil?
|
147
|
+
|
148
|
+
attr = create_uml_class(classes)
|
149
|
+
model.classes = [] if model.classes.nil?
|
150
|
+
model.classes << attr
|
151
|
+
hash
|
152
|
+
end
|
153
|
+
|
154
|
+
def create_uml_enums(model, hash)
|
155
|
+
enums = hash.delete(:enums)
|
156
|
+
return [] if enums.nil?
|
157
|
+
|
158
|
+
attr = create_uml_enum(enums)
|
159
|
+
model.enums = [] if model.enums.nil?
|
160
|
+
model.enums << attr
|
161
|
+
hash
|
162
|
+
end
|
163
|
+
|
164
|
+
def create_uml_data_types(model, hash)
|
165
|
+
data_types = hash.delete(:data_types)
|
166
|
+
return [] if data_types.nil?
|
167
|
+
|
168
|
+
attr = create_uml_data_type(data_types)
|
169
|
+
model.data_types = [] if model.data_types.nil?
|
170
|
+
model.data_types << attr
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
def create_uml_diagrams(model, hash)
|
175
|
+
diagrams = hash.delete(:diagrams)
|
176
|
+
return [] if diagrams.nil?
|
177
|
+
|
178
|
+
attr = create_uml_diagram(diagrams)
|
179
|
+
model.diagrams = [] if model.diagrams.nil?
|
180
|
+
model.diagrams << attr
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
def create_uml_attributes(model, hash)
|
185
|
+
attributes = hash.delete(:attributes)
|
186
|
+
return [] if attributes.nil?
|
187
|
+
|
188
|
+
attr = create_uml_attribute(attributes)
|
189
|
+
model.attributes = [] if model.attributes.nil?
|
190
|
+
model.attributes << attr
|
191
|
+
hash
|
192
|
+
end
|
193
|
+
|
194
|
+
def create_uml_associations(model, hash)
|
195
|
+
associations = hash.delete(:associations)
|
196
|
+
return [] if associations.nil?
|
197
|
+
|
198
|
+
attr = create_uml_association(associations)
|
199
|
+
model.associations = [] if model.associations.nil?
|
200
|
+
model.associations << attr
|
201
|
+
hash
|
202
|
+
end
|
203
|
+
|
204
|
+
def create_uml_operations(model, hash)
|
205
|
+
operations = hash.delete(:operations)
|
206
|
+
return [] if operations.nil?
|
207
|
+
|
208
|
+
attr = create_uml_operation(operations)
|
209
|
+
model.operations = [] if model.operations.nil?
|
210
|
+
model.operations << attr
|
211
|
+
hash
|
212
|
+
end
|
213
|
+
|
214
|
+
def create_uml_constraints(model, hash)
|
215
|
+
constraints = hash.delete(:constraints)
|
216
|
+
return [] if constraints.nil?
|
217
|
+
|
218
|
+
attr = create_uml_constraint(constraints)
|
219
|
+
model.constraints = [] if model.constraints.nil?
|
220
|
+
model.constraints << attr
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
def create_uml_values(model, hash)
|
225
|
+
values = hash.delete(:values)
|
226
|
+
return [] if values.nil?
|
227
|
+
|
228
|
+
attr = create_uml_value(values)
|
229
|
+
model.values = [] if model.values.nil?
|
230
|
+
model.values << attr
|
231
|
+
hash
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
module Lutaml
|
2
|
+
module Converter
|
3
|
+
module XmiHashToUml
|
4
|
+
def create_uml_document(hash)
|
5
|
+
::Lutaml::Uml::Document.new.tap do |doc|
|
6
|
+
doc.name = hash[:name]
|
7
|
+
hash[:packages]&.each do |package_hash|
|
8
|
+
pkg = create_uml_package(package_hash)
|
9
|
+
doc.packages = [] if doc.packages.nil?
|
10
|
+
doc.packages << pkg
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_uml_package(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
16
|
+
package = ::Lutaml::Uml::Package.new
|
17
|
+
package.xmi_id = hash[:xmi_id]
|
18
|
+
package.name = hash[:name]
|
19
|
+
package.definition = hash[:definition]
|
20
|
+
package.stereotype = hash[:stereotype]
|
21
|
+
|
22
|
+
hash[:classes]&.each do |class_hash|
|
23
|
+
class_obj = create_uml_class(class_hash)
|
24
|
+
package.classes = [] if package.classes.nil?
|
25
|
+
package.classes << class_obj
|
26
|
+
end
|
27
|
+
hash[:enums]&.each do |enum_hash|
|
28
|
+
enum_obj = create_uml_enum(enum_hash)
|
29
|
+
package.enums = [] if package.enums.nil?
|
30
|
+
package.enums << enum_obj
|
31
|
+
end
|
32
|
+
hash[:data_types]&.each do |data_type_hash|
|
33
|
+
data_type_obj = create_uml_data_type(data_type_hash)
|
34
|
+
package.data_types = [] if package.data_types.nil?
|
35
|
+
package.data_types << data_type_obj
|
36
|
+
end
|
37
|
+
hash[:diagrams]&.each do |diagram_hash|
|
38
|
+
diagram_obj = create_uml_diagram(diagram_hash)
|
39
|
+
package.diagrams = [] if package.diagrams.nil?
|
40
|
+
package.diagrams << diagram_obj
|
41
|
+
end
|
42
|
+
hash[:packages]&.each do |package_hash|
|
43
|
+
pkg = create_uml_package(package_hash)
|
44
|
+
package.packages = [] if package.packages.nil?
|
45
|
+
package.packages << pkg
|
46
|
+
end
|
47
|
+
|
48
|
+
package
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_uml_class(hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
52
|
+
::Lutaml::Uml::Class.new.tap do |klass| # rubocop:disable Metrics/BlockLength
|
53
|
+
klass.xmi_id = hash[:xmi_id]
|
54
|
+
klass.name = hash[:name]
|
55
|
+
klass.type = hash[:type]
|
56
|
+
klass.is_abstract = hash[:is_abstract]
|
57
|
+
klass.definition = hash[:definition]
|
58
|
+
klass.stereotype = hash[:stereotype]
|
59
|
+
hash[:attributes]&.each do |attr_hash|
|
60
|
+
attr = create_uml_attribute(attr_hash)
|
61
|
+
klass.attributes = [] if klass.attributes.nil?
|
62
|
+
klass.attributes << attr
|
63
|
+
end
|
64
|
+
hash[:associations]&.each do |assoc_hash|
|
65
|
+
assoc = create_uml_association(assoc_hash)
|
66
|
+
klass.associations = [] if klass.associations.nil?
|
67
|
+
klass.associations << assoc
|
68
|
+
end
|
69
|
+
hash[:operations]&.each do |op_hash|
|
70
|
+
op = create_uml_operation(op_hash)
|
71
|
+
klass.operations = [] if klass.operations.nil?
|
72
|
+
klass.operations << op
|
73
|
+
end
|
74
|
+
hash[:constraints]&.each do |constraint_hash|
|
75
|
+
constraint = create_uml_constraint(constraint_hash)
|
76
|
+
klass.constraints = [] if klass.constraints
|
77
|
+
klass.constraints << constraint
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def create_uml_enum(hash) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
83
|
+
::Lutaml::Uml::Enum.new.tap do |enum|
|
84
|
+
enum.xmi_id = hash[:xmi_id]
|
85
|
+
enum.name = hash[:name]
|
86
|
+
hash[:values]&.each do |value_hash|
|
87
|
+
value = create_uml_value(value_hash)
|
88
|
+
enum.values = [] if enum.values.nil?
|
89
|
+
enum.values << value
|
90
|
+
end
|
91
|
+
enum.definition = hash[:definition]
|
92
|
+
enum.stereotype = hash[:stereotype]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_uml_data_type(hash) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
97
|
+
::Lutaml::Uml::DataType.new.tap do |data_type|
|
98
|
+
data_type.xmi_id = hash[:xmi_id]
|
99
|
+
data_type.name = hash[:name]
|
100
|
+
data_type.is_abstract = hash[:is_abstract]
|
101
|
+
data_type.definition = hash[:definition]
|
102
|
+
data_type.stereotype = hash[:stereotype]
|
103
|
+
hash[:attributes]&.each do |attr_hash|
|
104
|
+
attr = create_uml_attribute(attr_hash)
|
105
|
+
data_type.attributes = [] if data_type.attributes.nil?
|
106
|
+
data_type.attributes << attr
|
107
|
+
end
|
108
|
+
hash[:operations]&.each do |op_hash|
|
109
|
+
op = create_uml_operation(op_hash)
|
110
|
+
data_type.operations = [] if data_type.operations.nil?
|
111
|
+
data_type.operations << op
|
112
|
+
end
|
113
|
+
hash[:associations]&.each do |assoc_hash|
|
114
|
+
assoc = create_uml_association(assoc_hash)
|
115
|
+
data_type.associations = [] if data_type.associations.nil?
|
116
|
+
data_type.associations << assoc
|
117
|
+
end
|
118
|
+
hash[:constraints]&.each do |constraint_hash|
|
119
|
+
constraint = create_uml_constraint(constraint_hash)
|
120
|
+
data_type.constraints = [] if data_type.constraints
|
121
|
+
data_type.constraints << constraint
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def create_uml_diagram(hash)
|
127
|
+
::Lutaml::Uml::Diagram.new.tap do |diagram|
|
128
|
+
diagram.xmi_id = hash[:xmi_id]
|
129
|
+
diagram.name = hash[:name]
|
130
|
+
diagram.definition = hash[:definition]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def create_uml_attribute(hash) # rubocop:disable Metrics/AbcSize
|
135
|
+
::Lutaml::Uml::TopElementAttribute.new.tap do |attr|
|
136
|
+
attr.id = hash[:id]
|
137
|
+
attr.name = hash[:name]
|
138
|
+
attr.type = hash[:type]
|
139
|
+
attr.xmi_id = hash[:xmi_id]
|
140
|
+
attr.is_derived = hash[:is_derived]
|
141
|
+
attr.cardinality = create_uml_cardinality(hash[:cardinality])
|
142
|
+
attr.definition = hash[:definition]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def create_uml_cardinality(hash)
|
147
|
+
::Lutaml::Uml::Cardinality.new.tap do |cardinality|
|
148
|
+
cardinality.min = hash[:min]
|
149
|
+
cardinality.max = hash[:max]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def create_uml_association(hash) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
154
|
+
::Lutaml::Uml::Association.new.tap do |assoc|
|
155
|
+
assoc.xmi_id = hash[:xmi_id]
|
156
|
+
assoc.member_end = hash[:member_end]
|
157
|
+
assoc.member_end_type = hash[:member_end_type]
|
158
|
+
assoc.member_end_cardinality = create_uml_cardinality(
|
159
|
+
hash[:member_end_cardinality],
|
160
|
+
)
|
161
|
+
assoc.member_end_attribute_name = hash[:member_end_attribute_name]
|
162
|
+
assoc.member_end_xmi_id = hash[:member_end_xmi_id]
|
163
|
+
assoc.owner_end = hash[:owner_end]
|
164
|
+
assoc.owner_end_xmi_id = hash[:owner_end_xmi_id]
|
165
|
+
assoc.definition = hash[:definition]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_uml_operation(hash)
|
170
|
+
::Lutaml::Uml::Operation.new.tap do |op|
|
171
|
+
op.id = hash[:id]
|
172
|
+
op.xmi_id = hash[:xmi_id]
|
173
|
+
op.name = hash[:name]
|
174
|
+
op.definition = hash[:definition]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def create_uml_constraint(hash)
|
179
|
+
::Lutaml::Uml::Constraint.new.tap do |constraint|
|
180
|
+
constraint.name = hash[:name]
|
181
|
+
constraint.type = hash[:type]
|
182
|
+
constraint.weight = hash[:weight]
|
183
|
+
constraint.status = hash[:status]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_uml_value(hash)
|
188
|
+
::Lutaml::Uml::Value.new.tap do |value|
|
189
|
+
value.name = hash[:name]
|
190
|
+
value.type = hash[:type]
|
191
|
+
value.definition = hash[:definition]
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|