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)
18 19 20 21 22 23 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 18 def initialize(database, = {}) @database = database @options = .merge() @resolver = ReferenceResolver.new @transformers = {} end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
9 10 11 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 9 def database @database end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 9 def @options end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
9 10 11 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 9 def resolver @resolver end |
Instance Method Details
#create_document ⇒ Lutaml::Uml::Document
Create complete UML document from EA database
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 27 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
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 106 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
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 84 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
126 127 128 129 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 126 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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 61 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
138 139 140 141 |
# File 'lib/lutaml/qea/factory/ea_to_uml_factory.rb', line 138 def with_transformers(transformers) @transformers.merge!(transformers) self end |