Skip to content

Commit

Permalink
add configuration for using a custom ObjectFactory (#673)
Browse files Browse the repository at this point in the history
* add configuration for using a custom ObjectFactory

this is a first step toward #672 and valkyrie support. we want to be able to
drop in an ObjectFactory implementation that finds and saves using Valkyrie
instead of ActiveFedora.

* fallback to default (#675)

Update import_behavior.rb

@no-reply what do you think about this change?  This is mainly for projects that have Bulkrax already set up and don't have/don't know about the generated config that update to the latest version of Bulkrax.  Also, this should fix specs.

Co-authored-by: Kirk Wang <[email protected]>
  • Loading branch information
tamsin johnson and kirkkwang authored Nov 21, 2022
1 parent a2525f7 commit 88cb7ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
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

0 comments on commit 88cb7ac

Please sign in to comment.