Skip to content

Commit

Permalink
Merge pull request #4 from seth-shaw-unlv/issue-498
Browse files Browse the repository at this point in the history
Initial OAI-PMH Endpoint (issues 498 & 1192)
  • Loading branch information
mjordan authored Sep 9, 2019
2 parents e8fde6a + 8ef88b2 commit 72c490b
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 0 deletions.
37 changes: 37 additions & 0 deletions modules/islandora_oaipmh/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Islandora OAI-PMH Endpoint

This submodule leverages the [rest\_oai\_pmh module](https://www.drupal.org/project/rest_oai_pmh)
to provide an OAI-PMH endpoint to allow harvesting repository content.

By default the OAI-PMH endpoint is located at 'yoursite.example/oai/request'
and includes a set identified as 'oai\_pmh:all\_repository\_items' which can be
further configured by editing the provided OAI-PMH view. The provided set
includes all items using the 'repository item' content type that _don't_ use
the 'Collection' model. Additional sets can be created by making views with the
Entity Reference view display mode and enabling them on the rest\_oai\_pmh
configuration page: `/admin/config/services/rest/oai-pmh`. The module can use
any view using an Entity Reference view display mode, they do not need to be
part of the provided OAI-PMH view, it is simply available as a convenience.

The rest\_oai\_pmh module indexes set membership, so repository items may not appear
immediately in their respective sets. Indexing will happen automatically during
cron runs but can be triggered manually at `/admin/config/services/rest/oai-pmh/queue`.

This module uses the Dublin Core metadata defined by
the [repository item content model's RDF mapping](http://islandora-claw.github.io/CLAW/user-documentation/content_types/#update-create-an-rdf-mapping).
However, the RDF mapping does not include support for islandora\_default's use
of the linked agent field. Including agent links in the OAI-PMH metadata
currently requires updating the RDF mapping to include a Dublin Core predicate
for that field or any other additional fields. Alternatively, the rest\_oai\_pmh module
also supports defining mappings with the
[metatag module](https://www.drupal.org/project/metatag) or creating a custom
metadata profile using the Twig templating system.

## Configuration

1. Install rest\_oai\_pmh (e.g. `composer require drupal/rest\_oai\_pmh`).
1. Enable this module (e.g. `drush en -y islandora\_oaipmh`).
1. Trigger the OAI-PMH indexer: Click the button found on the page at `http://localhost:8000/admin/config/services/rest/oai-pmh/queue` (or wait for cron)
1. Give anonymous users the "Access GET on OAI-PMH resource" permission.

Your OAI-PMH Endpoint should now be ready. e.g. `http://localhost:8000/oai/request?verb=ListRecords&metadataPrefix=oai\_dc`
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rest_oai_pmh:
entity_type: node
view_displays:
'oai_pmh:all_repository_items': 'oai_pmh:all_repository_items'
support_sets: 1
mapping_source: rdf
repository_name: 'Islandora 8'
repository_email: [email protected]
expiration: '3600'
254 changes: 254 additions & 0 deletions modules/islandora_oaipmh/config/install/views.view.oai_pmh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
langcode: en
status: true
dependencies:
config:
- node.type.islandora_object
module:
- node
- taxonomy
- user
id: oai_pmh
label: OAI-PMH
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: mini
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ‹‹
next: ››
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
type:
id: type
table: node_field_data
field: type
value:
islandora_object: islandora_object
entity_type: node
entity_field: type
plugin_id: bundle
group: 1
field_external_uri_uri:
id: field_external_uri_uri
table: taxonomy_term__field_external_uri
field: field_external_uri_uri
relationship: field_model
group_type: group
admin_label: ''
operator: '!='
value: 'http://purl.org/dc/dcmitype/Collection'
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
placeholder: ''
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
header: { }
footer: { }
empty: { }
relationships:
field_model:
id: field_model
table: node__field_model
field: field_model
relationship: none
group_type: group
admin_label: 'field_model: Taxonomy term'
required: false
plugin_id: standard
arguments: { }
display_extenders: { }
filter_groups:
operator: AND
groups:
1: AND
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- url.query_args
- 'user.node_grants:view'
- user.permissions
tags: { }
all_repository_items:
display_plugin: entity_reference
id: all_repository_items
display_title: 'All Repository Items'
position: 1
display_options:
display_extenders: { }
style:
type: entity_reference
options:
search_fields:
title: title
display_description: ''
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- 'user.node_grants:view'
- user.permissions
tags: { }

1 change: 1 addition & 0 deletions modules/islandora_oaipmh/islandora_oaipmh.features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bundle: islandora
8 changes: 8 additions & 0 deletions modules/islandora_oaipmh/islandora_oaipmh.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: 'Islandora OAI-PMH Endpoint'
type: module
description: 'Default configuration for an OAI-PMH Endpoint'
core: 8.x
package: 'Islandora'
dependencies:
- rest_oai_pmh
- islandora_defaults
27 changes: 27 additions & 0 deletions modules/islandora_oaipmh/islandora_oaipmh.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* @file
* Supports Islandora submodule islandora_oaipmh.
*/

/**
* Implements hook_preprocess_rest_oai_pmh_record().
*/
function islandora_oaipmh_preprocess_rest_oai_pmh_record(&$variables) {
$entity = $variables['entity'];
if ($entity->hasField('field_linked_agent')) {
foreach ($entity->get('field_linked_agent') as $linked_agent) {
$creator_rels = [
'relators:cre',
'relators:art',
'relators:aut',
'relators:edc',
'relators:pht',
'relators:trl',
];
$dc_field = in_array($linked_agent->rel_type, $creator_rels) ? 'dc:creator' : 'dc:contributor';
$variables['elements'][$dc_field][] = $linked_agent->entity->label();
}
}
}

0 comments on commit 72c490b

Please sign in to comment.