Skip to content

Commit

Permalink
merges CurationConcerns::Curatable into CurationConcerns::GenericWork…
Browse files Browse the repository at this point in the history
…Behavior and adds CurationConcerns::Permissions to CurationConcerns::GenericWorkBehavior
  • Loading branch information
flyingzumwalt committed Jul 13, 2015
1 parent 298fb89 commit 77b2a4c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 85 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,67 @@
module CurationConcerns::GenericWorkBehavior
extend ActiveSupport::Concern

include Hydra::Works::GenericWorkBehavior
include ::CurationConcerns::Curatable
include ::CurationConcerns::HumanReadableType
include CurationConcerns::Noid
include CurationConcerns::Permissions
include CurationConcerns::Serializers
include Hydra::WithDepositor
include Hydra::Collections::Collectible
include Solrizer::Common
include ::CurationConcerns::HasRepresentative
include ::CurationConcerns::WithGenericFiles
include Hydra::AccessControls::Embargoable
include ::CurationConcerns::WithEditors

included do
property :owner, predicate: RDF::URI.new('http://opaquenamespace.org/ns/hydra/owner'), multiple: false
class_attribute :human_readable_short_description
attr_accessor :files
end

module ClassMethods
def indexer
CurationConcerns::GenericWorkIndexingService
end
end

# Modules in Curate's CurationConcerns::Work that we _might_ pull in later
# include Curate::ActiveModelAdaptor
# include CurationConcerns::WithLinkedContributors
# include CurationConcerns::WithRelatedWorks

def to_solr(solr_doc={}, opts={})
super(solr_doc).tap do |solr_doc|
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable)
end
end

def as_rdf_object
RDF::URI.new(internal_uri)
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

def index_collection_ids(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
2 changes: 1 addition & 1 deletion spec/factories/generic_works.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
title ["Test title"]
visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE

before(:create) do |work, evaluator|
after(:build) do |work, evaluator|
work.apply_depositor_metadata(evaluator.user.user_key)
end

Expand Down

0 comments on commit 77b2a4c

Please sign in to comment.