-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1460 from ualbertalib/msb/metadata_decorators
Metadata Decorators for OAI:DC and OAI:ETDMS
- Loading branch information
Showing
10 changed files
with
157 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class ApplicationDecorator < Draper::Decorator | ||
|
||
# see https://github.com/drapergem/draper/issues/859 for why we never want to NOT | ||
# delgate the id method | ||
delegate :id | ||
|
||
# URL Helpers. Normally you can access through the viewcontext via +h.helper_method+, BUT | ||
# this comes with the caveat that the URL helpers the viewcontext can *see* depends on what | ||
# engine the decorator is run from, which leads to varying and unpredictable behaviour of | ||
# decorated methods involving paths. By directly importing the Rails application instance's | ||
# URL helpers, we can ensure the decorated methods behave consistently. | ||
include Rails.application.routes.url_helpers | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class Metadata::OaiDc::ItemDecorator < ApplicationDecorator | ||
|
||
delegate :description, :publisher, :subject, :title, :updated_at | ||
|
||
def creator | ||
object.creators | ||
end | ||
|
||
def contributor | ||
object.contributors | ||
end | ||
|
||
def rights | ||
object.license.presence || object.rights | ||
end | ||
|
||
def identifiers | ||
[item_url(object), object.doi] | ||
end | ||
|
||
def date | ||
object.creation_date | ||
end | ||
|
||
def type | ||
I18n.t("controlled_vocabularies.item_type_with_status.#{object.item_type_with_status_code}") | ||
end | ||
|
||
def languages | ||
object.languages.map { |l| h.humanize_uri(:language, l) } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class Metadata::OaiEtdms::ThesisDecorator < ApplicationDecorator | ||
|
||
delegate :degree, :subject, :title, :updated_at | ||
|
||
def creator | ||
object.dissertant | ||
end | ||
|
||
def description | ||
"Abstract: #{object.abstract}" if object.abstract.present? | ||
end | ||
|
||
def contributor | ||
object.supervisors | ||
end | ||
|
||
def type | ||
I18n.t("controlled_vocabularies.item_type_with_status.#{object.item_type_with_status_code}") | ||
end | ||
|
||
def date | ||
# TODO: need to talk to metadata about fallback if date accepted is not present, which it isn't for legacy theses | ||
object.date_accepted || object.created_at | ||
end | ||
|
||
def identifiers | ||
files = object.files.map do |file| | ||
# LAC requires that there be no spaces in the URL, for whatever questionable reasons | ||
file_view_item_url(id: file.record.id, | ||
file_set_id: file.fileset_uuid, | ||
file_name: file.filename.to_s).tr(' ', '_') | ||
end | ||
[item_url(object), object.doi, files].flatten | ||
end | ||
|
||
delegate :rights, to: :object | ||
|
||
def language | ||
h.humanize_uri(:language, object.language) | ||
end | ||
|
||
def degree_level | ||
object.thesis_level | ||
end | ||
|
||
def discipline | ||
object.departments.first | ||
end | ||
|
||
def institution | ||
h.humanize_uri(:institution, object.institution) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.