-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this base is being copied from valkyrizing pals
- Loading branch information
1 parent
a9045bb
commit 246508f
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
# rubocop:disable Metrics/BlockLength | ||
|
||
Rails.application.config.after_initialize do | ||
# Add all concerns that are migrating from ActiveFedora here | ||
CONCERNS = [Thesis].freeze | ||
|
||
CONCERNS.each do |klass| | ||
Wings::ModelRegistry.register("#{klass}Resource".constantize, klass) | ||
# we register itself so we can pre-translate the class in Freyja instead of having to translate in each query_service | ||
Wings::ModelRegistry.register(klass, klass) | ||
end | ||
|
||
# Wings::ModelRegistry.register(GenericWorkResource, GenericWork) | ||
# Wings::ModelRegistry.register(ImageResource, Image) | ||
# Wings::ModelRegistry.register(ThesisResource, Thesis) | ||
|
||
Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name| | ||
# TODO: Can we use some kind of lookup. | ||
klass_name = resource_klass_name.gsub(/Resource$/, '') | ||
if CONCERNS.map(&:to_s).include?(klass_name) | ||
"#{klass_name}Resource".constantize | ||
elsif 'Collection' == klass_name | ||
CollectionResource | ||
elsif 'AdminSet' == klass_name | ||
AdminSetResource | ||
# Without this mapping, we'll see cases of Postgres Valkyrie adapter attempting to write to | ||
# Fedora. Yeah! | ||
elsif 'Hydra::AccessControl' == klass_name | ||
Hyrax::AccessControl | ||
elsif 'FileSet' == klass_name | ||
Hyrax::FileSet | ||
elsif 'Hydra::AccessControls::Embargo' == klass_name | ||
Hyrax::Embargo | ||
elsif 'Hydra::AccessControls::Lease' == klass_name | ||
Hyrax::Lease | ||
elsif 'Hydra::PCDM::File' == klass_name | ||
Hyrax::FileMetadata | ||
else | ||
klass_name.constantize | ||
end | ||
end | ||
end | ||
# rubocop:enable Metrics/BlockLength |