lib/bulkrax.rb in bulkrax-6.0.1 vs lib/bulkrax.rb in bulkrax-7.0.0
- old
+ new
@@ -1,11 +1,12 @@
# frozen_string_literal: true
require "bulkrax/version"
require "bulkrax/engine"
require 'active_support/all'
-
+require 'coderay'
+require 'denormalize_fields'
# rubocop:disable Metrics/ModuleLength
module Bulkrax
extend self # rubocop:disable Style/ModuleFunction
extend Forwardable
@@ -17,11 +18,10 @@
:default_field_mapping,
:default_work_type,
:export_path,
:field_mappings,
:file_model_class,
- :fill_in_blank_source_identifiers,
:generated_metadata_mapping,
:import_path,
:multi_value_element_join_on,
:multi_value_element_split_on,
:object_factory,
@@ -33,10 +33,90 @@
:removed_image_path,
:required_elements,
:reserved_properties,
:server_name
+ ##
+ # @return [#call] with arity 2. The first parameter is a {Bulkrax::ApplicationParser} and the
+ # second parameter is an Integer for the index of the record encountered in the import.
+ attr_accessor :fill_in_blank_source_identifiers
+
+ ##
+ # @param adapter [Class<Bulkrax::PersistenceLayer::AbstractAdapter>]
+ attr_writer :persistence_adapter
+
+ ##
+ # @param [String]
+ attr_writer :solr_key_for_member_file_ids
+
+ ##
+ # @return [String]
+ # @see https://github.com/samvera/hyrax/pull/6513
+ def solr_key_for_member_file_ids
+ return @solr_key_for_member_file_ids if @solr_key_for_member_file_ids.present?
+
+ return "member_ids_ssim" if defined?(Hyrax)
+
+ "#{file_model_class.name.to_s.underscore}_ids_ssim"
+ end
+
+ ##
+ # @param coercer [#call]
+ # @see Bulkrax::FactoryClassFinder
+ attr_writer :factory_class_name_coercer
+
+ ##
+ # A function responsible for converting the name of a factory class to the corresponding
+ # constant.
+ #
+ # @return [#call, Bulkrax::FactoryClassFinder::DefaultCoercer] an object responding to call,
+ # with one positional parameter (e.g. arity == 1)
+ #
+ # @example
+ # Bulkrax.factory_class_name_coercer.call("Work")
+ # => Work
+ def factory_class_name_coercer
+ @factory_class_name_coercer || Bulkrax::FactoryClassFinder::DefaultCoercer
+ end
+
+ attr_writer :ingest_queue_name
+ ##
+ # @return [String, Proc]
+ def ingest_queue_name
+ return @ingest_queue_name if @ingest_queue_name.present?
+ return Hyrax.config.ingest_queue_name if defined?(Hyrax)
+ :import
+ end
+
+ ##
+ # Configure the persistence adapter used for persisting imported data.
+ #
+ # @return [Class<Bulkrax::PersistenceLayer::AbstractAdapter>]
+ # @see Bulkrax::PersistenceLayer
+ def persistence_adapter
+ @persistence_adapter || derived_persistence_adapter
+ end
+
+ def derived_persistence_adapter
+ if defined?(Hyrax)
+ # There's probably some configuration of Hyrax we could use to better refine this; but it's
+ # likely a reasonable guess. The main goal is to not break existing implementations and
+ # maintain an upgrade path.
+ if Gem::Version.new(Hyrax::VERSION) >= Gem::Version.new('6.0.0')
+ Bulkrax::PersistenceLayer::ValkyrieAdapter
+ else
+ Bulkrax::PersistenceLayer::ActiveFedoraAdapter
+ end
+ elsif defined?(ActiveFedora)
+ Bulkrax::PersistenceLayer::ActiveFedoraAdapter
+ elsif defined?(Valkyrie)
+ Bulkrax::PersistenceLayer::ValkyrieAdapter
+ else
+ raise "Unable to derive a persistence adapter"
+ end
+ end
+
attr_writer :use_locking
def use_locking
return @use_locking if defined?(@use_locking)
@@ -61,10 +141,12 @@
:default_field_mapping=,
:default_work_type,
:default_work_type=,
:export_path,
:export_path=,
+ :factory_class_name_coercer,
+ :factory_class_name_coercer=,
:field_mappings,
:field_mappings=,
:file_model_class,
:file_model_class=,
:fill_in_blank_source_identifiers,
@@ -79,10 +161,12 @@
:multi_value_element_split_on=,
:object_factory,
:object_factory=,
:parsers,
:parsers=,
+ :persistence_adapter,
+ :persistence_adapter=,
:qa_controlled_properties,
:qa_controlled_properties=,
:related_children_field_mapping,
:related_children_field_mapping=,
:related_parents_field_mapping,
@@ -95,9 +179,11 @@
:required_elements=,
:reserved_properties,
:reserved_properties=,
:server_name,
:server_name=,
+ :solr_key_for_member_file_ids,
+ :solr_key_for_member_file_ids=,
:use_locking,
:use_locking=,
:use_locking?
config do |conf|