ea 0.6.153 → 0.6.155

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 (178) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ea/cli/app.rb +8 -2
  3. data/lib/ea/cli/command/base.rb +1 -3
  4. data/lib/ea/cli/command/convert.rb +2 -2
  5. data/lib/ea/cli/command/diagrams.rb +4 -4
  6. data/lib/ea/cli/command/export.rb +1 -1
  7. data/lib/ea/cli/command/info.rb +1 -1
  8. data/lib/ea/cli/command/list.rb +2 -2
  9. data/lib/ea/cli/command/render.rb +1 -2
  10. data/lib/ea/cli/command/svg.rb +1 -1
  11. data/lib/ea/cli/command/validate.rb +1 -3
  12. data/lib/ea/cli/error.rb +1 -1
  13. data/lib/ea/cli/output.rb +1 -1
  14. data/lib/ea/diagram/display_config.rb +1 -1
  15. data/lib/ea/export/json/generator.rb +5 -5
  16. data/lib/ea/export/json_schema/generator.rb +2 -2
  17. data/lib/ea/export/plantuml/generator.rb +2 -2
  18. data/lib/ea/fonts/metrics.rb +3 -4
  19. data/lib/ea/lint/rules/cyclic_generalization.rb +1 -1
  20. data/lib/ea/lint/rules/duplicate_name.rb +1 -1
  21. data/lib/ea/lint/rules/missing_stereotype.rb +4 -3
  22. data/lib/ea/lint/rules/naming_convention.rb +11 -11
  23. data/lib/ea/lint/rules/orphan_element.rb +6 -6
  24. data/lib/ea/mdg/document.rb +0 -1
  25. data/lib/ea/mdg/loader.rb +0 -1
  26. data/lib/ea/mdg/xml/technology.rb +1 -1
  27. data/lib/ea/mdg/xml.rb +0 -1
  28. data/lib/ea/mdg.rb +0 -1
  29. data/lib/ea/model/document.rb +2 -2
  30. data/lib/ea/model/ghost_label.rb +0 -1
  31. data/lib/ea/model/legend.rb +1 -1
  32. data/lib/ea/model/property.rb +1 -1
  33. data/lib/ea/qea/benchmark.rb +9 -13
  34. data/lib/ea/qea/database.rb +26 -28
  35. data/lib/ea/qea/factory/association_builder.rb +5 -5
  36. data/lib/ea/qea/factory/association_transformer.rb +3 -6
  37. data/lib/ea/qea/factory/attribute_transformer.rb +3 -3
  38. data/lib/ea/qea/factory/base_transformer.rb +4 -4
  39. data/lib/ea/qea/factory/class_transformer.rb +5 -5
  40. data/lib/ea/qea/factory/constraint_transformer.rb +2 -2
  41. data/lib/ea/qea/factory/data_type_transformer.rb +5 -7
  42. data/lib/ea/qea/factory/diagram_transformer.rb +3 -7
  43. data/lib/ea/qea/factory/document_builder.rb +33 -37
  44. data/lib/ea/qea/factory/ea_to_uml_factory.rb +12 -18
  45. data/lib/ea/qea/factory/enum_transformer.rb +1 -2
  46. data/lib/ea/qea/factory/generalization_builder.rb +9 -9
  47. data/lib/ea/qea/factory/generalization_transformer.rb +3 -5
  48. data/lib/ea/qea/factory/instance_transformer.rb +3 -8
  49. data/lib/ea/qea/factory/operation_transformer.rb +2 -4
  50. data/lib/ea/qea/factory/package_transformer.rb +3 -3
  51. data/lib/ea/qea/factory/reference_resolver.rb +1 -1
  52. data/lib/ea/qea/factory/stereotype_loader.rb +1 -5
  53. data/lib/ea/qea/file_detector.rb +6 -12
  54. data/lib/ea/qea/infrastructure/database_connection.rb +1 -3
  55. data/lib/ea/qea/infrastructure/schema_reader.rb +4 -4
  56. data/lib/ea/qea/infrastructure/table_reader.rb +1 -1
  57. data/lib/ea/qea/models/ea_attribute.rb +1 -2
  58. data/lib/ea/qea/models/ea_attribute_tag.rb +1 -2
  59. data/lib/ea/qea/models/ea_author.rb +1 -1
  60. data/lib/ea/qea/models/ea_diagram_link.rb +4 -8
  61. data/lib/ea/qea/models/ea_diagram_object.rb +3 -4
  62. data/lib/ea/qea/models/ea_document.rb +4 -5
  63. data/lib/ea/qea/models/ea_glossary.rb +1 -1
  64. data/lib/ea/qea/models/ea_list.rb +1 -1
  65. data/lib/ea/qea/models/ea_object.rb +2 -2
  66. data/lib/ea/qea/models/ea_object_constraint.rb +1 -2
  67. data/lib/ea/qea/models/ea_object_property.rb +1 -2
  68. data/lib/ea/qea/models/ea_operation.rb +1 -2
  69. data/lib/ea/qea/models/ea_phase.rb +1 -1
  70. data/lib/ea/qea/models/ea_script.rb +5 -6
  71. data/lib/ea/qea/models/ea_tagged_value.rb +2 -3
  72. data/lib/ea/qea/models/ea_version.rb +1 -1
  73. data/lib/ea/qea/models/ea_xref.rb +6 -7
  74. data/lib/ea/qea/repositories/base_repository.rb +1 -1
  75. data/lib/ea/qea/services/database_loader.rb +2 -4
  76. data/lib/ea/qea/validation/association_validator.rb +12 -12
  77. data/lib/ea/qea/validation/attribute_validator.rb +25 -26
  78. data/lib/ea/qea/validation/base_validator.rb +5 -5
  79. data/lib/ea/qea/validation/class_validator.rb +34 -34
  80. data/lib/ea/qea/validation/database/circular_reference_validator.rb +7 -7
  81. data/lib/ea/qea/validation/database/ocl_constraint_validator.rb +3 -3
  82. data/lib/ea/qea/validation/database/orphan_validator.rb +5 -7
  83. data/lib/ea/qea/validation/database/referential_integrity_validator.rb +39 -39
  84. data/lib/ea/qea/validation/diagram_validator.rb +39 -39
  85. data/lib/ea/qea/validation/formatters/json_formatter.rb +16 -16
  86. data/lib/ea/qea/validation/formatters/text_formatter.rb +10 -10
  87. data/lib/ea/qea/validation/operation_validator.rb +13 -14
  88. data/lib/ea/qea/validation/package_validator.rb +18 -18
  89. data/lib/ea/qea/validation/validation_engine.rb +5 -5
  90. data/lib/ea/qea/validation/validation_message.rb +56 -73
  91. data/lib/ea/qea/validation/validation_result.rb +6 -6
  92. data/lib/ea/qea/verification/comparison_result.rb +13 -21
  93. data/lib/ea/qea/verification/document_normalizer.rb +6 -12
  94. data/lib/ea/qea/verification/document_verifier.rb +39 -39
  95. data/lib/ea/qea/verification/element_comparator.rb +27 -31
  96. data/lib/ea/qea/verification/structure_matcher.rb +10 -10
  97. data/lib/ea/qea.rb +5 -7
  98. data/lib/ea/query/builder.rb +3 -3
  99. data/lib/ea/render/image_converter.rb +5 -3
  100. data/lib/ea/shapescript/parser.rb +4 -4
  101. data/lib/ea/sources/qea/classifier_builder.rb +7 -3
  102. data/lib/ea/sources/qea/context_diagram_support.rb +2 -2
  103. data/lib/ea/sources/qea/diagram_builder/routing.rb +4 -4
  104. data/lib/ea/sources/qea/diagram_builder.rb +80 -51
  105. data/lib/ea/sources/qea/id_normalizer.rb +0 -1
  106. data/lib/ea/sources/qea/instance_builder.rb +2 -2
  107. data/lib/ea/sources/qea/legend_builder.rb +1 -1
  108. data/lib/ea/sources/qea/note_builder.rb +4 -4
  109. data/lib/ea/sources/xmi/diagram_builder/stereotype_profiles.rb +1 -1
  110. data/lib/ea/sources/xmi/extension_style_parser.rb +2 -2
  111. data/lib/ea/sources/xmi/property_builder.rb +10 -2
  112. data/lib/ea/sources/xmi/relationship_builder.rb +10 -2
  113. data/lib/ea/sources/xmi/relationship_type_map.rb +1 -1
  114. data/lib/ea/sources/xmi/tag_builder.rb +1 -1
  115. data/lib/ea/sources/xmi/type_classifier_map.rb +1 -1
  116. data/lib/ea/spa/configuration.rb +2 -4
  117. data/lib/ea/spa/generator.rb +3 -3
  118. data/lib/ea/spa/output/strategy.rb +7 -5
  119. data/lib/ea/spa/projector.rb +21 -17
  120. data/lib/ea/svg/connector_router.rb +5 -3
  121. data/lib/ea/svg/ea_emitter/background.rb +0 -1
  122. data/lib/ea/svg/ea_emitter/bounds_calculator.rb +8 -10
  123. data/lib/ea/svg/ea_emitter/canvas.rb +1 -1
  124. data/lib/ea/svg/ea_emitter/color_resolver.rb +1 -1
  125. data/lib/ea/svg/ea_emitter/compartment/note_body.rb +1 -1
  126. data/lib/ea/svg/ea_emitter/connector_redock.rb +6 -3
  127. data/lib/ea/svg/ea_emitter/diagram_frame.rb +2 -2
  128. data/lib/ea/svg/ea_emitter/document.rb +1 -1
  129. data/lib/ea/svg/ea_emitter/element/attribute_renderer.rb +2 -4
  130. data/lib/ea/svg/ea_emitter/element/compartment_geometry.rb +18 -14
  131. data/lib/ea/svg/ea_emitter/element/header_line_pipeline.rb +6 -5
  132. data/lib/ea/svg/ea_emitter/element/header_line_provider/name.rb +1 -3
  133. data/lib/ea/svg/ea_emitter/element/header_line_provider/stereotype_label.rb +1 -1
  134. data/lib/ea/svg/ea_emitter/element/icon_renderer.rb +1 -1
  135. data/lib/ea/svg/ea_emitter/element/legend_renderer.rb +1 -1
  136. data/lib/ea/svg/ea_emitter/element/note_shape_renderer.rb +5 -5
  137. data/lib/ea/svg/ea_emitter/element/operation_renderer.rb +2 -3
  138. data/lib/ea/svg/ea_emitter/element/package_shape_renderer.rb +3 -4
  139. data/lib/ea/svg/ea_emitter/element/stereotype_icon_renderer.rb +1 -1
  140. data/lib/ea/svg/ea_emitter/elements.rb +64 -63
  141. data/lib/ea/svg/ea_emitter/ghost_labels.rb +0 -1
  142. data/lib/ea/svg/ea_emitter/label/end_label.rb +7 -7
  143. data/lib/ea/svg/ea_emitter/labels.rb +1 -1
  144. data/lib/ea/svg/ea_emitter/layer_sequencer.rb +5 -5
  145. data/lib/ea/svg/ea_emitter/marker/arrow_path.rb +4 -2
  146. data/lib/ea/svg/ea_emitter/marker/open_triangle.rb +4 -4
  147. data/lib/ea/svg/ea_emitter/markers.rb +3 -1
  148. data/lib/ea/svg/ea_emitter/render_context.rb +1 -1
  149. data/lib/ea/svg/ea_emitter/text_renderer.rb +15 -4
  150. data/lib/ea/theme/definition.rb +17 -17
  151. data/lib/ea/transformers/qea_to_xmi/context.rb +1 -1
  152. data/lib/ea/transformers/qea_to_xmi/run_state.rb +1 -1
  153. data/lib/ea/transformers/qea_to_xmi/transformer.rb +44 -44
  154. data/lib/ea/transformers/qea_to_xmi/visibility.rb +3 -3
  155. data/lib/ea/version.rb +1 -1
  156. data/lib/ea/xmi/liquid_drops/connector_drop.rb +2 -2
  157. data/lib/ea/xmi/liquid_drops/enum_drop.rb +4 -4
  158. data/lib/ea/xmi/liquid_drops/generalization_attribute_drop.rb +2 -8
  159. data/lib/ea/xmi/liquid_drops/generalization_drop.rb +3 -3
  160. data/lib/ea/xmi/liquid_drops/package_drop.rb +9 -9
  161. data/lib/ea/xmi/liquid_drops/root_drop.rb +1 -1
  162. data/lib/ea/xmi/loader.rb +5 -11
  163. data/lib/ea/xmi/lookup_service.rb +3 -3
  164. data/lib/ea/xmi/parser.rb +75 -81
  165. data/lib/ea/xmi/slicer.rb +16 -12
  166. data/lib/ea/xref_format/legend_definition.rb +31 -0
  167. data/lib/ea/xref_format/parser.rb +146 -0
  168. data/lib/ea/xref_format/property_definition.rb +25 -0
  169. data/lib/ea/xref_format/record.rb +37 -0
  170. data/lib/ea/xref_format/stereotype_application.rb +33 -0
  171. data/lib/ea/xref_format.rb +36 -0
  172. data/lib/ea.rb +1 -0
  173. metadata +26 -25
  174. data/lib/ea/sources/qea/xref/legend_definition.rb +0 -35
  175. data/lib/ea/sources/qea/xref/parser.rb +0 -150
  176. data/lib/ea/sources/qea/xref/property_definition.rb +0 -29
  177. data/lib/ea/sources/qea/xref/record.rb +0 -41
  178. data/lib/ea/sources/qea/xref/stereotype_application.rb +0 -37
data/lib/ea/xmi/parser.rb CHANGED
@@ -47,7 +47,7 @@ module Ea
47
47
  id_name_mapping: @id_name_mapping,
48
48
  lookup: lookup,
49
49
  with_gen: true,
50
- with_absolute_path: true,
50
+ with_absolute_path: true
51
51
  }
52
52
  LiquidDrops::RootDrop.new(document, guidance, options)
53
53
  end
@@ -63,9 +63,7 @@ module Ea
63
63
  @xmi_index
64
64
  end
65
65
 
66
- def id_name_mapping
67
- @id_name_mapping
68
- end
66
+ attr_reader :id_name_mapping
69
67
 
70
68
  # Public lookup methods used by LookupService and Liquid drops
71
69
 
@@ -92,13 +90,11 @@ module Ea
92
90
  end
93
91
  end
94
92
 
95
- def get_package_name(package) # rubocop:disable Metrics/AbcSize
93
+ def get_package_name(package)
96
94
  return package.name unless package.name.nil?
97
95
 
98
96
  connector = fetch_connector(package.id)
99
- if connector.target&.model&.name
100
- return "#{connector.target.model.name} (#{package.type.split(':').last})"
101
- end
97
+ return "#{connector.target.model.name} (#{package.type.split(":").last})" if connector.target&.model&.name
102
98
 
103
99
  "unnamed"
104
100
  end
@@ -111,7 +107,7 @@ module Ea
111
107
  xmi_index.find_parent(klass_id)
112
108
  end
113
109
 
114
- def find_subtype_of_from_owned_attribute_type(id) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
110
+ def find_subtype_of_from_owned_attribute_type(id) # rubocop:disable Metrics/CyclomaticComplexity
115
111
  @pkg_elements_owned_attributes ||= begin
116
112
  cache = {}
117
113
  all_packaged_elements.each do |e|
@@ -119,6 +115,7 @@ module Ea
119
115
 
120
116
  e.owned_attribute.each do |oa|
121
117
  next unless oa.association && oa.uml_type && oa.uml_type.idref
118
+
122
119
  cache[oa.uml_type.idref] = e.name
123
120
  end
124
121
  end
@@ -128,7 +125,7 @@ module Ea
128
125
  @pkg_elements_owned_attributes[id]
129
126
  end
130
127
 
131
- def find_subtype_of_from_generalization(id) # rubocop:disable Metrics/AbcSize,Metrics:CyclomaticComplexity,Metrics:MethodLength,Metrics:PerceivedComplexity
128
+ def find_subtype_of_from_generalization(id) # rubocop:disable Metrics:CyclomaticComplexity,Metrics:MethodLength,Metrics:PerceivedComplexity
132
129
  matched_element = xmi_index.find_element(id)
133
130
  return unless matched_element&.links&.any?
134
131
 
@@ -139,14 +136,13 @@ module Ea
139
136
  end
140
137
 
141
138
  return if matched_generalization&.end.nil?
139
+
142
140
  lookup_entity_name(matched_generalization.end)
143
141
  end
144
142
 
145
143
  def find_klass_packaged_element(path)
146
144
  lutaml_path = Lutaml::Path.parse(path)
147
- if lutaml_path.segments.one?
148
- return find_klass_packaged_element_by_name(path)
149
- end
145
+ return find_klass_packaged_element_by_name(path) if lutaml_path.segments.one?
150
146
 
151
147
  find_klass_packaged_element_by_path(lutaml_path)
152
148
  end
@@ -240,10 +236,10 @@ module Ea
240
236
 
241
237
  def setup_model(xmi_model)
242
238
  @xmi_root_model ||= xmi_model
243
- if @xmi_index.nil?
244
- @xmi_index = @xmi_root_model.index
245
- @id_name_mapping = @xmi_index.id_name_map
246
- end
239
+ return unless @xmi_index.nil?
240
+
241
+ @xmi_index = @xmi_root_model.index
242
+ @id_name_mapping = @xmi_index.id_name_map
247
243
  end
248
244
 
249
245
  # --- Document building ---
@@ -371,8 +367,8 @@ module Ea
371
367
  return [] if package.packaged_element.nil?
372
368
 
373
369
  package.packaged_element
374
- .select { |e| e.type?("uml:InstanceSpecification") }
375
- .map { |spec| build_instance(spec) }
370
+ .select { |e| e.type?("uml:InstanceSpecification") }
371
+ .map { |spec| build_instance(spec) }
376
372
  end
377
373
 
378
374
  def build_instance(spec)
@@ -385,7 +381,7 @@ module Ea
385
381
  end
386
382
  end
387
383
 
388
- def build_class(klass) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics:CyclomaticComplexity,Metrics:PerceivedComplexity
384
+ def build_class(klass) # rubocop:disable Metrics:CyclomaticComplexity,Metrics:PerceivedComplexity
389
385
  ::Lutaml::Uml::UmlClass.new.tap do |k|
390
386
  k.xmi_id = klass.id
391
387
  k.name = klass.name
@@ -401,9 +397,7 @@ module Ea
401
397
  k.constraints = build_constraints(klass.id)
402
398
  k.association_generalization = build_assoc_generalizations(klass)
403
399
 
404
- if klass.type?("uml:Class")
405
- k.generalization = build_generalization(klass)
406
- end
400
+ k.generalization = build_generalization(klass) if klass.type?("uml:Class")
407
401
  end
408
402
  end
409
403
 
@@ -411,44 +405,46 @@ module Ea
411
405
  return [] if package.packaged_element.nil?
412
406
 
413
407
  package.packaged_element
414
- .select { |e| e.type?("uml:Enumeration") }
415
- .map do |enum|
416
- ::Lutaml::Uml::Enum.new.tap do |en|
417
- en.xmi_id = enum.id
418
- en.name = enum.name
419
- en.values = build_values(enum)
420
- en.definition = doc_node_attribute_value(enum.id, "documentation")
421
- en_st = doc_node_attribute_value(enum.id, "stereotype")
422
- en.stereotype = [en_st] if en_st
423
- end
424
- end
408
+ .select { |e| e.type?("uml:Enumeration") }
409
+ .map do |enum|
410
+ ::Lutaml::Uml::Enum.new.tap do |en|
411
+ en.xmi_id = enum.id
412
+ en.name = enum.name
413
+ en.values = build_values(enum)
414
+ en.definition = doc_node_attribute_value(enum.id, "documentation")
415
+ en_st = doc_node_attribute_value(enum.id, "stereotype")
416
+ en.stereotype = [en_st] if en_st
417
+ end
418
+ end
425
419
  end
426
420
 
427
421
  def build_data_types(package) # rubocop:disable Metrics:AbcSize,Metrics:MethodLength
428
422
  return [] if package.packaged_element.nil?
429
423
 
430
424
  package.packaged_element
431
- .select { |e| e.type?("uml:DataType") }
432
- .map do |dt|
433
- ::Lutaml::Uml::DataType.new.tap do |data_type|
434
- data_type.xmi_id = dt.id
435
- data_type.name = dt.name
436
- data_type.is_abstract = doc_node_attribute_value(dt.id, "isAbstract")
437
- data_type.definition = doc_node_attribute_value(dt.id, "documentation")
438
- dt_st = doc_node_attribute_value(dt.id, "stereotype")
439
- data_type.stereotype = [dt_st] if dt_st
440
-
441
- data_type.attributes = build_class_attributes(dt)
442
- data_type.operations = build_operations(dt)
443
- data_type.associations = build_associations(dt.id)
444
- data_type.constraints = build_constraints(dt.id)
445
- data_type.association_generalization = build_assoc_generalizations(dt)
446
- # build_generalization always returns a Generalization for the
447
- # element itself, so only attach when XMI declares a parent.
448
- data_type.generalization =
449
- build_generalization(dt) if dt.generalization&.any?
450
- end
451
- end
425
+ .select { |e| e.type?("uml:DataType") }
426
+ .map do |dt|
427
+ ::Lutaml::Uml::DataType.new.tap do |data_type|
428
+ data_type.xmi_id = dt.id
429
+ data_type.name = dt.name
430
+ data_type.is_abstract = doc_node_attribute_value(dt.id, "isAbstract")
431
+ data_type.definition = doc_node_attribute_value(dt.id, "documentation")
432
+ dt_st = doc_node_attribute_value(dt.id, "stereotype")
433
+ data_type.stereotype = [dt_st] if dt_st
434
+
435
+ data_type.attributes = build_class_attributes(dt)
436
+ data_type.operations = build_operations(dt)
437
+ data_type.associations = build_associations(dt.id)
438
+ data_type.constraints = build_constraints(dt.id)
439
+ data_type.association_generalization = build_assoc_generalizations(dt)
440
+ # build_generalization always returns a Generalization for the
441
+ # element itself, so only attach when XMI declares a parent.
442
+ if dt.generalization&.any?
443
+ data_type.generalization =
444
+ build_generalization(dt)
445
+ end
446
+ end
447
+ end
452
448
  end
453
449
 
454
450
  def build_diagrams(node_id) # rubocop:disable Metrics:AbcSize,Metrics:MethodLength
@@ -529,8 +525,8 @@ module Ea
529
525
  owner_end_attribute_name = find_owner_attribute_name(xmi_id, assoc.id)
530
526
 
531
527
  return nil unless member_end &&
532
- ((member_end_type != "aggregation") ||
533
- (member_end_type == "aggregation" && member_end_attribute_name))
528
+ ((member_end_type != "aggregation") ||
529
+ (member_end_type == "aggregation" && member_end_attribute_name))
534
530
 
535
531
  ::Lutaml::Uml::Association.new.tap do |association|
536
532
  association.xmi_id = assoc.id
@@ -595,18 +591,18 @@ module Ea
595
591
  return [] if enum.owned_literal.nil?
596
592
 
597
593
  enum.owned_literal
598
- .select { |lit| lit.type?("uml:EnumerationLiteral") }
599
- .map do |owned_literal|
600
- uml_type_id = owned_literal&.uml_type&.idref
601
-
602
- ::Lutaml::Uml::Value.new.tap do |value|
603
- value.name = owned_literal.name
604
- ext_attr = fetch_attribute_node(owned_literal.id)
605
- value.initial = ext_attr.initial if ext_attr&.initial
606
- value.type = lookup_entity_name(uml_type_id) || uml_type_id
607
- value.definition = lookup_attribute_documentation(owned_literal.id)
594
+ .select { |lit| lit.type?("uml:EnumerationLiteral") }
595
+ .map do |owned_literal|
596
+ uml_type_id = owned_literal&.uml_type&.idref
597
+
598
+ ::Lutaml::Uml::Value.new.tap do |value|
599
+ value.name = owned_literal.name
600
+ ext_attr = fetch_attribute_node(owned_literal.id)
601
+ value.initial = ext_attr.initial if ext_attr&.initial
602
+ value.type = lookup_entity_name(uml_type_id) || uml_type_id
603
+ value.definition = lookup_attribute_documentation(owned_literal.id)
604
+ end
608
605
  end
609
- end
610
606
  end
611
607
 
612
608
  # --- Generalization building ---
@@ -764,12 +760,12 @@ module Ea
764
760
  end
765
761
  end
766
762
 
767
- if general_item&.has_general && general_item.general
768
- level += 1
769
- loop_general_item(
770
- general_item.general, level, inherited_props, inherited_assoc_props
771
- )
772
- end
763
+ return unless general_item&.has_general && general_item.general
764
+
765
+ level += 1
766
+ loop_general_item(
767
+ general_item.general, level, inherited_props, inherited_assoc_props
768
+ )
773
769
  end
774
770
 
775
771
  def build_assoc_generalizations(klass) # rubocop:disable Metrics:AbcSize
@@ -849,9 +845,7 @@ module Ea
849
845
  fetch_owned_attribute_node(xmi_id)
850
846
  end
851
847
 
852
- if fetch_connector_name(link.id)
853
- member_end = fetch_connector_name(link.id)
854
- end
848
+ member_end = fetch_connector_name(link.id) if fetch_connector_name(link.id)
855
849
 
856
850
  [member_end, member_end_type, member_end_cardinality,
857
851
  member_end_attribute_name, xmi_id]
@@ -906,7 +900,7 @@ module Ea
906
900
 
907
901
  def fetch_owned_attribute_node(xmi_id)
908
902
  oa = xmi_index.find_owned_attrs_by_type(xmi_id)
909
- .find { |a| !!a.association }
903
+ .find { |a| !!a.association }
910
904
 
911
905
  if oa
912
906
  cardinality = cardinality_min_max_value(
@@ -977,8 +971,8 @@ module Ea
977
971
  return node.name if node&.name
978
972
 
979
973
  return if node.nil? ||
980
- node.public_send(source_or_target.to_sym).nil? ||
981
- node.public_send(source_or_target.to_sym).model.nil?
974
+ node.public_send(source_or_target.to_sym).nil? ||
975
+ node.public_send(source_or_target.to_sym).model.nil?
982
976
 
983
977
  node.public_send(source_or_target.to_sym).model.name
984
978
  end
@@ -1025,7 +1019,7 @@ module Ea
1025
1019
 
1026
1020
  def iterate_relative_packaged_element(name_array)
1027
1021
  matched_elements = xmi_index.packaged_elements_of_type("uml:Package")
1028
- .select { |e| e.name == name_array[0] }
1022
+ .select { |e| e.name == name_array[0] }
1029
1023
 
1030
1024
  result = matched_elements.map do |e|
1031
1025
  iterate_packaged_element(e, name_array, type: "uml:Class")
data/lib/ea/xmi/slicer.rb CHANGED
@@ -51,7 +51,7 @@ module Ea
51
51
  model: ["packagedElement", "umldi:Diagram"].freeze,
52
52
  elements: ["element"].freeze,
53
53
  connectors: ["connector"].freeze,
54
- diagrams: ["diagram"].freeze,
54
+ diagrams: ["diagram"].freeze
55
55
  }.freeze
56
56
  private_constant :GATED
57
57
 
@@ -59,7 +59,7 @@ module Ea
59
59
  "elements" => :elements,
60
60
  "connectors" => :connectors,
61
61
  "diagrams" => :drop,
62
- "profiles" => :drop,
62
+ "profiles" => :drop
63
63
  }.freeze
64
64
  private_constant :SECTION_CHILD
65
65
 
@@ -160,7 +160,11 @@ module Ea
160
160
  # the parent is the nearest id-bearing element already on the
161
161
  # stack, so it has to be read before this element is pushed
162
162
  parent = nearest_id
163
- refs = is_node ? [] : (@stack.last ? @stack.last[1] : [])
163
+ refs = if is_node
164
+ []
165
+ else
166
+ (@stack.last ? @stack.last[1] : [])
167
+ end
164
168
  @stack << [is_node ? id : nil, refs]
165
169
  unless is_node
166
170
  collect_refs(attributes, refs)
@@ -171,7 +175,7 @@ module Ea
171
175
  id: id, tag: name,
172
176
  xmi_type: attributes["xmi:type"], name: attributes["name"],
173
177
  parent_id: parent, section: @section.last, refs: refs,
174
- links_refs: [],
178
+ links_refs: []
175
179
  )
176
180
  @nodes[id] = node
177
181
  collect_refs(attributes, node.refs)
@@ -260,13 +264,13 @@ module Ea
260
264
  node.refs.each { |r| frontier << [r, false] }
261
265
  node.links_refs.each { |r| frontier << [r, true] }
262
266
  # keeping a model element keeps its package ancestry
263
- if node.section == :model
264
- anc = nodes[node.parent_id]
265
- while anc && !keep[anc.id]
266
- keep[anc.id] = true
267
- anc.refs.each { |r| frontier << [r, false] } unless anc.section == :model
268
- anc = nodes[anc.parent_id]
269
- end
267
+ next unless node.section == :model
268
+
269
+ anc = nodes[node.parent_id]
270
+ while anc && !keep[anc.id]
271
+ keep[anc.id] = true
272
+ anc.refs.each { |r| frontier << [r, false] } unless anc.section == :model
273
+ anc = nodes[anc.parent_id]
270
274
  end
271
275
  end
272
276
  keep_diagrams(nodes, keep)
@@ -318,7 +322,7 @@ module Ea
318
322
  def initialize(keeps, outputs)
319
323
  @keeps = keeps
320
324
  @outputs = outputs
321
- @open = [] # [name, keys] - keys = group indexes keeping this element
325
+ @open = [] # [name, keys] - keys = group indexes keeping this element
322
326
  @section = []
323
327
  @events = 0
324
328
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module XrefFormat
5
+ # Legend definition record. Produced when the Description contains
6
+ # `@PROP=` blocks with `@TYPE=LEGEND_*`. EA encodes legend
7
+ # entries as color/style rules keyed by name.
8
+ #
9
+ # Example source:
10
+ # @PROP=@NAME=GMLに定義されたクラス@ENDNAME;
11
+ # @TYPE=LEGEND_OBJECTSTYLE@ENDTYPE;
12
+ # @VALU=#Back_Ground_Color#=13434828;#Pen_Color#=0;
13
+ # #Pen_Size#=1;#Legend_Type#=LEGEND_OBJECTSTYLE;
14
+ # @ENDVALU;@PRMT=0@ENDPRMT;@ENDPROP;
15
+ LegendDefinition = Struct.new(:name, :legend_type, :colors,
16
+ :parameter, keyword_init: true) do
17
+ # EA encodes colors as signed 32-bit integers (VB-style).
18
+ # Convert to `#RRGGBB` hex string for SVG consumption.
19
+ # @param key [Symbol] color key, e.g. :back_ground_color
20
+ # @return [String, nil] hex color (`#RRGGBB`) or nil
21
+ def hex_color(key)
22
+ value = colors&.dig(key)
23
+ return nil if value.nil?
24
+
25
+ int = value.to_i
26
+ int = (int + 2**32) % 2**32 if int.negative?
27
+ format("#%06X", int & 0xFFFFFF)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module XrefFormat
5
+ # Pure parser for EA's `t_xref.Description` mini-language.
6
+ # Stateless — every call returns a fresh `XrefFormat::Record`.
7
+ #
8
+ # Supported formats:
9
+ # @STEREO;Name=X;FQName=Y;@ENDSTEREO;
10
+ # @PROP=@NAME=..@ENDNAME;@TYPE=..@ENDTYPE;@VALU=..@ENDVALU;@PRMT=..@ENDPRMT;@ENDPROP;
11
+ # <key>=<value>;<key>=<value>;
12
+ #
13
+ # Unknown formats fall through to key=value parsing.
14
+ module Parser
15
+ module_function
16
+
17
+ # Parse one Description string into a typed Record.
18
+ # @param description [String, nil]
19
+ # @return [Ea::XrefFormat::Record]
20
+ def parse(description)
21
+ return Record.new if description.nil? || description.empty?
22
+
23
+ Record.new(
24
+ stereotype: parse_stereotype(description),
25
+ properties: parse_properties(description),
26
+ legends: parse_legends(description),
27
+ key_values: parse_key_values(description),
28
+ raw: description
29
+ )
30
+ end
31
+
32
+ # -- per-format extractors ----------------------------------
33
+
34
+ # Matches both legacy `@STEREO;Name=X;GUID={..};` and the
35
+ # plateau form `@STEREO;Name=X;FQName=Y;@ENDSTEREO;`.
36
+ STEREO_REGEX = /
37
+ @STEREO;
38
+ (.*?)
39
+ (?:@ENDSTEREO;|\z)
40
+ /mx
41
+
42
+ def parse_stereotype(description)
43
+ match = description.match(STEREO_REGEX)
44
+ return nil unless match
45
+
46
+ fields = parse_semicolon_fields(match[1])
47
+ StereotypeApplication.new(
48
+ name: fields["Name"],
49
+ fqname: fields["FQName"]
50
+ )
51
+ end
52
+
53
+ # One Description can carry multiple @PROP=...@ENDPROP; blocks.
54
+ # Split, then classify each as PropertyDefinition or LegendDefinition.
55
+ PROP_REGEX = /
56
+ @PROP=
57
+ (.*?)
58
+ @ENDPROP;
59
+ /mx
60
+
61
+ def parse_properties(description)
62
+ blocks = description.scan(PROP_REGEX).flatten
63
+ blocks.each_with_object([]) do |block, acc|
64
+ record = build_prop_record(block)
65
+ acc << record if record
66
+ end
67
+ end
68
+
69
+ def parse_legends(description)
70
+ parse_properties(description).select do |prop|
71
+ prop.is_a?(LegendDefinition)
72
+ end
73
+ end
74
+
75
+ def build_prop_record(block)
76
+ name = extract_tagged_value(block, "NAME")
77
+ type = extract_tagged_value(block, "TYPE")
78
+ value = extract_tagged_value(block, "VALU")
79
+ parameter = extract_tagged_value(block, "PRMT")
80
+
81
+ if type&.start_with?("LEGEND_")
82
+ LegendDefinition.new(
83
+ name: name,
84
+ legend_type: type,
85
+ colors: parse_color_value(value),
86
+ parameter: parameter
87
+ )
88
+ else
89
+ PropertyDefinition.new(
90
+ name: name,
91
+ type: type,
92
+ value: value,
93
+ parameter: parameter
94
+ )
95
+ end
96
+ end
97
+
98
+ # Extracts the content between @TAG=...@ENDTAG; markers.
99
+ # Returns nil when the tag is absent.
100
+ def extract_tagged_value(block, tag)
101
+ pattern = /@#{tag}=(.*?)@END#{tag};/m
102
+ match = block.match(pattern)
103
+ match ? match[1] : nil
104
+ end
105
+
106
+ # EA encodes legend VALU as `#key#=value;` pairs.
107
+ # Returns a hash keyed by underscored symbol.
108
+ def parse_color_value(value)
109
+ return {} if value.nil? || value.empty?
110
+
111
+ value.scan(/#([^#=]+)#=([^;]*);/).each_with_object({}) do |(k, v), acc|
112
+ acc[k.downcase.to_sym] = v
113
+ end
114
+ end
115
+
116
+ # Legacy `Key=Value;Key=Value;` parsing. Skips content that
117
+ # looks like @STEREO or @PROP blocks to avoid noise.
118
+ def parse_key_values(description)
119
+ stripped = description
120
+ .gsub(/@STEREO;.*?(?:@ENDSTEREO;|\z)/m, "")
121
+ .gsub(/@PROP=.*?@ENDPROP;/m, "")
122
+ pairs = stripped.split(";").map { |s| s.split("=", 2) }
123
+ pairs.each_with_object({}) do |(k, v), acc|
124
+ next if k.nil? || k.empty? || v.nil?
125
+
126
+ acc[k.downcase.to_sym] = v
127
+ end
128
+ end
129
+
130
+ # Parse `Key=Value;Key=value;` into a string-keyed hash.
131
+ # Used internally for the @STEREO body fields.
132
+ def parse_semicolon_fields(body)
133
+ body.split(";").each_with_object({}) do |part, acc|
134
+ key, value = part.split("=", 2)
135
+ next if key.nil? || key.empty? || value.nil?
136
+
137
+ # Strip @END* terminators that may be attached when the
138
+ # body wasn't cleanly split (defensive — usually already
139
+ # consumed by STEREO_REGEX).
140
+ cleaned = value.sub(/@END\w+\z/, "")
141
+ acc[key] = cleaned
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module XrefFormat
5
+ # Tagged-value / property definition record. Produced when the
6
+ # Description contains one or more `@PROP=@NAME=..@ENDNAME;`
7
+ # blocks for non-legend properties.
8
+ #
9
+ # Example source:
10
+ # @PROP=@NAME=isActive@ENDNAME;@TYPE=Boolean@ENDTYPE;
11
+ # @VALU=@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
12
+ PropertyDefinition = Struct.new(:name, :type, :value, :parameter,
13
+ keyword_init: true) do
14
+ # @return [Boolean] true when the value field is non-empty
15
+ def default_value?
16
+ !value.nil? && !value.empty?
17
+ end
18
+
19
+ # @return [Boolean] true when the property is declared as Boolean
20
+ def boolean?
21
+ type == "Boolean"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module XrefFormat
5
+ # Parsed t_xref.Description. Holds typed records for each block
6
+ # found in the source string. One Description can carry multiple
7
+ # records (e.g., several `@PROP=` blocks defining a stereotype's
8
+ # tagged-value set).
9
+ #
10
+ # Consumers branch on record type without re-parsing strings.
11
+ Record = Struct.new(:stereotype, :properties, :legends,
12
+ :key_values, :raw, keyword_init: true) do
13
+ def initialize(*)
14
+ super
15
+ self.properties ||= []
16
+ self.legends ||= []
17
+ self.key_values ||= {}
18
+ end
19
+
20
+ # @return [Boolean] true when a stereotype application is present
21
+ def stereotype?
22
+ !stereotype.nil?
23
+ end
24
+
25
+ # @return [Boolean] true when at least one legend is present
26
+ def legend?
27
+ !legends.empty?
28
+ end
29
+
30
+ # Convenience: first legend's name (the legend's title).
31
+ # @return [String, nil]
32
+ def legend_title
33
+ legends.first&.name
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module XrefFormat
5
+ # Stereotype application record. Produced when the Description
6
+ # starts with `@STEREO;`. Captures the short name and the
7
+ # fully-qualified `tech::Stereo` form when present.
8
+ #
9
+ # Example source:
10
+ # @STEREO;Name=FeatureType;FQName=GML::FeatureType;@ENDSTEREO;
11
+ StereotypeApplication = Struct.new(:name, :fqname, keyword_init: true) do
12
+ # Returns the technology prefix from FQName, or nil.
13
+ # @return [String, nil]
14
+ def technology
15
+ return nil unless fqname
16
+
17
+ idx = fqname.index("::")
18
+ idx ? fqname[0, idx] : nil
19
+ end
20
+
21
+ # Returns the stereotype name without technology prefix.
22
+ # Falls back to +name+ when FQName is absent.
23
+ # @return [String, nil]
24
+ def unqualified_name
25
+ if fqname && fqname.include?("::")
26
+ fqname.split("::", 2).last
27
+ else
28
+ name
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ # Shared parser for EA's `t_xref.Description` mini-language — the
5
+ # canonical converter for `@STEREO`/`@PROP`/key-value description
6
+ # blocks (house style alongside GuidFormat, Rtf, XmlEscape).
7
+ #
8
+ # Lives at the top level so the QEA model layer can use it without
9
+ # reaching up into the Sources adapter layer. Consumers:
10
+ # Ea::Qea::Models::EaXref, Ea::Query::Builder, Ea::Lint stereotype
11
+ # rules, Ea::Qea::Factory::StereotypeLoader, and the Sources
12
+ # diagram builders.
13
+ module XrefFormat
14
+ autoload :Parser, "ea/xref_format/parser"
15
+ autoload :Record, "ea/xref_format/record"
16
+ autoload :StereotypeApplication, "ea/xref_format/stereotype_application"
17
+ autoload :PropertyDefinition, "ea/xref_format/property_definition"
18
+ autoload :LegendDefinition, "ea/xref_format/legend_definition"
19
+
20
+ module_function
21
+
22
+ # The `Name` field of the first `@STEREO;...;` application in the
23
+ # description, or nil. Handles both the legacy
24
+ # `@STEREO;Name=X;GUID={..};` and plateau `@STEREO;Name=X;FQName=Y;`
25
+ # forms; unqualified for FQName-carrying applications.
26
+ # @param description [String, nil]
27
+ # @return [String, nil]
28
+ def stereotype_name(description)
29
+ return nil if description.nil? || description.empty?
30
+ return nil unless description.include?("@STEREO")
31
+
32
+ application = Parser.parse(description).stereotype
33
+ application&.unqualified_name
34
+ end
35
+ end
36
+ end