Class: MendixBridge::ChangePlanner

Inherits:
Object
  • Object
show all
Defined in:
lib/mendix_bridge/change_planner.rb

Defined Under Namespace

Classes: Operation, Result

Constant Summary collapse

TYPE_NAMES =
MDLGenerator::TYPE_NAMES

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, inventory) ⇒ ChangePlanner

Returns a new instance of ChangePlanner.



37
38
39
40
# File 'lib/mendix_bridge/change_planner.rb', line 37

def initialize(model, inventory)
  @model = model
  @inventory = inventory
end

Class Method Details

.plan(model, inventory) ⇒ Object



33
34
35
# File 'lib/mendix_bridge/change_planner.rb', line 33

def self.plan(model, inventory)
  new(model, inventory).plan
end

Instance Method Details

#planObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mendix_bridge/change_planner.rb', line 42

def plan
  operations = @model.modules.flat_map { |app_module| plan_module(app_module) }
  operations.concat(@model.user_roles.map { |role| plan_user_role(role) })
  operations << plan_project_security(@model.project_security) if @model.project_security
  operations.concat(
    @model.navigation_profiles.map { |profile| plan_navigation(profile) }
  )
  declared = operations.map { |operation| "#{operation.type}:#{operation.name}" }.to_set
  managed_types = %w[
    entity association enumeration microflow page
    modulerole userrole projectsecurity
    navprofile
  ]
  preserved = @inventory.elements.count do |element|
    managed_types.include?(element.type) &&
      !declared.include?("#{element.type}:#{element.qualified_name}")
  end

  Result.new(operations:, preserved_undeclared: preserved)
end