Class: Collection

Inherits:
Ddr::Models::Base show all
Includes:
Ddr::Models::HasAttachments, Ddr::Models::HasChildren, Hydra::AdminPolicyBehavior
Defined in:
app/models/collection.rb

Overview

A Collection is a conceptual and administrative entity containing a set of items.

Constant Summary

Constants included from Ddr::Index::Fields

Ddr::Index::Fields::ACCESS_ROLE, Ddr::Index::Fields::ACTIVE_FEDORA_MODEL, Ddr::Index::Fields::ADMIN_SET, Ddr::Index::Fields::ADMIN_SET_FACET, Ddr::Index::Fields::BOX_NUMBER_FACET, Ddr::Index::Fields::COLLECTION_FACET, Ddr::Index::Fields::COLLECTION_URI, Ddr::Index::Fields::CONTENT_CONTROL_GROUP, Ddr::Index::Fields::CONTENT_SIZE, Ddr::Index::Fields::CONTENT_SIZE_HUMAN, Ddr::Index::Fields::CREATOR_FACET, Ddr::Index::Fields::DATE_FACET, Ddr::Index::Fields::DATE_SORT, Ddr::Index::Fields::DEPOSITOR, Ddr::Index::Fields::DISPLAY_FORMAT, Ddr::Index::Fields::DOI, Ddr::Index::Fields::EAD_ID, Ddr::Index::Fields::EXTRACTED_TEXT, Ddr::Index::Fields::HAS_MODEL, Ddr::Index::Fields::ID, Ddr::Index::Fields::IDENTIFIER_ALL, Ddr::Index::Fields::INTERNAL_URI, Ddr::Index::Fields::IS_ATTACHED_TO, Ddr::Index::Fields::IS_EXTERNAL_TARGET_FOR, Ddr::Index::Fields::IS_GOVERNED_BY, Ddr::Index::Fields::IS_MEMBER_OF, Ddr::Index::Fields::IS_MEMBER_OF_COLLECTION, Ddr::Index::Fields::IS_PART_OF, Ddr::Index::Fields::LAST_FIXITY_CHECK_ON, Ddr::Index::Fields::LAST_FIXITY_CHECK_OUTCOME, Ddr::Index::Fields::LAST_VIRUS_CHECK_ON, Ddr::Index::Fields::LAST_VIRUS_CHECK_OUTCOME, Ddr::Index::Fields::LICENSE, Ddr::Index::Fields::LOCAL_ID, Ddr::Index::Fields::MEDIA_MAJOR_TYPE, Ddr::Index::Fields::MEDIA_SUB_TYPE, Ddr::Index::Fields::MEDIA_TYPE, Ddr::Index::Fields::MULTIRES_IMAGE_FILE_PATH, Ddr::Index::Fields::OBJECT_CREATE_DATE, Ddr::Index::Fields::OBJECT_MODIFIED_DATE, Ddr::Index::Fields::OBJECT_PROFILE, Ddr::Index::Fields::OBJECT_STATE, Ddr::Index::Fields::PERMANENT_ID, Ddr::Index::Fields::PERMANENT_URL, Ddr::Index::Fields::PID, Ddr::Index::Fields::POLICY_ROLE, Ddr::Index::Fields::PUBLISHER_FACET, Ddr::Index::Fields::RESEARCH_HELP_CONTACT, Ddr::Index::Fields::RESOURCE_ROLE, Ddr::Index::Fields::SERIES_FACET, Ddr::Index::Fields::SPATIAL_FACET, Ddr::Index::Fields::STRUCT_MAPS, Ddr::Index::Fields::TECHMD_COLOR_SPACE, Ddr::Index::Fields::TECHMD_CREATING_APPLICATION, Ddr::Index::Fields::TECHMD_CREATION_TIME, Ddr::Index::Fields::TECHMD_FILE_SIZE, Ddr::Index::Fields::TECHMD_FITS_DATETIME, Ddr::Index::Fields::TECHMD_FITS_VERSION, Ddr::Index::Fields::TECHMD_FORMAT_LABEL, Ddr::Index::Fields::TECHMD_FORMAT_VERSION, Ddr::Index::Fields::TECHMD_IMAGE_HEIGHT, Ddr::Index::Fields::TECHMD_IMAGE_WIDTH, Ddr::Index::Fields::TECHMD_MEDIA_TYPE, Ddr::Index::Fields::TECHMD_MODIFICATION_TIME, Ddr::Index::Fields::TECHMD_PRONOM_IDENTIFIER, Ddr::Index::Fields::TECHMD_VALID, Ddr::Index::Fields::TECHMD_WELL_FORMED, Ddr::Index::Fields::TITLE, Ddr::Index::Fields::TYPE_FACET, Ddr::Index::Fields::WORKFLOW_STATE, Ddr::Index::Fields::YEAR_FACET

Constants included from Ddr::Index::LegacyLicenseFields

Ddr::Index::LegacyLicenseFields::DEFAULT_LICENSE_DESCRIPTION, Ddr::Index::LegacyLicenseFields::DEFAULT_LICENSE_TITLE, Ddr::Index::LegacyLicenseFields::DEFAULT_LICENSE_URL, Ddr::Index::LegacyLicenseFields::LICENSE_DESCRIPTION, Ddr::Index::LegacyLicenseFields::LICENSE_TITLE, Ddr::Index::LegacyLicenseFields::LICENSE_URL

Constants included from Ddr::Models::FileManagement

Ddr::Models::FileManagement::EXTERNAL_FILE_PERMISSIONS

Instance Method Summary collapse

Methods included from Ddr::Models::HasChildren

#first_child

Methods inherited from Ddr::Models::Base

#adapt_to_cmodel, #association_query, #copy_admin_policy_or_permissions_from, #copy_admin_policy_or_roles_from, #has_extracted_text?, #legacy_authorization, #model_pid, #move_first_identifier_to_local_id

Methods included from Ddr::Models::HasAdminMetadata

#assign_permanent_id!, #copy_resource_roles_from, #effective_license, #effective_permissions, #finding_aid, #inherited_license, #inherited_roles, #permanent_id_manager, #research_help, #roles, #workflow

Methods included from Ddr::Models::Indexing

#admin_set_facet, #all_identifiers, #associated_collection, #collection_facet, #date_sort, #index_fields, #title_display, #to_solr, #year_facet

Methods included from Ddr::Index::Fields

get, techmd

Methods included from Ddr::Models::FileManagement

#add_external_datastream, #add_external_file, #add_file, #create_external_file_path!, #external_datastream_file_paths, #external_datastreams, #generate_external_file_path

Methods included from Ddr::Models::FixityCheckable

#datastreams_to_validate, #fixity_check, #fixity_checks, #last_fixity_check, #last_fixity_check_on, #last_fixity_check_outcome

Methods included from Ddr::Models::EventLoggable

#events, #has_events?, #notify_event, #update_events

Methods included from Ddr::Models::HasThumbnail

#copy_thumbnail_from, #thumbnail_changed?

Methods included from Ddr::Models::AccessControllable

#copy_permissions_from, #set_initial_permissions

Methods included from Ddr::Models::Governable

#copy_admin_policy_from, #inherited_permissions, #inherited_rights

Methods included from Ddr::Models::Describable

#desc_metadata_attributes, #desc_metadata_terms, #desc_metadata_values, #desc_metadata_vocabs, #has_desc_metadata?, #set_desc_metadata, #set_desc_metadata_values

Instance Method Details

#components_from_solrObject

Returns the SolrDocuments for Components associated with the Collection.

Returns:

  • A lazy enumerator of SolrDocuments.



24
25
26
27
28
29
# File 'app/models/collection.rb', line 24

def components_from_solr
  query = "#{Ddr::Index::Fields::COLLECTION_URI}:#{RSolr.solr_escape(internal_uri)}"
  filter = ActiveFedora::SolrService.construct_query_for_rel(:has_model => Component.to_class_uri)
  results = ActiveFedora::SolrService.query(query, fq: filter, rows: 100000)
  results.lazy.map {|doc| SolrDocument.new(doc)}
end

#default_entities_for_permission(type, access) ⇒ Array<String>

Returns a list of entities (either users or groups) having a default access level on objects governed by the Collection.

Parameters:

  • type (String)

    the type of entity, “user” or “group”.

  • access (String)

    the default access level, “discover”, “read”, or “edit”.

Returns:

  • (Array<String>)

    the entities (users or groups)



37
38
39
# File 'app/models/collection.rb', line 37

def default_entities_for_permission(type, access)
  default_permissions.collect { |p| p[:name] if p[:type] == type and p[:access] == access }.compact
end

#grant_roles_to_creator(creator) ⇒ Object



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

def grant_roles_to_creator(creator)
  roles.grant type: Ddr::Auth::Roles::CURATOR, agent: creator.agent, scope: Ddr::Auth::Roles::RESOURCE_SCOPE
  roles.grant type: Ddr::Auth::Roles::CURATOR, agent: creator.agent, scope: Ddr::Auth::Roles::POLICY_SCOPE
end