-
Notifications
You must be signed in to change notification settings - Fork 19
OAI-PMH 2.0 Implementation to export Materials #1146
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
base: master
Are you sure you want to change the base?
Conversation
Oai pmh support
Oai pmh repo url fix
Merge remote changes and small OAI-PMH fixes
Merge main developments into oai-pmh branch
Remaining TODOs for this pull request:
|
config/environment.rb
Outdated
class PublicMaterial < Material | ||
default_scope { where(visible: true) } | ||
|
||
# Pretend to be a regular Material (for URLs in RDF serialization) | ||
def self.model_name | ||
Material.model_name | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs, we can pass a scoped relation to OAI::Provider::ActiveRecordWrapper.new
instead of needing to make a new class:
https://github.com/code4lib/ruby-oai/blob/master/lib/oai/provider.rb#L249-L253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Changed in 7c2a9e7.
config/environment.rb
Outdated
class OAIRDF < OAI::Provider::Metadata::Format | ||
def initialize | ||
@prefix = 'rdf' | ||
@schema = 'http://www.openarchives.org/OAI/2.0/rdf.xsd' | ||
@namespace = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' | ||
@element_namespace = 'rdf' | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put all classes into their own files. We can have lib/oai/...
or something for all the OAI-PMH related code.
See this https://api.rubyonrails.org/classes/ActiveSupport/Inflector/Inflections.html
if you are having issues with it not being able to find classes/modules due to them being called OAI
and not Oai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to initializers in a71a345.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good tests, but might be nice to use an XML parser to parse and check the responses.
We already have a gem (nokogiri
) that can do this, see an example here in another repo for the (slightly awkward) syntax:
https://github.com/seek4science/seek/blob/ee17e7b6caa0733be1f922ec7eb98c78379ee67c/test/unit/datacite_metadata_test.rb#L90-L96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsed everything using nokogiri
in 323abaf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only the oai
gem is needed here. Those other gems are already included via the linkeddata
gem we are using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed other gems in c757a91.
app/models/material.rb
Outdated
# Dublin Core mappings for OAI-PMH | ||
# no mapping needed for contributor, description and title | ||
# coverage and source not mappable | ||
alias_attribute :creators, :authors | ||
|
||
def dates | ||
[date_published, date_created, date_modified].compact.map(&:iso8601) | ||
end | ||
|
||
def format = 'text/html' | ||
|
||
def identifier | ||
if !doi.nil? && !doi.empty? | ||
doi_iri = doi.start_with?('http://', 'https://') ? doi : "https://doi.org/#{doi}" | ||
else | ||
url | ||
end | ||
end | ||
|
||
def language = 'en' | ||
|
||
def publishers | ||
if content_provider | ||
[content_provider.title] | ||
else | ||
[] | ||
end | ||
end | ||
|
||
# currently only url of tess resource, content provider url | ||
def relations | ||
[ | ||
"#{TeSS::Config.base_url}#{Rails.application.routes.url_helpers.material_path(self)}" | ||
] + (content_provider ? [content_provider.url] : []) | ||
end | ||
|
||
alias_attribute :rights, :licence | ||
|
||
def subjects | ||
keywords + scientific_topics.map(&:uri) + operations.map(&:uri) | ||
end | ||
|
||
def types | ||
['http://purl.org/dc/dcmitype/Text', 'https://schema.org/LearningResource'] + resource_type | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner if we could move these methods into another class if that's possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to one method in 8b54db2.
@@ -0,0 +1,21 @@ | |||
class OaiController < ApplicationController | |||
# This view only returns static public content and CSRF token authentication causes problems with OAI-PMH POST requests | |||
skip_before_action :verify_authenticity_token |
Check failure
Code scanning / CodeQL
CSRF protection weakened or disabled High
Summary of changes
/oai-pmh
that allows harvesting of visible training materials in Dublin Core and RDF (Bioschemas) metadata standardMotivation and context
This is a relevant step in the mTeSS-X project.
Screenshots
Checklist
to license it to the TeSS codebase under the
BSD license.