Class: MendixBridge::VisualEntityPlan
- Inherits:
-
Object
- Object
- MendixBridge::VisualEntityPlan
- Defined in:
- lib/mendix_bridge/visual_entity_plan.rb
Constant Summary collapse
- TYPES =
{ "autonumber" => "autonumber", "binary" => "binary", "boolean" => "boolean", "datetime" => "datetime", "decimal" => "decimal", "hash_string" => "hash_string", "integer" => "integer", "long" => "long", "string" => "string" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(inventory:, payload:) ⇒ VisualEntityPlan
constructor
A new instance of VisualEntityPlan.
Constructor Details
#initialize(inventory:, payload:) ⇒ VisualEntityPlan
Returns a new instance of VisualEntityPlan.
21 22 23 24 |
# File 'lib/mendix_bridge/visual_entity_plan.rb', line 21 def initialize(inventory:, payload:) @inventory = inventory @payload = payload end |
Class Method Details
.build(inventory:, payload:) ⇒ Object
17 18 19 |
# File 'lib/mendix_bridge/visual_entity_plan.rb', line 17 def self.build(inventory:, payload:) new(inventory:, payload:).build end |
Instance Method Details
#build ⇒ Object
26 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 58 59 60 61 62 63 64 65 66 |
# File 'lib/mendix_bridge/visual_entity_plan.rb', line 26 def build qn = string!("qn") app_module, entity_name = qualified_name!(qn) attributes = array!("attributes").map { |attribute| build_attribute(attribute) } duplicate = attributes.group_by(&:name).find { |_name, values| values.length > 1 } raise ArgumentError, "duplicate attribute: #{duplicate.first}" if duplicate entity = Model::Entity.new( name: entity_name, persistable: boolean!("persistable"), attributes:, associations: [], access_rules: existing_access_rules(qn) ) model = Model::App.new( name: "Visual editor", version: nil, modules: [ Model::AppModule.new( name: app_module, entities: [entity], enumerations: [], microflows: [], pages: [], module_roles: [] ) ], user_roles: [], project_security: nil, navigation_profiles: [] ) operation = ChangePlanner.plan(model, @inventory).operations.find do |candidate| candidate.type == "entity" && candidate.name == qn end { "ok" => !operation.action.eql?("blocked"), "blocked" => operation.action.eql?("blocked"), "operation" => stringify(operation.to_h), "mdl" => MDLGenerator.new(model).generate } end |