Class: Ea::Sources::Xmi::DiagramBuilder
- Inherits:
-
Object
- Object
- Ea::Sources::Xmi::DiagramBuilder
- Defined in:
- lib/ea/sources/xmi/diagram_builder.rb
Overview
Translates EA diagrams from the XMI source into Ea::Model instances. Uses the rich placement data inside the xmi:Extension block (Left/Top/Right/Bottom, BCol, font, SOID/EOID, EDGE, label boxes) when present. Falls back to the UML-DI owned_element bounds otherwise.
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#xmi_path ⇒ Object
readonly
Returns the value of attribute xmi_path.
Instance Method Summary collapse
- #build_all ⇒ Object
- #build_one(ext_diagram) ⇒ Object
-
#extension_diagrams ⇒ Object
The XMI stores diagrams in two places: - root.model.diagram — UML-DI shape (often just one or none) - root.extension.diagrams.diagram — the rich EA extension block with placement/style/connector data (the source of truth for rendering).
-
#initialize(root, xmi_path = nil) ⇒ DiagramBuilder
constructor
A new instance of DiagramBuilder.
-
#style_ex_for(ext_diagram) ⇒ Object
EA's XMI stores StyleEx in the diagram's
style2.valueattribute (alongside Style1 instyle1.value). -
#style_for(ext_diagram) ⇒ Object
EA's XMI stores Style (a.k.a. Style1) in
style1.value— the per-diagram feature visibility flags (HideAtts, HideOps, HideStereo, etc.).
Constructor Details
#initialize(root, xmi_path = nil) ⇒ DiagramBuilder
Returns a new instance of DiagramBuilder.
14 15 16 17 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 14 def initialize(root, xmi_path = nil) @root = root @xmi_path = xmi_path end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
12 13 14 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 12 def root @root end |
#xmi_path ⇒ Object (readonly)
Returns the value of attribute xmi_path.
12 13 14 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 12 def xmi_path @xmi_path end |
Instance Method Details
#build_all ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 19 def build_all ext_diagrams = extension_diagrams return [] if ext_diagrams.empty? ext_diagrams.map { |d| build_one(d) } end |
#build_one(ext_diagram) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 40 def build_one(ext_diagram) id = IdNormalizer.from_xmi_id(ext_diagram.id) ext_elements = ExtensionElements.new(ext_diagram) placed_elements = ext_elements.placed_elements placed_connectors = ext_elements.placed_connectors props = ext_diagram.properties umldi_keywords = keywords_for(id) Ea::Model::Diagram.new( id: id, name: props&.name || ext_diagram.id, package_id: ext_diagram.model&.package, diagram_type: props&.type&.split(":")&.last&.downcase, bounds: canvas_bounds(placed_elements), style: style_for(ext_diagram), style_ex: style_ex_for(ext_diagram), elements: build_elements(placed_elements, id, umldi_keywords), connectors: build_connectors(placed_connectors, placed_elements, id), annotations: [] ) end |
#extension_diagrams ⇒ Object
The XMI stores diagrams in two places:
- root.model.diagram — UML-DI shape (often just one or none)
- root.extension.diagrams.diagram — the rich EA extension block with placement/style/connector data (the source of truth for rendering). We use the extension block when present; fall back to UML-DI otherwise.
33 34 35 36 37 38 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 33 def extension_diagrams ext = root.extension return [] unless ext&.diagrams ext.diagrams.diagram.to_a end |
#style_ex_for(ext_diagram) ⇒ Object
EA's XMI stores StyleEx in the diagram's style2.value
attribute (alongside Style1 in style1.value). The value
is a semicolon-separated key=value string carrying the
Theme=:NNN identifier and behavioral flags (SuppressFOC,
AttPkg, ShowNotes, etc.) — the same shape our Diagram
model expects in style_ex.
80 81 82 83 84 85 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 80 def style_ex_for(ext_diagram) style2 = ext_diagram.style2 return nil unless style2 style2.value end |
#style_for(ext_diagram) ⇒ Object
EA's XMI stores Style (a.k.a. Style1) in style1.value —
the per-diagram feature visibility flags (HideAtts, HideOps,
HideStereo, etc.). Parsed by DisplayConfig alongside
StyleEx.
67 68 69 70 71 72 |
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 67 def style_for(ext_diagram) style1 = ext_diagram.style1 return nil unless style1 style1.value end |