Class: Ddr::Models::Base

Inherits:
ActiveFedora::Base
  • Object
show all
Extended by:
Deprecation
Includes:
Describable, EventLoggable, FileManagement, FixityCheckable, Governable, HasAdminMetadata, HasThumbnail, Indexing, Hydra::Validations
Defined in:
lib/ddr/models/base.rb

Direct Known Subclasses

Attachment, Collection, Component, Item, Target

Constant Summary collapse

INGEST =

Lifecycle events

"ingest.repo_object"
UPDATE =
"update.repo_object"
DELETE =
"delete.repo_object"
DEACCESSION =
"deaccession.repo_object"

Constants included from Index::Fields

Index::Fields::ACCESS_ROLE, Index::Fields::ACTIVE_FEDORA_MODEL, Index::Fields::ADMIN_SET, Index::Fields::ADMIN_SET_FACET, Index::Fields::ADMIN_SET_TITLE, Index::Fields::ALL_TEXT, Index::Fields::ARRANGER_FACET, Index::Fields::ASPACE_ID, Index::Fields::ATTACHED_FILES_HAVING_CONTENT, Index::Fields::BOX_NUMBER_FACET, Index::Fields::CATEGORY_FACET, Index::Fields::COLLECTION_FACET, Index::Fields::COLLECTION_TITLE, Index::Fields::COLLECTION_URI, Index::Fields::COMPANY_FACET, Index::Fields::COMPOSER_FACET, Index::Fields::CONTENT_CONTROL_GROUP, Index::Fields::CONTENT_CREATE_DATE, Index::Fields::CONTENT_SIZE, Index::Fields::CONTENT_SIZE_HUMAN, Index::Fields::CONTRIBUTOR_FACET, Index::Fields::CREATOR_FACET, Index::Fields::DATE_FACET, Index::Fields::DATE_SORT, Index::Fields::DC_IS_PART_OF, Index::Fields::DEPOSITOR, Index::Fields::DISPLAY_FORMAT, Index::Fields::DOI, Index::Fields::EAD_ID, Index::Fields::ENGRAVER_FACET, Index::Fields::EXTRACTED_TEXT, Index::Fields::FOLDER_FACET, Index::Fields::FORMAT_FACET, Index::Fields::GENRE_FACET, Index::Fields::HAS_MODEL, Index::Fields::ID, Index::Fields::IDENTIFIER_ALL, Index::Fields::ILLUSTRATED_FACET, Index::Fields::ILLUSTRATOR_FACET, Index::Fields::INGESTED_BY, Index::Fields::INGESTION_DATE, Index::Fields::INSTRUMENTATION_FACET, Index::Fields::INTERNAL_URI, Index::Fields::INTERVIEWER_NAME_FACET, Index::Fields::IS_ATTACHED_TO, Index::Fields::IS_EXTERNAL_TARGET_FOR, Index::Fields::IS_FORMAT_OF, Index::Fields::IS_GOVERNED_BY, Index::Fields::IS_LOCKED, Index::Fields::IS_MEMBER_OF, Index::Fields::IS_MEMBER_OF_COLLECTION, Index::Fields::IS_PART_OF, Index::Fields::LAST_FIXITY_CHECK_ON, Index::Fields::LAST_FIXITY_CHECK_OUTCOME, Index::Fields::LAST_VIRUS_CHECK_ON, Index::Fields::LAST_VIRUS_CHECK_OUTCOME, Index::Fields::LICENSE, Index::Fields::LITHOGRAPHER_FACET, Index::Fields::LOCAL_ID, Index::Fields::LYRICIST_FACET, Index::Fields::MEDIA_MAJOR_TYPE, Index::Fields::MEDIA_SUB_TYPE, Index::Fields::MEDIA_TYPE, Index::Fields::MEDIUM_FACET, Index::Fields::MULTIRES_IMAGE_FILE_PATH, Index::Fields::OBJECT_CREATE_DATE, Index::Fields::OBJECT_MODIFIED_DATE, Index::Fields::OBJECT_PROFILE, Index::Fields::OBJECT_STATE, Index::Fields::PERFORMER_FACET, Index::Fields::PERMANENT_ID, Index::Fields::PERMANENT_URL, Index::Fields::PLACEMENT_COMPANY_FACET, Index::Fields::POLICY_ROLE, Index::Fields::PRODUCER_FACET, Index::Fields::PRODUCT_FACET, Index::Fields::PUBLICATION_FACET, Index::Fields::PUBLISHER_FACET, Index::Fields::RESEARCH_HELP_CONTACT, Index::Fields::RESOURCE_ROLE, Index::Fields::RIGHTS_NOTE, Index::Fields::ROLL_NUMBER_FACET, Index::Fields::SERIES_FACET, Index::Fields::SETTING_FACET, Index::Fields::SPATIAL_FACET, Index::Fields::STRUCTURE, Index::Fields::SUBJECT_FACET, Index::Fields::SUBSERIES_FACET, Index::Fields::TECHMD_COLOR_SPACE, Index::Fields::TECHMD_CREATING_APPLICATION, Index::Fields::TECHMD_CREATION_TIME, Index::Fields::TECHMD_FILE_SIZE, Index::Fields::TECHMD_FITS_DATETIME, Index::Fields::TECHMD_FITS_VERSION, Index::Fields::TECHMD_FORMAT_LABEL, Index::Fields::TECHMD_FORMAT_VERSION, Index::Fields::TECHMD_ICC_PROFILE_NAME, Index::Fields::TECHMD_ICC_PROFILE_VERSION, Index::Fields::TECHMD_IMAGE_HEIGHT, Index::Fields::TECHMD_IMAGE_WIDTH, Index::Fields::TECHMD_MD5, Index::Fields::TECHMD_MEDIA_TYPE, Index::Fields::TECHMD_MODIFICATION_TIME, Index::Fields::TECHMD_PRONOM_IDENTIFIER, Index::Fields::TECHMD_VALID, Index::Fields::TECHMD_WELL_FORMED, Index::Fields::TEMPORAL_FACET, Index::Fields::TITLE, Index::Fields::TONE_FACET, Index::Fields::TYPE_FACET, Index::Fields::VOLUME_FACET, Index::Fields::WORKFLOW_STATE, Index::Fields::YEAR_FACET

Instance Method Summary collapse

Methods included from HasAdminMetadata

#copy_resource_roles_from, #effective_license, #effective_permissions, #finding_aid, #grant_roles_to_creator, #inherited_license, #inherited_roles, #lock, #lock!, #locked?, #research_help, #roles, #unlock, #unlock!, #workflow

Methods included from Indexing

#admin_set_facet, #admin_set_title, #all_identifiers, #associated_collection, #collection_facet, #collection_title, const_missing, #date_sort, #index_fields, #title_display, #to_solr, #year_facet

Methods included from Index::Fields

const_missing, descmd, get, techmd

Methods included from FileManagement

#add_external_datastream, #add_external_file, #add_file, #add_file_datastream, #external_datastream_file_paths, #external_datastreams

Methods included from FixityCheckable

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

Methods included from EventLoggable

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

Methods included from HasThumbnail

#copy_thumbnail_from, #thumbnail_changed?

Methods included from Governable

#copy_admin_policy_from, #inherited_permissions, #inherited_rights

Methods included from 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

#adapt_to_cmodelObject

See ActiveFedora overrides in engine initializers



67
68
69
70
71
# File 'lib/ddr/models/base.rb', line 67

def adapt_to_cmodel
  super
rescue ::TypeError
  raise ContentModelError, "Cannot adapt to nil content model."
end

#association_query(association) ⇒ Object



55
56
57
58
# File 'lib/ddr/models/base.rb', line 55

def association_query(association)
  # XXX Ideally we would include a clause to limit by AF model, but this should suffice
  ActiveFedora::SolrService.construct_query_for_rel(reflections[association].options[:property] => internal_uri)
end

#copy_admin_policy_or_permissions_from(other) ⇒ Object



45
46
47
48
49
# File 'lib/ddr/models/base.rb', line 45

def copy_admin_policy_or_permissions_from(other)
  Deprecation.warn(self.class, "`copy_admin_policy_or_permissions_from` is deprecated." \
                               " Use `copy_admin_policy_or_roles_from` instead.")
  copy_admin_policy_or_roles_from(other)
end

#copy_admin_policy_or_roles_from(other) ⇒ Object



51
52
53
# File 'lib/ddr/models/base.rb', line 51

def copy_admin_policy_or_roles_from(other)
  copy_resource_roles_from(other) unless copy_admin_policy_from(other)
end

#datastream_historyObject



96
97
98
99
100
# File 'lib/ddr/models/base.rb', line 96

def datastream_history
  datastreams_having_content.each_with_object({}) do |(dsid, ds), memo|
    memo[dsid] = ds.version_history
  end
end

#datastreams_changedObject



85
86
87
# File 'lib/ddr/models/base.rb', line 85

def datastreams_changed
  datastreams.select { |dsid, ds| ds.changed? }
end

#datastreams_having_contentObject Also known as: attached_files_having_content, datastreams_to_validate



89
90
91
# File 'lib/ddr/models/base.rb', line 89

def datastreams_having_content
  datastreams.select { |dsid, ds| ds.has_content? }
end

#deaccessionObject



39
40
41
42
43
# File 'lib/ddr/models/base.rb', line 39

def deaccession
  run_callbacks :deaccession do
    delete
  end
end

#has_extracted_text?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/ddr/models/base.rb', line 73

def has_extracted_text?
  false
end

#model_pidObject

e.g., “Collection duke:1”



61
62
63
# File 'lib/ddr/models/base.rb', line 61

def model_pid
  [self.class.to_s, pid].join(" ")
end

#publishable?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


77
78
79
# File 'lib/ddr/models/base.rb', line 77

def publishable?
  raise NotImplementedError, "Must be implemented by subclasses"
end

#save(options = {}) ⇒ Object



81
82
83
# File 'lib/ddr/models/base.rb', line 81

def save(options={})
  cache.with(options) { super }
end