Class: Ea::Transformers::QeaToXmi::Transformer
- Inherits:
-
Object
- Object
- Ea::Transformers::QeaToXmi::Transformer
- Defined in:
- lib/ea/transformers/qea_to_xmi/transformer.rb
Overview
Orchestrates serialization of an Ea::Qea::Database to Sparx XMI.
Walks the package tree starting at root packages, constructing
xmi gem models (Xmi::Uml::UmlModel, Xmi::Uml::PackagedElement,
Xmi::Uml::OwnedAttribute, Xmi::Uml::OwnedEnd, etc.) from each
QEA row, then asks the xmi gem to render them via
to_xml(use_prefix: true) to produce Sparx XMI in the canonical
mixed-prefix style. The serialized output is run through
XmlSanitizer to strip truly-empty elements that the xmi gem's
round-trip-oriented VALUE_MAP emits but Sparx XMI does not.
Element-kind dispatch (Class vs Enumeration vs DataType vs Instance) is registry-driven — see CLASSIFIER_BUILDERS. Adding a new kind = adding one entry to that hash, no method change. Polymorphism for XMI element shape lives in the xmi gem's models (xmi:type discriminator on PackagedElement), not here.
This is the FULL-FIDELITY path — no Lutaml::Uml::Document intermediate. Sparx-specific concepts (multiplicities, tagged values, stereotypes, primitive types, instance specifications, association ends) come straight from the QEA tables.
Phase 2 will extend the xmi gem with visibility / isAbstract / classifier / aggregation attributes that the QEA database contains but the xmi gem's models don't yet declare.
Constant Summary collapse
- MODEL_NAME =
"EA_Model"- EXPORTER =
"Enterprise Architect"- EXPORTER_VERSION =
"6.5"- RELATIONSHIP_AT_PACKAGE_LEVEL =
{ "Association" => :association, "Aggregation" => :association, "Composition" => :association, "Dependency" => :dependency, "Usage" => :dependency, }.freeze
- CLASSIFIER_BUILDERS =
OCP registry: maps EaObject#transformer_type to the builder that constructs the corresponding Xmi::Uml element. To add a new element kind (Signal, Interface, ...), append one entry here —
build_classifierrequires no edit.Builders are lambdas evaluated via
instance_exec, so they run inside the Transformer instance and can call its private helpers withoutsend/public_senddispatch. { class: ->(obj) { build_class(obj) }, enumeration: ->(obj) { build_enumeration(obj) }, data_type: ->(obj) { build_data_type(obj) }, instance: ->(obj) { build_instance(obj) }, }.freeze
Instance Method Summary collapse
-
#initialize(database) ⇒ Transformer
constructor
A new instance of Transformer.
-
#serialize ⇒ String
The xmi gem's VALUE_MAP is generation-friendly (
to: { nil: :omitted, ... }), so empty collections and nil-valued attributes are skipped at the source.
Constructor Details
#initialize(database) ⇒ Transformer
Returns a new instance of Transformer.
61 62 63 64 |
# File 'lib/ea/transformers/qea_to_xmi/transformer.rb', line 61 def initialize(database) @database = database @context = Context.new(database: database) end |
Instance Method Details
#serialize ⇒ String
The xmi gem's VALUE_MAP is generation-friendly
(to: { nil: :omitted, ... }), so empty collections and
nil-valued attributes are skipped at the source. No
post-processing pass is needed — the prior XmlSanitizer
workaround (TODO 21 §1) has been removed.
73 74 75 |
# File 'lib/ea/transformers/qea_to_xmi/transformer.rb', line 73 def serialize build_root.to_xml(use_prefix: true) end |