-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
1,627 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
require "bundler/gem_tasks" | ||
require 'engine_cart/rake_task' | ||
|
||
|
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,57 @@ | ||
module GenericWorkRdfProperties | ||
extend ActiveSupport::Concern | ||
included do | ||
property :part_of, predicate: RDF::DC.isPartOf | ||
property :resource_type, predicate: RDF::DC.type do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :title, predicate: RDF::DC.title do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :creator, predicate: RDF::DC.creator do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :contributor, predicate: RDF::DC.contributor do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :description, predicate: RDF::DC.description do |index| | ||
index.type :text | ||
index.as :stored_searchable | ||
end | ||
property :relation, predicate: RDF::DC.relation | ||
property :rights, predicate: RDF::DC.rights do |index| | ||
index.as :stored_searchable | ||
end | ||
property :publisher, predicate: RDF::DC.publisher do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :created, predicate: RDF::DC.created | ||
|
||
property :date, predicate: RDF::DC.date do |index| | ||
index.type :date | ||
index.as :stored_sortable | ||
end | ||
property :date_uploaded, predicate: RDF::DC.dateSubmitted do |index| | ||
index.type :date | ||
index.as :stored_sortable | ||
end | ||
property :date_modified, predicate: RDF::DC.modified do |index| | ||
index.type :date | ||
index.as :stored_sortable | ||
end | ||
property :subject, predicate: RDF::DC.subject do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :language, predicate: RDF::DC.language do |index| | ||
index.as :stored_searchable, :facetable | ||
end | ||
property :identifier, predicate: RDF::DC.identifier do |index| | ||
index.as :stored_searchable | ||
end | ||
property :bibliographic_citation, predicate: RDF::DC.bibliographicCitation | ||
property :source, predicate: RDF::DC.source | ||
property :coverage, predicate: RDF::DC.coverage | ||
property :type, predicate: RDF::DC.type | ||
property :content_format, predicate: RDF::DC.format | ||
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,3 @@ | ||
class Hydra::Works::GenericWorkMetadata < ActiveFedora::NtriplesRDFDatastream | ||
include GenericWorkRdfProperties | ||
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,27 @@ | ||
# properties datastream: catch-all for info that didn't have another home. | ||
class Hydra::Works::PropertiesDatastream < ActiveFedora::OmDatastream | ||
set_terminology do |t| | ||
t.root path: "fields" | ||
# This is where we put the user id of the object depositor | ||
t.depositor index_as: :stored_searchable | ||
t.owner | ||
|
||
# Although we aren't using these fields, they are required because sufia-models delegates to them. | ||
t.relative_path | ||
t.import_url | ||
|
||
#This attribute should hold the selected file which represent the work. | ||
t.representative | ||
end | ||
|
||
def self.xml_template | ||
builder = Nokogiri::XML::Builder.new do |xml| | ||
xml.fields | ||
end | ||
builder.doc | ||
end | ||
|
||
def prefix | ||
'properties_' | ||
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,8 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
extend ActiveSupport::Autoload | ||
|
||
autoload :Work | ||
|
||
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,77 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module Curatable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include HumanReadableType | ||
include Sufia::Noid | ||
include Sufia::ModelMethods | ||
include Hydra::Collections::Collectible | ||
include Solrizer::Common | ||
include HasRepresentative | ||
|
||
has_metadata 'properties', type: Hydra::Works::PropertiesDatastream | ||
has_attributes :relative_path, :depositor, :owner, datastream: :properties, multiple: false | ||
class_attribute :human_readable_short_description | ||
attr_accessor :files | ||
end | ||
|
||
def as_json(options) | ||
{ pid: pid, title: title, model: self.class.to_s, curation_concern_type: human_readable_type } | ||
end | ||
|
||
def as_rdf_object | ||
RDF::URI.new(internal_uri) | ||
end | ||
|
||
def to_solr(solr_doc={}, opts={}) | ||
super.tap do |solr_doc| | ||
index_collection_pids(solr_doc) | ||
solr_doc[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)] = noid | ||
add_derived_date_created(solr_doc) | ||
end | ||
end | ||
|
||
def to_s | ||
title.join(', ') | ||
end | ||
|
||
# Returns a string identifying the path associated with the object. ActionPack uses this to find a suitable partial to represent the object. | ||
def to_partial_path | ||
"curation_concern/#{super}" | ||
end | ||
|
||
def can_be_member_of_collection?(collection) | ||
collection == self ? false : true | ||
end | ||
|
||
protected | ||
|
||
# A searchable date field that is derived from the (text) field date_created | ||
def add_derived_date_created(solr_doc) | ||
if self.respond_to?(:date_created) | ||
self.class.create_and_insert_terms('date_created_derived', derived_dates, [:dateable], solr_doc) | ||
end | ||
end | ||
|
||
def derived_dates | ||
dates = Array(date_created) | ||
dates.map { |date| Curate::DateFormatter.parse(date.to_s).to_s } | ||
end | ||
|
||
def index_collection_pids(solr_doc) | ||
solr_doc[Solrizer.solr_name(:collection, :facetable)] ||= [] | ||
solr_doc[Solrizer.solr_name(:collection)] ||= [] | ||
self.collection_ids.each do |collection_id| | ||
collection_obj = ActiveFedora::Base.load_instance_from_solr(collection_id) | ||
if collection_obj.is_a?(Collection) | ||
solr_doc[Solrizer.solr_name(:collection, :facetable)] << collection_id | ||
solr_doc[Solrizer.solr_name(:collection)] << collection_id | ||
end | ||
end | ||
solr_doc | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
app/models/hydra/works/curation_concern/has_representative.rb
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,18 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module HasRepresentative | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_attributes :representative, datastream: :properties, multiple: false | ||
end | ||
|
||
def to_solr(solr_doc={}, opts={}) | ||
super.tap do |solr_doc| | ||
solr_doc[Solrizer.solr_name('representative', :stored_searchable)] = representative | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
app/models/hydra/works/curation_concern/human_readable_type.rb
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,24 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module HumanReadableType | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
class_attribute :human_readable_short_description, :human_readable_type | ||
self.human_readable_type = name.demodulize.titleize | ||
end | ||
|
||
def human_readable_type | ||
self.class.human_readable_type | ||
end | ||
|
||
def to_solr(solr_doc={}, opts={}) | ||
super(solr_doc, opts) | ||
solr_doc[Solrizer.solr_name('human_readable_type',:facetable)] = human_readable_type | ||
solr_doc[Solrizer.solr_name('human_readable_type', :stored_searchable)] = human_readable_type | ||
return solr_doc | ||
end | ||
|
||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
app/models/hydra/works/curation_concern/with_basic_metadata.rb
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,53 @@ | ||
# Basic metadata for all Works | ||
# Required fields: | ||
# dc:title | ||
# dc:rights | ||
# | ||
# Optional fields: | ||
# dc:contributor | ||
# dc:coverage | ||
# dc:creator | ||
# dc:date | ||
# dc:description | ||
# dc:format | ||
# dc:identifier | ||
# dc:language | ||
# dc:publisher | ||
# dc:relation | ||
# dc:source | ||
# dc:subject | ||
# dc:type | ||
module Hydra::Works | ||
module CurationConcern | ||
module WithBasicMetadata | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_metadata "descMetadata", type: GenericWorkMetadata | ||
# Validations that apply to all types of Work AND Collections | ||
validates_presence_of :title, message: 'Your work must have a title.' | ||
|
||
|
||
# Single-value fields | ||
has_attributes :created, :date_modified, :date_uploaded, datastream: :descMetadata, multiple: false | ||
|
||
# Multi-value fields | ||
has_attributes :contributor, :creator, :coverage, :date, :description, :content_format, :identifier, | ||
:language, :publisher, :relation, :rights, :source, :subject, :title, :type, | ||
datastream: :descMetadata, multiple: true | ||
end | ||
|
||
|
||
# TODO created and date_uploaded? | ||
# TODO created and date_created | ||
# has_attributes :date_uploaded, :date_modified, :title, :description, | ||
# datastream: :descMetadata, multiple: false | ||
# | ||
# has_attributes :related_url, :based_near, :part_of, :creator, :contributor, | ||
# :tag, :rights, :publisher, :date_created, :subject, :resource_type, | ||
# :identifier, :language, | ||
# datastream: :descMetadata, multiple: true | ||
|
||
end | ||
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,45 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module WithEditors | ||
extend ActiveSupport::Concern | ||
|
||
def add_editor_group(group_name) | ||
self.edit_groups += [group] | ||
end | ||
|
||
# @param groups [Array<String>] a list of group names to add | ||
def add_editor_groups(groups) | ||
groups.each { |g| add_editor_group(g) } | ||
end | ||
|
||
def remove_editor_group(group) | ||
self.edit_groups -= [group] | ||
end | ||
|
||
# @param groups [Array<String>] a list of users to remove | ||
def remove_editor_groups(groups) | ||
groups.each { |g| remove_editor_group(g) } | ||
end | ||
|
||
# @param user [String] the user account you want to grant edit access to. | ||
def add_editor(user) | ||
self.edit_users += [user] | ||
end | ||
|
||
# @param users [Array<String>] a list of users to add | ||
def add_editors(users) | ||
users.each { |u| add_editor(u) } | ||
end | ||
|
||
# @param user [String] the user account you want to revoke edit access for. | ||
def remove_editor(user) | ||
self.edit_users -= [user] | ||
end | ||
|
||
# @param users [Array<String>] a list of users to remove | ||
def remove_editors(users) | ||
users.each { |u| remove_editor(u) } | ||
end | ||
end | ||
end | ||
end |
24 changes: 24 additions & 0 deletions
24
app/models/hydra/works/curation_concern/with_generic_files.rb
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,24 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module WithGenericFiles | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_many :generic_files, property: :is_part_of, class_name: "Worthwhile::GenericFile" | ||
before_destroy :before_destroy_cleanup_generic_files | ||
end | ||
|
||
def before_destroy_cleanup_generic_files | ||
generic_files.each(&:destroy) | ||
end | ||
|
||
def copy_visibility_to_files | ||
generic_files.each do |gf| | ||
gf.visibility = visibility | ||
gf.save! | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
22 changes: 22 additions & 0 deletions
22
app/models/hydra/works/curation_concern/with_linked_resources.rb
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,22 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module WithLinkedResources | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
|
||
# attribute :linked_resource_urls, multiple: true | ||
attr_accessor :linked_resource_urls | ||
|
||
has_many :linked_resources, property: :is_part_of, class_name:"Worthwhile::LinkedResource" | ||
|
||
after_destroy :after_destroy_cleanup_linked_resources | ||
end | ||
|
||
def after_destroy_cleanup_linked_resources | ||
linked_resources.each(&:destroy) | ||
end | ||
|
||
end | ||
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,23 @@ | ||
module Hydra::Works | ||
module CurationConcern | ||
module Work | ||
extend ActiveSupport::Concern | ||
include Curatable | ||
include WithGenericFiles | ||
include Hydra::AccessControls::Embargoable | ||
include WithEditors | ||
include WithLinkedResources | ||
|
||
included do | ||
has_metadata "properties", type: Hydra::Works::PropertiesDatastream | ||
has_attributes :depositor, :representative, datastream: :properties, multiple: false | ||
end | ||
|
||
def to_solr(solr_doc={}, opts={}) | ||
super(solr_doc, opts) | ||
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable) | ||
return solr_doc | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.