diff --git a/Gemfile.lock b/Gemfile.lock index ce8a7e78..d560e5a6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,7 @@ GIT GIT remote: https://github.com/samvera/hyrax.git - revision: 0108fed6c83dd4a449b37cc1a6c19787ec54921d + revision: b7891b758411c59f71ff54212e0d250fcc47e35f branch: double_combo specs: hyrax (5.0.0.rc2) diff --git a/app/indexers/ams/valkyrie_work_indexer.rb b/app/indexers/ams/valkyrie_work_indexer.rb new file mode 100644 index 00000000..f86e60d3 --- /dev/null +++ b/app/indexers/ams/valkyrie_work_indexer.rb @@ -0,0 +1,26 @@ +module AMS + class ValkyrieWorkIndexer < Hyrax::ValkyrieWorkIndexer + include SolrHelper + + def to_solr + find_index_child_attributes(super) + end + + private + def find_index_child_attributes(solr_doc) + resource.members.each do |child| + parent_indexable_properties = [ "language", "contributor"] + child.class.fields.each do |field_name| + parent_indexable_properties << field_name if child.class.schema.key(field_name).meta['index_to_parent'] + end + parent_indexable_properties.uniq.each do |prop| + solr_doc["#{child.class.to_s.underscore}_#{prop}_ssim"] ||= [] + solr_doc["#{child.class.to_s.underscore}_#{prop}_ssim"] |= Array.wrap(child.send(prop)) + solr_doc["#{prop}_ssim"] ||= [] + solr_doc["#{prop}_ssim"] |= Array.wrap(child.send(prop)) + end + end + solr_doc + end + end +end diff --git a/app/indexers/ams/work_indexer.rb b/app/indexers/ams/work_indexer.rb index 83227237..cc44186c 100644 --- a/app/indexers/ams/work_indexer.rb +++ b/app/indexers/ams/work_indexer.rb @@ -24,4 +24,4 @@ def find_index_child_attributes(solr_doc) solr_doc end end -end \ No newline at end of file +end diff --git a/app/indexers/asset_resource_indexer.rb b/app/indexers/asset_resource_indexer.rb index 9e6202d0..0ed8b24b 100644 --- a/app/indexers/asset_resource_indexer.rb +++ b/app/indexers/asset_resource_indexer.rb @@ -2,7 +2,7 @@ # Generated via # `rails generate hyrax:work_resource AssetResource` -class AssetResourceIndexer < Hyrax::ValkyrieWorkIndexer +class AssetResourceIndexer < AMS::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:asset_resource) diff --git a/app/indexers/contribution_resource_indexer.rb b/app/indexers/contribution_resource_indexer.rb index 36758448..cdc99f1f 100644 --- a/app/indexers/contribution_resource_indexer.rb +++ b/app/indexers/contribution_resource_indexer.rb @@ -2,7 +2,7 @@ # Generated via # `rails generate hyrax:work_resource ContributionResource` -class ContributionResourceIndexer < Hyrax::ValkyrieWorkIndexer +class ContributionResourceIndexer < AMS::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:contribution_resource) diff --git a/app/indexers/digital_instantiation_resource_indexer.rb b/app/indexers/digital_instantiation_resource_indexer.rb index ee541e93..e7b9bc0c 100644 --- a/app/indexers/digital_instantiation_resource_indexer.rb +++ b/app/indexers/digital_instantiation_resource_indexer.rb @@ -2,7 +2,7 @@ # Generated via # `rails generate hyrax:work_resource DigitalInstantiationResource` -class DigitalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer +class DigitalInstantiationResourceIndexer < AMS::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:digital_instantiation_resource) diff --git a/app/indexers/essence_track_resource_indexer.rb b/app/indexers/essence_track_resource_indexer.rb index 3666a646..9eb8a554 100644 --- a/app/indexers/essence_track_resource_indexer.rb +++ b/app/indexers/essence_track_resource_indexer.rb @@ -2,7 +2,7 @@ # Generated via # `rails generate hyrax:work_resource EssenceTrackResource` -class EssenceTrackResourceIndexer < Hyrax::ValkyrieWorkIndexer +class EssenceTrackResourceIndexer < AMS::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:essence_track_resource) diff --git a/app/indexers/physical_instantiation_resource_indexer.rb b/app/indexers/physical_instantiation_resource_indexer.rb index 194a3f5e..bf1e4433 100644 --- a/app/indexers/physical_instantiation_resource_indexer.rb +++ b/app/indexers/physical_instantiation_resource_indexer.rb @@ -2,7 +2,7 @@ # Generated via # `rails generate hyrax:work_resource PhysicalInstantiationResource` -class PhysicalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer +class PhysicalInstantiationResourceIndexer < AMS::ValkyrieWorkIndexer include Hyrax::Indexer(:basic_metadata) include Hyrax::Indexer(:physical_instantiation_resource) diff --git a/app/presenters/aapb/instantiation_admin_data_presenter.rb b/app/presenters/aapb/instantiation_admin_data_presenter.rb index d1d80e45..ee1089e0 100644 --- a/app/presenters/aapb/instantiation_admin_data_presenter.rb +++ b/app/presenters/aapb/instantiation_admin_data_presenter.rb @@ -15,9 +15,9 @@ def attribute_to_html(field, options = {}) options.merge!({:html_dl=> true}) solr_document = ::SolrDocument.find(id) - old_models = ['Asset', 'PhysicalInstantiation', 'DigitalInstantiation', 'Contribution'] - work_class = old_models.include?(solr_document['has_model_ssim'].first) ? "#{solr_document['has_model_ssim'].first}Resource" : solr_document['has_model_ssim'].first + work_class = solr_document['has_model_ssim'].first work_class = work_class.constantize + work_class = Wings::ModelRegistry.reverse_lookup(work_class) || work_class if attribute_indexed_to_parent?(field, work_class) && attribute_facetable?(field, work_class) # Use :symbol for field_name since all attributes indexed to parent are indexed as symbols. diff --git a/config/metadata/.#physical_instantiation_resource.yaml b/config/metadata/.#physical_instantiation_resource.yaml new file mode 120000 index 00000000..55389b66 --- /dev/null +++ b/config/metadata/.#physical_instantiation_resource.yaml @@ -0,0 +1 @@ +rob@Robs-MacBook-Pro.local.83041 \ No newline at end of file diff --git a/config/metadata/contribution_resource.yaml b/config/metadata/contribution_resource.yaml index 0d46bbe4..8a9a04e6 100644 --- a/config/metadata/contribution_resource.yaml +++ b/config/metadata/contribution_resource.yaml @@ -38,6 +38,7 @@ attributes: portrayal: type: string multiple: false + index_to_parent: true index_keys: - "portrayal_tesim" form: @@ -47,6 +48,7 @@ attributes: affiliation: type: string multiple: false + index_to_parent: true index_keys: - "affiliation_tesim" form: diff --git a/config/metadata/digital_instantiation_resource.yaml b/config/metadata/digital_instantiation_resource.yaml index 1803948d..e0f83d44 100644 --- a/config/metadata/digital_instantiation_resource.yaml +++ b/config/metadata/digital_instantiation_resource.yaml @@ -33,6 +33,7 @@ attributes: date: type: string multiple: true + index_to_parent: true index_keys: - "date_sim" - "date_tesim" @@ -79,6 +80,7 @@ attributes: media_type: type: string multiple: false + index_to_parent: true index_keys: - "media_type_sim" - "media_type_tesim" @@ -89,6 +91,7 @@ attributes: generations: type: string multiple: true + index_to_parent: true index_keys: - "generations_sim" - "generations_tesim" @@ -171,6 +174,7 @@ attributes: local_instantiation_identifier: type: string multiple: true + index_to_parent: true index_keys: - "local_instantiation_identifier_tesim" form: @@ -207,6 +211,7 @@ attributes: holding_organization: type: string multiple: false + index_to_parent: true index_keys: - "holding_organization_sim" - "holding_organization_tesim" diff --git a/config/metadata/physical_instantiation_resource.yaml b/config/metadata/physical_instantiation_resource.yaml index 14d8b2fa..bb221fea 100644 --- a/config/metadata/physical_instantiation_resource.yaml +++ b/config/metadata/physical_instantiation_resource.yaml @@ -33,6 +33,7 @@ attributes: date: type: string multiple: true + index_to_parent: true index_keys: - "date_sim" - "date_tesim" @@ -61,6 +62,7 @@ attributes: format: type: string multiple: false + index_to_parent: true index_keys: - "format_tesim" form: @@ -88,6 +90,7 @@ attributes: media_type: type: string multiple: false + index_to_parent: true index_keys: - "media_type_sim" - "media_type_tesim" @@ -162,6 +165,7 @@ attributes: local_instantiation_identifier: type: string multiple: true + index_to_parent: true index_keys: - "local_instantiation_identifier_tesim" form: diff --git a/docker-compose.yml b/docker-compose.yml index 9f373e48..05a41e2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -213,7 +213,7 @@ services: environment: - VIRTUAL_PORT=3000 - VIRTUAL_HOST=.ams.test - # command: sh -l -c "bundle && bundle exec puma -v -b tcp://0.0.0.0:3000" + # command: sh -l -c "sleep infinity" cap_add: - SYS_PTRACE depends_on: @@ -237,7 +237,6 @@ services: condition: service_started initialize_app: condition: service_completed_successfully - expose: - 3000