Class: AdminSet
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- AdminSet
- Includes:
- Hydra::AccessControls::Permissions, Hyrax::HasRepresentative, Hyrax::HumanReadableType, Hyrax::Noid, Hyrax::Permissions
- Defined in:
- app/models/admin_set.rb
Overview
There is an interplay between an AdminSet and a PermissionTemplate. Given that AdminSet is an ActiveFedora::Base and PermissionTemplate is ActiveRecord::Base we don’t have the usual :has_many or :belongs_to methods to assist in defining that relationship. However, from a conceptual standpoint:
-
An AdminSet has_one :permission_tempate
-
A PermissionTemplate belongs_to :admin_set
When an object is added as a member of an AdminSet, the AdminSet’s associated PermissionTemplate is applied to that object (e.g. some of the object’s attributes are updated as per the rules of the permission template)
Constant Summary collapse
- DEFAULT_ID =
Hyrax::AdminSetCreateService::DEFAULT_ID
- DEFAULT_TITLE =
Hyrax::AdminSetCreateService::DEFAULT_TITLE
- DEFAULT_WORKFLOW_NAME =
Hyrax.config.default_active_workflow_name
Class Method Summary collapse
- .default_set?(id) ⇒ Boolean
-
.find_or_create_default_admin_set_id ⇒ Object
Creates the default AdminSet and an associated PermissionTemplate with workflow.
Instance Method Summary collapse
- #active_workflow ⇒ Sipity::Workflow
-
#assign_id ⇒ Object
return an id for the AdminSet.
- #collection_type_gid ⇒ Object
- #default_set? ⇒ Boolean
-
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB.
-
#reset_access_controls! ⇒ Object
deprecated
Deprecated.
use PermissionTemplate#reset_access_controls_for instead
- #to_s ⇒ Object
Methods included from Hyrax::Permissions::Readable
#private?, #public?, #registered?
Methods included from Hyrax::Permissions::Writable
Methods included from Hyrax::HumanReadableType
#human_readable_type, #to_solr
Methods inherited from ActiveFedora::Base
Class Method Details
.default_set?(id) ⇒ Boolean
45 46 47 48 49 |
# File 'app/models/admin_set.rb', line 45 def self.default_set?(id) Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \ "Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.") Hyrax::AdminSetCreateService.default_admin_set?(id: id) end |
.find_or_create_default_admin_set_id ⇒ Object
Creates the default AdminSet and an associated PermissionTemplate with workflow
58 59 60 61 62 |
# File 'app/models/admin_set.rb', line 58 def self.find_or_create_default_admin_set_id Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \ "Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.") Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s end |
Instance Method Details
#active_workflow ⇒ Sipity::Workflow
85 86 87 |
# File 'app/models/admin_set.rb', line 85 def active_workflow Sipity::Workflow.find_active_workflow_for(admin_set_id: id) end |
#assign_id ⇒ Object
return an id for the AdminSet. defaults to calling Hyrax::Noid, but needs a fall back if noid is off
104 105 106 |
# File 'app/models/admin_set.rb', line 104 def assign_id super || SecureRandom.uuid end |
#collection_type_gid ⇒ Object
64 65 66 67 |
# File 'app/models/admin_set.rb', line 64 def collection_type_gid # allow AdminSet to behave more like a regular Collection Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id end |
#default_set? ⇒ Boolean
51 52 53 54 55 |
# File 'app/models/admin_set.rb', line 51 def default_set? Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \ "Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.") self.class.default_set?(id) end |
#permission_template ⇒ Hyrax::PermissionTemplate
A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB
77 78 79 |
# File 'app/models/admin_set.rb', line 77 def Hyrax::PermissionTemplate.find_by!(source_id: id) end |
#reset_access_controls! ⇒ Object
use PermissionTemplate#reset_access_controls_for instead
Calculate and update who should have edit access based on who has “manage” access in the PermissionTemplateAccess
94 95 96 97 98 |
# File 'app/models/admin_set.rb', line 94 def reset_access_controls! Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls_for instead.") .reset_access_controls_for(collection: self) end |
#to_s ⇒ Object
69 70 71 |
# File 'app/models/admin_set.rb', line 69 def to_s title.presence || 'No Title' end |