class PIM::CommunicationPlan

Attributes

actions[RW]
label[RW]
name[RW]

Public Class Methods

new(name, label = nil) click to toggle source
# File pim.rb, line 9525
def initialize name, label = nil
  @name = name
  @label = label
  @actions = {}
end

Public Instance Methods

as_json() click to toggle source
# File pim.rb, line 9531
def as_json
  # TODO: Add name, label and list of aggregated allowed channel types
  json = {
    :name => @name,
    :label => @label
  }
  json[:planCategory] = @plan_category.to_s if @plan_category
  json[:publicationCategory] = @publication_category.to_s if @publication_category
  json[:unpublicationCategory] = @unpublication_category.to_s if @unpublication_category
  json[:subscriptionCategory] = @subscription_category.to_s if @subscription_category
  json[:supportsSubDestinations] = @supports_sub_destinations.to_s if @supports_sub_destinations
  json[:autoDeleteSubDestinationPublications] = @auto_delete_sub_destination_publications.to_s if @auto_delete_sub_destination_publications
  json[:publicationChunkSize] = @publication_chunk_size if @publication_chunk_size
  json[:unpublicationChunkSize] = @unpublication_chunk_size if @unpublication_chunk_size
  if !@actions.empty?
    json_actions = {}
    @actions.each_pair do |action_type, actions|
      json_actions[action_type] = actions.keys.sort.uniq
    end
    json[:planActions] = json_actions
  end
  json
end
auto_delete_sub_destination_publications(delete = nil) click to toggle source
# File pim.rb, line 9580
def auto_delete_sub_destination_publications delete = nil
  @auto_delete_sub_destination_publications = delete unless delete.nil?
  @auto_delete_sub_destination_publications
end
execute_plan_action(action_type, action_creator, action_tags, action_date, channel, organization, data) click to toggle source
# File pim.rb, line 9912
def execute_plan_action action_type, action_creator, action_tags, action_date, channel, organization, data
  actions = @actions[to_sym(action_type)]
  if actions.nil?
    PIM.log_info("No actions for action type '#{action_type}' found in plan '#{@name}'")
    return nil
  end
  action = actions[channel.type]
  if action.nil?
    PIM.log_info("No action for action type '#{action_type}' and channel type '#{channel.type}' found in plan '#{@name}'")
    return nil
  end
  executor = ActionExecutor.new self, action_type, action_creator, action_tags, action_date, channel, organization, data
  executor.execute &action
end
plan_category(category = nil) click to toggle source
# File pim.rb, line 9555
def plan_category category = nil
  @plan_category = category if category
  @plan_category
end
publication_category(category = nil) click to toggle source
# File pim.rb, line 9560
def publication_category category = nil
  @publication_category = category if category
  @publication_category
end
publication_chunk_size(size = nil) click to toggle source
# File pim.rb, line 9585
def publication_chunk_size size = nil
  @publication_chunk_size = size if size
  @publication_chunk_size
end
subscription_category(category = nil) click to toggle source
# File pim.rb, line 9570
def subscription_category category = nil
  @subscription_category = category if category
  @subscription_category
end
supports_sub_destinations(supports = nil) click to toggle source
# File pim.rb, line 9575
def supports_sub_destinations supports = nil
  @supports_sub_destinations = supports unless supports.nil?
  @supports_sub_destinations
end
unpublication_category(category = nil) click to toggle source
# File pim.rb, line 9565
def unpublication_category category = nil
  @unpublication_category = category if category
  @unpublication_category
end
unpublication_chunk_size(size = nil) click to toggle source
# File pim.rb, line 9590
def unpublication_chunk_size size = nil
  @unpublication_chunk_size = size if size
  @unpublication_chunk_size
end