Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oai-pmh mods representation #52

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified assets/migrate/tags.csv
100644 → 100755
Empty file.
Empty file modified assets/patches/default_settings.txt
100644 → 100755
Empty file.
13 changes: 13 additions & 0 deletions assets/patches/oaipmh_groupby.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/Plugin/rest/resource/OaiPmh.php b/src/Plugin/rest/resource/OaiPmh.php
index db2ea29..6e66d79 100644
--- a/src/Plugin/rest/resource/OaiPmh.php
+++ b/src/Plugin/rest/resource/OaiPmh.php
@@ -500,7 +500,7 @@ class OaiPmh extends ResourceBase {
// XXX: GROUP_CONCAT() doesn't exist in PostgreSQL.
$query->addExpression("STRING_AGG(m.set_id, ',')", 'sets');
}
- $query->groupBy('r.entity_type, r.entity_id');
+ $query->groupBy('r.entity_id')->groupBy('r.entity_type');

// XXX: Result sets can be unpredictable when limiting without an ORDER BY
// clause.
137 changes: 137 additions & 0 deletions assets/templates/mods.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<titleInfo>
<title lang="eng">{{ elements.title }}</title>
{% if elements.subtitle is not empty%}
<subTitle>{{ elements.subtitle }}</subTitle>
{% endif %}
</titleInfo>

{% for role_name_info in elements.linked_agent |split ('|') %}
{% set role_name = role_name_info|split(':') %}
{% set name_type_info = elements.linked_agent_vocabulary|split(',') %}

{% set name_type_info_x = name_type_info[loop.index - 1]|replace({"Person":"person"})|raw %}
{% set name_type_info_x = name_type_info_x|replace({"Corporate Body":"corporate"})|raw %}

<name type="{{ name_type_info_x }}">
<role>
<roleTerm type="text">{{ role_name[0] }}</roleTerm>
</role>
<namePart>{{ role_name[1] }}</namePart>
</name>
{% endfor %}

<typeOfResource>{{ elements.typeofresource }}</typeOfResource>
<genre>{{ elements.genre }} </genre>
<abstract>{{ elements.description }}</abstract>
<language>
{% for language in elements.language_iso6392b |split ('|') %}
<languageTerm authority="iso639-2b" type="code">{{ language|trim }}</languageTerm>
{% endfor %}
</language>
<originInfo>
<publisher>{{ elements.publisher }}</publisher>
<place>
<placeTerm type="text">{{ elements.published_place }}</placeTerm>
<placeTerm authority="marccountry">{{ elements.published_place_marccountry }}</placeTerm>
</place>
<dateCreated keyDate="yes">{{ elements.datecreated_rad14b5 }}</dateCreated>
{% if elements.datecreated_start_iso8601 is not empty%}
<dateCreated point="start">{{ elements.datecreated_start_iso8601 }}</dateCreated>
{% endif %}
{% if elements.datecreated_end_iso8601 is not empty%}
<dateCreated point="end">{{ elements.datecreated_end_iso8601 }}</dateCreated>
{% endif %}
<copyrightDate>{{ elements.datecopyright_iso8601 }}</copyrightDate>
</originInfo>
<physicalDescription>
<form authority="smd">{{ elements.physicaldescription_form }}</form>
<extent>{{ elements.physicaldescription_extent }}</extent>
<reformattingQuality>{{ elements.physicaldescription_reformatting_quality }}</reformattingQuality>
<digitalOrigin>{{ elements.physicaldescription_digitalorigin }}</digitalOrigin>
<internetMediaType>{{ elements.physicaldescription_internetmediatype }}</internetMediaType>
<note>{{ elements.physicaldescription_note }}</note>
</physicalDescription>
<subject authority="local">
{% for topic in elements.subject_topic |split ('|') %}
<topic>{{ topic|trim }}</topic>
{% endfor %}
{% for geographic in elements.subject_geographic |split ('|') %}
<geographic>{{ geographic|trim }}</geographic>
{% endfor %}
{% for temporal in elements.subject_temporal |split ('|') %}
<temporal>{{ temporal|trim }}</temporal>
{% endfor %}

{% set name_type_info = elements.subjects_name_vocabulary|split('|') %}
{% for subject_name_info in elements.subjects_name |split ('|') %}

{% set name_type_info_x = name_type_info[loop.index - 1]|replace({"Person":"person"})|raw %}
{% set name_type_info_x = name_type_info_x|replace({"Corporate Body":"corporate"})|raw %}

<name type="{{ name_type_info_x }}">
<namePart>{{ subject_name_info }}</namePart>
</name>
{% endfor %}

<hierarchicalGeographic>
<continent>{{ elements.subject_hierarchicalgeographic_continent }}</continent>
<country>{{ elements.subject_hierarchicalgeographic_country }}</country>
<state>{{ elements.subject_hierarchicalgeographic_state }}</state>
<province>{{ elements.subject_hierarchicalgeographic_province }}</province>
<region>{{ elements.subject_hierarchicalgeographic_region }}</region>
<county>{{ elements.subject_hierarchicalgeographic_county }}</county>
<island>{{ elements.subject_hierarchicalgeographic_island }}</island>
<city>{{ elements.subject_hierarchicalgeographic_city }}</city>
<citySection>{{ elements.subject_hierarchicalgeographic_citysection }}</citySection>
</hierarchicalGeographic>
<cartographics>
<coordinates>{{ elements.subject_geographic_coordinates }}</coordinates>
</cartographics>
</subject>
{% if elements.relateditem_title is not empty %}
<relatedItem type="host">
<titleInfo>
<title>{{ elements.relateditem_title }}</title>
</titleInfo>
</relatedItem>
{% endif %}
{% if elements.relateditem_collection_title is not empty %}
<relatedItem type="collection">
<titleInfo>
<title>{{ elements.relateditem_collection_title }}</title>
</titleInfo>
</relatedItem>
{% endif %}
{% if elements.accesscondition_restrictionandaccess is not empty%}
<accessCondition type="restriction and access">{{ elements.accesscondition_restrictionandaccess }}</accessCondition>
{% endif %}
<accessCondition type="use and reproduction">{{ elements.accesscondition_useandreproduction }}</accessCondition>
<location>
<url usage="primary display">{{ elements.location_url }}</url>
{% if elements.location_physical is not empty %}
<physicalLocation>{{ elements.location_physical }}</physicalLocation>
{% endif %}
</location>
<identifier type="uri">{{ elements.identifier_uri}}</identifier>
<identifier type="local">{{ elements.identifier_local}}</identifier>
<identifier type="ark">{{ elements.identifier_ark}}</identifier>
<note>{{ elements.note }}</note>
<recordInfo>
{% if elements.recordinfo_note_coursecode is not empty %}
<recordInfoNote type="courseCode">{{ elements.recordinfo_note_coursecode }}</recordInfoNote>
{% endif %}
{% if elements.recordinfo_note_courseyear is not empty %}
<recordInfoNote type="courseYear">{{ elements.recordinfo_note_courseyear }}</recordInfoNote>
{% endif %}
{% if elements.recordinfo_note_courseterm is not empty %}
<recordInfoNote type="courseTerm">{{ elements.recordinfo_note_courseterm }}</recordInfoNote>
{% endif %}
<languageOfCataloging>
{% if elements.recordinfo_cataloguing_language_iso6392b is not empty %}
<languageTerm authority="iso639-2b" type="code">{{ elements.recordinfo_cataloguing_language_iso6392b }}</languageTerm>
{% else %}
{# Assume language of cataloguing is eng #}
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
{% endif %}
</languageOfCataloging>
</recordInfo>
12 changes: 10 additions & 2 deletions composer.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"drupal/matomo": "^1.19",
"drupal/pdf": "^1.1",
"drupal/rest_oai_pmh": "^2.0@beta",
"drupal/search_api_solr": "^4.2",
"drupal/search_api_solr": "*",
"drupal/taxonomy_manager": "^2.0",
"drupal/transliterate_filenames": "^2.0",
"drupal/twig_tweak": "^3.2",
Expand All @@ -54,7 +54,9 @@
"islandora/islandora": "^2",
"islandora/openseadragon": "^2",
"library/pdf.js": "^2.4",
"mjordan/islandora_workbench_integration": "^1.0"
"maennchen/zipstream-php": "2.2.6",
"mjordan/islandora_workbench_integration": "^1.0",
"symfony/string": "5.4"
},
"conflict": {
"drupal/drupal": "*",
Expand Down Expand Up @@ -115,8 +117,14 @@
]
},
"patches": {
"drupal/rest_oai_pmh": {
"Drupal Core 9.5.3 Group by issue": "assets/patches/oaipmh_groupby.patch"
}
}
},
"scripts": {
"post-update-cmd": ["cp -f assets/templates/mods.html.twig web/modules/contrib/rest_oai_pmh/templates/mods.html.twig"]
},
"require-dev": {
"drupal/config_inspector": "^2.1",
"drupal/devel": "^5.0",
Expand Down
Loading