module PIM::Services::SimpleMappingService

Public Instance Methods

__simple_mapping_service() click to toggle source
# File services.rb, line 2540
def __simple_mapping_service
  __service(:simpleMappingService)
end
contains_key?(mapping_name, key) click to toggle source
# File services.rb, line 2503
def contains_key? mapping_name, key
  return __simple_mapping_service.existsSimpleMappingEntry(mapping_name, key)
end
exists_simple_mapping?(mapping_id_or_name) click to toggle source
# File services.rb, line 2499
def exists_simple_mapping? mapping_id_or_name
  return __simple_mapping_service.existsSimpleMapping(mapping_id_or_name)
end
get_simple_mapping_entry(mapping_id_or_name, key) click to toggle source
# File services.rb, line 2507
def get_simple_mapping_entry mapping_id_or_name, key
  return __simple_mapping_service.getSimpleMappingEntry(mapping_id_or_name, key)
end
get_simple_mapping_value(mapping_id_or_name, key, opts = {}) click to toggle source
# File services.rb, line 2511
def get_simple_mapping_value mapping_id_or_name, key, opts = {}

  mapped_value = __simple_mapping_service.getSimpleMappingEntryValue(mapping_id_or_name, key)

  # Get default label, if necessary
  if mapped_value.nil? and opts[:use_default_label]

    simple_mapping = __simple_mapping_service.getSimpleMapping(mapping_id_or_name)
    unless simple_mapping.nil?

      filter_attribute = opts[:attribute]
      filter_attribute = filter_attribute.nil? ? nil : filter_attribute.is_a?(PIM::Attribute) ? filter_attribute.name : filter_attribute.to_s

      language = opts[:language]
      attributes = simple_mapping.linked_attributes || []

      attributes.each do |attribute|
        next unless filter_attribute.nil? or attribute == filter_attribute
        mapped_value = PIM::Services::TranslationService.translate_option_key(language, key, attribute: attribute, no_default_option_key: true);
        break unless mapped_value.nil?
      end

    end

  end

  return mapped_value
end