ea 0.6.155 → 0.6.157
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +423 -0
- data/config/qea_schema.yml +2 -0
- data/lib/ea/ocl/parser.rb +2 -2
- data/lib/ea/qea/benchmark.rb +4 -4
- data/lib/ea/qea/factory/association_builder.rb +1 -1
- data/lib/ea/qea/factory/association_transformer.rb +2 -2
- data/lib/ea/qea/factory/attribute_transformer.rb +1 -1
- data/lib/ea/qea/factory/base_transformer.rb +2 -20
- data/lib/ea/qea/factory/constraint_transformer.rb +1 -1
- data/lib/ea/qea/factory/data_type_transformer.rb +1 -1
- data/lib/ea/qea/factory/diagram_transformer.rb +3 -3
- data/lib/ea/qea/factory/document_builder.rb +3 -3
- data/lib/ea/qea/factory/ea_to_uml_factory.rb +2 -2
- data/lib/ea/qea/factory/enum_transformer.rb +3 -2
- data/lib/ea/qea/factory/generalization_builder.rb +6 -4
- data/lib/ea/qea/factory/generalization_transformer.rb +1 -1
- data/lib/ea/qea/factory/instance_transformer.rb +1 -1
- data/lib/ea/qea/factory/operation_transformer.rb +1 -1
- data/lib/ea/qea/factory/package_transformer.rb +1 -1
- data/lib/ea/qea/file_detector.rb +2 -2
- data/lib/ea/qea/infrastructure/table_reader.rb +2 -2
- data/lib/ea/qea/models/ea_xref.rb +1 -1
- data/lib/ea/qea/repositories/base_repository.rb +1 -1
- data/lib/ea/qea/rules/cardinality.rb +78 -0
- data/lib/ea/qea/rules/enum_literal.rb +22 -0
- data/lib/ea/qea/rules/generalization.rb +39 -0
- data/lib/ea/qea/rules/visibility.rb +35 -0
- data/lib/ea/qea/rules.rb +22 -0
- data/lib/ea/qea/services/configuration.rb +16 -2
- data/lib/ea/qea/services/database_loader.rb +2 -2
- data/lib/ea/qea/validation/association_validator.rb +2 -2
- data/lib/ea/qea/validation/attribute_validator.rb +2 -2
- data/lib/ea/qea/validation/base_validator.rb +3 -3
- data/lib/ea/qea/validation/class_validator.rb +3 -3
- data/lib/ea/qea/validation/database/circular_reference_validator.rb +3 -3
- data/lib/ea/qea/validation/database/orphan_validator.rb +4 -4
- data/lib/ea/qea/validation/database/referential_integrity_validator.rb +3 -3
- data/lib/ea/qea/validation/diagram_validator.rb +3 -3
- data/lib/ea/qea/validation/formatters/json_formatter.rb +2 -2
- data/lib/ea/qea/validation/formatters/text_formatter.rb +4 -4
- data/lib/ea/qea/validation/operation_validator.rb +2 -2
- data/lib/ea/qea/validation/package_validator.rb +3 -3
- data/lib/ea/qea/validation/validation_engine.rb +5 -5
- data/lib/ea/qea/validation/validation_message.rb +1 -1
- data/lib/ea/qea/verification/comparison_result.rb +4 -4
- data/lib/ea/qea/verification/document_normalizer.rb +3 -3
- data/lib/ea/qea/verification/document_verifier.rb +3 -3
- data/lib/ea/qea/verification/element_comparator.rb +5 -5
- data/lib/ea/qea/verification/structure_matcher.rb +4 -4
- data/lib/ea/qea.rb +2 -1
- data/lib/ea/rtf.rb +2 -2
- data/lib/ea/sources/qea/classifier_builder.rb +4 -8
- data/lib/ea/sources/qea/operation_builder.rb +1 -6
- data/lib/ea/sources/qea/property_builder.rb +1 -7
- data/lib/ea/svg/ea_emitter/text_renderer.rb +1 -1
- data/lib/ea/theme/loader.rb +0 -2
- data/lib/ea/transformers/qea_to_xmi/cardinality.rb +7 -35
- data/lib/ea/transformers/qea_to_xmi/extension_serializer.rb +2 -2
- data/lib/ea/version.rb +1 -1
- data/lib/ea/xmi/parser.rb +25 -25
- metadata +8 -2
|
@@ -36,8 +36,9 @@ module Ea
|
|
|
36
36
|
def load_association_generalizations(object_id)
|
|
37
37
|
return [] if object_id.nil?
|
|
38
38
|
|
|
39
|
-
gen_connectors =
|
|
40
|
-
|
|
39
|
+
gen_connectors = Ea::Qea::Rules::Generalization.connectors_from(
|
|
40
|
+
object_id, database.connectors_for_object(object_id)
|
|
41
|
+
)
|
|
41
42
|
|
|
42
43
|
gen_connectors.filter_map do |ea_connector|
|
|
43
44
|
build_assoc_generalization(ea_connector)
|
|
@@ -140,8 +141,9 @@ module Ea
|
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
def ea_connector_for(object_id)
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
Ea::Qea::Rules::Generalization.connector_for(
|
|
145
|
+
object_id, database.connectors_for_object(object_id)
|
|
146
|
+
)
|
|
145
147
|
end
|
|
146
148
|
|
|
147
149
|
def populate_generalization_attrs(generalization, object_id)
|
|
@@ -11,7 +11,7 @@ module Ea
|
|
|
11
11
|
# @param current_object [EaObject]
|
|
12
12
|
# Current object that owns this generalization
|
|
13
13
|
# @return [Lutaml::Uml::Generalization] UML generalization
|
|
14
|
-
def transform(ea_connector, current_object)
|
|
14
|
+
def transform(ea_connector, current_object)
|
|
15
15
|
return nil if current_object.nil?
|
|
16
16
|
|
|
17
17
|
# ea_connector can be nil for terminal nodes (classes with no parent)
|
|
@@ -8,7 +8,7 @@ module Ea
|
|
|
8
8
|
# Transform EA object to UML instance
|
|
9
9
|
# @param ea_object [EaObject] EA object model
|
|
10
10
|
# @return [Lutaml::Uml::Instance] UML instance
|
|
11
|
-
def transform(ea_object)
|
|
11
|
+
def transform(ea_object)
|
|
12
12
|
return nil if ea_object.nil?
|
|
13
13
|
return nil unless ea_object.instance?
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ module Ea
|
|
|
8
8
|
# Transform EA operation to UML operation
|
|
9
9
|
# @param ea_operation [EaOperation] EA operation model
|
|
10
10
|
# @return [Lutaml::Uml::Operation] UML operation
|
|
11
|
-
def transform(ea_operation)
|
|
11
|
+
def transform(ea_operation)
|
|
12
12
|
return nil if ea_operation.nil?
|
|
13
13
|
|
|
14
14
|
Lutaml::Uml::Operation.new.tap do |op|
|
|
@@ -8,7 +8,7 @@ module Ea
|
|
|
8
8
|
# Transform EA package to UML package
|
|
9
9
|
# @param ea_package [EaPackage] EA package model
|
|
10
10
|
# @return [Lutaml::Uml::Package] UML package
|
|
11
|
-
def transform(ea_package)
|
|
11
|
+
def transform(ea_package)
|
|
12
12
|
return nil if ea_package.nil?
|
|
13
13
|
|
|
14
14
|
Lutaml::Uml::Package.new.tap do |pkg|
|
data/lib/ea/qea/file_detector.rb
CHANGED
|
@@ -43,7 +43,7 @@ module Ea
|
|
|
43
43
|
# else
|
|
44
44
|
# puts "Errors: #{result[:errors]}"
|
|
45
45
|
# end
|
|
46
|
-
def validate_qea(path)
|
|
46
|
+
def validate_qea(path)
|
|
47
47
|
errors = []
|
|
48
48
|
warnings = []
|
|
49
49
|
|
|
@@ -101,7 +101,7 @@ module Ea
|
|
|
101
101
|
# info = FileDetector.file_info("model.qea")
|
|
102
102
|
# puts "Size: #{info[:size_mb]} MB"
|
|
103
103
|
# puts "Tables: #{info[:table_count]}"
|
|
104
|
-
def file_info(path)
|
|
104
|
+
def file_info(path)
|
|
105
105
|
return { error: "File not found" } unless File.exist?(path)
|
|
106
106
|
|
|
107
107
|
info = {
|
|
@@ -96,7 +96,7 @@ module Ea
|
|
|
96
96
|
#
|
|
97
97
|
# @example With limit
|
|
98
98
|
# reader.where("Object_Type = ?", "Class", limit: 10)
|
|
99
|
-
def where(conditions, *values, limit: nil, offset: nil)
|
|
99
|
+
def where(conditions, *values, limit: nil, offset: nil)
|
|
100
100
|
query = "SELECT * FROM #{@table_name} WHERE #{conditions}"
|
|
101
101
|
params = values.flatten
|
|
102
102
|
|
|
@@ -213,7 +213,7 @@ module Ea
|
|
|
213
213
|
# @example
|
|
214
214
|
# reader.select(["Object_ID", "Name"], "Object_Type = ?", "Class")
|
|
215
215
|
# # => [{"Object_ID"=>1, "Name"=>"Class1"}, ...]
|
|
216
|
-
def select(columns, conditions = nil, *values, limit: nil)
|
|
216
|
+
def select(columns, conditions = nil, *values, limit: nil)
|
|
217
217
|
column_list = columns.join(", ")
|
|
218
218
|
query = "SELECT #{column_list} FROM #{@table_name}"
|
|
219
219
|
|
|
@@ -104,7 +104,7 @@ module Ea
|
|
|
104
104
|
#
|
|
105
105
|
# @param desc [String] Description field content
|
|
106
106
|
# @return [Hash] Parsed data
|
|
107
|
-
def parse_description_field(desc)
|
|
107
|
+
def parse_description_field(desc)
|
|
108
108
|
return {} if desc.nil? || desc.empty?
|
|
109
109
|
|
|
110
110
|
result = { raw: desc }
|
|
@@ -76,7 +76,7 @@ module Ea
|
|
|
76
76
|
#
|
|
77
77
|
# @example Block condition
|
|
78
78
|
# repository.where { |r| r.name.start_with?("Test") }
|
|
79
|
-
def where(conditions = nil, &block)
|
|
79
|
+
def where(conditions = nil, &block)
|
|
80
80
|
if block
|
|
81
81
|
@records.select(&block)
|
|
82
82
|
elsif conditions.is_a?(Hash)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ea
|
|
4
|
+
module Qea
|
|
5
|
+
module Rules
|
|
6
|
+
# Canonical cardinality / multiplicity parser for EA's free-text
|
|
7
|
+
# bound fields (t_attribute.upperbound / lowerbound,
|
|
8
|
+
# t_connector.sourcecard, etc.).
|
|
9
|
+
#
|
|
10
|
+
# EA stores cardinality as opaque strings: `1`, `0..1`, `*`,
|
|
11
|
+
# occasionally `unbounded` or `*-1`. The canonical form is the
|
|
12
|
+
# `{ min:, max: }` pair with the UML conventions: unlimited tokens
|
|
13
|
+
# mean 0..*, a bare value means N..N, and blank means unspecified
|
|
14
|
+
# (0..*).
|
|
15
|
+
module Cardinality
|
|
16
|
+
# Tokens EA uses for "unbounded". Matched case-insensitively.
|
|
17
|
+
UNLIMITED_TOKENS = %w[* *-1 -1 unbounded].freeze
|
|
18
|
+
|
|
19
|
+
# UML defaults when EA carries no explicit bound.
|
|
20
|
+
DEFAULT_MIN = "0"
|
|
21
|
+
DEFAULT_MAX = "*"
|
|
22
|
+
|
|
23
|
+
module_function
|
|
24
|
+
|
|
25
|
+
# @param raw [String, nil] e.g. "1..*", "0..1", "1", "*", nil
|
|
26
|
+
# @return [Hash{Symbol=>String}] `{ min:, max: }` always
|
|
27
|
+
# populated; nil/blank input returns the UML default 0..*.
|
|
28
|
+
def parse(raw)
|
|
29
|
+
return defaults if raw.nil? || raw.to_s.strip.empty?
|
|
30
|
+
|
|
31
|
+
stripped = raw.to_s.strip
|
|
32
|
+
return parse_range(stripped) if stripped.include?("..")
|
|
33
|
+
|
|
34
|
+
# Bare unlimited token (e.g. "*") means "many" — 0..*.
|
|
35
|
+
return defaults if UNLIMITED_TOKENS.include?(stripped.downcase)
|
|
36
|
+
|
|
37
|
+
{ min: stripped, max: stripped }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Normalise a max-bound token: `*` / `unbounded` → `*`.
|
|
41
|
+
# @param raw [String, Integer, nil]
|
|
42
|
+
# @return [String]
|
|
43
|
+
def normalize_max(raw)
|
|
44
|
+
return DEFAULT_MAX if raw.nil?
|
|
45
|
+
|
|
46
|
+
stripped = raw.to_s.strip
|
|
47
|
+
return DEFAULT_MAX if stripped.empty?
|
|
48
|
+
|
|
49
|
+
UNLIMITED_TOKENS.include?(stripped.downcase) ? "*" : stripped
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Normalise a min-bound token: empty/nil → "0" (UML default).
|
|
53
|
+
# Unlimited tokens also → "0" — a lower bound cannot hold `*`.
|
|
54
|
+
# @param raw [String, Integer, nil]
|
|
55
|
+
# @return [String]
|
|
56
|
+
def normalize_min(raw)
|
|
57
|
+
return DEFAULT_MIN if raw.nil?
|
|
58
|
+
|
|
59
|
+
stripped = raw.to_s.strip
|
|
60
|
+
return DEFAULT_MIN if stripped.empty?
|
|
61
|
+
|
|
62
|
+
UNLIMITED_TOKENS.include?(stripped.downcase) ? DEFAULT_MIN : stripped
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# ---- Internal helpers ----
|
|
66
|
+
|
|
67
|
+
def defaults
|
|
68
|
+
{ min: DEFAULT_MIN, max: DEFAULT_MAX }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def parse_range(stripped)
|
|
72
|
+
min, max = stripped.split("..", 2)
|
|
73
|
+
{ min: normalize_min(min), max: normalize_max(max) }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ea
|
|
4
|
+
module Qea
|
|
5
|
+
module Rules
|
|
6
|
+
# Enumeration detection: an EA object is an enumeration either by
|
|
7
|
+
# its t_object.Object_Type ("Enumeration") or by carrying the
|
|
8
|
+
# `enumeration` stereotype.
|
|
9
|
+
module EnumLiteral
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# @param object_type [String, nil] t_object.Object_Type
|
|
13
|
+
# @param stereotype [String, nil] the object's stereotype
|
|
14
|
+
# @return [Boolean]
|
|
15
|
+
def enumeration?(object_type, stereotype)
|
|
16
|
+
object_type == "Enumeration" ||
|
|
17
|
+
stereotype.to_s.downcase == "enumeration"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ea
|
|
4
|
+
module Qea
|
|
5
|
+
module Rules
|
|
6
|
+
# Generalization traversal rules. EA's Generalization connector
|
|
7
|
+
# points from the specific (child) to the general (parent):
|
|
8
|
+
# Start_Object_ID is the child, End_Object_ID is the parent.
|
|
9
|
+
module Generalization
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# The generalization connector whose child (start) is the given
|
|
13
|
+
# object — i.e. the object's direct parent link.
|
|
14
|
+
# @param object_id [Integer, nil] child Object_ID
|
|
15
|
+
# @param connectors [Array<Ea::Qea::Models::EaConnector>]
|
|
16
|
+
# @return [Ea::Qea::Models::EaConnector, nil]
|
|
17
|
+
def connector_for(object_id, connectors)
|
|
18
|
+
return nil if object_id.nil?
|
|
19
|
+
|
|
20
|
+
connectors.find do |c|
|
|
21
|
+
c.generalization? && c.start_object_id == object_id
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# All generalization connectors originating at the given child.
|
|
26
|
+
# @param object_id [Integer, nil]
|
|
27
|
+
# @param connectors [Array<Ea::Qea::Models::EaConnector>]
|
|
28
|
+
# @return [Array<Ea::Qea::Models::EaConnector>]
|
|
29
|
+
def connectors_from(object_id, connectors)
|
|
30
|
+
return [] if object_id.nil?
|
|
31
|
+
|
|
32
|
+
connectors.select do |c|
|
|
33
|
+
c.generalization? && c.start_object_id == object_id
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ea
|
|
4
|
+
module Qea
|
|
5
|
+
module Rules
|
|
6
|
+
# Canonical EA scope → visibility token mapping.
|
|
7
|
+
#
|
|
8
|
+
# QEA stores scope as text ("Public", "Private", "Protected",
|
|
9
|
+
# "Package") in t_attribute.Scope / t_operation.Scope /
|
|
10
|
+
# t_object.Scope. Matching is case-insensitive; unrecognised or
|
|
11
|
+
# blank values default to "public".
|
|
12
|
+
module Visibility
|
|
13
|
+
TOKENS = %w[public private protected package].freeze
|
|
14
|
+
DEFAULT = "public"
|
|
15
|
+
|
|
16
|
+
# Extension-property wire form: EA's own XMI exports carry the
|
|
17
|
+
# capitalized form ("Public") in <properties scope="...">.
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
# @param scope [String, Symbol, nil] EA scope text
|
|
21
|
+
# @return [String] the canonical lowercase token, "public" default
|
|
22
|
+
def canonical(scope)
|
|
23
|
+
token = scope.to_s.strip.downcase
|
|
24
|
+
TOKENS.include?(token) ? token : DEFAULT
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param scope [String, Symbol, nil] EA scope text
|
|
28
|
+
# @return [String] capitalized wire form, "Public" default
|
|
29
|
+
def extension_scope(scope)
|
|
30
|
+
canonical(scope).capitalize
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/ea/qea/rules.rb
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ea
|
|
4
|
+
module Qea
|
|
5
|
+
# Canonical semantic rules shared by every QEA walker.
|
|
6
|
+
#
|
|
7
|
+
# The factory (→ Lutaml::Uml), the Sources adapters (→ Ea::Model)
|
|
8
|
+
# and the QEA→XMI exporter each re-implemented the same EA-domain
|
|
9
|
+
# mappings — visibility tokens, cardinality bounds, enumeration
|
|
10
|
+
# detection — with drift between them (e.g. two Sources builders
|
|
11
|
+
# silently mapped "Package" scope to public). Ea::Qea::Rules is the
|
|
12
|
+
# single source for the canonical form; pipeline-specific wire
|
|
13
|
+
# policies (the XMI exporter omitting the "public" default, for
|
|
14
|
+
# example) layer on top in their own modules.
|
|
15
|
+
module Rules
|
|
16
|
+
autoload :Visibility, "ea/qea/rules/visibility"
|
|
17
|
+
autoload :Cardinality, "ea/qea/rules/cardinality"
|
|
18
|
+
autoload :EnumLiteral, "ea/qea/rules/enum_literal"
|
|
19
|
+
autoload :Generalization, "ea/qea/rules/generalization"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -46,6 +46,10 @@ module Ea
|
|
|
46
46
|
attribute :collection_name, :string
|
|
47
47
|
attribute :description, :string
|
|
48
48
|
attribute :columns, ColumnDefinition, collection: true
|
|
49
|
+
# Blob columns (e.g. t_image.Image) are excluded from the load
|
|
50
|
+
# when the loader runs in blob-free mode; declared per table so
|
|
51
|
+
# the loader knows what to drop.
|
|
52
|
+
attribute :blob_columns, :string, collection: true
|
|
49
53
|
|
|
50
54
|
yaml do
|
|
51
55
|
map "table_name", to: :table_name
|
|
@@ -54,6 +58,7 @@ module Ea
|
|
|
54
58
|
map "collection_name", to: :collection_name
|
|
55
59
|
map "description", to: :description
|
|
56
60
|
map "columns", to: :columns
|
|
61
|
+
map "blob_columns", to: :blob_columns
|
|
57
62
|
end
|
|
58
63
|
|
|
59
64
|
# Get column definition by name
|
|
@@ -93,6 +98,10 @@ module Ea
|
|
|
93
98
|
attribute :boolean_fields, :string, collection: true
|
|
94
99
|
attribute :null_handling, NullHandling
|
|
95
100
|
attribute :tables, TableDefinition, collection: true
|
|
101
|
+
# Runtime toggle (not file-backed): when false, tables declaring
|
|
102
|
+
# blob_columns are excluded from enabled_tables — the memory win
|
|
103
|
+
# for consumers that never read embedded images.
|
|
104
|
+
attribute :include_blobs, :boolean, default: -> { true }
|
|
96
105
|
|
|
97
106
|
yaml do
|
|
98
107
|
map "version", to: :version
|
|
@@ -131,11 +140,16 @@ module Ea
|
|
|
131
140
|
end
|
|
132
141
|
end
|
|
133
142
|
|
|
134
|
-
# Get list of enabled tables
|
|
143
|
+
# Get list of enabled tables. In blob-free mode tables carrying
|
|
144
|
+
# declared blob columns are dropped entirely (their content
|
|
145
|
+
# cannot be partially loaded into the typed models).
|
|
135
146
|
#
|
|
136
147
|
# @return [Array<TableDefinition>] Array of enabled table definitions
|
|
137
148
|
def enabled_tables
|
|
138
|
-
tables&.select(&:enabled) || []
|
|
149
|
+
all = tables&.select(&:enabled) || []
|
|
150
|
+
return all if include_blobs
|
|
151
|
+
|
|
152
|
+
all.reject { |t| t.blob_columns&.any? }
|
|
139
153
|
end
|
|
140
154
|
|
|
141
155
|
# Get table configuration by table name
|
|
@@ -127,7 +127,7 @@ module Ea
|
|
|
127
127
|
# @param table_name [String] Table name to load
|
|
128
128
|
# @return [Array] Array of model instances
|
|
129
129
|
# @raise [ArgumentError] if table not configured or not enabled
|
|
130
|
-
def load_table(table_name)
|
|
130
|
+
def load_table(table_name)
|
|
131
131
|
table_def = @config.table_config_for(table_name)
|
|
132
132
|
unless table_def
|
|
133
133
|
raise ArgumentError,
|
|
@@ -166,7 +166,7 @@ module Ea
|
|
|
166
166
|
# @param db [SQLite3::Database] Database connection
|
|
167
167
|
# @param table_name [String] Table name
|
|
168
168
|
# @return [Array] Array of model instances
|
|
169
|
-
def load_table_records(db, table_name)
|
|
169
|
+
def load_table_records(db, table_name)
|
|
170
170
|
model_class = MODEL_CLASSES[table_name]
|
|
171
171
|
raise ArgumentError, "No model class for table #{table_name}" unless model_class
|
|
172
172
|
|
|
@@ -19,7 +19,7 @@ module Ea
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def validate_start_object(connector)
|
|
22
|
+
def validate_start_object(connector)
|
|
23
23
|
return if reference_exists?("t_object", "ea_object_id",
|
|
24
24
|
connector.start_object_id)
|
|
25
25
|
|
|
@@ -34,7 +34,7 @@ module Ea
|
|
|
34
34
|
)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
def validate_end_object(connector)
|
|
37
|
+
def validate_end_object(connector)
|
|
38
38
|
return if reference_exists?("t_object", "ea_object_id",
|
|
39
39
|
connector.end_object_id)
|
|
40
40
|
|
|
@@ -12,7 +12,7 @@ module Ea
|
|
|
12
12
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
|
-
def validate_parent_object_references
|
|
15
|
+
def validate_parent_object_references
|
|
16
16
|
attributes.each do |attr|
|
|
17
17
|
next if reference_exists?("t_object", "ea_object_id",
|
|
18
18
|
attr.ea_object_id)
|
|
@@ -42,7 +42,7 @@ module Ea
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def validate_type_references
|
|
45
|
+
def validate_type_references
|
|
46
46
|
attributes.each do |attr|
|
|
47
47
|
next unless attr.classifier && !attr.classifier.empty?
|
|
48
48
|
|
|
@@ -79,7 +79,7 @@ module Ea
|
|
|
79
79
|
# @param id_column [String] ID column name in the reference table
|
|
80
80
|
# @param category [Symbol] Validation category
|
|
81
81
|
# @return [Boolean] True if reference exists, false otherwise
|
|
82
|
-
def check_reference_exists(
|
|
82
|
+
def check_reference_exists(
|
|
83
83
|
entity_id:,
|
|
84
84
|
entity_name:,
|
|
85
85
|
entity_type:,
|
|
@@ -219,7 +219,7 @@ module Ea
|
|
|
219
219
|
# @param package_id [Integer] Package ID to resolve
|
|
220
220
|
# @return [String] Qualified path like
|
|
221
221
|
# "Root::ModelA::PackageB (package_id: 123)"
|
|
222
|
-
def resolve_package_path(package_id)
|
|
222
|
+
def resolve_package_path(package_id)
|
|
223
223
|
return "Root" if package_id.nil? || package_id.zero?
|
|
224
224
|
|
|
225
225
|
path_parts = []
|
|
@@ -257,7 +257,7 @@ module Ea
|
|
|
257
257
|
# @param object_name [String, nil] Object name if already known
|
|
258
258
|
# @return [String] Qualified name like "Package::ClassName
|
|
259
259
|
# (object_id: 456)"
|
|
260
|
-
def resolve_class_path(object_id, object_name = nil)
|
|
260
|
+
def resolve_class_path(object_id, object_name = nil)
|
|
261
261
|
return "Unknown (object_id: #{object_id})" if object_id.nil?
|
|
262
262
|
|
|
263
263
|
# Get object from collection directly
|
|
@@ -13,7 +13,7 @@ module Ea
|
|
|
13
13
|
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
def validate_package_references
|
|
16
|
+
def validate_package_references
|
|
17
17
|
objects.each do |obj|
|
|
18
18
|
next unless obj.package_id
|
|
19
19
|
|
|
@@ -33,7 +33,7 @@ module Ea
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def validate_duplicate_names
|
|
36
|
+
def validate_duplicate_names
|
|
37
37
|
objects_by_package = objects.group_by(&:package_id)
|
|
38
38
|
|
|
39
39
|
objects_by_package.each do |package_id, package_objects|
|
|
@@ -64,7 +64,7 @@ module Ea
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def validate_generalization_parents
|
|
67
|
+
def validate_generalization_parents
|
|
68
68
|
connectors.select(&:generalization?).each do |gen|
|
|
69
69
|
parent_id = gen.end_object_id
|
|
70
70
|
|
|
@@ -12,7 +12,7 @@ module Ea
|
|
|
12
12
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
|
-
def detect_circular_packages
|
|
15
|
+
def detect_circular_packages
|
|
16
16
|
packages.each do |package|
|
|
17
17
|
next if package.root?
|
|
18
18
|
|
|
@@ -42,7 +42,7 @@ module Ea
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def detect_circular_generalizations
|
|
45
|
+
def detect_circular_generalizations
|
|
46
46
|
# Build generalization graph
|
|
47
47
|
generalizations = connectors.select(&:generalization?)
|
|
48
48
|
|
|
@@ -80,7 +80,7 @@ module Ea
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
def format_inheritance_path(visited_ids, circular_id)
|
|
83
|
+
def format_inheritance_path(visited_ids, circular_id)
|
|
84
84
|
path = visited_ids.map do |id|
|
|
85
85
|
obj = objects.find { |o| o.ea_object_id == id }
|
|
86
86
|
obj&.name || id.to_s
|
|
@@ -14,7 +14,7 @@ module Ea
|
|
|
14
14
|
|
|
15
15
|
private
|
|
16
16
|
|
|
17
|
-
def find_orphaned_objects
|
|
17
|
+
def find_orphaned_objects
|
|
18
18
|
objects.each do |obj|
|
|
19
19
|
next unless obj.package_id
|
|
20
20
|
next if package_exists?(obj.package_id)
|
|
@@ -32,7 +32,7 @@ module Ea
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def find_orphaned_attributes
|
|
35
|
+
def find_orphaned_attributes
|
|
36
36
|
attributes.each do |attr|
|
|
37
37
|
next if object_exists?(attr.ea_object_id)
|
|
38
38
|
|
|
@@ -49,7 +49,7 @@ module Ea
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def find_orphaned_operations
|
|
52
|
+
def find_orphaned_operations
|
|
53
53
|
operations.each do |op|
|
|
54
54
|
next if object_exists?(op.ea_object_id)
|
|
55
55
|
|
|
@@ -66,7 +66,7 @@ module Ea
|
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
def find_unreferenced_objects
|
|
69
|
+
def find_unreferenced_objects
|
|
70
70
|
# Find objects that are not referenced by any connector,
|
|
71
71
|
# attribute, or diagram
|
|
72
72
|
object_ids = objects.to_set(&:ea_object_id)
|
|
@@ -13,7 +13,7 @@ module Ea
|
|
|
13
13
|
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
def validate_all_package_references
|
|
16
|
+
def validate_all_package_references
|
|
17
17
|
# Check all parent_id references in packages
|
|
18
18
|
packages.each do |pkg|
|
|
19
19
|
next if pkg.root?
|
|
@@ -33,7 +33,7 @@ module Ea
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def validate_all_object_references
|
|
36
|
+
def validate_all_object_references
|
|
37
37
|
# Check all package_id references in objects
|
|
38
38
|
objects.each do |obj|
|
|
39
39
|
next unless obj.package_id
|
|
@@ -68,7 +68,7 @@ module Ea
|
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
def validate_all_connector_references
|
|
71
|
+
def validate_all_connector_references
|
|
72
72
|
# Check all object references in connectors
|
|
73
73
|
connectors.each do |conn|
|
|
74
74
|
unless object_exists?(conn.start_object_id)
|
|
@@ -13,7 +13,7 @@ module Ea
|
|
|
13
13
|
|
|
14
14
|
private
|
|
15
15
|
|
|
16
|
-
def validate_package_references
|
|
16
|
+
def validate_package_references
|
|
17
17
|
diagrams.each do |diagram|
|
|
18
18
|
next unless diagram.package_id
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ module Ea
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def validate_diagram_objects
|
|
34
|
+
def validate_diagram_objects
|
|
35
35
|
diagram_objects.each do |diag_obj|
|
|
36
36
|
next if object_exists?(diag_obj.ea_object_id)
|
|
37
37
|
|
|
@@ -51,7 +51,7 @@ module Ea
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def validate_diagram_links
|
|
54
|
+
def validate_diagram_links
|
|
55
55
|
diagram_links.each do |diag_link|
|
|
56
56
|
next if connector_exists?(diag_link.connectorid)
|
|
57
57
|
|
|
@@ -73,7 +73,7 @@ module Ea
|
|
|
73
73
|
# Builds the messages array
|
|
74
74
|
#
|
|
75
75
|
# @return [Array<Hash>]
|
|
76
|
-
def build_messages
|
|
76
|
+
def build_messages
|
|
77
77
|
result.messages.map do |message|
|
|
78
78
|
{
|
|
79
79
|
severity: message.severity,
|
|
@@ -114,7 +114,7 @@ module Ea
|
|
|
114
114
|
#
|
|
115
115
|
# @param messages [Array<ValidationMessage>]
|
|
116
116
|
# @return [Hash]
|
|
117
|
-
def format_severity_group(messages)
|
|
117
|
+
def format_severity_group(messages)
|
|
118
118
|
{
|
|
119
119
|
count: messages.size,
|
|
120
120
|
by_category: messages
|
|
@@ -37,7 +37,7 @@ module Ea
|
|
|
37
37
|
# Formats the validation result as text
|
|
38
38
|
#
|
|
39
39
|
# @return [String] Formatted text output
|
|
40
|
-
def format
|
|
40
|
+
def format
|
|
41
41
|
lines = []
|
|
42
42
|
lines << header
|
|
43
43
|
lines << ""
|
|
@@ -84,7 +84,7 @@ module Ea
|
|
|
84
84
|
# Formats the summary
|
|
85
85
|
#
|
|
86
86
|
# @return [String]
|
|
87
|
-
def summary
|
|
87
|
+
def summary
|
|
88
88
|
status = if result.valid?
|
|
89
89
|
colorize("✓ VALID", :green, bold: true)
|
|
90
90
|
elsif result.has_errors?
|
|
@@ -122,7 +122,7 @@ module Ea
|
|
|
122
122
|
#
|
|
123
123
|
# @param messages [Array<ValidationMessage>] Messages to format
|
|
124
124
|
# @return [String]
|
|
125
|
-
def format_messages(messages)
|
|
125
|
+
def format_messages(messages)
|
|
126
126
|
lines = []
|
|
127
127
|
messages_to_show = apply_limit(messages)
|
|
128
128
|
|
|
@@ -211,7 +211,7 @@ module Ea
|
|
|
211
211
|
# @param color [Symbol] Color name
|
|
212
212
|
# @param bold [Boolean] Make text bold
|
|
213
213
|
# @return [String]
|
|
214
|
-
def colorize(text, color = nil, bold: false)
|
|
214
|
+
def colorize(text, color = nil, bold: false)
|
|
215
215
|
return text unless options[:color]
|
|
216
216
|
|
|
217
217
|
codes = []
|