Class: Ea::Sources::Xmi::DiagramBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/xmi/diagram_builder.rb

Overview

Translates XMI uml:Diagram elements into Ea::Model::Diagram instances. Coordinates come from the UML-DI owned_element bounds; element references come from the model_element attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ DiagramBuilder

Returns a new instance of DiagramBuilder.



13
14
15
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 13

def initialize(root)
  @root = root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



11
12
13
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 11

def root
  @root
end

Instance Method Details

#build_allObject



17
18
19
20
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 17

def build_all
  diagrams = Array(root.model.diagram)
  diagrams.map { |d| build_one(d) }
end

#build_one(diagram) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ea/sources/xmi/diagram_builder.rb', line 22

def build_one(diagram)
  id = IdNormalizer.from_xmi_id(diagram.id)
  ext_diagram = extension_diagram_for(id)
  Ea::Model::Diagram.new(
    id: id,
    name: ext_diagram&.properties&.name,
    package_id: ext_diagram&.model&.package,
    diagram_type: ext_diagram&.properties&.type&.split(":")&.last&.downcase,
    bounds: bounds_for(diagram),
    elements: build_elements(diagram, id),
    connectors: [],
    annotations: AnnotationBuilder.from_element(diagram, id)
  )
end