Module: Dor::Governable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Abstract
- Defined in:
- lib/dor/models/concerns/governable.rb
Instance Method Summary collapse
- #add_collection(collection_or_druid) ⇒ Object
- #initiate_apo_workflow(name) ⇒ Object
-
#reapplyAdminPolicyObjectDefaults ⇒ Object
set the rights metadata datastream to the content of the APO’s default object rights.
- #remove_collection(collection_or_druid) ⇒ Object
- #reset_to_apo_default ⇒ Object
- #rights ⇒ Object
- #set_read_rights(rights) ⇒ Object
- #unshelve_and_unpublish ⇒ Object
Instance Method Details
#add_collection(collection_or_druid) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/dor/models/concerns/governable.rb', line 40 def add_collection(collection_or_druid) collection = case collection_or_druid when String Dor::Collection.find(collection_or_druid) when Dor::Collection collection_or_druid end collections << collection sets << collection end |
#initiate_apo_workflow(name) ⇒ Object
13 14 15 |
# File 'lib/dor/models/concerns/governable.rb', line 13 def initiate_apo_workflow(name) CreateWorkflowService.create_workflow(self, name: name, create_ds: !new_record?) end |
#reapplyAdminPolicyObjectDefaults ⇒ Object
set the rights metadata datastream to the content of the APO’s default object rights
66 67 68 |
# File 'lib/dor/models/concerns/governable.rb', line 66 def reapplyAdminPolicyObjectDefaults rightsMetadata.content = admin_policy_object.datastreams['defaultObjectRights'].content end |
#remove_collection(collection_or_druid) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dor/models/concerns/governable.rb', line 52 def remove_collection(collection_or_druid) collection = case collection_or_druid when String Dor::Collection.find(collection_or_druid) when Dor::Collection collection_or_druid end collections.delete(collection) sets.delete(collection) end |
#reset_to_apo_default ⇒ Object
18 19 20 |
# File 'lib/dor/models/concerns/governable.rb', line 18 def reset_to_apo_default rightsMetadata.content = admin_policy_object.rightsMetadata.ng_xml end |
#rights ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dor/models/concerns/governable.rb', line 70 def rights return nil unless respond_to? :rightsMetadata return nil if rightsMetadata.nil? xml = rightsMetadata.ng_xml return nil if xml.search('//rightsMetadata').length != 1 # ORLY? if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1 'Stanford' elsif xml.search('//rightsMetadata/access[@type=\'read\']/machine/world').length == 1 'World' elsif xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1 'Dark' else 'None' end end |
#set_read_rights(rights) ⇒ Object
22 23 24 25 |
# File 'lib/dor/models/concerns/governable.rb', line 22 def set_read_rights(rights) rightsMetadata.set_read_rights(rights) unshelve_and_unpublish if rights == 'dark' end |
#unshelve_and_unpublish ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dor/models/concerns/governable.rb', line 27 def unshelve_and_unpublish if respond_to? :contentMetadata content_ds = datastreams['contentMetadata'] unless content_ds.nil? content_ds.ng_xml.xpath('/contentMetadata/resource//file').each_with_index do |file_node, index| content_ds.ng_xml_will_change! if index == 0 file_node['publish'] = 'no' file_node['shelve'] = 'no' end end end end |