Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add configuration for using a custom ObjectFactory #673

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions app/models/concerns/bulkrax/import_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,16 @@ def active_id_for_authority?(value, field)
end

def factory
@factory ||= Bulkrax::ObjectFactory.new(attributes: self.parsed_metadata,
source_identifier_value: identifier,
work_identifier: parser.work_identifier,
related_parents_parsed_mapping: parser.related_parents_parsed_mapping,
replace_files: replace_files,
user: user,
klass: factory_class,
importer_run_id: importerexporter.last_run.id,
update_files: update_files)
of = Bulkrax.object_factory || Bulkrax::ObjectFactory
@factory ||= of.new(attributes: self.parsed_metadata,
source_identifier_value: identifier,
work_identifier: parser.work_identifier,
related_parents_parsed_mapping: parser.related_parents_parsed_mapping,
replace_files: replace_files,
user: user,
klass: factory_class,
importer_run_id: importerexporter.last_run.id,
update_files: update_files)
end

def factory_class
Expand Down
1 change: 1 addition & 0 deletions lib/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class << self
:import_path,
:multi_value_element_join_on,
:multi_value_element_split_on,
:object_factory,
:parsers,
:qa_controlled_properties,
:related_children_field_mapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# Default is the first returned by Hyrax.config.curation_concerns
# config.default_work_type = MyWork

# Factory Class to use when generating and saving objects
config.object_factory = Bulkrax::ObjectFactory

# Path to store pending imports
# config.import_path = 'tmp/imports'

Expand Down