xmi 0.3.11 → 0.3.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f28d3c54dae3a98e330a2796b7b4e56b037872d8dc97d368abf03933395f0cd6
4
- data.tar.gz: 9394121164c9cea9289e307fedc169f93582fcf919c97754d4019e291571cac8
3
+ metadata.gz: 29186153bf7800bf8598896c54e39d3fedf33050f30f4b293d7dc7f7a7feb647
4
+ data.tar.gz: 6015b0dd368ce974936e5523c6922b25c32ecc1da0de7b6cb513befa374faee3
5
5
  SHA512:
6
- metadata.gz: 7b177985b1f6ade3ac48774edd3646ba3919fbe1584fccb1a73acea26838dc7280521915b188a67a61e2ead40522bbe9a7fbbefe423b46a9eb09948833e1b516
7
- data.tar.gz: 4955196380b0766d438d82ac6b597ed74cbdc06c4474a5c553fe81c7328d945331a25fea4af62d2609f9a56da7945dd89211e1bf8007d2a0ffd0731d3a08b694
6
+ metadata.gz: b37243cfcaa5af49787ab29ed5716b8f4a35a5ae05c7a2a68ff33fa48ab1e6e646a8b3a8aecee63748b9b25437c7020c2a2ea6f8c85869891c8e5b8f60f108a6
7
+ data.tar.gz: 870d45548e6778f05da8ef5f511e5259e5f914df115dc5e3e56a30112735b4cb47c58f2ff12de986280ef17e4cb97c26ccbf2ae650b2f712e808b4a40a923301
data/Gemfile CHANGED
@@ -4,9 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in xmi.gemspec
6
6
  gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
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 < Shale::Mapper
10
- attribute :id, Shale::Type::Value
11
- attribute :label, Shale::Type::String
12
- attribute :uuid, Shale::Type::String
13
- attribute :href, Shale::Type::Value
14
- attribute :idref, Shale::Type::Value
15
- attribute :type, Shale::Type::Value
16
- attribute :target, Shale::Type::Value
17
- attribute :container, Shale::Type::Value
18
- attribute :position, Shale::Type::Integer
19
- attribute :addition, Shale::Type::Value
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 < Shale::Mapper
10
- attribute :id, Shale::Type::Value
11
- attribute :label, Shale::Type::String
12
- attribute :uuid, Shale::Type::String
13
- attribute :href, Shale::Type::Value
14
- attribute :idref, Shale::Type::Value
15
- attribute :type, Shale::Type::Value
16
- attribute :target, Shale::Type::Value
17
- attribute :container, Shale::Type::Value
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
 
@@ -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 < Shale::Mapper
9
- attribute :id, Shale::Type::Value
10
- attribute :label, Shale::Type::String
11
- attribute :uuid, Shale::Type::String
12
- attribute :href, Shale::Type::Value
13
- attribute :idref, Shale::Type::Value
14
- attribute :type, Shale::Type::Value
15
- attribute :target, Shale::Type::Value
16
- attribute :container, Shale::Type::Value
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
 
@@ -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 < Shale::Mapper
9
- attribute :id, Shale::Type::Value
10
- attribute :label, Shale::Type::String
11
- attribute :uuid, Shale::Type::String
12
- attribute :href, Shale::Type::Value
13
- attribute :idref, Shale::Type::Value
14
- attribute :type, Shale::Type::Value
15
- attribute :contact, Shale::Type::String, collection: true
16
- attribute :exporter, Shale::Type::String
17
- attribute :exporter_version, Shale::Type::String
18
- attribute :exporter_id, Shale::Type::String
19
- attribute :long_description, Shale::Type::String, collection: true
20
- attribute :short_description, Shale::Type::String, collection: true
21
- attribute :notice, Shale::Type::String, collection: true
22
- attribute :owner, Shale::Type::String, collection: true
23
- attribute :timestamp, Shale::Type::Time, collection: true
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 = construct_shale_xml_mappings(new_klasses, module_name)
65
- update_shale_attributes(new_klasses, Xmi::Sparx::SparxRoot, module_name)
66
- update_shale_xml_mappings(map_elements, Xmi::Sparx::SparxRoot)
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 construct_shale_xml_mappings(new_klasses, module_name) # rubocop:disable Metrics/MethodLength
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#", Shale::Utils.snake_case(klass.to_s))
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 update_shale_attributes(new_klasses, sparx_root, module_name)
85
+ def update_model_attributes(new_klasses, sparx_root, module_name)
86
86
  new_klasses.each do |klass|
87
- method_name = Shale::Utils.snake_case(klass)
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 update_shale_xml_mappings(map_elements, sparx_root)
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 Shale::Mapper.to_s unless node
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 = Shale::Utils.snake_case(attr_method)
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 = "Shale::Type::String")
140
- tag_name = Shale::Utils.snake_case(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#", Shale::Utils.classify(klass_name))
179
- .gsub("#FROM_KLASS#", "Shale::Mapper")
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#", Shale::Utils.classify(node_name))
272
- .gsub("#FROM_KLASS#", Shale::Utils.classify(abstract_klass_name))
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 < Shale::Mapper
7
- attribute :id, Shale::Type::String
8
- attribute :label, Shale::Type::String
9
- attribute :uuid, Shale::Type::String
10
- attribute :href, Shale::Type::String
11
- attribute :idref, Shale::Type::String
12
- attribute :type, Shale::Type::String
13
- attribute :extender, Shale::Type::String
14
- attribute :extender_id, Shale::Type::String
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"
@@ -3,8 +3,8 @@
3
3
  module Xmi
4
4
  class EaRoot
5
5
  module Eauml
6
- class Import < Shale::Mapper
7
- attribute :base_package_import, Shale::Type::String
6
+ class Import < Lutaml::Model::Serializable
7
+ attribute :base_package_import, :string
8
8
 
9
9
  xml do
10
10
  root "import"
@@ -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 < Shale::Mapper
9
- attribute :version, Shale::Type::String
10
- attribute :xsd_document, Shale::Type::String
11
- attribute :xmlns, Shale::Type::String
12
- attribute :target_namespace, Shale::Type::String
13
- attribute :base_package, Shale::Type::String
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 "xmlns", to: :xmlns
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 < Shale::Mapper
27
- attribute :as_dictionary, Shale::Type::String
28
- attribute :default_code_space, Shale::Type::String
29
- attribute :base_class, Shale::Type::String
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 < Shale::Mapper
41
- attribute :is_collection, Shale::Type::String
42
- attribute :no_property_type, Shale::Type::String
43
- attribute :base_class, Shale::Type::String
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 < Shale::Mapper
55
- attribute :is_collection, Shale::Type::String
56
- attribute :no_property_type, Shale::Type::String
57
- attribute :base_class, Shale::Type::String
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 < Shale::Mapper
69
- attribute :base_enumeration, Shale::Type::String
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 < Shale::Mapper
79
- attribute :is_collection, Shale::Type::String
80
- attribute :no_property_type, Shale::Type::String
81
- attribute :base_class, Shale::Type::String
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 < Shale::Mapper
93
- attribute :is_collection, Shale::Type::String
94
- attribute :no_property_type, Shale::Type::String
95
- attribute :base_class, Shale::Type::String
96
- attribute :by_value_property_type, Shale::Type::String
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 < Shale::Mapper
109
- attribute :sequence_number, Shale::Type::String
110
- attribute :base_property, Shale::Type::String
111
- attribute :is_metadata, Shale::Type::String
112
- attribute :inline_or_by_reference, Shale::Type::String
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 < Shale::Mapper
10
- attribute :id, Shale::Type::Value
11
- attribute :label, Shale::Type::String
12
- attribute :uuid, Shale::Type::String
13
- attribute :href, Shale::Type::Value
14
- attribute :idref, Shale::Type::Value
15
- attribute :type, Shale::Type::Value
16
- attribute :target, Shale::Type::Value
17
- attribute :container, Shale::Type::Value
18
- attribute :position, Shale::Type::Integer
19
- attribute :replacement, Shale::Type::Value
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, Shale::Type::String
12
- attribute :label, Shale::Type::String
13
- attribute :uuid, Shale::Type::String
14
- attribute :href, Shale::Type::String
15
- attribute :idref, Shale::Type::String
16
- attribute :type, Shale::Type::String
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 < Shale::Mapper
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