Class: AdminSet

Inherits:
ActiveFedora::Base show all
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)

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)


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

class_attribute :internal_resource, default: "AdminSet"

Class Method Details

.to_rdf_representationObject



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

def self.to_rdf_representation
  internal_resource
end

Instance Method Details

#active_workflowSipity::Workflow

Returns:

Raises:

  • (ActiveRecord::RecordNotFound)


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_idObject

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



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

def assign_id
  super || SecureRandom.uuid
end

#collection_type_gidObject



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

#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)


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

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

#to_rdf_representationObject



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

def to_rdf_representation
  internal_resource
end

#to_sObject



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

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