Skip to content

Commit

Permalink
Merge branch 'double_combo' into flexible_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ShanaLMoore authored Jun 11, 2024
2 parents 6209db7 + f3534d1 commit 77ad3db
Show file tree
Hide file tree
Showing 60 changed files with 777 additions and 294 deletions.
1 change: 1 addition & 0 deletions .dassie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ TB_RSPEC_FORMATTER=progress
VALKYRIE_ID_TYPE=string
VALKYRIE_SOLR_HOST=solr
VALKYRIE_SOLR_PORT=8983
VALKYRIE_TRANSITION=false
4 changes: 3 additions & 1 deletion .dassie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ gem 'dalli'
gem 'devise'
gem 'devise-guests', '~> 0.8'
gemspec name: 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'pg', '~> 1.3'
Expand All @@ -24,7 +26,7 @@ gem 'riiif', '~> 2.1'
gem 'rsolr', '>= 1.0', '< 3'
gem 'sass-rails', '~> 6.0'
gem 'sidekiq', '~> 6.4'
# gem 'turbolinks', '~> 5'
gem 'turbolinks', '~> 5'
gem 'twitter-typeahead-rails', '0.11.1.pre.corejavascript'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'uglifier', '>= 1.3.0'
Expand Down
1 change: 1 addition & 0 deletions .dassie/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//
//=
//= require activestorage
//= require turbolinks
//
// Required by Blacklight
//= require jquery3
Expand Down
6 changes: 4 additions & 2 deletions .dassie/app/controllers/hyrax/generic_works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class GenericWorksController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::GenericWorkResource
if ENV.fetch('VALKYRIE_TRANSITION', false)
self.curation_concern_type = ::GenericWorkResource

self.work_form_service = Hyrax::FormFactory.new
self.work_form_service = Hyrax::FormFactory.new
end

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::GenericWorkPresenter
Expand Down
2 changes: 1 addition & 1 deletion .dassie/app/models/collection_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class CollectionResource < Hyrax::PcdmCollection
include Hyrax::Schema(:basic_metadata) unless ENV.fetch('HYRAX_FLEXIBLE', false)
include Hyrax::Schema(:collection_resource) unless ENV.fetch('HYRAX_FLEXIBLE', false)

Hyrax::ValkyrieLazyMigration.migrating(self, from: ::Collection)
Hyrax::ValkyrieLazyMigration.migrating(self, from: ::Collection) if ENV.fetch('VALKYRIE_TRANSITION', false)
end
2 changes: 1 addition & 1 deletion .dassie/app/models/file_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class FileSet < ActiveFedora::Base
include ::Hyrax::FileSetBehavior
end

Hyrax::ValkyrieLazyMigration.migrating(Hyrax::FileSet, from: ::FileSet)
Hyrax::ValkyrieLazyMigration.migrating(Hyrax::FileSet, from: ::FileSet) if ENV.fetch('VALKYRIE_TRANSITION', false)
7 changes: 6 additions & 1 deletion .dassie/config/analytics.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
analytics:
ga4:
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
property_id: <%= ENV['GOOGLE_ANALYTICS_PROPERTY_ID'] %>
account_json: <%= ENV['GOOGLE_ACCOUNT_JSON'] %>
account_json_path: <%= ENV['GOOGLE_ACCOUNT_JSON_PATH'] %>
google:
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
app_name: <%= ENV['GOOGLE_OAUTH_APP_NAME'] %>
app_version: <%= ENV['GOOGLE_OAUTH_APP_VERSION'] %>
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
privkey_path: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_PATH'] %>
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
privkey_secret: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_SECRET'] %>
client_email: <%= ENV['GOOGLE_OAUTH_CLIENT_EMAIL'] %>
matomo:
Expand Down
15 changes: 11 additions & 4 deletions .dassie/config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Injected via `rails g hyrax:work_resource Monograph`
config.register_curation_concern :monograph
# Injected via `rails g hyrax:work_resource GenericWorkResource`
config.register_curation_concern :generic_work_resource
# config.register_curation_concern :generic_work_resource

config.iiif_image_server = true
config.work_requires_files = false
Expand Down Expand Up @@ -68,9 +68,16 @@

# dassie needs legacy AF models
# If using Frayja/Frigg then use the resource they provide
config.collection_model = 'CollectionResource'
config.admin_set_model = 'AdminSetResource'
config.file_set_model = 'Hyrax::FileSet'
if ENV.fetch('VALKYRIE_TRANSITION', false)
config.collection_model = 'CollectionResource'
config.admin_set_model = 'AdminSetResource'
config.file_set_model = 'Hyrax::FileSet'
else
# dassie needs legacy AF models
config.collection_model = '::Collection'
config.admin_set_model = 'AdminSet'
config.file_set_model = '::FileSet'
end
end

Date::DATE_FORMATS[:standard] = "%m/%d/%Y"
Expand Down
187 changes: 94 additions & 93 deletions .dassie/config/initializers/wings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,107 +2,108 @@
# rubocop:disable Metrics/BlockLength

# Freyja setup adapted from hyku
if ENV.fetch('VALKYRIE_TRANSITION', false)
Rails.application.config.after_initialize do
[ # List AF work models
GenericWork
].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(Collection, Collection)
Wings::ModelRegistry.register(CollectionResource, Collection)
Wings::ModelRegistry.register(AdminSet, AdminSet)
Wings::ModelRegistry.register(AdminSetResource, AdminSet)
Wings::ModelRegistry.register(FileSet, FileSet)
Wings::ModelRegistry.register(Hyrax::FileSet, FileSet)
Wings::ModelRegistry.register(Hydra::PCDM::File, Hydra::PCDM::File)
Wings::ModelRegistry.register(Hyrax::FileMetadata, Hydra::PCDM::File)

Rails.application.config.after_initialize do
[ # List AF work models
GenericWork
].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(Collection, Collection)
Wings::ModelRegistry.register(CollectionResource, Collection)
Wings::ModelRegistry.register(AdminSet, AdminSet)
Wings::ModelRegistry.register(AdminSetResource, AdminSet)
Wings::ModelRegistry.register(FileSet, FileSet)
Wings::ModelRegistry.register(Hyrax::FileSet, FileSet)
Wings::ModelRegistry.register(Hydra::PCDM::File, Hydra::PCDM::File)
Wings::ModelRegistry.register(Hyrax::FileMetadata, Hydra::PCDM::File)

Valkyrie::MetadataAdapter.register(
Freyja::MetadataAdapter.new,
:freyja
)
Valkyrie.config.metadata_adapter = :freyja
Hyrax.config.query_index_from_valkyrie = true
Hyrax.config.index_adapter = :solr_index
Valkyrie::MetadataAdapter.register(
Freyja::MetadataAdapter.new,
:freyja
)
Valkyrie.config.metadata_adapter = :freyja
Hyrax.config.query_index_from_valkyrie = true
Hyrax.config.index_adapter = :solr_index

Valkyrie::StorageAdapter.register(
Valkyrie::Storage::VersionedDisk.new(base_path: Rails.root.join("storage", "files"),
file_mover: FileUtils.method(:cp)),
:disk
)
Valkyrie.config.storage_adapter = :disk
Valkyrie.config.indexing_adapter = :solr_index
Valkyrie::StorageAdapter.register(
Valkyrie::Storage::VersionedDisk.new(base_path: Rails.root.join("storage", "files"),
file_mover: FileUtils.method(:cp)),
:disk
)
Valkyrie.config.storage_adapter = :disk
Valkyrie.config.indexing_adapter = :solr_index

# load all the sql based custom queries
[
Hyrax::CustomQueries::Navigators::CollectionMembers,
Hyrax::CustomQueries::Navigators::ChildCollectionsNavigator,
Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator,
Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator,
Hyrax::CustomQueries::Navigators::ChildWorksNavigator,
Hyrax::CustomQueries::Navigators::FindFiles,
Hyrax::CustomQueries::FindAccessControl,
Hyrax::CustomQueries::FindCollectionsByType,
Hyrax::CustomQueries::FindFileMetadata,
Hyrax::CustomQueries::FindIdsByModel,
Hyrax::CustomQueries::FindManyByAlternateIds,
Hyrax::CustomQueries::FindModelsByAccess,
Hyrax::CustomQueries::FindCountBy,
Hyrax::CustomQueries::FindByDateRange,
# Hyrax::CustomQueries::FindBySourceIdentifier # from bulkrax
].each do |handler|
Hyrax.query_service.services[0].custom_queries.register_query_handler(handler)
end
# load all the sql based custom queries
[
Hyrax::CustomQueries::Navigators::CollectionMembers,
Hyrax::CustomQueries::Navigators::ChildCollectionsNavigator,
Hyrax::CustomQueries::Navigators::ParentCollectionsNavigator,
Hyrax::CustomQueries::Navigators::ChildFileSetsNavigator,
Hyrax::CustomQueries::Navigators::ChildWorksNavigator,
Hyrax::CustomQueries::Navigators::FindFiles,
Hyrax::CustomQueries::FindAccessControl,
Hyrax::CustomQueries::FindCollectionsByType,
Hyrax::CustomQueries::FindFileMetadata,
Hyrax::CustomQueries::FindIdsByModel,
Hyrax::CustomQueries::FindManyByAlternateIds,
Hyrax::CustomQueries::FindModelsByAccess,
Hyrax::CustomQueries::FindCountBy,
Hyrax::CustomQueries::FindByDateRange,
# Hyrax::CustomQueries::FindBySourceIdentifier # from bulkrax
].each do |handler|
Hyrax.query_service.services[0].custom_queries.register_query_handler(handler)
end

# [
# Wings::CustomQueries::FindBySourceIdentifier
# ].each do |handler|
# Hyrax.query_service.services[1].custom_queries.register_query_handler(handler)
# end
# [
# Wings::CustomQueries::FindBySourceIdentifier
# ].each do |handler|
# Hyrax.query_service.services[1].custom_queries.register_query_handler(handler)
# end

# Register each work resource pair
# Wings::ModelRegistry.register(GenericWorkResource, GenericWork)
end

Rails.application.config.to_prepare do
AdminSetResource.class_eval do
attribute :internal_resource, Valkyrie::Types::Any.default("AdminSet"), internal: true
# Register each work resource pair
# Wings::ModelRegistry.register(GenericWorkResource, GenericWork)
end

CollectionResource.class_eval do
attribute :internal_resource, Valkyrie::Types::Any.default("Collection"), internal: true
end
Rails.application.config.to_prepare do
AdminSetResource.class_eval do
attribute :internal_resource, Valkyrie::Types::Any.default("AdminSet"), internal: true
end

Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
# TODO: Can we use some kind of lookup.
klass_name = resource_klass_name.gsub(/^Wings\((.+)\)$/, '\1')
klass_name = klass_name.gsub(/Resource$/, '')
if %w[
GenericWork
].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
CollectionResource.class_eval do
attribute :internal_resource, Valkyrie::Types::Any.default("Collection"), internal: true
end

Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
# TODO: Can we use some kind of lookup.
klass_name = resource_klass_name.gsub(/^Wings\((.+)\)$/, '\1')
klass_name = klass_name.gsub(/Resource$/, '')
if %w[
GenericWork
].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
end
# rubocop:enable Metrics/BlockLength
5 changes: 0 additions & 5 deletions .dassie/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
require 'sidekiq/web'

Rails.application.routes.draw do
# ['generic_work'].each do |resource|
# get "/concern/#{resource}s/:id/edit", to: redirect("/concern/#{resource}_resources/%{id}/edit")
# get "/concern/#{resource}s/:id", to: redirect("/concern/#{resource}_resources/%{id}")
# end

mount Sidekiq::Web => '/sidekiq' # for sidekik monitoring; completely public
mount Riiif::Engine => 'images', as: :riiif if Hyrax.config.iiif_image_server?
mount BrowseEverything::Engine => '/browse'
Expand Down
2 changes: 2 additions & 0 deletions .koppie/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ gem 'coffee-rails', '~> 4.2'
gem 'dalli'
gem 'devise'
gem 'devise-guests', '~> 0.8'
gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux
gemspec name: 'hyrax', path: ENV.fetch('HYRAX_ENGINE_PATH', '..')
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
Expand Down
7 changes: 6 additions & 1 deletion .koppie/config/analytics.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
analytics:
ga4:
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
property_id: <%= ENV['GOOGLE_ANALYTICS_PROPERTY_ID'] %>
account_json: <%= ENV['GOOGLE_ACCOUNT_JSON'] %>
account_json_path: <%= ENV['GOOGLE_ACCOUNT_JSON_PATH'] %>
google:
analytics_id: <%= ENV['GOOGLE_ANALYTICS_ID'] %>
app_name: <%= ENV['GOOGLE_OAUTH_APP_NAME'] %>
app_version: <%= ENV['GOOGLE_OAUTH_APP_VERSION'] %>
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
privkey_path: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_PATH'] %>
privkey_value: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_VALUE'] %>
privkey_secret: <%= ENV['GOOGLE_OAUTH_PRIVATE_KEY_SECRET'] %>
client_email: <%= ENV['GOOGLE_OAUTH_CLIENT_EMAIL'] %>
matomo:
Expand Down
Loading

0 comments on commit 77ad3db

Please sign in to comment.