ea 0.6.158 → 0.6.160

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b53a1999c9d2b7778aba533c893bc69687c6c5d2d92d44a4e9d34d3cf679bba3
4
- data.tar.gz: 3194efbc3a2eae9323871b0b1737dfbd0a9d8441dbef581bc3aca406999de804
3
+ metadata.gz: 49b4c14803c18a073f0865fd62b669e4fa406fc4ce2a834e93ee336f116cdb07
4
+ data.tar.gz: 7cdde2b925a364a8a2d751178799d20e7bef4b2b41319bd1ad891dc8a481760e
5
5
  SHA512:
6
- metadata.gz: 9b746cad739bab8efce585c04319206c8de61f944eba28180b2c69a077bccec407d63921583949a16875a71c566a5edd82786e2397a41d9ad3f7f9a363f4678b
7
- data.tar.gz: 3f330638750065f94934404f6a33eb7a60ce1f5988e734a1711d78eaca439fbfe1dcb4edcc86a21510fc0980301a51f46c37eab888f8ef4c3d7985a47e0b559c
6
+ metadata.gz: 9a3fc9dc18856ea421b83ab03044651e48bc51f71bbcc580f25c631a8a022e1faee6712da9ff80cd606461bc58d250c7cbb763b0a44b6efb2aebf8c9277b04bf
7
+ data.tar.gz: 99252d51bca9cfe0856828a07e3df362bf7019de874a431631a39e36f4a0d275ad64d8a555a348b31a35c11de713ace45f83efa57075c69d210fde69705284c3
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2026-11-25 03:27:39 UTC using RuboCop version 1.92.3.
2
+ # `rubocop --auto-gen-config --no-auto-gen-timestamp`
3
+ # using RuboCop version 1.92.3.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -158,43 +158,43 @@ Lint/Void:
158
158
  - 'lib/ea/cli/output.rb'
159
159
  - 'lib/ea/svg/ea_emitter/marker.rb'
160
160
 
161
- # Offense count: 302
161
+ # Offense count: 282
162
162
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
163
163
  Metrics/AbcSize:
164
164
  Max: 175
165
165
 
166
- # Offense count: 491
166
+ # Offense count: 6
167
167
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
168
168
  # AllowedMethods: refine
169
169
  Metrics/BlockLength:
170
- Max: 708
170
+ Max: 38
171
171
 
172
- # Offense count: 49
172
+ # Offense count: 50
173
173
  # Configuration parameters: CountComments, CountAsOne.
174
174
  Metrics/ClassLength:
175
175
  Max: 897
176
176
 
177
- # Offense count: 146
177
+ # Offense count: 142
178
178
  # Configuration parameters: AllowedMethods, AllowedPatterns.
179
179
  Metrics/CyclomaticComplexity:
180
180
  Max: 81
181
181
 
182
- # Offense count: 358
182
+ # Offense count: 326
183
183
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
184
184
  Metrics/MethodLength:
185
185
  Max: 153
186
186
 
187
- # Offense count: 8
187
+ # Offense count: 7
188
188
  # Configuration parameters: CountComments, CountAsOne.
189
189
  Metrics/ModuleLength:
190
190
  Max: 931
191
191
 
192
- # Offense count: 67
192
+ # Offense count: 63
193
193
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
194
194
  Metrics/ParameterLists:
195
195
  Max: 33
196
196
 
197
- # Offense count: 109
197
+ # Offense count: 106
198
198
  # Configuration parameters: AllowedMethods, AllowedPatterns.
199
199
  Metrics/PerceivedComplexity:
200
200
  Max: 83
@@ -223,13 +223,7 @@ Naming/MethodName:
223
223
  Exclude:
224
224
  - 'spec/ea/svg/ea_emitter/compartment_spec.rb'
225
225
 
226
- # Offense count: 80
227
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
228
- # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
229
- Naming/MethodParameterName:
230
- Enabled: false
231
-
232
- # Offense count: 17
226
+ # Offense count: 4
233
227
  # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
234
228
  # NamePrefix: is_, has_, have_, does_
235
229
  # ForbiddenPrefixes: is_, has_, have_, does_
@@ -238,13 +232,6 @@ Naming/MethodParameterName:
238
232
  Naming/PredicatePrefix:
239
233
  Exclude:
240
234
  - 'spec/**/*'
241
- - 'lib/ea/qea/models/ea_datatype.rb'
242
- - 'lib/ea/qea/models/ea_document.rb'
243
- - 'lib/ea/qea/models/ea_script.rb'
244
- - 'lib/ea/qea/validation/validation_result.rb'
245
- - 'lib/ea/qea/verification/comparison_result.rb'
246
- - 'lib/ea/svg/ea_emitter/element/package_shape_renderer.rb'
247
- - 'lib/ea/svg/ea_emitter/elements.rb'
248
235
  - 'lib/ea/xmi/liquid_drops/data_type_drop.rb'
249
236
  - 'lib/ea/xmi/liquid_drops/generalization_attribute_drop.rb'
250
237
  - 'lib/ea/xmi/liquid_drops/generalization_drop.rb'
@@ -258,27 +245,6 @@ Naming/VariableNumber:
258
245
  Exclude:
259
246
  - 'spec/ea/svg/ea_emitter/color_resolver_spec.rb'
260
247
 
261
- # Offense count: 24
262
- # This cop supports unsafe autocorrection (--autocorrect-all).
263
- Style/CommentedKeyword:
264
- Exclude:
265
- - 'lib/ea/xmi/parser.rb'
266
-
267
- # Offense count: 84
268
- # Configuration parameters: AllowedConstants.
269
- Style/Documentation:
270
- Enabled: false
271
-
272
- # Offense count: 5
273
- # This cop supports unsafe autocorrection (--autocorrect-all).
274
- # Configuration parameters: EnforcedStyle.
275
- # SupportedStyles: allowed_in_returns, forbidden
276
- Style/DoubleNegation:
277
- Exclude:
278
- - 'lib/ea/qea/factory/generalization_builder.rb'
279
- - 'lib/ea/xmi/liquid_drops/connector_drop.rb'
280
- - 'lib/ea/xmi/parser.rb'
281
-
282
248
  # Offense count: 1
283
249
  # This cop supports unsafe autocorrection (--autocorrect-all).
284
250
  # Configuration parameters: EnforcedStyle.
@@ -415,7 +381,7 @@ Style/StructInheritance:
415
381
  Exclude:
416
382
  - 'lib/ea/svg/ea_emitter/render_context.rb'
417
383
 
418
- # Offense count: 45
384
+ # Offense count: 41
419
385
  # This cop supports safe autocorrection (--autocorrect).
420
386
  # Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
421
387
  # URISchemes: http, https
@@ -35,6 +35,49 @@ module Ea
35
35
  # @return [void]
36
36
  attr_writer :connection
37
37
 
38
+ # The DatabaseConnection the loader used. Kept (not connected)
39
+ # so blob fetches can reopen the QEA file on demand; nil for
40
+ # hand-constructed Databases.
41
+ attr_accessor :blob_connection
42
+
43
+ # Fetch a blob column value on demand by reopening the QEA file
44
+ # read-only for the duration of the fetch. The container's load
45
+ # connection is closed after load (an open handle locks the file
46
+ # on Windows), so each fetch opens, reads, and closes per call —
47
+ # fetched values are returned, never stored, keeping the frozen
48
+ # container contract intact.
49
+ #
50
+ # @param table_name [String] EA table carrying the blob
51
+ # @param pk_column [String] primary-key column of that table
52
+ # @param column [String] the blob column to read
53
+ # @param id [Object] primary-key value of the row
54
+ # @return [String, nil] the blob value, or nil when no connection
55
+ # route exists, the row is absent, or the fetch fails
56
+ def blob_value(table_name, pk_column, column, id)
57
+ conn = blob_connection
58
+ return nil unless conn
59
+
60
+ conn.with_connection do |db|
61
+ row = db.get_first_row(
62
+ "SELECT #{quote_ident(column)} FROM #{quote_ident(table_name)} " \
63
+ "WHERE #{quote_ident(pk_column)} = ?", [id]
64
+ )
65
+ row && row[column]
66
+ end
67
+ rescue StandardError
68
+ # Best-effort accessor: missing/locked file, absent row or table
69
+ # all mean "blob unavailable"; callers already handle nil.
70
+ nil
71
+ end
72
+
73
+ # Fetch a t_image blob by its ImageID.
74
+ #
75
+ # @param image_id [Integer] t_image.ImageID
76
+ # @return [String, nil] the Image blob, or nil when unavailable
77
+ def image_blob(image_id)
78
+ blob_value("t_image", "ImageID", "Image", image_id)
79
+ end
80
+
38
81
  # Close the database connection if open
39
82
  # @return [void]
40
83
  def close_connection
@@ -288,6 +331,12 @@ module Ea
288
331
 
289
332
  private
290
333
 
334
+ # @param name [String] SQL identifier from the EA schema
335
+ # @return [String] double-quoted, escaped identifier
336
+ def quote_ident(name)
337
+ %("#{name.to_s.gsub('"', '""')}")
338
+ end
339
+
291
340
  def ensure_lookup_indexes
292
341
  return if @lookup_indexes_built
293
342
 
@@ -54,17 +54,23 @@ module Ea
54
54
  end
55
55
 
56
56
  def to_general_attribute(attr)
57
- Lutaml::Uml::GeneralAttribute.new(
58
- **base_attr_hash(attr),
59
- is_derived: !!attr.is_derived,
60
- has_association: !!attr.association
57
+ Ea::Rules::GeneralAttributeMapping.build(
58
+ id: attr.id,
59
+ name: attr.name,
60
+ type: attr.type,
61
+ xmi_id: attr.xmi_id,
62
+ cardinality: attr.cardinality,
63
+ definition: attr.definition,
64
+ association: attr.association,
65
+ type_ns: attr.type_ns,
66
+ is_derived: attr.is_derived
61
67
  )
62
68
  end
63
69
 
64
70
  def to_top_element_attribute(attr)
65
71
  Lutaml::Uml::TopElementAttribute.new(
66
72
  **base_attr_hash(attr),
67
- is_derived: !!attr.is_derived
73
+ is_derived: attr.is_derived == true
68
74
  )
69
75
  end
70
76
 
@@ -120,16 +126,6 @@ module Ea
120
126
  end
121
127
  end
122
128
 
123
- def resolve_name_ns(type_ns, upper_klass)
124
- ns = case type_ns
125
- when "core", "gml"
126
- upper_klass
127
- else
128
- type_ns
129
- end
130
- ns || upper_klass
131
- end
132
-
133
129
  def build_generalization(object_id, current_obj)
134
130
  ea_connector = ea_connector_for(object_id)
135
131
  gen_transformer = GeneralizationTransformer.new(database)
@@ -174,7 +170,9 @@ module Ea
174
170
  upper_klass = generalization.general_upper_klass
175
171
  general_attrs.each do |attr|
176
172
  attr.gen_name = generalization.general_name
177
- attr.name_ns = resolve_name_ns(attr.type_ns, upper_klass)
173
+ attr.name_ns = Ea::Rules::Namespacing.resolve_name_ns(
174
+ attr.type_ns, upper_klass
175
+ )
178
176
  end
179
177
  end
180
178
 
@@ -196,7 +194,9 @@ module Ea
196
194
 
197
195
  generalization.general_attributes.map do |attr|
198
196
  transformed = attr.dup
199
- transformed.name_ns = resolve_name_ns(attr.type_ns, upper_klass)
197
+ transformed.name_ns = Ea::Rules::Namespacing.resolve_name_ns(
198
+ attr.type_ns, upper_klass
199
+ )
200
200
  transformed.gen_name = gen_name
201
201
  transformed.name = "" if transformed.name.nil?
202
202
  transformed
@@ -44,6 +44,13 @@ module Ea
44
44
  !row.nil?
45
45
  end
46
46
 
47
+ # @return [Array<String>] the table's actual column names
48
+ def column_names
49
+ @database
50
+ .execute("PRAGMA table_info(#{@table_name})")
51
+ .map { |row| row["name"] }
52
+ end
53
+
47
54
  # Read all records from the table
48
55
  #
49
56
  # @param limit [Integer, nil] Maximum number of records to return
@@ -66,6 +73,8 @@ module Ea
66
73
  # Stream records row-by-row without materializing the full
67
74
  # result set (halves peak memory on large tables).
68
75
  #
76
+ # @param columns [Array<String>, nil] column subset to select;
77
+ # nil selects every column
69
78
  # @param limit [Integer, nil]
70
79
  # @param offset [Integer, nil]
71
80
  # @yieldparam row [Hash] one database row
@@ -73,8 +82,12 @@ module Ea
73
82
  #
74
83
  # @example
75
84
  # reader.each_row { |row| models << Model.from_db_row(row) }
76
- def each_row(limit: nil, offset: nil, &block)
77
- query, params = build_select_query(limit: limit, offset: offset)
85
+ #
86
+ # @example Metadata-only streaming (skip the heavy blob column)
87
+ # reader.each_row(columns: %w[ImageID Name Type]) { |row| ... }
88
+ def each_row(columns: nil, limit: nil, offset: nil, &block)
89
+ query, params = build_select_query(columns: columns,
90
+ limit: limit, offset: offset)
78
91
  @database.execute(query, params, &block)
79
92
  end
80
93
 
@@ -233,8 +246,8 @@ module Ea
233
246
 
234
247
  private
235
248
 
236
- def build_select_query(limit: nil, offset: nil)
237
- query = +"SELECT * FROM #{@table_name}"
249
+ def build_select_query(columns: nil, limit: nil, offset: nil)
250
+ query = +"SELECT #{select_list(columns)} FROM #{@table_name}"
238
251
  params = []
239
252
  if limit
240
253
  query << " LIMIT ?"
@@ -246,6 +259,15 @@ module Ea
246
259
  end
247
260
  [query, params]
248
261
  end
262
+
263
+ # @param columns [Array<String>, nil] quoted identifier list, or
264
+ # "*" when no subset is requested
265
+ # @return [String] the SELECT list
266
+ def select_list(columns)
267
+ return "*" unless columns
268
+
269
+ columns.map { |name| %("#{name.to_s.gsub('"', '""')}") }.join(", ")
270
+ end
249
271
  end
250
272
  end
251
273
  end
@@ -64,13 +64,13 @@ module Ea
64
64
 
65
65
  # Check if type has length parameter
66
66
  # @return [Boolean]
67
- def has_length?
67
+ def length?
68
68
  size == 1 || !haslength.nil?
69
69
  end
70
70
 
71
71
  # Check if type has precision parameter
72
72
  # @return [Boolean]
73
- def has_precision?
73
+ def precision?
74
74
  size == 2
75
75
  end
76
76
 
@@ -47,13 +47,13 @@ module Ea
47
47
 
48
48
  # Check if document has string content
49
49
  # @return [Boolean]
50
- def has_content?
50
+ def content?
51
51
  !str_content.nil? && !str_content.empty?
52
52
  end
53
53
 
54
54
  # Check if document has binary content
55
55
  # @return [Boolean]
56
- def has_binary_content?
56
+ def binary_content?
57
57
  !bin_content.nil? && !bin_content.empty?
58
58
  end
59
59
  end
@@ -46,13 +46,13 @@ module Ea
46
46
 
47
47
  # Check if script has content
48
48
  # @return [Boolean]
49
- def has_content?
49
+ def content?
50
50
  !script.nil? && !script.empty?
51
51
  end
52
52
 
53
53
  # Check if script has notes
54
54
  # @return [Boolean]
55
- def has_notes?
55
+ def notes?
56
56
  !notes.nil? && !notes.empty?
57
57
  end
58
58
  end
@@ -140,16 +140,14 @@ module Ea
140
140
  end
141
141
  end
142
142
 
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).
143
+ # Get list of enabled tables. In blob-free mode blob-declaring
144
+ # tables stay enabled — their metadata loads normally while the
145
+ # loader excludes the blob columns themselves; blob content then
146
+ # resolves on demand via Database#blob_value.
146
147
  #
147
148
  # @return [Array<TableDefinition>] Array of enabled table definitions
148
149
  def enabled_tables
149
- all = tables&.select(&:enabled) || []
150
- return all if include_blobs
151
-
152
- all.reject { |t| t.blob_columns&.any? }
150
+ tables&.select(&:enabled) || []
153
151
  end
154
152
 
155
153
  # Get table configuration by table name
@@ -106,19 +106,20 @@ module Ea
106
106
  db = @connection.connection
107
107
 
108
108
  database = Database.new(@qea_path, db)
109
+ # Kept for on-demand blob fetches after load (the connection
110
+ # itself closes in ensure; Database reopens per fetch).
111
+ database.blob_connection = @connection
109
112
 
110
113
  @config.enabled_tables.each do |table_def|
111
- table_name = table_def.table_name
112
- collection_name = table_def.collection_name
113
-
114
- records = load_table_records(db, table_name)
115
- database.add_collection(collection_name, records)
114
+ records = load_table_records(db, table_def)
115
+ database.add_collection(table_def.collection_name, records)
116
116
  end
117
117
 
118
118
  database.freeze
119
119
  ensure
120
- # All tables are in memory; nothing reads the connection after
121
- # load, and an open handle locks the file on Windows.
120
+ # All tables are in memory; nothing keeps the handle open, and
121
+ # an open handle locks the file on Windows. Blob fetches go
122
+ # through Database#blob_value, which reopens per call.
122
123
  @connection.close
123
124
  end
124
125
 
@@ -139,7 +140,7 @@ module Ea
139
140
  end
140
141
 
141
142
  @connection.with_connection do |db|
142
- load_table_records(db, table_name)
143
+ load_table_records(db, table_def)
143
144
  end
144
145
  end
145
146
 
@@ -164,20 +165,22 @@ module Ea
164
165
  # Load records for a table
165
166
  #
166
167
  # @param db [SQLite3::Database] Database connection
167
- # @param table_name [String] Table name
168
+ # @param table_def [Configuration::TableDefinition] Table config
168
169
  # @return [Array] Array of model instances
169
- def load_table_records(db, table_name)
170
+ def load_table_records(db, table_def)
171
+ table_name = table_def.table_name
170
172
  model_class = MODEL_CLASSES[table_name]
171
173
  raise ArgumentError, "No model class for table #{table_name}" unless model_class
172
174
 
173
175
  reader = Infrastructure::TableReader.new(db, table_name)
174
176
  return [] unless reader.table_exists?
175
177
 
178
+ columns = load_columns(reader, table_def)
176
179
  total = reader.count
177
180
  records = []
178
181
  index = 0
179
182
 
180
- reader.each_row do |row|
183
+ reader.each_row(columns: columns) do |row|
181
184
  index += 1
182
185
  record = model_class.from_db_row(scrub_row(row))
183
186
  records << record if record
@@ -197,6 +200,23 @@ module Ea
197
200
  records
198
201
  end
199
202
 
203
+ # Column subset for the load. In blob-free mode the declared
204
+ # blob columns are cut from the SELECT — the table's metadata
205
+ # still loads and the blob resolves on demand via
206
+ # Database#blob_value.
207
+ #
208
+ # @param reader [Infrastructure::TableReader]
209
+ # @param table_def [Configuration::TableDefinition]
210
+ # @return [Array<String>, nil] columns to select, nil for all
211
+ def load_columns(reader, table_def)
212
+ return nil if @config.include_blobs
213
+
214
+ blobs = Array(table_def.blob_columns)
215
+ return nil if blobs.empty?
216
+
217
+ reader.column_names - blobs
218
+ end
219
+
200
220
  # Replace invalid byte sequences (e.g. CP1252 bytes stored by
201
221
  # older EA projects) so one bad field no longer drops the whole
202
222
  # row at model-build time.
@@ -44,19 +44,19 @@ module Ea
44
44
  lines << summary
45
45
  lines << ""
46
46
 
47
- if result.has_errors?
47
+ if result.errors?
48
48
  lines << section_header("ERRORS", result.errors.size)
49
49
  lines << format_messages(result.errors)
50
50
  lines << ""
51
51
  end
52
52
 
53
- if result.has_warnings?
53
+ if result.warnings?
54
54
  lines << section_header("WARNINGS", result.warnings.size)
55
55
  lines << format_messages(result.warnings)
56
56
  lines << ""
57
57
  end
58
58
 
59
- if result.has_info? && options[:verbose]
59
+ if result.info? && options[:verbose]
60
60
  lines << section_header("INFO", result.info.size)
61
61
  lines << format_messages(result.info)
62
62
  lines << ""
@@ -87,7 +87,7 @@ module Ea
87
87
  def summary
88
88
  status = if result.valid?
89
89
  colorize("✓ VALID", :green, bold: true)
90
- elsif result.has_errors?
90
+ elsif result.errors?
91
91
  colorize("✗ INVALID", :red, bold: true)
92
92
  else
93
93
  colorize("⚠ WARNINGS", :yellow, bold: true)
@@ -160,7 +160,7 @@ module Ea
160
160
  # @return [Boolean]
161
161
  def valid?(validators: nil)
162
162
  result = validate(validators: validators)
163
- !result.has_errors?
163
+ !result.errors?
164
164
  end
165
165
 
166
166
  # Builds validation context from document and database
@@ -346,20 +346,20 @@ module Ea
346
346
  puts result.summary
347
347
  puts
348
348
 
349
- if result.has_errors?
349
+ if result.errors?
350
350
  puts "ERRORS (#{result.errors.size}):"
351
351
  puts
352
352
  display_messages_by_category(result.errors)
353
353
  end
354
354
 
355
- if result.has_warnings?
355
+ if result.warnings?
356
356
  puts
357
357
  puts "WARNINGS (#{result.warnings.size}):"
358
358
  puts
359
359
  display_messages_by_category(result.warnings)
360
360
  end
361
361
 
362
- if result.has_info? && @options[:verbose]
362
+ if result.info? && @options[:verbose]
363
363
  puts
364
364
  puts "INFO (#{result.info.size}):"
365
365
  puts
@@ -60,21 +60,21 @@ module Ea
60
60
  # Checks if there are any error messages
61
61
  #
62
62
  # @return [Boolean]
63
- def has_errors?
63
+ def errors?
64
64
  @messages.any?(&:error?)
65
65
  end
66
66
 
67
67
  # Checks if there are any warning messages
68
68
  #
69
69
  # @return [Boolean]
70
- def has_warnings?
70
+ def warnings?
71
71
  @messages.any?(&:warning?)
72
72
  end
73
73
 
74
74
  # Checks if there are any info messages
75
75
  #
76
76
  # @return [Boolean]
77
- def has_info?
77
+ def info?
78
78
  @messages.any?(&:info?)
79
79
  end
80
80
 
@@ -82,7 +82,7 @@ module Ea
82
82
  #
83
83
  # @return [Boolean]
84
84
  def valid?
85
- !has_errors?
85
+ !errors?
86
86
  end
87
87
 
88
88
  # Returns all error messages
@@ -198,7 +198,7 @@ module Ea
198
198
  # Check if there are any issues
199
199
  #
200
200
  # @return [Boolean] True if there are issues
201
- def has_issues?
201
+ def issues?
202
202
  !equivalent?
203
203
  end
204
204
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module Rules
5
+ # Shared construction of Lutaml::Uml::GeneralAttribute rows for
6
+ # both the QEA factory and the XMI parser — one place for the
7
+ # field list and the boolean coercions (is_derived normalizes
8
+ # boolean-or-nil, has_association mirrors the presence of an
9
+ # association reference). The definition is taken verbatim: each
10
+ # walker resolves and strips it according to its own source
11
+ # semantics.
12
+ module GeneralAttributeMapping
13
+ module_function
14
+
15
+ # @param fields [Hash] :id, :name, :type, :xmi_id, :cardinality,
16
+ # :definition, :association, :type_ns, :is_derived
17
+ # @return [Lutaml::Uml::GeneralAttribute]
18
+ def build(fields)
19
+ association = fields[:association]
20
+ Lutaml::Uml::GeneralAttribute.new(
21
+ id: fields[:id],
22
+ name: fields[:name],
23
+ type: fields[:type],
24
+ xmi_id: fields[:xmi_id],
25
+ cardinality: fields[:cardinality],
26
+ definition: fields[:definition],
27
+ association: association,
28
+ type_ns: fields[:type_ns],
29
+ is_derived: fields[:is_derived] == true,
30
+ has_association: !association.nil?
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ea
4
+ module Rules
5
+ # EA namespacing rule for attribute type references. Types in the
6
+ # "core" and "gml" namespaces resolve against the classifier's own
7
+ # upper-level package namespace; any other namespace string is
8
+ # kept as-is; a missing namespace falls back to the upper package.
9
+ module Namespacing
10
+ module_function
11
+
12
+ # @param type_ns [String, nil] attribute type namespace
13
+ # @param upper_klass [String, nil] the classifier's upper-level
14
+ # package namespace
15
+ # @return [String, nil] resolved namespace
16
+ def resolve_name_ns(type_ns, upper_klass)
17
+ ns = case type_ns
18
+ when "core", "gml"
19
+ upper_klass
20
+ else
21
+ type_ns
22
+ end
23
+ ns || upper_klass
24
+ end
25
+ end
26
+ end
27
+ end