Skip to content

Commit

Permalink
[WIP] Use .apply_schema to setup metadata
Browse files Browse the repository at this point in the history
Begins move of schema application to `.apply_schema`.

Further work is blocked by
ActiveTriples/ActiveTriples#255

Once a solution that aligns schema and property application with shared
code is in place,
[`ActiveFedora::Schema`](https://github.com/projecthydra/active_fedora/blob/master/lib/active_fedora/schema.rb)
should be refactored, and possibly simply removed.
  • Loading branch information
Tom Johnson committed Jan 3, 2017
1 parent b23c756 commit a399443
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 98 deletions.
10 changes: 1 addition & 9 deletions app/models/concerns/curation_concerns/admin_set_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ module AdminSetBehavior
validates_with HasOneTitleValidator
class_attribute :human_readable_short_description, :indexer
self.indexer = CurationConcerns::AdminSetIndexer
property :title, predicate: ::RDF::Vocab::DC.title do |index|
index.as :stored_searchable, :facetable
end
property :description, predicate: ::RDF::Vocab::DC.description do |index|
index.as :stored_searchable
end

property :creator, predicate: ::RDF::Vocab::DC11.creator do |index|
index.as :symbol
end
apply_schema(CurationConcerns::Schema::AdminSetMetadata)

has_many :members,
predicate: ::RDF::Vocab::DC.isPartOf,
Expand Down
65 changes: 1 addition & 64 deletions app/models/concerns/curation_concerns/basic_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,7 @@ module BasicMetadata
extend ActiveSupport::Concern

included do
property :label, predicate: ActiveFedora::RDF::Fcrepo::Model.downloadFilename, multiple: false

property :relative_path, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath'), multiple: false

property :import_url, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl'), multiple: false do |index|
index.as :symbol
end

property :part_of, predicate: ::RDF::Vocab::DC.isPartOf
property :resource_type, predicate: ::RDF::Vocab::DC.type do |index|
index.as :stored_searchable, :facetable
end
property :creator, predicate: ::RDF::Vocab::DC11.creator do |index|
index.as :stored_searchable, :facetable
end
property :contributor, predicate: ::RDF::Vocab::DC11.contributor do |index|
index.as :stored_searchable, :facetable
end
property :description, predicate: ::RDF::Vocab::DC11.description do |index|
index.type :text
index.as :stored_searchable
end
property :keyword, predicate: ::RDF::Vocab::DC11.relation do |index|
index.as :stored_searchable, :facetable
end

# Used for a license
property :rights, predicate: ::RDF::Vocab::DC.rights do |index|
index.as :stored_searchable
end

# This is for the rights statement
property :rights_statement, predicate: ::RDF::Vocab::EDM.rights do |index|
index.as :stored_searchable
end

property :publisher, predicate: ::RDF::Vocab::DC11.publisher do |index|
index.as :stored_searchable, :facetable
end
property :date_created, predicate: ::RDF::Vocab::DC.created do |index|
index.as :stored_searchable
end

property :subject, predicate: ::RDF::Vocab::DC11.subject do |index|
index.as :stored_searchable, :facetable
end
property :language, predicate: ::RDF::Vocab::DC11.language do |index|
index.as :stored_searchable, :facetable
end
property :identifier, predicate: ::RDF::Vocab::DC.identifier do |index|
index.as :stored_searchable
end
property :based_near, predicate: ::RDF::Vocab::FOAF.based_near do |index|
index.as :stored_searchable, :facetable
end
property :related_url, predicate: ::RDF::RDFS.seeAlso do |index|
index.as :stored_searchable
end
property :bibliographic_citation, predicate: ::RDF::Vocab::DC.bibliographicCitation do |index|
index.as :stored_searchable
end
property :source, predicate: ::RDF::Vocab::DC.source do |index|
index.as :stored_searchable
end
apply_schema(CurationConcerns::Schema::BasicMetadata)
end
end
end
23 changes: 1 addition & 22 deletions app/models/concerns/curation_concerns/required_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,11 @@ module RequiredMetadata
extend ActiveSupport::Concern

included do
property :depositor, predicate: ::RDF::URI.new('http://id.loc.gov/vocabulary/relators/dpt'), multiple: false do |index|
index.as :symbol, :stored_searchable
end

property :title, predicate: ::RDF::Vocab::DC.title do |index|
index.as :stored_searchable, :facetable
end
apply_schema(CurationConcerns::Schema::RequiredMetadata)

def first_title
title.first
end

# We reserve date_uploaded for the original creation date of the record.
# For example, when migrating data from a fedora3 repo to fedora4,
# fedora's system created date will reflect the date when the record
# was created in fedora4, but the date_uploaded will preserve the
# original creation date from the old repository.
property :date_uploaded, predicate: ::RDF::Vocab::DC.dateSubmitted, multiple: false do |index|
index.type :date
index.as :stored_sortable
end

property :date_modified, predicate: ::RDF::Vocab::DC.modified, multiple: false do |index|
index.type :date
index.as :stored_sortable
end
end
end
end
3 changes: 1 addition & 2 deletions app/models/concerns/curation_concerns/suppressible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ module Suppressible
extend ActiveSupport::Concern

included do
# This holds the workflow state
property :state, predicate: Vocab::FedoraResourceStatus.objState, multiple: false
apply_schema(CurationConcerns::Schema::SuppressibleMetadata)
end

##
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/curation_concerns/work_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module CurationConcerns::WorkBehavior
include CurationConcerns::Suppressible

included do
property :owner, predicate: RDF::URI.new('http://opaquenamespace.org/ns/hydra/owner'), multiple: false
apply_schema(ActiveTriples::Schema::WorkMetadata)
class_attribute :human_readable_short_description, :indexer
self.indexer = CurationConcerns::WorkIndexer
end
Expand Down

0 comments on commit a399443

Please sign in to comment.