Class: Collection
- Inherits:
-
Ddr::Models::Base
- Object
- ActiveFedora::Base
- Ddr::Models::Base
- Collection
- 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.
Provides default permissions (Hydra admin policy) for objects associated with the collection via an isGovernedBy relation.
Constant Summary
Constants included from Ddr::Auth::LegacyRoles
Ddr::Auth::LegacyRoles::LEGACY_ROLES
Constants included from Ddr::IndexFields
Ddr::IndexFields::ACTIVE_FEDORA_MODEL, Ddr::IndexFields::COLLECTION_URI, Ddr::IndexFields::CONTENT_CONTROL_GROUP, Ddr::IndexFields::CONTENT_SIZE, Ddr::IndexFields::CONTENT_SIZE_HUMAN, Ddr::IndexFields::DEFAULT_LICENSE_DESCRIPTION, Ddr::IndexFields::DEFAULT_LICENSE_TITLE, Ddr::IndexFields::DEFAULT_LICENSE_URL, Ddr::IndexFields::FILE_GROUP, Ddr::IndexFields::FILE_USE, Ddr::IndexFields::HAS_MODEL, Ddr::IndexFields::IDENTIFIER, Ddr::IndexFields::INTERNAL_URI, Ddr::IndexFields::IS_ATTACHED_TO, Ddr::IndexFields::IS_EXTERNAL_TARGET_FOR, Ddr::IndexFields::IS_GOVERNED_BY, Ddr::IndexFields::IS_MEMBER_OF, Ddr::IndexFields::IS_MEMBER_OF_COLLECTION, Ddr::IndexFields::IS_PART_OF, Ddr::IndexFields::LAST_FIXITY_CHECK_ON, Ddr::IndexFields::LAST_FIXITY_CHECK_OUTCOME, Ddr::IndexFields::LAST_VIRUS_CHECK_ON, Ddr::IndexFields::LAST_VIRUS_CHECK_OUTCOME, Ddr::IndexFields::LICENSE_DESCRIPTION, Ddr::IndexFields::LICENSE_TITLE, Ddr::IndexFields::LICENSE_URL, Ddr::IndexFields::LOCAL_ID, Ddr::IndexFields::MEDIA_MAJOR_TYPE, Ddr::IndexFields::MEDIA_SUB_TYPE, Ddr::IndexFields::MEDIA_TYPE, Ddr::IndexFields::OBJECT_CREATE_DATE, Ddr::IndexFields::OBJECT_MODIFIED_DATE, Ddr::IndexFields::OBJECT_PROFILE, Ddr::IndexFields::OBJECT_STATE, Ddr::IndexFields::ORDER, Ddr::IndexFields::PERMANENT_ID, Ddr::IndexFields::PERMANENT_URL, Ddr::IndexFields::TITLE, Ddr::IndexFields::WORKFLOW_STATE
Constants included from Ddr::Models::FileManagement
Ddr::Models::FileManagement::EXTERNAL_FILE_PERMISSIONS
Instance Method Summary collapse
-
#components_from_solr ⇒ Object
Returns the SolrDocuments for Components associated with the Collection.
-
#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.
-
#default_license ⇒ Hash
Returns the license attributes provided as default values for objects governed by the Collection.
-
#default_license=(new_license) ⇒ Object
Sets the default license attributes for objects governed by the Collection.
- #legacy_default_permissions ⇒ Object
-
#set_policy_roles ⇒ Object
Sets policy roles based on default permissions.
Methods included from Ddr::Models::HasChildren
Methods inherited from Ddr::Models::Base
#association_query, #copy_admin_policy_or_permissions_from, #model_pid
Methods included from Ddr::Models::HasAdminMetadata
#assign_permanent_id!, #permanent_id_manager, #roles, #workflow
Methods included from Ddr::Auth::LegacyRoles
#legacy_downloader_to_resource_roles, #principal_has_role?, #principals
Methods included from Ddr::Models::Indexing
#identifier_sort, #index_fields, #title_display, #to_solr
Methods included from Ddr::IndexFields
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
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::Licensable
Methods included from Ddr::Models::AccessControllable
#copy_permissions_from, #set_initial_permissions
Methods included from Ddr::Models::Governable
#copy_admin_policy_from, #inherited_license, #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_solr ⇒ Object
Returns the SolrDocuments for Components associated with the Collection.
43 44 45 46 47 48 |
# File 'app/models/collection.rb', line 43 def components_from_solr query = "#{Ddr::IndexFields::COLLECTION_URI}:#{RSolr.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.
75 76 77 |
# File 'app/models/collection.rb', line 75 def (type, access) .collect { |p| p[:name] if p[:type] == type and p[:access] == access }.compact end |
#default_license ⇒ Hash
Returns the license attributes provided as default values for objects governed by the Collection.
54 55 56 57 58 |
# File 'app/models/collection.rb', line 54 def default_license if default_license_title.present? or default_license_description.present? or default_license_url.present? {title: default_license_title, description: default_license_description, url: default_license_url} end end |
#default_license=(new_license) ⇒ Object
Sets the default license attributes for objects governed by the Collection.
61 62 63 64 65 66 67 |
# File 'app/models/collection.rb', line 61 def default_license=(new_license) raise ArgumentError unless new_license.is_a?(Hash) # XXX don't do this - not duck-typeable l = new_license.with_indifferent_access self.default_license_title = l[:title] self.default_license_description = l[:description] self.default_license_url = l[:url] end |
#legacy_default_permissions ⇒ Object
91 92 93 |
# File 'app/models/collection.rb', line 91 def Ddr::Auth::LegacyPermissions.new() end |
#set_policy_roles ⇒ Object
Sets policy roles based on default permissions
86 87 88 89 |
# File 'app/models/collection.rb', line 86 def set_policy_roles roles.revoke_policy_roles roles.grant *(.to_policy_roles) end |