class Libis::Ingester::FileMappingGrouper
Public Instance Methods
apply_options(opts)
click to toggle source
Calls superclass method
# File lib/libis/ingester/tasks/file_mapping_grouper.rb, line 41 def apply_options(opts) super(opts) required = Set.new(parameter(:required_fields)) required << parameter(:group_field) if parameter(:group_field) required << parameter(:file_label_field) if parameter(:file_label_field) required << parameter(:collection_field) if parameter(:collection_field) set = Set.new(parameter(:mapping_headers)) set += required required = [parameter(:mapping_key)] + required.to_a parameter(:mapping_headers, set.to_a) parameter(:required_fields, required) end
Protected Instance Methods
process(item)
click to toggle source
# File lib/libis/ingester/tasks/file_mapping_grouper.rb, line 56 def process(item) target_parent = item.parent if (collection_field = parameter(:collection_field)) if (collections = lookup(item.filename, collection_field)) collections.to_s.split('/') rescue [].each do |collection| sub_parent = target_parent.get_items.select do |c| c.is_a?(Libis::Ingester::Collection) && c.name == collection end.first unless sub_parent sub_parent = Libis::Ingester::Collection.new sub_parent.name = collection sub_parent.navigate = parameter(:collection_navigate) sub_parent.publish = parameter(:collection_publish) target_parent.add_item(sub_parent) debug 'Created new Collection item: %s', sub_parent, collection end target_parent = sub_parent end end