Skip to content

Instantly share code, notes, and snippets.

@mankind
Forked from ashikajith/oai_export_doc.md
Created August 9, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mankind/0f5e990ffecaa823cfbe240b5129bd02 to your computer and use it in GitHub Desktop.
Save mankind/0f5e990ffecaa823cfbe240b5129bd02 to your computer and use it in GitHub Desktop.
OAI Export Feature

OAI Export

For OAI we are using the BlackLightOaiProvider gem (https://github.com/projectblacklight/blacklight_oai_provider) which harvest the data automatically once it is configured in the catalog controller. We have divided into two phases.

We do have an ENV variable which acts as a switch to enable this feature .

ENABLE_OAI_METADATA: 'true'
  • Phase1 Controller Changes In the catalog_controller we made the below confi changes to display the OAI template in the view
# app/controllers/catalog_controller.rb

  config.oai = {
      provider: {
        repository_name: Settings.oai.name
      },
      document: {
        limit: 25, # number of records returned with each request, default: 15
        set_fields: [ # ability to define ListSets, optional, default: nil
          { label: 'collection', solr_field: 'isPartOf_ssim' }
        ]
      }
    }

Once it is configured we need to provide the solr fields to diplay the values in the OAI template

  field_semantics.merge!(
    title: 'title_tesim',
    creator: 'creator_search_tesim',
    subject: 'keyword_tesim',
    description: 'abstract_oai_tesim',
    publisher: 'publisher_tesim',
    contributor: ['contributor_list_tesim', 'editor_list_tesim', 'funder_tesim'],
    date: 'date_published_tesim',
    identifier: ['official_link_oai_tesim', 'doi_oai_tesim', 'all_orcid_isni_tesim', 'work_tenant_url_tesim', 'collection_tenant_url_tesim'],
    language: 'language_tesim',
    relation: 'journal_title_tesim',
    rights: 'license_tesim',
    type: 'human_readable_type_tesim'
  )
  

All the above fields are in the solr name format and it will display the values if the correpsonding work has the values.

Note : We cannot add custom keys in OAI, It supports only few fields. Please find the doc below to know the available columns in OAI http://www.openarchives.org/OAI/openarchivesprotocol.html

We are also overriding few methods from the gem to meet our requiorement. Please find the overridden methods below

  • Overriding oai_config to display Request URL
# app/controllers/ubiquity/oai_extension.rb
module Ubiquity
  module OaiExtension
    extend ActiveSupport::Concern
    def oai_config
      blacklight_config.oai.merge(provider: { repository_url: request.original_url }) || {provider: { repository_url: request.original_url }}
    end
  end
end
  • Filtering public records to harvest in OAI We override the SolrWrapperExtension class from the gem to enable this filter. Please navigate to the below file app/controllers/ubiquity/oai_solr_wrapper_extension.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment