Class: AdminSet

Inherits:
ActiveFedora::Base show all
Includes:
Hydra::AccessControls::Permissions, Hydra::PCDM::CollectionBehavior, 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)

See Also:

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 Attributes collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hyrax::Permissions::Readable

#private?, #public?, #registered?

Methods included from Hyrax::Permissions::Writable

#paranoid_permissions

Methods included from Hyrax::HumanReadableType

#human_readable_type, #to_solr

Methods inherited from ActiveFedora::Base

supports_property?

Instance Attribute Details

#internal_resourceString

Returns:

  • (String)


38
# File 'app/models/admin_set.rb', line 38

class_attribute :internal_resource, default: "AdminSet"

Class Method Details

.to_rdf_representationObject



44
45
46
# File 'app/models/admin_set.rb', line 44

def self.to_rdf_representation
  internal_resource
end

Instance Method Details

#active_workflowSipity::Workflow

Returns:

Raises:

  • (ActiveRecord::RecordNotFound)


86
87
88
# File 'app/models/admin_set.rb', line 86

def active_workflow
  Sipity::Workflow.find_active_workflow_for(admin_set_id: id)
end

#assign_idObject

return an id for the AdminSet. defaults to calling Hyrax::Noid, but needs a fall back if noid is off



94
95
96
# File 'app/models/admin_set.rb', line 94

def assign_id
  super || SecureRandom.uuid
end

#collection_type_gidObject



65
66
67
68
# File 'app/models/admin_set.rb', line 65

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

#permission_templateHyrax::PermissionTemplate

A bit of an analogue for a ‘has_one :admin_set` as it crosses from Fedora to the DB

Returns:

Raises:

  • (ActiveRecord::RecordNotFound)


78
79
80
# File 'app/models/admin_set.rb', line 78

def permission_template
  Hyrax::PermissionTemplate.find_by!(source_id: id)
end

#to_rdf_representationObject



48
49
50
# File 'app/models/admin_set.rb', line 48

def to_rdf_representation
  internal_resource
end

#to_sObject



70
71
72
# File 'app/models/admin_set.rb', line 70

def to_s
  title.presence || 'No Title'
end