Module: Ea::Qea

Defined in:
lib/ea/qea.rb,
lib/ea/qea/models.rb,
lib/ea/qea/factory.rb,
lib/ea/qea/database.rb,
lib/ea/qea/services.rb,
lib/ea/qea/benchmark.rb,
lib/ea/qea/validation.rb,
lib/ea/qea/repositories.rb,
lib/ea/qea/verification.rb,
lib/ea/qea/file_detector.rb,
lib/ea/qea/infrastructure.rb,
lib/ea/qea/models/ea_xref.rb,
lib/ea/qea/models/ea_object.rb,
lib/ea/qea/models/ea_script.rb,
lib/ea/qea/models/base_model.rb,
lib/ea/qea/models/ea_diagram.rb,
lib/ea/qea/models/ea_package.rb,
lib/ea/qea/models/ea_datatype.rb,
lib/ea/qea/models/ea_document.rb,
lib/ea/qea/models/ea_attribute.rb,
lib/ea/qea/models/ea_connector.rb,
lib/ea/qea/models/ea_operation.rb,
lib/ea/qea/validation/database.rb,
lib/ea/qea/models/ea_stereotype.rb,
lib/ea/qea/models/ea_object_type.rb,
lib/ea/qea/models/ea_status_type.rb,
lib/ea/qea/validation/formatters.rb,
lib/ea/qea/models/ea_diagram_link.rb,
lib/ea/qea/models/ea_diagram_type.rb,
lib/ea/qea/models/ea_tagged_value.rb,
lib/ea/qea/services/configuration.rb,
lib/ea/qea/models/ea_attribute_tag.rb,
lib/ea/qea/factory/base_transformer.rb,
lib/ea/qea/factory/document_builder.rb,
lib/ea/qea/factory/enum_transformer.rb,
lib/ea/qea/models/ea_connector_type.rb,
lib/ea/qea/models/ea_diagram_object.rb,
lib/ea/qea/services/database_loader.rb,
lib/ea/qea/factory/class_transformer.rb,
lib/ea/qea/factory/ea_to_uml_factory.rb,
lib/ea/qea/factory/stereotype_loader.rb,
lib/ea/qea/models/ea_complexity_type.rb,
lib/ea/qea/models/ea_constraint_type.rb,
lib/ea/qea/models/ea_object_property.rb,
lib/ea/qea/models/ea_operation_param.rb,
lib/ea/qea/validation/base_validator.rb,
lib/ea/qea/factory/reference_resolver.rb,
lib/ea/qea/validation/class_validator.rb,
lib/ea/qea/factory/association_builder.rb,
lib/ea/qea/factory/diagram_transformer.rb,
lib/ea/qea/factory/package_transformer.rb,
lib/ea/qea/infrastructure/table_reader.rb,
lib/ea/qea/models/ea_object_constraint.rb,
lib/ea/qea/factory/instance_transformer.rb,
lib/ea/qea/factory/transformer_registry.rb,
lib/ea/qea/infrastructure/schema_reader.rb,
lib/ea/qea/repositories/base_repository.rb,
lib/ea/qea/validation/diagram_validator.rb,
lib/ea/qea/validation/package_validator.rb,
lib/ea/qea/validation/validation_engine.rb,
lib/ea/qea/validation/validation_result.rb,
lib/ea/qea/factory/attribute_transformer.rb,
lib/ea/qea/factory/data_type_transformer.rb,
lib/ea/qea/factory/operation_transformer.rb,
lib/ea/qea/validation/validation_message.rb,
lib/ea/qea/validation/validator_registry.rb,
lib/ea/qea/factory/constraint_transformer.rb,
lib/ea/qea/factory/generalization_builder.rb,
lib/ea/qea/repositories/object_repository.rb,
lib/ea/qea/validation/attribute_validator.rb,
lib/ea/qea/validation/operation_validator.rb,
lib/ea/qea/verification/comparison_result.rb,
lib/ea/qea/verification/document_verifier.rb,
lib/ea/qea/verification/structure_matcher.rb,
lib/ea/qea/factory/association_transformer.rb,
lib/ea/qea/verification/element_comparator.rb,
lib/ea/qea/factory/tagged_value_transformer.rb,
lib/ea/qea/validation/association_validator.rb,
lib/ea/qea/verification/document_normalizer.rb,
lib/ea/qea/factory/attribute_tag_transformer.rb,
lib/ea/qea/factory/generalization_transformer.rb,
lib/ea/qea/infrastructure/database_connection.rb,
lib/ea/qea/factory/object_property_transformer.rb,
lib/ea/qea/validation/database/orphan_validator.rb,
lib/ea/qea/validation/formatters/json_formatter.rb,
lib/ea/qea/validation/formatters/text_formatter.rb,
lib/ea/qea/validation/database/circular_reference_validator.rb,
lib/ea/qea/validation/database/referential_integrity_validator.rb

Defined Under Namespace

Modules: Factory, Infrastructure, Models, Repositories, Services, Validation, Verification Classes: Benchmark, Database, FileDetector

Class Method Summary collapse

Class Method Details

.configurationServices::Configuration

Get the current configuration

Returns:



20
21
22
# File 'lib/ea/qea.rb', line 20

def configuration
  @configuration ||= Services::Configuration.load
end

.configuration=(config) ⇒ Object

Set a custom configuration

Parameters:



27
28
29
# File 'lib/ea/qea.rb', line 27

def configuration=(config)
  @configuration = config
end

.connect(file_path) ⇒ Infrastructure::DatabaseConnection

Connect to a QEA file

Parameters:

  • file_path (String)

    Path to the .qea file

Returns:



43
44
45
# File 'lib/ea/qea.rb', line 43

def connect(file_path)
  Infrastructure::DatabaseConnection.new(file_path)
end

.database_info(qea_path, config = nil) ⇒ Hash<String, Integer>

Get quick database statistics without full loading

Parameters:

Returns:

  • (Hash<String, Integer>)

    Collection names to record counts



104
105
106
107
# File 'lib/ea/qea.rb', line 104

def database_info(qea_path, config = nil)
  loader = Services::DatabaseLoader.new(qea_path, config)
  loader.quick_stats
end

.load(qea_path, config = nil, &progress_callback) ⇒ Database

Load complete database with all tables and models (standalone API)

This is the primary standalone entry point — returns EA-native data without requiring lutaml-uml.

Parameters:

  • qea_path (String)

    Path to the .qea file

  • config (Services::Configuration, nil) (defaults to: nil)

    Optional custom config

Returns:

  • (Database)

    Loaded database with all collections



84
85
86
# File 'lib/ea/qea.rb', line 84

def load(qea_path, config = nil, &progress_callback)
  load_database(qea_path, config, &progress_callback)
end

.load_database(qea_path, config = nil, &progress_callback) ⇒ Database

Load complete database with all tables and models

Parameters:

Returns:

  • (Database)

    Loaded database with all collections



93
94
95
96
97
# File 'lib/ea/qea.rb', line 93

def load_database(qea_path, config = nil, &progress_callback)
  loader = Services::DatabaseLoader.new(qea_path, config)
  loader.on_progress(&progress_callback) if progress_callback
  loader.load
end

.open(file_path) {|Infrastructure::DatabaseConnection| ... } ⇒ Object

Open a QEA file and yield the connection

Parameters:

  • file_path (String)

    Path to the .qea file

Yields:

Returns:

  • (Object)

    The result of the block



52
53
54
55
56
57
# File 'lib/ea/qea.rb', line 52

def open(file_path)
  connection = connect(file_path)
  yield connection
ensure
  connection&.close if connection&.connected?
end

.parse(qea_path, options = {}) ⇒ Lutaml::Uml::Document, Hash

Parse QEA file to UML Document (convenience: load + to_uml)

Requires lutaml-uml for the UML conversion.

Parameters:

  • qea_path (String)

    Path to the .qea file

  • options (Hash) (defaults to: {})

    Transformation options

Returns:

  • (Lutaml::Uml::Document, Hash)

    Document, or hash with :document and :validation_result

Raises:

  • (Ea::Error)

    if lutaml-uml is not available



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/ea/qea.rb', line 130

def parse(qea_path, options = {}) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
  require_uml!
  config = options.delete(:config)
  validate = options.delete(:validate)

  loader = Services::DatabaseLoader.new(qea_path, config)
  ea_database = loader.load

  begin
    factory = Factory::EaToUmlFactory.new(ea_database, options)
    document = factory.create_document

    if validate
      engine = Validation::ValidationEngine.new(
        document,
        database: ea_database,
        **options,
      )
      validation_result = engine.validate

      {
        document: document,
        validation_result: validation_result,
      }
    else
      document
    end
  ensure
    ea_database.close_connection unless validate
  end
end

.reload_configuration(config_path = nil) ⇒ Services::Configuration

Reload configuration from file

Parameters:

  • config_path (String, nil) (defaults to: nil)

    Optional custom config path

Returns:



35
36
37
# File 'lib/ea/qea.rb', line 35

def reload_configuration(config_path = nil)
  @configuration = Services::Configuration.load(config_path)
end

.schema_info(file_path) ⇒ Hash

Get schema information from a QEA file

Parameters:

  • file_path (String)

    Path to the .qea file

Returns:

  • (Hash)

    Schema information including tables and row counts



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ea/qea.rb', line 63

def schema_info(file_path)
  connection = connect(file_path)
  connection.with_connection do |db|
    reader = Infrastructure::SchemaReader.new(db)
    {
      tables: reader.tables,
      statistics: reader.statistics,
    }
  end
ensure
  connection&.close if connection&.connected?
end

.to_uml(database, options = {}) ⇒ Lutaml::Uml::Document

Convert an EA database to a UML Document (requires lutaml-uml)

Parameters:

  • database (Database)

    Loaded EA database

  • options (Hash) (defaults to: {})

    Transformation options

Returns:

  • (Lutaml::Uml::Document)

    UML document

Raises:

  • (Ea::Error)

    if lutaml-uml is not available



115
116
117
118
119
# File 'lib/ea/qea.rb', line 115

def to_uml(database, options = {})
  require_uml!
  factory = Factory::EaToUmlFactory.new(database, options)
  factory.create_document
end