ea 0.6.151 → 0.6.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/qea_schema.yml +0 -85
- data/lib/ea/cli/command/list.rb +30 -12
- data/lib/ea/cli/command.rb +0 -1
- data/lib/ea/export/plantuml/generator.rb +45 -32
- data/lib/ea/spa/projector.rb +36 -19
- data/lib/ea/svg/ea_emitter/diagram_frame.rb +25 -12
- data/lib/ea/theme/definition.rb +167 -16
- data/lib/ea/theme/loader.rb +129 -107
- data/lib/ea/theme/theme_document.rb +53 -0
- data/lib/ea/theme.rb +1 -0
- data/lib/ea/transformers/qea_to_xmi/extension_serializer.rb +6 -2
- data/lib/ea/transformers/qea_to_xmi/transformer.rb +2 -1
- data/lib/ea/transformers.rb +1 -10
- data/lib/ea/version.rb +1 -1
- data/lib/ea.rb +0 -1
- metadata +2 -9
- data/config/diagram_styles.yml +0 -200
- data/config/model_transformations.yml +0 -266
- data/lib/ea/cli/command/repository_builder.rb +0 -64
- data/lib/ea/transformers/uml_to_xmi/id_generator.rb +0 -54
- data/lib/ea/transformers/uml_to_xmi/transformer.rb +0 -152
- data/lib/ea/transformers/uml_to_xmi/writer.rb +0 -96
- data/lib/ea/validation/xmi_parity.rb +0 -80
- data/lib/ea/validation.rb +0 -12
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
# Model Transformations Configuration
|
|
2
|
-
# This file configures the unified model transformation system for LutaML
|
|
3
|
-
#
|
|
4
|
-
# Version: 1.0
|
|
5
|
-
# Description: External configuration for model format parsers and transformation options
|
|
6
|
-
|
|
7
|
-
version: "1.0"
|
|
8
|
-
description: "LutaML Model Transformations Configuration"
|
|
9
|
-
|
|
10
|
-
# Parser configurations define how different model formats are handled
|
|
11
|
-
parsers:
|
|
12
|
-
# XML Metadata Interchange (XMI) Parser
|
|
13
|
-
- format: "xmi"
|
|
14
|
-
extension: ".xmi"
|
|
15
|
-
parser_class: "Lutaml::ModelTransformations::Parsers::XmiParser"
|
|
16
|
-
enabled: true
|
|
17
|
-
priority: 100
|
|
18
|
-
description: "XML Metadata Interchange parser for UML models"
|
|
19
|
-
options:
|
|
20
|
-
- "validate_xml"
|
|
21
|
-
- "resolve_references"
|
|
22
|
-
- "preserve_namespaces"
|
|
23
|
-
- "include_documentation"
|
|
24
|
-
|
|
25
|
-
# Enterprise Architect Database (QEA) Parser
|
|
26
|
-
- format: "qea"
|
|
27
|
-
extension: ".qea"
|
|
28
|
-
parser_class: "Lutaml::ModelTransformations::Parsers::QeaParser"
|
|
29
|
-
enabled: true
|
|
30
|
-
priority: 90
|
|
31
|
-
description: "Enterprise Architect database parser"
|
|
32
|
-
options:
|
|
33
|
-
- "include_diagrams"
|
|
34
|
-
- "validate_transformation"
|
|
35
|
-
- "load_progress_callback"
|
|
36
|
-
- "cache_database"
|
|
37
|
-
|
|
38
|
-
# Legacy XML support (lower priority than XMI)
|
|
39
|
-
- format: "xml"
|
|
40
|
-
extension: ".xml"
|
|
41
|
-
parser_class: "Lutaml::ModelTransformations::Parsers::XmiParser"
|
|
42
|
-
enabled: true
|
|
43
|
-
priority: 80
|
|
44
|
-
description: "Generic XML parser (delegates to XMI parser)"
|
|
45
|
-
options:
|
|
46
|
-
- "validate_xml"
|
|
47
|
-
- "resolve_references"
|
|
48
|
-
|
|
49
|
-
# Enterprise Architect Project files (legacy format)
|
|
50
|
-
- format: "eap"
|
|
51
|
-
extension: ".eap"
|
|
52
|
-
parser_class: "Lutaml::ModelTransformations::Parsers::QeaParser"
|
|
53
|
-
enabled: true
|
|
54
|
-
priority: 70
|
|
55
|
-
description: "Enterprise Architect project file parser"
|
|
56
|
-
options:
|
|
57
|
-
- "include_diagrams"
|
|
58
|
-
- "legacy_format_support"
|
|
59
|
-
|
|
60
|
-
# Enterprise Architect Exchange files
|
|
61
|
-
- format: "eapx"
|
|
62
|
-
extension: ".eapx"
|
|
63
|
-
parser_class: "Lutaml::ModelTransformations::Parsers::QeaParser"
|
|
64
|
-
enabled: true
|
|
65
|
-
priority: 75
|
|
66
|
-
description: "Enterprise Architect exchange file parser"
|
|
67
|
-
options:
|
|
68
|
-
- "include_diagrams"
|
|
69
|
-
- "compressed_format"
|
|
70
|
-
|
|
71
|
-
# Global transformation options
|
|
72
|
-
transformation_options:
|
|
73
|
-
# Validate output document structure after parsing
|
|
74
|
-
validate_output: false
|
|
75
|
-
|
|
76
|
-
# Include diagram information in transformed documents
|
|
77
|
-
include_diagrams: true
|
|
78
|
-
|
|
79
|
-
# Preserve original XMI/QEA IDs in transformed elements
|
|
80
|
-
preserve_ids: true
|
|
81
|
-
|
|
82
|
-
# Resolve cross-references between model elements
|
|
83
|
-
resolve_references: true
|
|
84
|
-
|
|
85
|
-
# Enable strict validation mode (fail on warnings)
|
|
86
|
-
strict_mode: false
|
|
87
|
-
|
|
88
|
-
# Format detection configuration
|
|
89
|
-
format_detection:
|
|
90
|
-
# Use file extensions for format detection
|
|
91
|
-
use_file_extension: true
|
|
92
|
-
|
|
93
|
-
# Use content analysis (magic bytes) for format detection
|
|
94
|
-
use_content_sniffing: true
|
|
95
|
-
|
|
96
|
-
# Fallback parser when format cannot be detected
|
|
97
|
-
fallback_parser: "Lutaml::ModelTransformations::Parsers::XmiParser"
|
|
98
|
-
|
|
99
|
-
# Magic byte signatures for content detection
|
|
100
|
-
magic_bytes:
|
|
101
|
-
- "SQLite format 3" # QEA/SQLite files
|
|
102
|
-
- "<?xml" # XML/XMI files
|
|
103
|
-
|
|
104
|
-
# Error handling configuration
|
|
105
|
-
error_handling:
|
|
106
|
-
# Error handling strategy: "continue", "fail_fast", "collect"
|
|
107
|
-
strategy: "continue"
|
|
108
|
-
|
|
109
|
-
# Log errors and warnings to console
|
|
110
|
-
log_errors: true
|
|
111
|
-
|
|
112
|
-
# Maximum number of errors before aborting (0 = unlimited)
|
|
113
|
-
max_errors: 10
|
|
114
|
-
|
|
115
|
-
# Fail immediately on first error
|
|
116
|
-
fail_fast: false
|
|
117
|
-
|
|
118
|
-
# Format-specific configurations
|
|
119
|
-
format_specific:
|
|
120
|
-
xmi:
|
|
121
|
-
# XMI-specific options
|
|
122
|
-
namespace_handling: "preserve"
|
|
123
|
-
reference_resolution: "eager"
|
|
124
|
-
xml_validation: "lenient"
|
|
125
|
-
encoding_detection: "auto"
|
|
126
|
-
|
|
127
|
-
qea:
|
|
128
|
-
# QEA-specific options
|
|
129
|
-
database_timeout: 30
|
|
130
|
-
load_strategy: "progressive"
|
|
131
|
-
diagram_processing: "full"
|
|
132
|
-
schema_validation: "basic"
|
|
133
|
-
|
|
134
|
-
# Performance tuning
|
|
135
|
-
performance:
|
|
136
|
-
# Enable parser instance caching
|
|
137
|
-
cache_parsers: true
|
|
138
|
-
|
|
139
|
-
# Maximum size for parser cache (number of instances)
|
|
140
|
-
max_parser_cache_size: 10
|
|
141
|
-
|
|
142
|
-
# Enable transformation history tracking
|
|
143
|
-
track_history: true
|
|
144
|
-
|
|
145
|
-
# Maximum number of history entries to keep
|
|
146
|
-
max_history_size: 1000
|
|
147
|
-
|
|
148
|
-
# Logging configuration
|
|
149
|
-
logging:
|
|
150
|
-
# Log level: "debug", "info", "warn", "error"
|
|
151
|
-
level: "info"
|
|
152
|
-
|
|
153
|
-
# Include timestamps in log messages
|
|
154
|
-
include_timestamps: true
|
|
155
|
-
|
|
156
|
-
# Include parser class names in log messages
|
|
157
|
-
include_parser_names: true
|
|
158
|
-
|
|
159
|
-
# Log transformation statistics
|
|
160
|
-
log_statistics: true
|
|
161
|
-
|
|
162
|
-
# Plugin/extension support
|
|
163
|
-
plugins:
|
|
164
|
-
# Enable plugin system
|
|
165
|
-
enabled: false
|
|
166
|
-
|
|
167
|
-
# Plugin discovery paths
|
|
168
|
-
discovery_paths:
|
|
169
|
-
- "lib/lutaml/model_transformations/plugins"
|
|
170
|
-
- "~/.lutaml/plugins"
|
|
171
|
-
|
|
172
|
-
# Auto-load plugins on startup
|
|
173
|
-
auto_load: false
|
|
174
|
-
|
|
175
|
-
# Validation rules
|
|
176
|
-
validation:
|
|
177
|
-
# Required elements validation
|
|
178
|
-
require_packages: false
|
|
179
|
-
require_classes: false
|
|
180
|
-
|
|
181
|
-
# Reference validation
|
|
182
|
-
check_broken_references: true
|
|
183
|
-
allow_external_references: true
|
|
184
|
-
|
|
185
|
-
# Naming validation
|
|
186
|
-
validate_naming_conventions: false
|
|
187
|
-
naming_patterns:
|
|
188
|
-
package: "^[A-Z][a-zA-Z0-9]*$"
|
|
189
|
-
class: "^[A-Z][a-zA-Z0-9]*$"
|
|
190
|
-
attribute: "^[a-z][a-zA-Z0-9]*$"
|
|
191
|
-
|
|
192
|
-
# Transformation presets for common scenarios
|
|
193
|
-
presets:
|
|
194
|
-
# Fast parsing preset (minimal validation, no diagrams)
|
|
195
|
-
fast:
|
|
196
|
-
transformation_options:
|
|
197
|
-
validate_output: false
|
|
198
|
-
include_diagrams: false
|
|
199
|
-
resolve_references: false
|
|
200
|
-
error_handling:
|
|
201
|
-
strategy: "fail_fast"
|
|
202
|
-
log_errors: false
|
|
203
|
-
|
|
204
|
-
# Comprehensive parsing preset (full validation and processing)
|
|
205
|
-
comprehensive:
|
|
206
|
-
transformation_options:
|
|
207
|
-
validate_output: true
|
|
208
|
-
include_diagrams: true
|
|
209
|
-
resolve_references: true
|
|
210
|
-
strict_mode: true
|
|
211
|
-
error_handling:
|
|
212
|
-
strategy: "collect"
|
|
213
|
-
log_errors: true
|
|
214
|
-
max_errors: 0
|
|
215
|
-
|
|
216
|
-
# Production preset (balanced performance and reliability)
|
|
217
|
-
production:
|
|
218
|
-
transformation_options:
|
|
219
|
-
validate_output: true
|
|
220
|
-
include_diagrams: true
|
|
221
|
-
resolve_references: true
|
|
222
|
-
strict_mode: false
|
|
223
|
-
error_handling:
|
|
224
|
-
strategy: "continue"
|
|
225
|
-
log_errors: true
|
|
226
|
-
max_errors: 5
|
|
227
|
-
performance:
|
|
228
|
-
cache_parsers: true
|
|
229
|
-
track_history: false
|
|
230
|
-
|
|
231
|
-
# Compatibility settings
|
|
232
|
-
compatibility:
|
|
233
|
-
# Support legacy LutaML API
|
|
234
|
-
legacy_api_support: true
|
|
235
|
-
|
|
236
|
-
# Automatic migration of old configuration formats
|
|
237
|
-
auto_migrate_config: true
|
|
238
|
-
|
|
239
|
-
# Deprecated feature warnings
|
|
240
|
-
warn_deprecated: true
|
|
241
|
-
|
|
242
|
-
# Development/debugging options
|
|
243
|
-
development:
|
|
244
|
-
# Enable debug mode
|
|
245
|
-
debug_mode: false
|
|
246
|
-
|
|
247
|
-
# Dump intermediate transformation results
|
|
248
|
-
dump_intermediate: false
|
|
249
|
-
|
|
250
|
-
# Benchmark transformation performance
|
|
251
|
-
benchmark_mode: false
|
|
252
|
-
|
|
253
|
-
# Verbose parser output
|
|
254
|
-
verbose_parsing: false
|
|
255
|
-
|
|
256
|
-
# Integration settings
|
|
257
|
-
integration:
|
|
258
|
-
# UML Repository integration
|
|
259
|
-
auto_build_repository: true
|
|
260
|
-
repository_lazy_loading: false
|
|
261
|
-
|
|
262
|
-
# CLI integration
|
|
263
|
-
register_cli_commands: true
|
|
264
|
-
|
|
265
|
-
# Web UI integration
|
|
266
|
-
enable_web_ui: false
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ea
|
|
4
|
-
module Cli
|
|
5
|
-
module Command
|
|
6
|
-
# Shared helper for building a `Lutaml::UmlRepository::Repository`
|
|
7
|
-
# from any file format supported by `Ea::Transformations`.
|
|
8
|
-
#
|
|
9
|
-
# Single source of truth for "QEA/XMI/LUR → Repository" wiring.
|
|
10
|
-
# Used by `Ea::Cli::Command::Diagrams` (extract action) and
|
|
11
|
-
# `Ea::Cli::Command::Spa` (SPA generation).
|
|
12
|
-
#
|
|
13
|
-
# `.lur` files take the fast path via `Repository.from_file` (the
|
|
14
|
-
# native LUR loader). QEA/XMI files are parsed via
|
|
15
|
-
# `Ea::Transformations.parse` and wrapped via
|
|
16
|
-
# `Repository.from_document`.
|
|
17
|
-
module RepositoryBuilder
|
|
18
|
-
LUR_EXT = ".lur".freeze
|
|
19
|
-
|
|
20
|
-
module_function
|
|
21
|
-
|
|
22
|
-
# @param path [String] file path (QEA, XMI, or LUR)
|
|
23
|
-
# @return [Lutaml::UmlRepository::Repository]
|
|
24
|
-
def build_repository(path)
|
|
25
|
-
require_lutaml_uml!
|
|
26
|
-
|
|
27
|
-
if lur?(path)
|
|
28
|
-
require_lutaml_uml_repository!
|
|
29
|
-
return Lutaml::UmlRepository::Repository.from_file(path)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
document = Ea::Transformations.to_uml(path)
|
|
33
|
-
require_lutaml_uml_repository!
|
|
34
|
-
Lutaml::UmlRepository::Repository.from_document(document)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def lur?(path)
|
|
38
|
-
File.extname(path).downcase == LUR_EXT
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Loads the bridge gem. The lutaml-uml gem is an optional
|
|
42
|
-
# dependency; if missing, raise the CLI's MissingUmlDependency
|
|
43
|
-
# so the user gets a clear message about installing it.
|
|
44
|
-
def require_lutaml_uml!
|
|
45
|
-
require "lutaml/uml"
|
|
46
|
-
rescue LoadError => e
|
|
47
|
-
raise Ea::Cli::MissingUmlDependency,
|
|
48
|
-
"spa and diagrams-extract commands require the " \
|
|
49
|
-
"`lutaml-uml` gem. Install it via `gem install lutaml-uml` " \
|
|
50
|
-
"or add it to your Gemfile. (#{e.message})"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def require_lutaml_uml_repository!
|
|
54
|
-
require "lutaml/uml_repository"
|
|
55
|
-
rescue LoadError => e
|
|
56
|
-
raise Ea::Cli::MissingUmlDependency,
|
|
57
|
-
"spa and diagrams-extract commands require the " \
|
|
58
|
-
"`lutaml-uml` gem. Install it via `gem install lutaml-uml` " \
|
|
59
|
-
"or add it to your Gemfile. (#{e.message})"
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ea
|
|
4
|
-
module Transformers
|
|
5
|
-
module UmlToXmi
|
|
6
|
-
# Allocates xmi:id values for UML elements during lossy serialization.
|
|
7
|
-
#
|
|
8
|
-
# Strategy:
|
|
9
|
-
# 1. If the element already has an `xmi_id` (set by the QEA factory
|
|
10
|
-
# during parsing), reuse it.
|
|
11
|
-
# 2. Otherwise synthesize a stable `EAID_…` from a counter.
|
|
12
|
-
#
|
|
13
|
-
# This class is used only by the lossy {UmlToXmi::Transformer} path.
|
|
14
|
-
# The full-fidelity {QeaToXmi} path uses {QeaToXmi::GuidFormat} to
|
|
15
|
-
# normalize raw EA GUIDs.
|
|
16
|
-
class IdGenerator
|
|
17
|
-
PREFIX = "EAID"
|
|
18
|
-
MODEL_ID = "#{PREFIX}_EA_MODEL"
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
@assigned = {} # object_id → xmi:id
|
|
22
|
-
@counter = 0
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def eaid_for(element)
|
|
26
|
-
key = element.object_id
|
|
27
|
-
@assigned[key] ||= begin
|
|
28
|
-
@counter += 1
|
|
29
|
-
extract_id(element) || synthesize(@counter)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def model_id
|
|
34
|
-
MODEL_ID
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
# `Lutaml::Uml::Value` exposes its XMI identifier via `id` (it does
|
|
40
|
-
# not inherit from TopElement, so it has no `xmi_id`). All other
|
|
41
|
-
# serializable UML types use `xmi_id`.
|
|
42
|
-
def extract_id(element)
|
|
43
|
-
return element.id if element.is_a?(Lutaml::Uml::Value)
|
|
44
|
-
|
|
45
|
-
element.xmi_id
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def synthesize(n)
|
|
49
|
-
format("%<prefix>s_%<hex>08X", prefix: PREFIX, hex: n)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ea
|
|
4
|
-
module Transformers
|
|
5
|
-
module UmlToXmi
|
|
6
|
-
# Orchestrates transformation of a {Lutaml::Uml::Document} to Sparx XMI.
|
|
7
|
-
#
|
|
8
|
-
# Walks the UML tree (packages → classifiers → features) and emits XML
|
|
9
|
-
# via {Writer}. Each UML element type has its own private emitter method.
|
|
10
|
-
#
|
|
11
|
-
# This is the LOSSY path — Sparx-specific concepts (stereotypes,
|
|
12
|
-
# multiplicities, tagged values, EA extension block) are not modeled in
|
|
13
|
-
# Lutaml::Uml and therefore not emitted. For Sparx-to-Sparx round-trip
|
|
14
|
-
# with full fidelity, use {Ea::Transformers::QeaToXmi}.
|
|
15
|
-
class Transformer
|
|
16
|
-
MODEL_NAME = "EA_Model"
|
|
17
|
-
|
|
18
|
-
def initialize(document)
|
|
19
|
-
@document = document
|
|
20
|
-
@id_gen = IdGenerator.new
|
|
21
|
-
@writer = Writer.new
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# @return [String] XMI XML document
|
|
25
|
-
def serialize
|
|
26
|
-
assign_ids!
|
|
27
|
-
@writer.xmi_root do
|
|
28
|
-
@writer.documentation
|
|
29
|
-
@writer.uml_model(@id_gen.model_id, MODEL_NAME) do
|
|
30
|
-
emit_top_level
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
@writer.to_xml
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def assign_ids!
|
|
39
|
-
walk_all(@document.packages)
|
|
40
|
-
walk_all(@document.classes)
|
|
41
|
-
walk_all(@document.enums)
|
|
42
|
-
walk_all(@document.data_types)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def walk_all(elements)
|
|
46
|
-
elements.each { |e| register!(e) }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def register!(element)
|
|
50
|
-
@id_gen.eaid_for(element)
|
|
51
|
-
case element
|
|
52
|
-
when Lutaml::Uml::Package then register_package!(element)
|
|
53
|
-
when Lutaml::Uml::UmlClass then register_class!(element)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def register_package!(pkg)
|
|
58
|
-
walk_all(pkg.packages)
|
|
59
|
-
walk_all(pkg.classes)
|
|
60
|
-
walk_all(pkg.enums)
|
|
61
|
-
walk_all(pkg.data_types)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def register_class!(klass)
|
|
65
|
-
klass.attributes.each { |a| @id_gen.eaid_for(a) }
|
|
66
|
-
klass.operations.each { |o| @id_gen.eaid_for(o) }
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def emit_top_level
|
|
70
|
-
@document.packages.each { |p| emit_package(@writer, p) }
|
|
71
|
-
@document.classes.each { |c| emit_class(@writer, c) }
|
|
72
|
-
@document.enums.each { |e| emit_enum(@writer, e) }
|
|
73
|
-
@document.data_types.each { |d| emit_data_type(@writer, d) }
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def emit_package(w, pkg)
|
|
77
|
-
w.packaged_element("uml:Package", @id_gen.eaid_for(pkg), pkg.name) do
|
|
78
|
-
pkg.packages.each { |p| emit_package(w, p) }
|
|
79
|
-
pkg.classes.each { |c| emit_class(w, c) }
|
|
80
|
-
pkg.enums.each { |e| emit_enum(w, e) }
|
|
81
|
-
pkg.data_types.each { |d| emit_data_type(w, d) }
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def emit_class(w, klass)
|
|
86
|
-
w.packaged_element(
|
|
87
|
-
"uml:Class",
|
|
88
|
-
@id_gen.eaid_for(klass),
|
|
89
|
-
klass.name,
|
|
90
|
-
is_abstract: klass.is_abstract,
|
|
91
|
-
) do
|
|
92
|
-
klass.attributes.each { |a| emit_attribute(w, a) }
|
|
93
|
-
klass.operations.each { |o| emit_operation(w, o) }
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def emit_enum(w, enum)
|
|
98
|
-
w.packaged_element(
|
|
99
|
-
"uml:Enumeration",
|
|
100
|
-
@id_gen.eaid_for(enum),
|
|
101
|
-
enum.name,
|
|
102
|
-
) do
|
|
103
|
-
(enum.values || []).each { |v| emit_literal(w, v) }
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def emit_data_type(w, data_type)
|
|
108
|
-
w.packaged_element(
|
|
109
|
-
"uml:DataType",
|
|
110
|
-
@id_gen.eaid_for(data_type),
|
|
111
|
-
data_type.name,
|
|
112
|
-
) do
|
|
113
|
-
data_type.attributes.each { |a| emit_attribute(w, a) }
|
|
114
|
-
data_type.operations.each { |o| emit_operation(w, o) }
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def emit_attribute(w, attr)
|
|
119
|
-
type_ref = type_reference(attr.type)
|
|
120
|
-
w.owned_attribute(@id_gen.eaid_for(attr), attr.name, type: type_ref) do
|
|
121
|
-
# Multiplicity / defaults not modeled in Lutaml::Uml; deferred.
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def emit_operation(w, op)
|
|
126
|
-
w.owned_operation(@id_gen.eaid_for(op), op.name)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def emit_literal(w, literal)
|
|
130
|
-
case literal
|
|
131
|
-
when Lutaml::Uml::Value
|
|
132
|
-
w.owned_literal(@id_gen.eaid_for(literal), literal.name)
|
|
133
|
-
when String
|
|
134
|
-
w.owned_literal(synthesize_literal_id(literal), literal)
|
|
135
|
-
else
|
|
136
|
-
w.owned_literal(synthesize_literal_id(literal.to_s), literal.to_s)
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def type_reference(type_name)
|
|
141
|
-
return nil if type_name.nil? || type_name.empty?
|
|
142
|
-
|
|
143
|
-
type_name
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
def synthesize_literal_id(name)
|
|
147
|
-
format("EAID_LIT_%<hex>08X", hex: name.to_s.bytes.sum)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "nokogiri"
|
|
4
|
-
|
|
5
|
-
module Ea
|
|
6
|
-
module Transformers
|
|
7
|
-
module UmlToXmi
|
|
8
|
-
# Low-level XML structural primitives for emitting Sparx-flavored XMI.
|
|
9
|
-
#
|
|
10
|
-
# This class has no UML domain knowledge — it only knows the XML shapes
|
|
11
|
-
# (XMI root, uml:Model, packagedElement, ownedAttribute, …) required to
|
|
12
|
-
# produce a well-formed Sparx XMI document. {Transformer} drives it.
|
|
13
|
-
class Writer
|
|
14
|
-
XMI_NS = "http://www.omg.org/spec/XMI/20131001"
|
|
15
|
-
UML_NS = "http://www.omg.org/spec/UML/20161101"
|
|
16
|
-
|
|
17
|
-
attr_reader :builder
|
|
18
|
-
|
|
19
|
-
def initialize
|
|
20
|
-
@builder = Nokogiri::XML::Builder.new(encoding: "UTF-8")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def xmi_root
|
|
24
|
-
@builder["xmi"].XMI(root_attributes) { yield self }
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def documentation(exporter: "ea-rb", exporter_version: Ea::VERSION)
|
|
28
|
-
@builder["xmi"].Documentation(
|
|
29
|
-
exporter: exporter,
|
|
30
|
-
exporterVersion: exporter_version,
|
|
31
|
-
)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def uml_model(id, name)
|
|
35
|
-
@builder["uml"].Model(
|
|
36
|
-
"xmi:type": "uml:Model",
|
|
37
|
-
"xmi:id": id,
|
|
38
|
-
name: name,
|
|
39
|
-
) { yield self }
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def packaged_element(uml_type, id, name, **attrs)
|
|
43
|
-
@builder.packagedElement(packaged_attrs(uml_type, id, name, attrs)) do
|
|
44
|
-
yield self if block_given?
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def owned_attribute(id, name, type: nil, visibility: "public")
|
|
49
|
-
attrs = { "xmi:type": "uml:Property", "xmi:id": id, name: name,
|
|
50
|
-
visibility: visibility }
|
|
51
|
-
attrs[:type] = type if type
|
|
52
|
-
@builder.ownedAttribute(attrs) { yield self if block_given? }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def owned_operation(id, name, visibility: "public")
|
|
56
|
-
@builder.ownedOperation(
|
|
57
|
-
"xmi:type": "uml:Operation", "xmi:id": id, name: name,
|
|
58
|
-
visibility: visibility,
|
|
59
|
-
) { yield self if block_given? }
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def owned_literal(id, name)
|
|
63
|
-
@builder.ownedLiteral(
|
|
64
|
-
"xmi:type": "uml:EnumerationLiteral", "xmi:id": id, name: name,
|
|
65
|
-
)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def generalization(id, general_id)
|
|
69
|
-
@builder.generalization(
|
|
70
|
-
"xmi:type": "uml:Generalization",
|
|
71
|
-
"xmi:id": id,
|
|
72
|
-
general: general_id,
|
|
73
|
-
)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def to_xml
|
|
77
|
-
@builder.doc.to_xml
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
private
|
|
81
|
-
|
|
82
|
-
def root_attributes
|
|
83
|
-
{ "xmlns:xmi": XMI_NS, "xmlns:uml": UML_NS }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def packaged_attrs(uml_type, id, name, attrs)
|
|
87
|
-
result = { "xmi:type": uml_type, "xmi:id": id }
|
|
88
|
-
result[:name] = name if name
|
|
89
|
-
result[:"isAbstract"] = "true" if attrs[:is_abstract]
|
|
90
|
-
result[:visibility] = attrs[:visibility] if attrs[:visibility]
|
|
91
|
-
result
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ea
|
|
4
|
-
module Validation
|
|
5
|
-
# Compares Ea::Transformers.qea_to_xmi output against EA's
|
|
6
|
-
# reference XMI export (`examples/exports/*/model.xml`).
|
|
7
|
-
#
|
|
8
|
-
# Reports per-element-type counts (packagedElement, ownedAttribute,
|
|
9
|
-
# ownedEnd, memberEnd, generalization, connector, diagram, style,
|
|
10
|
-
# tags, documentation, xmi:Extension) so gaps surface clearly.
|
|
11
|
-
#
|
|
12
|
-
# Used by the parity regression spec to track XMI export fidelity
|
|
13
|
-
# over time. Improvements to QeaToXmi should shrink the gaps.
|
|
14
|
-
class XmiParity
|
|
15
|
-
ELEMENT_TYPES = %w[
|
|
16
|
-
packagedElement
|
|
17
|
-
ownedAttribute
|
|
18
|
-
ownedOperation
|
|
19
|
-
ownedEnd
|
|
20
|
-
memberEnd
|
|
21
|
-
generalization
|
|
22
|
-
connector
|
|
23
|
-
diagram
|
|
24
|
-
taggedValue
|
|
25
|
-
xmi:Extension
|
|
26
|
-
style
|
|
27
|
-
tags
|
|
28
|
-
documentation
|
|
29
|
-
].freeze
|
|
30
|
-
|
|
31
|
-
# Per-element counts for one XMI document.
|
|
32
|
-
Counts = Struct.new(:total, :by_type, keyword_init: true) do
|
|
33
|
-
def initialize(*)
|
|
34
|
-
super
|
|
35
|
-
self.by_type ||= {}
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def delta(other)
|
|
39
|
-
result = { total: total - other.total }
|
|
40
|
-
ELEMENT_TYPES.each do |t|
|
|
41
|
-
result[t] = (by_type[t] || 0) - (other.by_type[t] || 0)
|
|
42
|
-
end
|
|
43
|
-
result
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# @param qea_path [String] path to the QEA file
|
|
48
|
-
# @param reference_xmi_path [String] path to EA's reference XMI
|
|
49
|
-
# @return [Hash] {:ours, :reference, :delta} each a Counts
|
|
50
|
-
def self.compare(qea_path, reference_xmi_path)
|
|
51
|
-
database = Ea::Qea.load(qea_path)
|
|
52
|
-
ours_xml = Ea::Transformers.qea_to_xmi(database)
|
|
53
|
-
ref_xml = File.read(reference_xmi_path)
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
qea: qea_path,
|
|
57
|
-
reference: reference_xmi_path,
|
|
58
|
-
ours: count(ours_xml),
|
|
59
|
-
reference_counts: count(ref_xml),
|
|
60
|
-
delta: count(ours_xml).delta(count(ref_xml))
|
|
61
|
-
}
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# @param xml [String] XMI markup (any encoding)
|
|
65
|
-
# @return [Counts]
|
|
66
|
-
def self.count(xml)
|
|
67
|
-
# EA exports use windows-1252; force UTF-8 for safe regex.
|
|
68
|
-
safe = xml.to_s.encode("UTF-8", invalid: :replace, undef: :replace,
|
|
69
|
-
replace: "?")
|
|
70
|
-
by_type = ELEMENT_TYPES.each_with_object({}) do |tag, acc|
|
|
71
|
-
# Match `<tag>` followed by space, `/`, or `>` (covers
|
|
72
|
-
# `<tag/>`, `<tag foo=...>`, `<tag>`). Using %r{} to avoid
|
|
73
|
-
# `/` regex-delimiter conflict with the `/` in the class.
|
|
74
|
-
acc[tag] = safe.scan(%r{<#{tag}[\s/>]}).size
|
|
75
|
-
end
|
|
76
|
-
Counts.new(total: by_type.values.sum, by_type: by_type)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|