xmi 0.3.21 → 0.5.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +13 -6
  3. data/.gitignore +2 -1
  4. data/.rubocop.yml +12 -13
  5. data/.rubocop_todo.yml +150 -13
  6. data/CHANGELOG.md +55 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +10 -0
  9. data/README.adoc +319 -6
  10. data/benchmark_parse.rb +60 -0
  11. data/docs/migration.md +141 -0
  12. data/docs/versioning.md +255 -0
  13. data/lib/xmi/add.rb +14 -38
  14. data/lib/xmi/{the_custom_profile.rb → custom_profile.rb} +25 -25
  15. data/lib/xmi/delete.rb +14 -38
  16. data/lib/xmi/difference.rb +14 -38
  17. data/lib/xmi/documentation.rb +16 -101
  18. data/lib/xmi/ea_root.rb +114 -33
  19. data/lib/xmi/extension.rb +6 -6
  20. data/lib/xmi/namespace/dynamic.rb +28 -0
  21. data/lib/xmi/namespace/omg.rb +81 -0
  22. data/lib/xmi/namespace/sparx.rb +39 -0
  23. data/lib/xmi/namespace.rb +9 -0
  24. data/lib/xmi/namespace_detector.rb +138 -0
  25. data/lib/xmi/namespace_registry.rb +119 -0
  26. data/lib/xmi/parsing.rb +113 -0
  27. data/lib/xmi/replace.rb +14 -38
  28. data/lib/xmi/root.rb +49 -213
  29. data/lib/xmi/sparx/connector.rb +241 -0
  30. data/lib/xmi/sparx/custom_profile.rb +19 -0
  31. data/lib/xmi/sparx/diagram.rb +97 -0
  32. data/lib/xmi/sparx/ea_stub.rb +20 -0
  33. data/lib/xmi/{extensions/eauml.rb → sparx/ea_uml.rb} +3 -2
  34. data/lib/xmi/sparx/element.rb +453 -0
  35. data/lib/xmi/sparx/extension.rb +43 -0
  36. data/lib/xmi/{extensions → sparx}/gml.rb +9 -3
  37. data/lib/xmi/sparx/mappings/base_mapping.rb +182 -0
  38. data/lib/xmi/sparx/mappings.rb +10 -0
  39. data/lib/xmi/sparx/primitive_type.rb +18 -0
  40. data/lib/xmi/sparx/root.rb +60 -0
  41. data/lib/xmi/sparx/sys_ph_s.rb +18 -0
  42. data/lib/xmi/sparx.rb +17 -1376
  43. data/lib/xmi/type.rb +37 -0
  44. data/lib/xmi/uml.rb +191 -469
  45. data/lib/xmi/v20110701.rb +81 -0
  46. data/lib/xmi/v20131001.rb +68 -0
  47. data/lib/xmi/v20161101.rb +61 -0
  48. data/lib/xmi/version.rb +1 -1
  49. data/lib/xmi/version_registry.rb +164 -0
  50. data/lib/xmi/versioned.rb +142 -0
  51. data/lib/xmi.rb +83 -11
  52. data/scripts-xmi-profile/profile_xmi_simple.rb +213 -0
  53. data/xmi.gemspec +3 -9
  54. metadata +38 -77
data/lib/xmi/uml.rb CHANGED
@@ -3,83 +3,80 @@
3
3
  module Xmi
4
4
  module Uml
5
5
  class AnnotatedElement < Lutaml::Model::Serializable
6
- attribute :idref, :string
6
+ attribute :idref, ::Xmi::Type::XmiIdRef
7
7
 
8
8
  xml do
9
9
  root "annotatedElement"
10
+ namespace ::Xmi::Namespace::Omg::Uml
10
11
 
11
- map_attribute "idref", to: :idref, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
12
+ map_attribute "idref", to: :idref
12
13
  end
13
14
  end
14
15
 
15
16
  class Type < Lutaml::Model::Serializable
16
- attribute :idref, :string
17
+ attribute :idref, ::Xmi::Type::XmiIdRef
17
18
  attribute :href, :string
18
19
 
19
20
  xml do
20
21
  root "type"
22
+ namespace ::Xmi::Namespace::Omg::Uml
21
23
 
22
- map_attribute "idref", to: :idref, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
24
+ map_attribute "idref", to: :idref
23
25
  map_attribute "href", to: :href
24
26
  end
25
27
  end
26
28
 
27
29
  class MemberEnd < Lutaml::Model::Serializable
28
- attribute :idref, :string
30
+ attribute :idref, ::Xmi::Type::XmiIdRef
29
31
 
30
32
  xml do
31
33
  root "memberEnd"
34
+ namespace ::Xmi::Namespace::Omg::Uml
32
35
 
33
- map_attribute "idref", to: :idref, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
34
- end
35
- end
36
-
37
- module OwnedEndAttributes
38
- def self.included(klass) # rubocop:disable Metrics/MethodLength
39
- klass.class_eval do
40
- attribute :type, :string
41
- attribute :id, :string
42
- attribute :association, :string
43
- attribute :name, :string
44
- attribute :type_attr, :string
45
- attribute :uml_type, Uml::Type
46
- attribute :member_end, :string
47
- attribute :lower, :integer
48
- attribute :upper, :integer
49
- attribute :is_composite, :boolean
50
- end
36
+ map_attribute "idref", to: :idref
51
37
  end
52
38
  end
53
39
 
54
40
  class OwnedEnd < Lutaml::Model::Serializable
55
- include OwnedEndAttributes
41
+ attribute :type, ::Xmi::Type::XmiType
42
+ attribute :id, ::Xmi::Type::XmiId
43
+ attribute :association, :string
44
+ attribute :name, :string
45
+ attribute :type_attr, :string
46
+ attribute :uml_type, Uml::Type
47
+ attribute :member_end, :string
48
+ attribute :lower, :integer
49
+ attribute :upper, :integer
50
+ attribute :is_composite, :boolean
56
51
 
57
52
  xml do
58
53
  root "ownedEnd"
54
+ namespace ::Xmi::Namespace::Omg::Uml
59
55
 
60
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
61
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
56
+ map_attribute "type", to: :type
57
+ map_attribute "id", to: :id
62
58
  map_attribute "association", to: :association
63
59
  map_attribute "name", to: :name
64
60
  map_attribute "memberEnd", to: :member_end
65
- map_attribute "type", to: :type_attr, namespace: nil, prefix: nil
61
+ map_attribute "type", to: :type_attr
66
62
  map_attribute "lower", to: :lower
67
63
  map_attribute "upper", to: :upper
68
64
  map_attribute "isComposite", to: :is_composite
69
- map_element "type", to: :uml_type, namespace: nil, prefix: nil
65
+ map_element "type", to: :uml_type
70
66
  end
71
67
  end
72
68
 
73
69
  class DefaultValue < Lutaml::Model::Serializable
74
- attribute :type, :string
75
- attribute :id, :string
70
+ attribute :type, ::Xmi::Type::XmiType
71
+ attribute :id, ::Xmi::Type::XmiId
76
72
  attribute :value, :string
77
73
 
78
74
  xml do
79
75
  root "defaultValue"
76
+ namespace ::Xmi::Namespace::Omg::Uml
80
77
 
81
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
82
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
78
+ map_attribute "type", to: :type
79
+ map_attribute "id", to: :id
83
80
  map_attribute "value", to: :value
84
81
  end
85
82
  end
@@ -87,9 +84,10 @@ module Xmi
87
84
  class UpperValue < DefaultValue
88
85
  xml do
89
86
  root "upperValue"
87
+ namespace ::Xmi::Namespace::Omg::Uml
90
88
 
91
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
92
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
89
+ map_attribute "type", to: :type
90
+ map_attribute "id", to: :id
93
91
  map_attribute "value", to: :value
94
92
  end
95
93
  end
@@ -97,67 +95,62 @@ module Xmi
97
95
  class LowerValue < DefaultValue
98
96
  xml do
99
97
  root "lowerValue"
98
+ namespace ::Xmi::Namespace::Omg::Uml
100
99
 
101
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
102
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
100
+ map_attribute "type", to: :type
101
+ map_attribute "id", to: :id
103
102
  map_attribute "value", to: :value
104
103
  end
105
104
  end
106
105
 
107
106
  class OwnedLiteral < Lutaml::Model::Serializable
108
- attribute :type, :string
109
- attribute :id, :string
107
+ attribute :type, ::Xmi::Type::XmiType
108
+ attribute :id, ::Xmi::Type::XmiId
110
109
  attribute :name, :string
111
110
  attribute :uml_type, Uml::Type
112
111
 
113
112
  xml do
114
113
  root "ownedLiteral"
114
+ namespace ::Xmi::Namespace::Omg::Uml
115
115
 
116
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
117
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
116
+ map_attribute "type", to: :type
117
+ map_attribute "id", to: :id
118
118
  map_attribute "name", to: :name
119
119
 
120
- map_element "type", to: :uml_type, namespace: nil, prefix: nil
121
- end
122
- end
123
-
124
- module OwnedAttributeAttributes
125
- def self.included(klass)
126
- klass.class_eval do
127
- attribute :type, :string
128
- attribute :id, :string
129
- attribute :association, :string
130
- attribute :name, :string
131
- attribute :is_derived, :string
132
- attribute :uml_type, Uml::Type
133
- attribute :upper_value, UpperValue
134
- attribute :lower_value, LowerValue
135
- end
120
+ map_element "type", to: :uml_type
136
121
  end
137
122
  end
138
123
 
139
124
  class OwnedAttribute < Lutaml::Model::Serializable
140
- include OwnedAttributeAttributes
125
+ attribute :type, ::Xmi::Type::XmiType
126
+ attribute :id, ::Xmi::Type::XmiId
127
+ attribute :association, :string
128
+ attribute :name, :string
129
+ attribute :is_derived, :string
130
+ attribute :uml_type, Uml::Type
131
+ attribute :upper_value, UpperValue
132
+ attribute :lower_value, LowerValue
141
133
 
142
134
  xml do
143
135
  root "ownedAttribute"
136
+ namespace ::Xmi::Namespace::Omg::Uml
144
137
 
145
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
146
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
138
+ map_attribute "type", to: :type
139
+ map_attribute "id", to: :id
147
140
  map_attribute "association", to: :association
148
141
  map_attribute "name", to: :name
149
142
  map_attribute "isDerived", to: :is_derived
150
143
 
151
- map_element "type", to: :uml_type, namespace: nil, prefix: nil
152
- map_element "upperValue", to: :upper_value, namespace: nil, prefix: nil
153
- map_element "lowerValue", to: :lower_value, namespace: nil, prefix: nil
144
+ map_element "type", to: :uml_type
145
+ map_element "upperValue", to: :upper_value
146
+ map_element "lowerValue", to: :lower_value
154
147
  end
155
148
  end
156
149
 
157
150
  class OwnedParameter < Lutaml::Model::Serializable
158
- attribute :id, :string
151
+ attribute :id, ::Xmi::Type::XmiId
159
152
  attribute :name, :string
160
- attribute :type, :string
153
+ attribute :type, ::Xmi::Type::XmiType
161
154
  attribute :direction, :string
162
155
  attribute :upper_value, UpperValue
163
156
  attribute :lower_value, LowerValue
@@ -165,173 +158,132 @@ module Xmi
165
158
 
166
159
  xml do
167
160
  root "ownedParameter"
161
+ namespace ::Xmi::Namespace::Omg::Uml
168
162
 
169
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
163
+ map_attribute "id", to: :id
170
164
  map_attribute "name", to: :name
171
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
165
+ map_attribute "type", to: :type
172
166
  map_attribute "direction", to: :direction
173
167
 
174
- map_element "upperValue", to: :upper_value, namespace: nil, prefix: nil
175
- map_element "lowerValue", to: :lower_value, namespace: nil, prefix: nil
176
- map_element "defaultValue", to: :default_value, namespace: nil, prefix: nil
168
+ map_element "upperValue", to: :upper_value
169
+ map_element "lowerValue", to: :lower_value
170
+ map_element "defaultValue", to: :default_value
177
171
  end
178
172
  end
179
173
 
180
174
  class Specification < Lutaml::Model::Serializable
181
- attribute :id, :string
182
- attribute :type, :string
175
+ attribute :id, ::Xmi::Type::XmiId
176
+ attribute :type, ::Xmi::Type::XmiType
183
177
  attribute :language, :string
184
178
 
185
179
  xml do
186
180
  root "specification"
187
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
188
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
181
+ namespace ::Xmi::Namespace::Omg::Uml
182
+
183
+ map_attribute "id", to: :id
184
+ map_attribute "type", to: :type
189
185
  map_attribute "language", to: :language
190
186
  end
191
187
  end
192
188
 
193
189
  class Precondition < Lutaml::Model::Serializable
194
- attribute :id, :string
190
+ attribute :id, ::Xmi::Type::XmiId
195
191
  attribute :name, :string
196
- attribute :type, :string
192
+ attribute :type, ::Xmi::Type::XmiType
197
193
  attribute :specification, Specification
198
194
 
199
195
  xml do
200
196
  root "precondition"
201
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
197
+ namespace ::Xmi::Namespace::Omg::Uml
198
+
199
+ map_attribute "id", to: :id
202
200
  map_attribute "name", to: :name
203
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
204
- map_element "specification", to: :specification, namespace: nil, prefix: nil
201
+ map_attribute "type", to: :type
202
+ map_element "specification", to: :specification
205
203
  end
206
204
  end
207
205
 
208
206
  class OwnedOperation < Lutaml::Model::Serializable
209
- attribute :id, :string
207
+ attribute :id, ::Xmi::Type::XmiId
210
208
  attribute :name, :string
211
209
  attribute :owned_parameter, OwnedParameter, collection: true
212
210
  attribute :precondition, Precondition
213
211
  attribute :uml_type, Uml::Type, collection: true
214
212
 
215
- xml do # rubocop:disable Metrics/BlockLength
213
+ xml do
216
214
  root "ownedOperation"
217
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
215
+ map_attribute "id", to: :id
218
216
  map_attribute "name", to: :name
219
- map_element "ownedParameter", to: :owned_parameter, namespace: nil,
220
- prefix: nil,
221
- value_map: {
222
- from: {
223
- nil: :empty,
224
- empty: :empty,
225
- omitted: :empty
226
- },
227
- to: {
228
- nil: :empty,
229
- empty: :empty,
230
- omitted: :empty
231
- }
232
- }
233
- map_element "precondition", to: :precondition, namespace: nil,
234
- prefix: nil
235
- map_element "type", to: :uml_type, namespace: nil, prefix: nil,
236
- value_map: {
237
- from: {
238
- nil: :empty,
239
- empty: :empty,
240
- omitted: :empty
241
- },
242
- to: {
243
- nil: :empty,
244
- empty: :empty,
245
- omitted: :empty
246
- }
247
- }
248
- end
249
- end
250
-
251
- module OwnedCommentAttributes
252
- def self.included(klass)
253
- klass.class_eval do
254
- attribute :type, :string
255
- attribute :id, :string
256
- attribute :name, :string
257
- attribute :body_element, :string
258
- attribute :body_attribute, :string
259
- attribute :annotated_attribute, :string
260
- attribute :annotated_element, AnnotatedElement
261
- end
217
+ map_element "ownedParameter", to: :owned_parameter, value_map: VALUE_MAP
218
+ map_element "precondition", to: :precondition
219
+ map_element "type", to: :uml_type, value_map: VALUE_MAP
262
220
  end
263
221
  end
264
222
 
265
223
  class OwnedComment < Lutaml::Model::Serializable
266
- include OwnedCommentAttributes
224
+ attribute :type, ::Xmi::Type::XmiType
225
+ attribute :id, ::Xmi::Type::XmiId
226
+ attribute :name, :string
227
+ attribute :body_element, :string
228
+ attribute :body_attribute, :string
229
+ attribute :annotated_attribute, :string
230
+ attribute :annotated_element, AnnotatedElement
267
231
 
268
232
  xml do
269
233
  root "ownedComment"
234
+ namespace ::Xmi::Namespace::Omg::Uml
270
235
 
271
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
272
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
236
+ map_attribute "type", to: :type
237
+ map_attribute "id", to: :id
273
238
  map_attribute "name", to: :name
274
239
  map_attribute "body", to: :body_attribute
275
240
  map_attribute "annotatedElement", to: :annotated_attribute
276
241
 
277
- map_element "annotatedElement", to: :annotated_element, prefix: nil, namespace: nil
278
- map_element "body", to: :body_element, namespace: nil, prefix: nil
279
- end
280
- end
281
-
282
- module AssociationGeneralizationAttributes
283
- def self.included(klass)
284
- klass.class_eval do
285
- attribute :type, :string
286
- attribute :id, :string
287
- attribute :general, :string
288
- end
242
+ map_element "annotatedElement", to: :annotated_element
243
+ map_element "body", to: :body_element
289
244
  end
290
245
  end
291
246
 
292
247
  class AssociationGeneralization < Lutaml::Model::Serializable
293
- include AssociationGeneralizationAttributes
248
+ attribute :type, ::Xmi::Type::XmiType
249
+ attribute :id, ::Xmi::Type::XmiId
250
+ attribute :general, :string
294
251
 
295
252
  xml do
296
253
  root "generalization"
254
+ namespace ::Xmi::Namespace::Omg::Uml
297
255
 
298
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
299
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
256
+ map_attribute "type", to: :type
257
+ map_attribute "id", to: :id
300
258
  map_attribute "general", to: :general
301
259
  end
302
260
  end
303
261
 
304
- module PackagedElementAttributes
305
- def self.included(klass) # rubocop:disable Metrics/MethodLength
306
- klass.class_eval do
307
- attribute :type, :string
308
- attribute :id, :string
309
- attribute :name, :string
310
- attribute :member_end, :string
311
- attribute :member_ends, MemberEnd, collection: true
312
- attribute :owned_literal, OwnedLiteral, collection: true
313
- attribute :owned_operation, OwnedOperation, collection: true
314
-
315
- # EA specific
316
- attribute :supplier, :string
317
- attribute :client, :string
318
- end
319
- end
320
- end
262
+ class PackagedElement < Lutaml::Model::Serializable
263
+ attribute :type, ::Xmi::Type::XmiType
264
+ attribute :id, ::Xmi::Type::XmiId
265
+ attribute :name, :string
266
+ attribute :member_end, :string
267
+ attribute :member_ends, MemberEnd, collection: true
268
+ attribute :owned_literal, OwnedLiteral, collection: true
269
+ attribute :owned_operation, OwnedOperation, collection: true
270
+
271
+ # EA specific
272
+ attribute :supplier, :string
273
+ attribute :client, :string
321
274
 
322
- class PackagedElement < Lutaml::Model::Serializable # rubocop:disable Metrics/ClassLength
323
- include PackagedElementAttributes
324
275
  attribute :packaged_element, PackagedElement, collection: true
325
276
  attribute :owned_end, OwnedEnd, collection: true
326
277
  attribute :owned_attribute, OwnedAttribute, collection: true
327
278
  attribute :owned_comment, OwnedComment, collection: true
328
279
  attribute :generalization, AssociationGeneralization, collection: true
329
280
 
330
- xml do # rubocop:disable Metrics/BlockLength
281
+ xml do
331
282
  root "packagedElement"
283
+ namespace ::Xmi::Namespace::Omg::Uml
332
284
 
333
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
334
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
285
+ map_attribute "type", to: :type
286
+ map_attribute "id", to: :id
335
287
  map_attribute "name", to: :name
336
288
  map_attribute "memberEnd", to: :member_end
337
289
 
@@ -339,122 +291,21 @@ module Xmi
339
291
  map_attribute "supplier", to: :supplier
340
292
  map_attribute "client", to: :client
341
293
 
342
- map_element "generalization", to: :generalization, namespace: nil,
343
- prefix: nil,
344
- value_map: {
345
- from: {
346
- nil: :empty,
347
- empty: :empty,
348
- omitted: :empty
349
- },
350
- to: {
351
- nil: :empty,
352
- empty: :empty,
353
- omitted: :empty
354
- }
355
- }
356
- map_element "ownedComment", to: :owned_comment, namespace: nil,
357
- prefix: nil,
358
- value_map: {
359
- from: {
360
- nil: :empty,
361
- empty: :empty,
362
- omitted: :empty
363
- },
364
- to: {
365
- nil: :empty,
366
- empty: :empty,
367
- omitted: :empty
368
- }
369
- }
370
- map_element "ownedEnd", to: :owned_end, namespace: nil, prefix: nil,
371
- value_map: {
372
- from: {
373
- nil: :empty,
374
- empty: :empty,
375
- omitted: :empty
376
- },
377
- to: {
378
- nil: :empty,
379
- empty: :empty,
380
- omitted: :empty
381
- }
382
- }
383
- map_element "ownedLiteral", to: :owned_literal, namespace: nil,
384
- prefix: nil,
385
- value_map: {
386
- from: {
387
- nil: :empty,
388
- empty: :empty,
389
- omitted: :empty
390
- },
391
- to: {
392
- nil: :empty,
393
- empty: :empty,
394
- omitted: :empty
395
- }
396
- }
397
- map_element "ownedAttribute", to: :owned_attribute, namespace: nil,
398
- prefix: nil,
399
- value_map: {
400
- from: {
401
- nil: :empty,
402
- empty: :empty,
403
- omitted: :empty
404
- },
405
- to: {
406
- nil: :empty,
407
- empty: :empty,
408
- omitted: :empty
409
- }
410
- }
411
- map_element "ownedOperation", to: :owned_operation, namespace: nil,
412
- prefix: nil,
413
- value_map: {
414
- from: {
415
- nil: :empty,
416
- empty: :empty,
417
- omitted: :empty
418
- },
419
- to: {
420
- nil: :empty,
421
- empty: :empty,
422
- omitted: :empty
423
- }
424
- }
425
- map_element "packagedElement", to: :packaged_element, namespace: nil,
426
- prefix: nil,
427
- value_map: {
428
- from: {
429
- nil: :empty,
430
- empty: :empty,
431
- omitted: :empty
432
- },
433
- to: {
434
- nil: :empty,
435
- empty: :empty,
436
- omitted: :empty
437
- }
438
- }
439
- map_element "memberEnd", to: :member_ends, namespace: nil, prefix: nil,
440
- value_map: {
441
- from: {
442
- nil: :empty,
443
- empty: :empty,
444
- omitted: :empty
445
- },
446
- to: {
447
- nil: :empty,
448
- empty: :empty,
449
- omitted: :empty
450
- }
451
- }
294
+ map_element "generalization", to: :generalization, value_map: VALUE_MAP
295
+ map_element "ownedComment", to: :owned_comment, value_map: VALUE_MAP
296
+ map_element "ownedEnd", to: :owned_end, value_map: VALUE_MAP
297
+ map_element "ownedLiteral", to: :owned_literal, value_map: VALUE_MAP
298
+ map_element "ownedAttribute", to: :owned_attribute, value_map: VALUE_MAP
299
+ map_element "ownedOperation", to: :owned_operation, value_map: VALUE_MAP
300
+ map_element "packagedElement", to: :packaged_element,
301
+ value_map: VALUE_MAP
302
+ map_element "memberEnd", to: :member_ends, value_map: VALUE_MAP
452
303
  end
453
304
  end
454
305
 
455
306
  class Bounds < Lutaml::Model::Serializable
456
- attribute :type, :string
457
- attribute :id, :string
307
+ attribute :type, ::Xmi::Type::XmiType
308
+ attribute :id, ::Xmi::Type::XmiId
458
309
  attribute :x, :integer
459
310
  attribute :y, :integer
460
311
  attribute :height, :integer
@@ -462,9 +313,10 @@ module Xmi
462
313
 
463
314
  xml do
464
315
  root "bounds"
316
+ namespace ::Xmi::Namespace::Omg::Uml
465
317
 
466
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
467
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
318
+ map_attribute "type", to: :type
319
+ map_attribute "id", to: :id
468
320
  map_attribute "x", to: :x
469
321
  map_attribute "y", to: :y
470
322
  map_attribute "height", to: :height
@@ -473,24 +325,25 @@ module Xmi
473
325
  end
474
326
 
475
327
  class Waypoint < Lutaml::Model::Serializable
476
- attribute :type, :string
477
- attribute :id, :string
328
+ attribute :type, ::Xmi::Type::XmiType
329
+ attribute :id, ::Xmi::Type::XmiId
478
330
  attribute :x, :integer
479
331
  attribute :y, :integer
480
332
 
481
333
  xml do
482
334
  root "waypoint"
335
+ namespace ::Xmi::Namespace::Omg::Uml
483
336
 
484
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
485
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
337
+ map_attribute "type", to: :type
338
+ map_attribute "id", to: :id
486
339
  map_attribute "x", to: :x
487
340
  map_attribute "y", to: :y
488
341
  end
489
342
  end
490
343
 
491
344
  class OwnedElement < Lutaml::Model::Serializable
492
- attribute :type, :string
493
- attribute :id, :string
345
+ attribute :type, ::Xmi::Type::XmiType
346
+ attribute :id, ::Xmi::Type::XmiId
494
347
  attribute :text, :string
495
348
  attribute :model_element, :string
496
349
  attribute :owned_element, OwnedElement, collection: true
@@ -499,112 +352,69 @@ module Xmi
499
352
  attribute :target, :string
500
353
  attribute :waypoint, Waypoint
501
354
 
502
- xml do # rubocop:disable Metrics/BlockLength
355
+ xml do
503
356
  root "ownedElement"
357
+ namespace ::Xmi::Namespace::Omg::Uml
504
358
 
505
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
506
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
359
+ map_attribute "type", to: :type
360
+ map_attribute "id", to: :id
507
361
  map_attribute "text", to: :text
508
362
  map_attribute "modelElement", to: :model_element
509
363
 
510
- map_element "ownedElement", to: :owned_element, namespace: nil,
511
- prefix: nil,
512
- value_map: {
513
- from: {
514
- nil: :empty,
515
- empty: :empty,
516
- omitted: :empty
517
- },
518
- to: {
519
- nil: :empty,
520
- empty: :empty,
521
- omitted: :empty
522
- }
523
- }
524
- map_element "bounds", to: :bounds, namespace: nil, prefix: nil,
525
- value_map: {
526
- from: {
527
- nil: :empty,
528
- empty: :empty,
529
- omitted: :empty
530
- },
531
- to: {
532
- nil: :empty,
533
- empty: :empty,
534
- omitted: :empty
535
- }
536
- }
537
- map_element "source", to: :source, namespace: nil, prefix: nil
538
- map_element "target", to: :target, namespace: nil, prefix: nil
539
- map_element "waypoint", to: :waypoint, namespace: nil, prefix: nil
540
- end
541
- end
542
-
543
- module DiagramAttributes
544
- def self.included(klass)
545
- klass.class_eval do
546
- attribute :type, :string
547
- attribute :id, :string
548
- attribute :is_frame, :boolean
549
- attribute :model_element, :string
550
- attribute :owned_element, OwnedElement, collection: true
551
- end
364
+ map_element "ownedElement", to: :owned_element, value_map: VALUE_MAP
365
+ map_element "bounds", to: :bounds, value_map: VALUE_MAP
366
+ map_element "source", to: :source
367
+ map_element "target", to: :target
368
+ map_element "waypoint", to: :waypoint
552
369
  end
553
370
  end
554
371
 
555
372
  class Diagram < Lutaml::Model::Serializable
556
- include DiagramAttributes
373
+ attribute :type, ::Xmi::Type::XmiType
374
+ attribute :id, ::Xmi::Type::XmiId
375
+ attribute :is_frame, :boolean
376
+ attribute :model_element, :string
377
+ attribute :owned_element, OwnedElement, collection: true
557
378
 
558
379
  xml do
559
380
  root "Diagram"
560
- namespace "http://www.omg.org/spec/UML/20131001/UMLDI", "umldi"
381
+ namespace ::Xmi::Namespace::Omg::UmlDi
561
382
 
562
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
563
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
383
+ map_attribute "type", to: :type
384
+ map_attribute "id", to: :id
564
385
  map_attribute "isFrame", to: :is_frame
565
386
  map_attribute "modelElement", to: :model_element
566
387
 
567
- map_element "ownedElement", to: :owned_element, namespace: nil,
568
- prefix: nil,
569
- value_map: {
570
- from: {
571
- nil: :empty,
572
- empty: :empty,
573
- omitted: :empty
574
- },
575
- to: {
576
- nil: :empty,
577
- empty: :empty,
578
- omitted: :empty
579
- }
580
- }
388
+ map_element "ownedElement", to: :owned_element, value_map: VALUE_MAP
581
389
  end
582
390
  end
583
391
 
584
392
  class ProfileApplicationAppliedProfile < Lutaml::Model::Serializable
585
- attribute :type, :string
393
+ attribute :type, ::Xmi::Type::XmiType
586
394
  attribute :href, :string
587
395
 
588
396
  xml do
589
397
  root "appliedProfile"
398
+ namespace ::Xmi::Namespace::Omg::Uml
590
399
 
591
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
400
+ map_attribute "type", to: :type
592
401
  map_attribute "href", to: :href
593
402
  end
594
403
  end
595
404
 
596
405
  class ProfileApplication < Lutaml::Model::Serializable
597
- attribute :type, :string
598
- attribute :id, :string
406
+ attribute :type, ::Xmi::Type::XmiType
407
+ attribute :id, ::Xmi::Type::XmiId
599
408
  attribute :applied_profile, ProfileApplicationAppliedProfile
600
409
 
601
410
  xml do
602
411
  root "profileApplication"
412
+ namespace ::Xmi::Namespace::Omg::Uml
603
413
 
604
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
605
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
414
+ map_attribute "type", to: :type
415
+ map_attribute "id", to: :id
606
416
 
607
- map_element "appliedProfile", to: :applied_profile, namespace: nil, prefix: nil
417
+ map_element "appliedProfile", to: :applied_profile
608
418
  end
609
419
  end
610
420
 
@@ -613,108 +423,56 @@ module Xmi
613
423
 
614
424
  xml do
615
425
  root "importedPackage"
426
+ namespace ::Xmi::Namespace::Omg::Uml
616
427
 
617
- map_attribute "href", to: :href, namespace: nil, prefix: nil
618
- end
619
- end
620
-
621
- module PackageImportAttributes
622
- def self.included(klass)
623
- klass.class_eval do
624
- attribute :id, :string
625
- attribute :imported_package, ImportedPackage
626
- end
428
+ map_attribute "href", to: :href
627
429
  end
628
430
  end
629
431
 
630
432
  class PackageImport < Lutaml::Model::Serializable
631
- include PackageImportAttributes
433
+ attribute :id, ::Xmi::Type::XmiId
434
+ attribute :imported_package, ImportedPackage
632
435
 
633
436
  xml do
634
437
  root "packageImport"
438
+ namespace ::Xmi::Namespace::Omg::Uml
635
439
 
636
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
440
+ map_attribute "id", to: :id
637
441
 
638
- map_element "importedPackage", to: :imported_package, namespace: nil, prefix: nil
639
- end
640
- end
641
-
642
- module UmlModelAttributes
643
- def self.included(klass)
644
- klass.class_eval do
645
- attribute :type, :string
646
- attribute :name, :string
647
- attribute :profile_application, ProfileApplication, collection: true
648
- end
442
+ map_element "importedPackage", to: :imported_package
649
443
  end
650
444
  end
651
445
 
652
446
  class UmlModel < Lutaml::Model::Serializable
653
- include UmlModelAttributes
447
+ attribute :type, ::Xmi::Type::XmiType
448
+ attribute :name, :string
449
+ attribute :profile_application, ProfileApplication, collection: true
654
450
  attribute :packaged_element, PackagedElement, collection: true
655
451
  attribute :package_import, PackageImport, collection: true
656
452
  attribute :diagram, Diagram
657
453
 
658
- xml do # rubocop:disable Metrics/BlockLength
454
+ xml do
659
455
  root "Model"
660
- namespace "http://www.omg.org/spec/UML/20131001", "uml"
456
+ namespace ::Xmi::Namespace::Omg::Uml
661
457
 
662
- map_attribute "type", to: :type, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
458
+ map_attribute "type", to: :type
663
459
  map_attribute "name", to: :name
664
460
 
665
- map_element "packageImport", to: :package_import, namespace: nil,
666
- prefix: nil,
667
- value_map: {
668
- from: {
669
- nil: :empty,
670
- empty: :empty,
671
- omitted: :empty
672
- },
673
- to: {
674
- nil: :empty,
675
- empty: :empty,
676
- omitted: :empty
677
- }
678
- }
679
- map_element "packagedElement", to: :packaged_element, namespace: nil,
680
- prefix: nil,
681
- value_map: {
682
- from: {
683
- nil: :empty,
684
- empty: :empty,
685
- omitted: :empty
686
- },
687
- to: {
688
- nil: :empty,
689
- empty: :empty,
690
- omitted: :empty
691
- }
692
- }
693
- map_element "Diagram", to: :diagram, namespace: "http://www.omg.org/spec/UML/20131001/UMLDI", prefix: "umldi"
461
+ map_element "packageImport", to: :package_import, value_map: VALUE_MAP
462
+ map_element "packagedElement", to: :packaged_element,
463
+ value_map: VALUE_MAP
464
+ map_element "Diagram", to: :diagram
694
465
  map_element "profileApplication", to: :profile_application,
695
- namespace: nil, prefix: nil,
696
- value_map: {
697
- from: {
698
- nil: :empty,
699
- empty: :empty,
700
- omitted: :empty
701
- },
702
- to: {
703
- nil: :empty,
704
- empty: :empty,
705
- omitted: :empty
706
- }
707
- }
466
+ value_map: VALUE_MAP
708
467
  end
709
468
  end
710
469
 
711
- # TODO: add attributes xmlns:uml and xmlns:xmi
712
470
  module ProfileAttributes
713
471
  def self.included(klass)
714
472
  klass.class_eval do
715
473
  attribute :packaged_element, PackagedElement, collection: true
716
474
  attribute :package_import, PackageImport, collection: true
717
- attribute :id, :string
475
+ attribute :id, ::Xmi::Type::XmiId
718
476
  attribute :name, :string
719
477
  # attribute :xmi, :string
720
478
  # attribute :uml, :string
@@ -728,58 +486,22 @@ module Xmi
728
486
 
729
487
  class Profile < Lutaml::Model::Serializable
730
488
  include ProfileAttributes
489
+
731
490
  attribute :owned_comment, OwnedComment, collection: true
732
491
 
733
- xml do # rubocop:disable Metrics/BlockLength
492
+ xml do
734
493
  root "Profile"
494
+ namespace ::Xmi::Namespace::Omg::Uml
735
495
 
736
- map_attribute "id", to: :id, namespace: "http://www.omg.org/spec/XMI/20131001", prefix: "xmi"
496
+ map_attribute "id", to: :id
737
497
  map_attribute "name", to: :name
738
498
  map_attribute "metamodelReference", to: :metamodel_reference
739
499
  map_attribute "nsPrefix", to: :ns_prefix
740
500
 
741
- map_element "ownedComment", to: :owned_comment, namespace: nil,
742
- prefix: nil,
743
- value_map: {
744
- from: {
745
- nil: :empty,
746
- empty: :empty,
747
- omitted: :empty
748
- },
749
- to: {
750
- nil: :empty,
751
- empty: :empty,
752
- omitted: :empty
753
- }
754
- }
755
- map_element "packageImport", to: :package_import, namespace: nil,
756
- prefix: nil,
757
- value_map: {
758
- from: {
759
- nil: :empty,
760
- empty: :empty,
761
- omitted: :empty
762
- },
763
- to: {
764
- nil: :empty,
765
- empty: :empty,
766
- omitted: :empty
767
- }
768
- }
769
- map_element "packagedElement", to: :packaged_element, namespace: nil,
770
- prefix: nil,
771
- value_map: {
772
- from: {
773
- nil: :empty,
774
- empty: :empty,
775
- omitted: :empty
776
- },
777
- to: {
778
- nil: :empty,
779
- empty: :empty,
780
- omitted: :empty
781
- }
782
- }
501
+ map_element "ownedComment", to: :owned_comment, value_map: VALUE_MAP
502
+ map_element "packageImport", to: :package_import, value_map: VALUE_MAP
503
+ map_element "packagedElement", to: :packaged_element,
504
+ value_map: VALUE_MAP
783
505
  end
784
506
  end
785
507
  end