Class: Dor::Abstract
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Dor::Abstract
- Extended by:
- Deprecation
- Defined in:
- lib/dor/models/abstract.rb
Direct Known Subclasses
Class Method Summary collapse
-
.assign_pid(_obj) ⇒ Object
Overrides the method in ActiveFedora to mint a pid using SURI rather than the default Fedora sequence.
- .has_object_type(str) ⇒ Object
Instance Method Summary collapse
-
#adapt_to_cmodel ⇒ Object
Override ActiveFedora::Core#adapt_to_cmodel (used with associations, among other places) to preferentially use the objectType asserted in the identityMetadata.
- #add_collection(collection_or_druid) ⇒ Object
-
#allows_modification? ⇒ Boolean
This is used by Argo and the MergeService.
- #current_version ⇒ Object
-
#druid_regex ⇒ Regex
a regex that can be used to identify a full druid with prefix (e.g. druid:oo000oo0001).
-
#pid_regex ⇒ Regex
a regex that can be used to identify the last part of a druid (e.g. oo000oo0001).
- #read_rights=(rights) ⇒ Object (also: #set_read_rights)
-
#reapply_admin_policy_object_defaults ⇒ Object
(also: #reapplyAdminPolicyObjectDefaults)
set the rights metadata datastream to the content of the APO’s default object rights.
- #remove_collection(collection_or_druid) ⇒ Object
-
#remove_druid_prefix(druid = id) ⇒ String
Since purl does not use the druid: prefix but much of dor does, use this function to strip the druid: if needed.
-
#to_solr ⇒ Object
Overrides the method in ActiveFedora.
Class Method Details
.assign_pid(_obj) ⇒ Object
Overrides the method in ActiveFedora to mint a pid using SURI rather than the default Fedora sequence
57 58 59 60 61 |
# File 'lib/dor/models/abstract.rb', line 57 def self.assign_pid(_obj) return Dor::SuriService.mint_id if Dor::Config.suri.mint_ids super end |
.has_object_type(str) ⇒ Object
50 51 52 53 |
# File 'lib/dor/models/abstract.rb', line 50 def self.has_object_type(str) self.object_type = str Dor.registered_classes[str] = self end |
Instance Method Details
#adapt_to_cmodel ⇒ Object
Override ActiveFedora::Core#adapt_to_cmodel (used with associations, among other places) to preferentially use the objectType asserted in the identityMetadata.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/dor/models/abstract.rb', line 70 def adapt_to_cmodel object_type = identityMetadata.objectType.first object_class = Dor.registered_classes[object_type] if object_class instance_of?(object_class) ? self : adapt_to(object_class) else begin super rescue ActiveFedora::ModelNotAsserted adapt_to(Dor::Item) end end end |
#add_collection(collection_or_druid) ⇒ Object
130 131 132 |
# File 'lib/dor/models/abstract.rb', line 130 def add_collection(collection_or_druid) collection_manager.add(collection_or_druid) end |
#allows_modification? ⇒ Boolean
this could be a workflow service endpoint
This is used by Argo and the MergeService
110 111 112 |
# File 'lib/dor/models/abstract.rb', line 110 def allows_modification? Dor::StateService.new(pid).allows_modification? end |
#current_version ⇒ Object
115 116 117 |
# File 'lib/dor/models/abstract.rb', line 115 def current_version versionMetadata.current_version_id end |
#druid_regex ⇒ Regex
a regex that can be used to identify a full druid with prefix (e.g. druid:oo000oo0001)
94 95 96 |
# File 'lib/dor/models/abstract.rb', line 94 def druid_regex /druid:#{pid_regex}/ end |
#pid_regex ⇒ Regex
a regex that can be used to identify the last part of a druid (e.g. oo000oo0001)
87 88 89 |
# File 'lib/dor/models/abstract.rb', line 87 def pid_regex /[a-zA-Z]{2}[0-9]{3}[a-zA-Z]{2}[0-9]{4}/ end |
#read_rights=(rights) ⇒ Object Also known as: set_read_rights
123 124 125 126 |
# File 'lib/dor/models/abstract.rb', line 123 def read_rights=(rights) rightsMetadata.set_read_rights(rights) unshelve_and_unpublish if rights == 'dark' end |
#reapply_admin_policy_object_defaults ⇒ Object Also known as: reapplyAdminPolicyObjectDefaults
set the rights metadata datastream to the content of the APO’s default object rights
139 140 141 |
# File 'lib/dor/models/abstract.rb', line 139 def reapply_admin_policy_object_defaults rightsMetadata.content = admin_policy_object.defaultObjectRights.content end |
#remove_collection(collection_or_druid) ⇒ Object
134 135 136 |
# File 'lib/dor/models/abstract.rb', line 134 def remove_collection(collection_or_druid) collection_manager.remove(collection_or_druid) end |
#remove_druid_prefix(druid = id) ⇒ String
Since purl does not use the druid: prefix but much of dor does, use this function to strip the druid: if needed
101 102 103 |
# File 'lib/dor/models/abstract.rb', line 101 def remove_druid_prefix(druid = id) PidUtils.remove_druid_prefix(druid) end |
#to_solr ⇒ Object
Overrides the method in ActiveFedora
64 65 66 |
# File 'lib/dor/models/abstract.rb', line 64 def to_solr resource_indexer.new(resource: self).to_solr end |