diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index ccb6d0b9..2d937cf5 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -117,7 +117,8 @@ def self.modified_field config.add_show_field solr_name("resource_type", :stored_searchable), label: "Resource Type" config.add_show_field solr_name("format", :stored_searchable), label: "File Format" config.add_show_field solr_name("identifier", :stored_searchable), label: "Identifier" - config.add_show_field solr_name("gw_affiliation", :stored_searchable), label: "GW Affiliation" + config.add_show_field solr_name("gw_affiliation", :stored_searchable), label: "GW Unit" + config.add_show_field solr_name("bibliographic_citation", :stored_searchable), label: "Previous Publication Information" config.add_show_field solr_name("degree", :stored_searchable), label: "Degree" config.add_show_field solr_name("advisor", :stored_searchable), label: "Advisor" config.add_show_field solr_name("committee_member", :stored_searchable), label: "Committee Member" diff --git a/app/models/concerns/hyrax/solr_document/metadata.rb b/app/models/concerns/hyrax/solr_document/metadata.rb new file mode 100644 index 00000000..fb6630e6 --- /dev/null +++ b/app/models/concerns/hyrax/solr_document/metadata.rb @@ -0,0 +1,92 @@ +module Hyrax + module SolrDocument + module Metadata + extend ActiveSupport::Concern + class_methods do + def attribute(name, type, field) + define_method name do + type.coerce(self[field]) + end + end + + def solr_name(*args) + Solrizer.solr_name(*args) + end + end + + module Solr + class Array + # @return [Array] + def self.coerce(input) + ::Array.wrap(input) + end + end + + class String + # @return [String] + def self.coerce(input) + ::Array.wrap(input).first + end + end + + class Date + # @return [Date] + def self.coerce(input) + field = String.coerce(input) + return if field.blank? + begin + ::Date.parse(field) + rescue ArgumentError + Rails.logger.info "Unable to parse date: #{field.first.inspect}" + end + end + end + end + + included do + attribute :identifier, Solr::Array, solr_name('identifier') + attribute :based_near, Solr::Array, solr_name('based_near') + attribute :based_near_label, Solr::Array, solr_name('based_near_label') + attribute :related_url, Solr::Array, solr_name('related_url') + attribute :resource_type, Solr::Array, solr_name('resource_type') + attribute :edit_groups, Solr::Array, ::Ability.edit_group_field + attribute :edit_people, Solr::Array, ::Ability.edit_user_field + attribute :read_groups, Solr::Array, ::Ability.read_group_field + attribute :collection_ids, Solr::Array, 'collection_ids_tesim' + attribute :admin_set, Solr::Array, solr_name('admin_set') + attribute :member_of_collection_ids, Solr::Array, solr_name('member_of_collection_ids', :symbol) + attribute :description, Solr::Array, solr_name('description') + attribute :title, Solr::Array, solr_name('title') + attribute :contributor, Solr::Array, solr_name('contributor') + attribute :subject, Solr::Array, solr_name('subject') + attribute :publisher, Solr::Array, solr_name('publisher') + attribute :language, Solr::Array, solr_name('language') + attribute :keyword, Solr::Array, solr_name('keyword') + attribute :license, Solr::Array, solr_name('license') + attribute :source, Solr::Array, solr_name('source') + attribute :date_created, Solr::Array, solr_name('date_created') + attribute :rights_statement, Solr::Array, solr_name('rights_statement') + attribute :bibliographic_citation, Solr::Array, solr_name('bibliographic_citation') + + attribute :mime_type, Solr::String, solr_name('mime_type', :stored_sortable) + attribute :workflow_state, Solr::String, solr_name('workflow_state_name', :symbol) + attribute :human_readable_type, Solr::String, solr_name('human_readable_type', :stored_searchable) + attribute :representative_id, Solr::String, solr_name('hasRelatedMediaFragment', :symbol) + # extract the term name from the rendering_predicate (it might be after the final / or #) + attribute :rendering_ids, Solr::Array, solr_name(Hyrax.config.rendering_predicate.value.split(/#|\/|,/).last, :symbol) + attribute :thumbnail_id, Solr::String, solr_name('hasRelatedImage', :symbol) + attribute :thumbnail_path, Solr::String, CatalogController.blacklight_config.index.thumbnail_field + attribute :label, Solr::String, solr_name('label') + attribute :file_format, Solr::String, solr_name('file_format') + attribute :suppressed?, Solr::String, solr_name('suppressed', Solrizer::Descriptor.new(:boolean, :stored, :indexed)) + + attribute :date_modified, Solr::Date, solr_name('date_modified', :stored_sortable, type: :date) + attribute :date_uploaded, Solr::Date, solr_name('date_uploaded', :stored_sortable, type: :date) + attribute :create_date, Solr::Date, solr_name('system_create', :stored_sortable, type: :date) + attribute :modified_date, Solr::Date, solr_name('system_modified', :stored_sortable, type: :date) + attribute :embargo_release_date, Solr::Date, Hydra.config.permissions.embargo.release_date + attribute :lease_expiration_date, Solr::Date, Hydra.config.permissions.lease.expiration_date + end + end + end +end diff --git a/app/presenters/hyrax/gw_etd_presenter.rb b/app/presenters/hyrax/gw_etd_presenter.rb index 2e935f9f..edf1b59e 100644 --- a/app/presenters/hyrax/gw_etd_presenter.rb +++ b/app/presenters/hyrax/gw_etd_presenter.rb @@ -1,6 +1,6 @@ module Hyrax class GwEtdPresenter < GwWorkPresenter - delegate :gw_affiliation, to: :solr_document + delegate :gw_affiliation, :bibliographic_citation, to: :solr_document delegate :degree, :advisor, :committee_member, to: :solr_document def permanent_url diff --git a/app/presenters/hyrax/gw_work_presenter.rb b/app/presenters/hyrax/gw_work_presenter.rb index 7fa98c9e..455deafb 100644 --- a/app/presenters/hyrax/gw_work_presenter.rb +++ b/app/presenters/hyrax/gw_work_presenter.rb @@ -1,6 +1,6 @@ module Hyrax class GwWorkPresenter < Hyrax::WorkShowPresenter - delegate :gw_affiliation, to: :solr_document + delegate :gw_affiliation, :bibliographic_citation, to: :solr_document def permanent_url Scholarspace::Application.config.permanent_url_base + "work/#{id}" diff --git a/app/views/hyrax/gw_etds/_attribute_rows.erb b/app/views/hyrax/gw_etds/_attribute_rows.erb index 8a5c584c..80f1dabb 100644 --- a/app/views/hyrax/gw_etds/_attribute_rows.erb +++ b/app/views/hyrax/gw_etds/_attribute_rows.erb @@ -16,3 +16,4 @@ <%= presenter.attribute_to_html(:advisor, render_as: :faceted) %> <%= presenter.attribute_to_html(:committee_member, render_as: :faceted) %> <%= presenter.attribute_to_html(:permanent_url, render_as: :external_link) %> +<%= presenter.attribute_to_html(:bibliographic_citation, render_as: :faceted) %> diff --git a/app/views/hyrax/gw_works/_attribute_rows.erb b/app/views/hyrax/gw_works/_attribute_rows.erb index 8a5c584c..80f1dabb 100644 --- a/app/views/hyrax/gw_works/_attribute_rows.erb +++ b/app/views/hyrax/gw_works/_attribute_rows.erb @@ -16,3 +16,4 @@ <%= presenter.attribute_to_html(:advisor, render_as: :faceted) %> <%= presenter.attribute_to_html(:committee_member, render_as: :faceted) %> <%= presenter.attribute_to_html(:permanent_url, render_as: :external_link) %> +<%= presenter.attribute_to_html(:bibliographic_citation, render_as: :faceted) %> diff --git a/config/locales/hyrax.en.yml b/config/locales/hyrax.en.yml index 37b5cfe8..09d0a78e 100644 --- a/config/locales/hyrax.en.yml +++ b/config/locales/hyrax.en.yml @@ -56,29 +56,17 @@ project from which the work was derived." search: fields: show: - resource_type_tesim: Type of Work - based_near_tesim: Location - contributor_tesim: Contributor - creator_tesim: Author + resource_type: Type of Work + based_near_label: Location + contributor: Contributor + creator: Author description_tesim: Description - gw_affiliation_tesim: GW Unit - degree_tesim: Degree - advisor_tesim: Advisor - committee_member_tesim: Committee Member(s) - bibliographic_citation_tesim: Previous Publication Information - permanent_url_tesim: Persistent URL - index: - resource_type_tesim: Type of Work - based_near_tesim: Location - contributor_tesim: Contributor - creator_tesim: Author - description_tesim: Description - gw_affiliation_tesim: GW Unit - degree_tesim: Degree - advisor_tesim: Advisor - committee_member_tesim: Committee Member(s) - bibliographic_citation_tesim: Previous Publication Information - permanent_url_tesim: Persistent URL + gw_affiliation: GW Unit + degree: Degree + advisor: Advisor + committee_member: Committee Member(s) + bibliographic_citation: Previous Publication Information + permanent_url: Persistent URL facet: gw_affiliation_sim: GW Unit degree_sim: Degree