Class: Lutaml::Qea::Factory::EaToUmlFactory
- Inherits:
-
Object
- Object
- Lutaml::Qea::Factory::EaToUmlFactory
- Defined in:
- lib/lutaml/qea/factory/ea_to_uml_factory.rb
Overview
Main factory for orchestrating EA to UML transformation Implements Facade pattern for complete model transformation
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
Instance Method Summary collapse
-
#create_document ⇒ Lutaml::Uml::Document
Create complete UML document from EA database.
-
#initialize(database, options = {}) ⇒ EaToUmlFactory
constructor
Initialize factory with EA database (default: true).
-
#transform_associations ⇒ Array<Lutaml::Uml::Association>
Transform all associations.
-
#transform_classes ⇒ Array<Lutaml::Uml::Class>
Transform all classes.
-
#transform_diagrams ⇒ Array<Lutaml::Uml::Diagram>
Transform all diagrams.
-
#transform_packages ⇒ Array<Lutaml::Uml::Package>
Transform all packages with hierarchy.
-
#with_transformers(transformers) ⇒ self
Use custom transformers.
Constructor Details
#initialize(database, options = {}) ⇒ EaToUmlFactory
Initialize factory with EA database (default: true)
25 26 27 28 29 30 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 25 def initialize(database, = {}) @database = database @options = .merge() @resolver = ReferenceResolver.new @transformers = {} end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
16 17 18 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 16 def database @database end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 16 def @options end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
16 17 18 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 16 def resolver @resolver end |
Instance Method Details
#create_document ⇒ Lutaml::Uml::Document
Create complete UML document from EA database
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 34 def create_document # rubocop:disable Metrics/AbcSize,Metrics/MethodLength builder = DocumentBuilder.new( name: [:document_name] || "EA Model", ) # Transform packages with hierarchy (includes all classes) packages = transform_packages # Transform associations (references classes by xmi_id) associations = transform_associations # Collect class-level associations from packages # class-level associations contain associations with both directions # and it may include associations in connector level # i.e. owner_end -> member_end and member_end -> owner_end class_associations = collect_class_associations(packages) # Build document with both connector-level and # class-level associations builder.add_packages(packages) .add_associations(associations) .add_associations(class_associations) # Add diagrams if requested if [:include_diagrams] transform_diagrams # Note: diagrams are stored in packages, not at document level end builder.build(validate: [:validate]) end |
#transform_associations ⇒ Array<Lutaml::Uml::Association>
Transform all associations
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 113 def transform_associations # rubocop:disable Metrics/MethodLength association_transformer = get_transformer(:association) # Get all association-type connectors ea_associations = database.connectors.select(&:association?) uml_associations = association_transformer.transform_collection( ea_associations, ) # Register all associations in resolver uml_associations.each do |uml_assoc| register_element(uml_assoc) end uml_associations end |
#transform_classes ⇒ Array<Lutaml::Uml::Class>
Transform all classes
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 91 def transform_classes # rubocop:disable Metrics/MethodLength class_transformer = get_transformer(:class) # Get all class-type objects ea_classes = database.objects.find_by_type("Class") ea_interfaces = database.objects.find_by_type("Interface") all_class_objects = ea_classes + ea_interfaces uml_classes = class_transformer.transform_collection( all_class_objects, ) # Register all classes in resolver uml_classes.each do |uml_class| register_element(uml_class) end uml_classes end |
#transform_diagrams ⇒ Array<Lutaml::Uml::Diagram>
Transform all diagrams
133 134 135 136 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 133 def transform_diagrams diagram_transformer = get_transformer(:diagram) diagram_transformer.transform_collection(database.diagrams) end |
#transform_packages ⇒ Array<Lutaml::Uml::Package>
Transform all packages with hierarchy
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 68 def transform_packages # rubocop:disable Metrics/MethodLength # Get root packages (those without parent) root_packages = database.packages.select do |pkg| pkg.parent_id.nil? || pkg.parent_id.zero? end # Transform each root package with its hierarchy package_transformer = get_transformer(:package) root_packages.filter_map do |ea_package| uml_package = package_transformer.transform_with_hierarchy( ea_package, include_children: true, ) # Register package and all descendants in resolver register_package_hierarchy(uml_package) uml_package end end |
#with_transformers(transformers) ⇒ self
Use custom transformers
145 146 147 148 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 145 def with_transformers(transformers) @transformers.merge!(transformers) self end |