xmi 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -5
- data/README.adoc +89 -0
- data/lib/xmi/add.rb +11 -13
- data/lib/xmi/delete.rb +9 -11
- data/lib/xmi/difference.rb +9 -11
- data/lib/xmi/documentation.rb +16 -18
- data/lib/xmi/ea_root.rb +18 -17
- data/lib/xmi/extension.rb +9 -11
- data/lib/xmi/extensions/eauml.rb +2 -2
- data/lib/xmi/extensions/gml.rb +37 -35
- data/lib/xmi/replace.rb +11 -13
- data/lib/xmi/root.rb +57 -10
- data/lib/xmi/sparx.rb +301 -288
- data/lib/xmi/the_custom_profile.rb +149 -0
- data/lib/xmi/uml.rb +135 -136
- data/lib/xmi/version.rb +1 -1
- data/lib/xmi.rb +15 -9
- data/xmi.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a854b84209bcc433a98f4e1b9b69f396f39aaab6e294e2a90d7037c3e2f72ada
|
4
|
+
data.tar.gz: 7a1fe9232b45069e3792dd58ed216e84b1630695a6abbdc71332f6e6d93ba619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044baa2ef11dc753715d6bb38bb3bfd6048033473af8bdd7cdee52de98e5e4d1f302bfb0dc16e3b7b945e9c270d2140ab9cd204ed9b3d33653d6338f58386751
|
7
|
+
data.tar.gz: 3d0f3471046e6fe2d902a734672153b26f5a3a688fec4f676b50f4847de4db8837f30344077a3bfd88ba7c3a032c9a72df9fce7526ed7ee0f650bbca48f95b2b
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -74,6 +74,95 @@ Xmi::EaRoot.output_rb_file('path/to/output_file.rb')
|
|
74
74
|
|
75
75
|
This approach allows you to save the dynamically generated Ruby code to a file for further use.
|
76
76
|
|
77
|
+
=== Create Extension XML File
|
78
|
+
|
79
|
+
If you would like to create an extension, which allows to be loaded later, you
|
80
|
+
can create an extension XML file.
|
81
|
+
|
82
|
+
For example, you would like to create an extension:
|
83
|
+
|
84
|
+
- A Module named `Mymodule`.
|
85
|
+
- A class named `Klass` under this module.
|
86
|
+
- The class `Klass` has two attributes: `base_apply_attribute` and `tag`.
|
87
|
+
|
88
|
+
First, you create an extension XML file `mymodule.xml` as the following:
|
89
|
+
|
90
|
+
[source,xml]
|
91
|
+
----
|
92
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
93
|
+
<MYMODULE version="1.0">
|
94
|
+
<UMLProfiles>
|
95
|
+
<UMLProfile profiletype="uml2">
|
96
|
+
<Documentation name="MYMODULE" version="1.0"
|
97
|
+
URI="http://www.test.com/profiles/MYMODULE/1.0" />
|
98
|
+
<Content>
|
99
|
+
<Stereotypes>
|
100
|
+
<Stereotype name="klass">
|
101
|
+
<AppliesTo>
|
102
|
+
<Apply type="ApplyAttribute" />
|
103
|
+
</AppliesTo>
|
104
|
+
<TaggedValues>
|
105
|
+
<Tag name="tag" type="String" description="" unit="" values="" default=""/>
|
106
|
+
</TaggedValues>
|
107
|
+
</Stereotype>
|
108
|
+
</Stereotypes>
|
109
|
+
<TaggedValueTypes />
|
110
|
+
<ViewDefinitions />
|
111
|
+
<Metamodel />
|
112
|
+
</Content>
|
113
|
+
</UMLProfile>
|
114
|
+
</UMLProfiles>
|
115
|
+
</MYMODULE>
|
116
|
+
----
|
117
|
+
|
118
|
+
- The attribute `name` in the `Documentation` defines the module name.
|
119
|
+
- The attribute `URI` in the `Documentation` defines the namespace.
|
120
|
+
- The attribute `version` in the `Documentation` defines the version.
|
121
|
+
- The attribute `name` in the `Stereotype` defines the class name.
|
122
|
+
- The attribute `type` in the `Apply` defines the attribute name with prefix `base_`.
|
123
|
+
- The attribute `name` in the `Tag` defines the attribute name.
|
124
|
+
|
125
|
+
To load the extension, you can use the following code:
|
126
|
+
|
127
|
+
[source,ruby]
|
128
|
+
----
|
129
|
+
mymodule_xml = "mymodule.xml"
|
130
|
+
Xmi::EaRoot.load_extension(mymodule_xml)
|
131
|
+
----
|
132
|
+
|
133
|
+
After you load the extension, a class `Klass` have been generated in the module
|
134
|
+
`Mymodule`.
|
135
|
+
|
136
|
+
[source,ruby]
|
137
|
+
----
|
138
|
+
module Xmi
|
139
|
+
class EaRoot
|
140
|
+
module Mymodule
|
141
|
+
class Klass < Lutaml::Model::Serializable
|
142
|
+
attribute :base_apply_attribute, :string
|
143
|
+
attribute :tag, :string
|
144
|
+
|
145
|
+
xml do
|
146
|
+
root "import"
|
147
|
+
|
148
|
+
map_attribute "base_ApplyAttribute", to: :base_apply_attribute
|
149
|
+
map_attribute "tag", to: :tag
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
----
|
156
|
+
|
157
|
+
=== Limitation
|
158
|
+
|
159
|
+
This module is designed to work with XMI files generated by Enterprise
|
160
|
+
Architect. It may not work with other XMI files.
|
161
|
+
|
162
|
+
Some XML elements, for example `GML:ApplicationSchema`, use `xmlns` as
|
163
|
+
attributes. As `Lutaml::Model::Serializable` uses `xmlns` as an internal
|
164
|
+
keyword, these attributes will be renamed to `altered_xmlns`.
|
165
|
+
|
77
166
|
== Development
|
78
167
|
|
79
168
|
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.
|
data/lib/xmi/add.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
require_relative "difference"
|
6
4
|
require_relative "extension"
|
7
5
|
|
8
6
|
module Xmi
|
9
|
-
class Add <
|
10
|
-
attribute :id,
|
11
|
-
attribute :label,
|
12
|
-
attribute :uuid,
|
13
|
-
attribute :href,
|
14
|
-
attribute :idref,
|
15
|
-
attribute :type,
|
16
|
-
attribute :target,
|
17
|
-
attribute :container,
|
18
|
-
attribute :position,
|
19
|
-
attribute :addition,
|
7
|
+
class Add < Lutaml::Model::Serializable
|
8
|
+
attribute :id, :string
|
9
|
+
attribute :label, :string
|
10
|
+
attribute :uuid, :string
|
11
|
+
attribute :href, :string
|
12
|
+
attribute :idref, :string
|
13
|
+
attribute :type, :string
|
14
|
+
attribute :target, :string
|
15
|
+
attribute :container, :string
|
16
|
+
attribute :position, :integer
|
17
|
+
attribute :addition, :string
|
20
18
|
attribute :difference, Difference, collection: true
|
21
19
|
attribute :extension, Extension, collection: true
|
22
20
|
|
data/lib/xmi/delete.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
require_relative "difference"
|
6
4
|
require_relative "extension"
|
7
5
|
|
8
6
|
module Xmi
|
9
|
-
class Delete <
|
10
|
-
attribute :id,
|
11
|
-
attribute :label,
|
12
|
-
attribute :uuid,
|
13
|
-
attribute :href,
|
14
|
-
attribute :idref,
|
15
|
-
attribute :type,
|
16
|
-
attribute :target,
|
17
|
-
attribute :container,
|
7
|
+
class Delete < Lutaml::Model::Serializable
|
8
|
+
attribute :id, :string
|
9
|
+
attribute :label, :string
|
10
|
+
attribute :uuid, :string
|
11
|
+
attribute :href, :string
|
12
|
+
attribute :idref, :string
|
13
|
+
attribute :type, :string
|
14
|
+
attribute :target, :string
|
15
|
+
attribute :container, :string
|
18
16
|
attribute :difference, Difference, collection: true
|
19
17
|
attribute :extension, Extension, collection: true
|
20
18
|
|
data/lib/xmi/difference.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
require_relative "extension"
|
6
4
|
|
7
5
|
module Xmi
|
8
|
-
class Difference <
|
9
|
-
attribute :id,
|
10
|
-
attribute :label,
|
11
|
-
attribute :uuid,
|
12
|
-
attribute :href,
|
13
|
-
attribute :idref,
|
14
|
-
attribute :type,
|
15
|
-
attribute :target,
|
16
|
-
attribute :container,
|
6
|
+
class Difference < Lutaml::Model::Serializable
|
7
|
+
attribute :id, :string
|
8
|
+
attribute :label, :string
|
9
|
+
attribute :uuid, :string
|
10
|
+
attribute :href, :string
|
11
|
+
attribute :idref, :string
|
12
|
+
attribute :type, :string
|
13
|
+
attribute :target, :string
|
14
|
+
attribute :container, :string
|
17
15
|
attribute :difference, Difference, collection: true
|
18
16
|
attribute :extension, Extension, collection: true
|
19
17
|
|
data/lib/xmi/documentation.rb
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
require_relative "extension"
|
6
4
|
|
7
5
|
module Xmi
|
8
|
-
class Documentation <
|
9
|
-
attribute :id,
|
10
|
-
attribute :label,
|
11
|
-
attribute :uuid,
|
12
|
-
attribute :href,
|
13
|
-
attribute :idref,
|
14
|
-
attribute :type,
|
15
|
-
attribute :contact,
|
16
|
-
attribute :exporter,
|
17
|
-
attribute :exporter_version,
|
18
|
-
attribute :exporter_id,
|
19
|
-
attribute :long_description,
|
20
|
-
attribute :short_description,
|
21
|
-
attribute :notice,
|
22
|
-
attribute :owner,
|
23
|
-
attribute :timestamp,
|
6
|
+
class Documentation < Lutaml::Model::Serializable
|
7
|
+
attribute :id, :string
|
8
|
+
attribute :label, :string
|
9
|
+
attribute :uuid, :string
|
10
|
+
attribute :href, :string
|
11
|
+
attribute :idref, :string
|
12
|
+
attribute :type, :string
|
13
|
+
attribute :contact, :string, collection: true
|
14
|
+
attribute :exporter, :string
|
15
|
+
attribute :exporter_version, :string
|
16
|
+
attribute :exporter_id, :string
|
17
|
+
attribute :long_description, :string, collection: true
|
18
|
+
attribute :short_description, :string, collection: true
|
19
|
+
attribute :notice, :string, collection: true
|
20
|
+
attribute :owner, :string, collection: true
|
21
|
+
attribute :timestamp, :time, collection: true
|
24
22
|
attribute :extension, Extension, collection: true
|
25
23
|
|
26
24
|
xml do
|
data/lib/xmi/ea_root.rb
CHANGED
@@ -61,12 +61,12 @@ module Xmi
|
|
61
61
|
|
62
62
|
def update_mappings(module_name)
|
63
63
|
new_klasses = all_new_klasses(module_name)
|
64
|
-
map_elements =
|
65
|
-
|
66
|
-
|
64
|
+
map_elements = construct_xml_mappings(new_klasses, module_name)
|
65
|
+
update_model_attributes(new_klasses, Xmi::Sparx::SparxRoot, module_name)
|
66
|
+
update_model_xml_mappings(map_elements, Xmi::Sparx::SparxRoot)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def construct_xml_mappings(new_klasses, module_name) # rubocop:disable Metrics/MethodLength
|
70
70
|
map_elements = []
|
71
71
|
new_klasses.each do |klass|
|
72
72
|
next unless Xmi::EaRoot.const_get(module_name).const_get(klass)
|
@@ -74,7 +74,7 @@ module Xmi
|
|
74
74
|
|
75
75
|
map_elements << MAP_ELEMENT
|
76
76
|
.gsub("#ELEMENT_NAME#", Xmi::EaRoot.const_get(module_name).const_get(klass).root_tag)
|
77
|
-
.gsub("#ELEMENT_METHOD#",
|
77
|
+
.gsub("#ELEMENT_METHOD#", Lutaml::Model::Utils.snake_case(klass.to_s))
|
78
78
|
.gsub("#NAMESPACE#", @def_namespace[:uri])
|
79
79
|
.gsub("#PREFIX#", @def_namespace[:name])
|
80
80
|
end
|
@@ -82,9 +82,9 @@ module Xmi
|
|
82
82
|
map_elements
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
85
|
+
def update_model_attributes(new_klasses, sparx_root, module_name)
|
86
86
|
new_klasses.each do |klass|
|
87
|
-
method_name =
|
87
|
+
method_name = Lutaml::Model::Utils.snake_case(klass)
|
88
88
|
full_klass_name = "Xmi::EaRoot::#{module_name}::#{klass}"
|
89
89
|
attr_line = "#{ATTRIBUTE_LINE.rstrip}, collection: true"
|
90
90
|
attr_line = attr_line
|
@@ -95,7 +95,7 @@ module Xmi
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
98
|
+
def update_model_xml_mappings(map_elements, sparx_root)
|
99
99
|
new_mapping = sparx_root.class_variable_get("@@default_mapping")
|
100
100
|
new_mapping += map_elements.join("\n")
|
101
101
|
sparx_root.class_variable_set("@@mapping", new_mapping) # rubocop:disable Style/ClassVars
|
@@ -120,14 +120,14 @@ module Xmi
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def get_klass_name_from_node(node)
|
123
|
-
return
|
123
|
+
return Lutaml::Model::Serializable.to_s unless node
|
124
124
|
|
125
125
|
node.attribute_nodes.find { |attr| attr.name == "name" }.value
|
126
126
|
end
|
127
127
|
|
128
128
|
def gen_map_attribute_line(attr_name, attr_method)
|
129
129
|
space_before = " " * 10
|
130
|
-
method_name =
|
130
|
+
method_name = Lutaml::Model::Utils.snake_case(attr_method)
|
131
131
|
|
132
132
|
map_attributes = MAP_ATTRIBUTES
|
133
133
|
.gsub("#ATTRIBUTE_NAME#", attr_name)
|
@@ -136,8 +136,8 @@ module Xmi
|
|
136
136
|
"#{space_before}#{map_attributes}"
|
137
137
|
end
|
138
138
|
|
139
|
-
def gen_attribute_line(tag_name, attribute_type = "
|
140
|
-
tag_name =
|
139
|
+
def gen_attribute_line(tag_name, attribute_type = ":string")
|
140
|
+
tag_name = Lutaml::Model::Utils.snake_case(tag_name)
|
141
141
|
space_before = " " * 8
|
142
142
|
|
143
143
|
attribute_line = ATTRIBUTE_LINE
|
@@ -148,7 +148,8 @@ module Xmi
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def get_tag_name(tag)
|
151
|
-
tag.attribute_nodes.find { |attr| attr.name == "name" }.value
|
151
|
+
tag_name = tag.attribute_nodes.find { |attr| attr.name == "name" }.value
|
152
|
+
tag_name == "xmlns" ? "altered_xmlns" : tag_name
|
152
153
|
end
|
153
154
|
|
154
155
|
def gen_tags(node)
|
@@ -175,8 +176,8 @@ module Xmi
|
|
175
176
|
klass_name = get_klass_name_from_node(@abstract_klass_node)
|
176
177
|
|
177
178
|
KLASS_TEMPLATE
|
178
|
-
.gsub("#KLASS_NAME#",
|
179
|
-
.gsub("#FROM_KLASS#", "
|
179
|
+
.gsub("#KLASS_NAME#", Lutaml::Model::Utils.classify(klass_name))
|
180
|
+
.gsub("#FROM_KLASS#", "Lutaml::Model::Serializable")
|
180
181
|
.gsub("#ATTRIBUTES#", attributes_lines.rstrip)
|
181
182
|
.gsub("#XML_MAPPING#", "")
|
182
183
|
.gsub("#ROOT_TAG_LINE#", "")
|
@@ -268,8 +269,8 @@ module Xmi
|
|
268
269
|
root_tag_line = "def self.root_tag = \"#{node_name}\""
|
269
270
|
|
270
271
|
KLASS_TEMPLATE
|
271
|
-
.gsub("#KLASS_NAME#",
|
272
|
-
.gsub("#FROM_KLASS#",
|
272
|
+
.gsub("#KLASS_NAME#", Lutaml::Model::Utils.classify(node_name))
|
273
|
+
.gsub("#FROM_KLASS#", Lutaml::Model::Utils.classify(abstract_klass_name))
|
273
274
|
.gsub("#ROOT_TAG_LINE#", root_tag_line)
|
274
275
|
.gsub("#ATTRIBUTES#", attributes_lines.rstrip)
|
275
276
|
.gsub("#XML_MAPPING#", "\n\n#{xml_mapping}")
|
data/lib/xmi/extension.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
module Xmi
|
6
|
-
class Extension <
|
7
|
-
attribute :id,
|
8
|
-
attribute :label,
|
9
|
-
attribute :uuid,
|
10
|
-
attribute :href,
|
11
|
-
attribute :idref,
|
12
|
-
attribute :type,
|
13
|
-
attribute :extender,
|
14
|
-
attribute :extender_id,
|
4
|
+
class Extension < Lutaml::Model::Serializable
|
5
|
+
attribute :id, :string
|
6
|
+
attribute :label, :string
|
7
|
+
attribute :uuid, :string
|
8
|
+
attribute :href, :string
|
9
|
+
attribute :idref, :string
|
10
|
+
attribute :type, :string
|
11
|
+
attribute :extender, :string
|
12
|
+
attribute :extender_id, :string
|
15
13
|
|
16
14
|
xml do
|
17
15
|
root "Extension"
|
data/lib/xmi/extensions/eauml.rb
CHANGED
data/lib/xmi/extensions/gml.rb
CHANGED
@@ -5,28 +5,30 @@ Dir[File.join(__dir__, "ea_extensions", "*.rb")].each { |file| require file }
|
|
5
5
|
module Xmi
|
6
6
|
class EaRoot
|
7
7
|
module Gml
|
8
|
-
class ApplicationSchema <
|
9
|
-
|
10
|
-
|
11
|
-
attribute :
|
12
|
-
attribute :
|
13
|
-
attribute :
|
8
|
+
class ApplicationSchema < Lutaml::Model::Serializable
|
9
|
+
# prefix altered_ is prepended to xmlns to avoid conflict with
|
10
|
+
# reserved keyword
|
11
|
+
attribute :version, :string
|
12
|
+
attribute :xsd_document, :string
|
13
|
+
attribute :altered_xmlns, :string
|
14
|
+
attribute :target_namespace, :string
|
15
|
+
attribute :base_package, :string
|
14
16
|
|
15
17
|
xml do
|
16
18
|
root "ApplicationSchema"
|
17
19
|
|
18
20
|
map_attribute "version", to: :version
|
19
21
|
map_attribute "xsdDocument", to: :xsd_document
|
20
|
-
map_attribute "
|
22
|
+
map_attribute "altered_xmlns", to: :altered_xmlns
|
21
23
|
map_attribute "targetNamespace", to: :target_namespace
|
22
24
|
map_attribute "base_Package", to: :base_package
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
class CodeList <
|
27
|
-
attribute :as_dictionary,
|
28
|
-
attribute :default_code_space,
|
29
|
-
attribute :base_class,
|
28
|
+
class CodeList < Lutaml::Model::Serializable
|
29
|
+
attribute :as_dictionary, :string
|
30
|
+
attribute :default_code_space, :string
|
31
|
+
attribute :base_class, :string
|
30
32
|
|
31
33
|
xml do
|
32
34
|
root "CodeList"
|
@@ -37,10 +39,10 @@ module Xmi
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
class DataType <
|
41
|
-
attribute :is_collection,
|
42
|
-
attribute :no_property_type,
|
43
|
-
attribute :base_class,
|
42
|
+
class DataType < Lutaml::Model::Serializable
|
43
|
+
attribute :is_collection, :string
|
44
|
+
attribute :no_property_type, :string
|
45
|
+
attribute :base_class, :string
|
44
46
|
|
45
47
|
xml do
|
46
48
|
root "DataType"
|
@@ -51,10 +53,10 @@ module Xmi
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
class Union <
|
55
|
-
attribute :is_collection,
|
56
|
-
attribute :no_property_type,
|
57
|
-
attribute :base_class,
|
56
|
+
class Union < Lutaml::Model::Serializable
|
57
|
+
attribute :is_collection, :string
|
58
|
+
attribute :no_property_type, :string
|
59
|
+
attribute :base_class, :string
|
58
60
|
|
59
61
|
xml do
|
60
62
|
root "Union"
|
@@ -65,8 +67,8 @@ module Xmi
|
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
|
-
class Enumeration <
|
69
|
-
attribute :base_enumeration,
|
70
|
+
class Enumeration < Lutaml::Model::Serializable
|
71
|
+
attribute :base_enumeration, :string
|
70
72
|
|
71
73
|
xml do
|
72
74
|
root "Enumeration"
|
@@ -75,10 +77,10 @@ module Xmi
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
78
|
-
class Type <
|
79
|
-
attribute :is_collection,
|
80
|
-
attribute :no_property_type,
|
81
|
-
attribute :base_class,
|
80
|
+
class Type < Lutaml::Model::Serializable
|
81
|
+
attribute :is_collection, :string
|
82
|
+
attribute :no_property_type, :string
|
83
|
+
attribute :base_class, :string
|
82
84
|
|
83
85
|
xml do
|
84
86
|
root "Type"
|
@@ -89,11 +91,11 @@ module Xmi
|
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
92
|
-
class FeatureType <
|
93
|
-
attribute :is_collection,
|
94
|
-
attribute :no_property_type,
|
95
|
-
attribute :base_class,
|
96
|
-
attribute :by_value_property_type,
|
94
|
+
class FeatureType < Lutaml::Model::Serializable
|
95
|
+
attribute :is_collection, :string
|
96
|
+
attribute :no_property_type, :string
|
97
|
+
attribute :base_class, :string
|
98
|
+
attribute :by_value_property_type, :string
|
97
99
|
|
98
100
|
xml do
|
99
101
|
root "FeatureType"
|
@@ -105,11 +107,11 @@ module Xmi
|
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
|
-
class Property <
|
109
|
-
attribute :sequence_number,
|
110
|
-
attribute :base_property,
|
111
|
-
attribute :is_metadata,
|
112
|
-
attribute :inline_or_by_reference,
|
110
|
+
class Property < Lutaml::Model::Serializable
|
111
|
+
attribute :sequence_number, :string
|
112
|
+
attribute :base_property, :string
|
113
|
+
attribute :is_metadata, :string
|
114
|
+
attribute :inline_or_by_reference, :string
|
113
115
|
|
114
116
|
xml do
|
115
117
|
root "property"
|
data/lib/xmi/replace.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
|
-
|
5
3
|
require_relative "difference"
|
6
4
|
require_relative "extension"
|
7
5
|
|
8
6
|
module Xmi
|
9
|
-
class Replace <
|
10
|
-
attribute :id,
|
11
|
-
attribute :label,
|
12
|
-
attribute :uuid,
|
13
|
-
attribute :href,
|
14
|
-
attribute :idref,
|
15
|
-
attribute :type,
|
16
|
-
attribute :target,
|
17
|
-
attribute :container,
|
18
|
-
attribute :position,
|
19
|
-
attribute :replacement,
|
7
|
+
class Replace < Lutaml::Model::Serializable
|
8
|
+
attribute :id, :string
|
9
|
+
attribute :label, :string
|
10
|
+
attribute :uuid, :string
|
11
|
+
attribute :href, :string
|
12
|
+
attribute :idref, :string
|
13
|
+
attribute :type, :string
|
14
|
+
attribute :target, :string
|
15
|
+
attribute :container, :string
|
16
|
+
attribute :position, :integer
|
17
|
+
attribute :replacement, :string
|
20
18
|
attribute :difference, Difference, collection: true
|
21
19
|
attribute :extension, Extension, collection: true
|
22
20
|
|
data/lib/xmi/root.rb
CHANGED
@@ -1,29 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "shale"
|
4
3
|
require_relative "documentation"
|
5
4
|
require_relative "uml"
|
6
5
|
|
7
6
|
module Xmi
|
8
7
|
module RootAttributes
|
9
|
-
def self.included(klass)
|
8
|
+
def self.included(klass) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
10
9
|
klass.class_eval do
|
11
|
-
attribute :id,
|
12
|
-
attribute :label,
|
13
|
-
attribute :uuid,
|
14
|
-
attribute :href,
|
15
|
-
attribute :idref,
|
16
|
-
attribute :type,
|
10
|
+
attribute :id, :string
|
11
|
+
attribute :label, :string
|
12
|
+
attribute :uuid, :string
|
13
|
+
attribute :href, :string
|
14
|
+
attribute :idref, :string
|
15
|
+
attribute :type, :string
|
17
16
|
attribute :documentation, Documentation
|
17
|
+
attribute :bibliography, TheCustomProfile::Bibliography, collection: true
|
18
|
+
attribute :basic_doc, TheCustomProfile::BasicDoc, collection: true
|
19
|
+
attribute :enumeration, TheCustomProfile::Enumeration, collection: true
|
20
|
+
attribute :ocl, TheCustomProfile::Ocl, collection: true
|
21
|
+
attribute :invariant, TheCustomProfile::Invariant, collection: true
|
22
|
+
attribute :publication_date, TheCustomProfile::PublicationDate, collection: true
|
23
|
+
attribute :edition, TheCustomProfile::Edition, collection: true
|
24
|
+
attribute :number, TheCustomProfile::Number, collection: true
|
25
|
+
attribute :year_version, TheCustomProfile::YearVersion, collection: true
|
26
|
+
attribute :informative, TheCustomProfile::Informative, collection: true
|
27
|
+
attribute :persistence, TheCustomProfile::Persistence, collection: true
|
28
|
+
attribute :abstract, TheCustomProfile::Abstract, collection: true
|
18
29
|
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
|
22
|
-
class Root <
|
33
|
+
class Root < Lutaml::Model::Serializable
|
23
34
|
include RootAttributes
|
24
35
|
attribute :model, Uml::UmlModel
|
25
36
|
|
26
|
-
xml do
|
37
|
+
xml do # rubocop:disable Metrics/BlockLength
|
27
38
|
root "XMI"
|
28
39
|
namespace "http://www.omg.org/spec/XMI/20131001", "xmi"
|
29
40
|
|
@@ -38,6 +49,42 @@ module Xmi
|
|
38
49
|
map_element "Model", to: :model,
|
39
50
|
namespace: "http://www.omg.org/spec/UML/20131001",
|
40
51
|
prefix: "uml"
|
52
|
+
map_element "Bibliography", to: :bibliography,
|
53
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
54
|
+
prefix: "thecustomprofile"
|
55
|
+
map_element "BasicDoc", to: :basic_doc,
|
56
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
57
|
+
prefix: "thecustomprofile"
|
58
|
+
map_element "enumeration", to: :enumeration,
|
59
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
60
|
+
prefix: "thecustomprofile"
|
61
|
+
map_element "OCL", to: :ocl,
|
62
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
63
|
+
prefix: "thecustomprofile"
|
64
|
+
map_element "invariant", to: :invariant,
|
65
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
66
|
+
prefix: "thecustomprofile"
|
67
|
+
map_element "publicationDate", to: :publication_date,
|
68
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
69
|
+
prefix: "thecustomprofile"
|
70
|
+
map_element "edition", to: :edition,
|
71
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
72
|
+
prefix: "thecustomprofile"
|
73
|
+
map_element "number", to: :number,
|
74
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
75
|
+
prefix: "thecustomprofile"
|
76
|
+
map_element "yearVersion", to: :year_version,
|
77
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
78
|
+
prefix: "thecustomprofile"
|
79
|
+
map_element "informative", to: :informative,
|
80
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
81
|
+
prefix: "thecustomprofile"
|
82
|
+
map_element "persistence", to: :persistence,
|
83
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
84
|
+
prefix: "thecustomprofile"
|
85
|
+
map_element "Abstract", to: :abstract,
|
86
|
+
namespace: "http://www.sparxsystems.com/profiles/thecustomprofile/1.0",
|
87
|
+
prefix: "thecustomprofile"
|
41
88
|
end
|
42
89
|
end
|
43
90
|
end
|