app/parsers/bulkrax/application_parser.rb in bulkrax-2.3.0 vs app/parsers/bulkrax/application_parser.rb in bulkrax-3.0.0.beta1
- old
+ new
@@ -54,41 +54,34 @@
def related_parents_raw_mapping
@related_parents_raw_mapping ||= get_field_mapping_hash_for('related_parents_field_mapping')&.values&.first&.[]('from')&.first
end
def related_parents_parsed_mapping
- @related_parents_parsed_mapping ||= get_field_mapping_hash_for('related_parents_field_mapping')&.keys&.first
+ @related_parents_parsed_mapping ||= (get_field_mapping_hash_for('related_parents_field_mapping')&.keys&.first || 'parents')
end
def related_children_raw_mapping
@related_children_raw_mapping ||= get_field_mapping_hash_for('related_children_field_mapping')&.values&.first&.[]('from')&.first
end
def related_children_parsed_mapping
- @related_children_parsed_mapping ||= get_field_mapping_hash_for('related_children_field_mapping')&.keys&.first
+ @related_children_parsed_mapping ||= (get_field_mapping_hash_for('related_children_field_mapping')&.keys&.first || 'children')
end
def get_field_mapping_hash_for(key)
return instance_variable_get("@#{key}_hash") if instance_variable_get("@#{key}_hash").present?
+ mapping = importerexporter.field_mapping == [{}] ? {} : importerexporter.field_mapping
instance_variable_set(
"@#{key}_hash",
- importerexporter.mapping.with_indifferent_access.select { |_, h| h.key?(key) }
+ mapping&.with_indifferent_access&.select { |_, h| h.key?(key) }
)
raise StandardError, "more than one #{key} declared: #{instance_variable_get("@#{key}_hash").keys.join(', ')}" if instance_variable_get("@#{key}_hash").length > 1
instance_variable_get("@#{key}_hash")
end
- def collection_field_mapping
- ActiveSupport::Deprecation.warn(
- 'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \
- ' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.'
- )
- Bulkrax.collection_field_mapping[self.entry_class.to_s]&.to_sym || :collection
- end
-
def model_field_mappings
model_mappings = Bulkrax.field_mappings[self.class.to_s]&.dig('model', :from) || []
model_mappings |= ['model']
model_mappings
@@ -113,9 +106,13 @@
def create_works
raise StandardError, 'must be defined' if importer?
end
def create_file_sets
+ raise StandardError, 'must be defined' if importer?
+ end
+
+ def create_relationships
raise StandardError, 'must be defined' if importer?
end
# Optional, define if using browse everything for file upload
def retrieve_cloud_files(files); end