Class: Mxrb::Compiler::JavaProxyGenerator

Inherits:
Object
  • Object
show all
Includes:
ModelValues
Defined in:
lib/mxrb/compiler/java_proxy_generator.rb

Overview

Materializes the subset of Studio Pro generated Java proxies required by project sources. Proxy syntax is intentionally kept together so generated Java remains auditable. rubocop:disable Metrics/AbcSize, Metrics/ClassLength, Metrics/CyclomaticComplexity rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity

Constant Summary collapse

TYPE_MAP =
{
  'DomainModels$StringAttributeType' => 'java.lang.String',
  'DomainModels$HashStringAttributeType' => 'java.lang.String',
  'DomainModels$HashedStringAttributeType' => 'java.lang.String',
  'DomainModels$IntegerAttributeType' => 'java.lang.Integer',
  'DomainModels$LongAttributeType' => 'java.lang.Long',
  'DomainModels$AutoNumberAttributeType' => 'java.lang.Long',
  'DomainModels$DecimalAttributeType' => 'java.math.BigDecimal',
  'DomainModels$BooleanAttributeType' => 'java.lang.Boolean',
  'DomainModels$DateTimeAttributeType' => 'java.util.Date',
  'DomainModels$BinaryAttributeType' => 'byte[]'
}.freeze
CONSTANT_TYPE_MAP =
{
  'DataTypes$StringType' => 'java.lang.String', 'DataTypes$IntegerType' => 'java.lang.Long',
  'DataTypes$DecimalType' => 'java.math.BigDecimal', 'DataTypes$BooleanType' => 'java.lang.Boolean',
  'DataTypes$DateTimeType' => 'java.util.Date'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(mpr_path, project_root: File.dirname(File.expand_path(mpr_path))) ⇒ JavaProxyGenerator

Returns a new instance of JavaProxyGenerator.



33
34
35
36
37
38
39
# File 'lib/mxrb/compiler/java_proxy_generator.rb', line 33

def initialize(mpr_path, project_root: File.dirname(File.expand_path(mpr_path)))
  @source = SourceModel.read(mpr_path)
  @project_root = File.expand_path(project_root)
  @system_seed = SystemModelSeed.for(@source.version)
  @domain_units = @source.units_of('DomainModels$DomainModel') + [system_domain_unit]
  @entities = entity_index
end

Instance Method Details

#generateObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/mxrb/compiler/java_proxy_generator.rb', line 41

def generate
  generated =  ? 1 : 0
  source_text = java_source_text
  generated += microflow_modules.count do |mod|
    microflows_referenced?(source_text, mod) && write_microflows(mod, source_text)
  end
  source_text = java_source_text if generated.positive?
  requested = requested_entities(source_text)
  entity_count = requested.count { |name| write_entity(name) }
  generated += entity_count
  source_text = java_source_text if entity_count.positive?
  generated += enumeration_units.count { |unit| referenced?(source_text, proxy_name(unit)) && write_enum(unit) }
  generated += constant_modules.count { |mod| constants_referenced?(source_text, mod) && write_constants(mod) }
  generated
end