Class: Ddr::Models::Base

Inherits:
ActiveFedora::Base
  • Object
show all
Extended by:
Deprecation
Includes:
AccessControllable, 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

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::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::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::DEPOSITOR, Index::Fields::DISPLAY_FORMAT, Index::Fields::DOI, Index::Fields::EAD_ID, Index::Fields::EXTRACTED_TEXT, Index::Fields::FOLDER_FACET, Index::Fields::FORMAT_FACET, Index::Fields::HAS_MODEL, Index::Fields::ID, Index::Fields::IDENTIFIER_ALL, Index::Fields::INTERNAL_URI, Index::Fields::IS_ATTACHED_TO, Index::Fields::IS_EXTERNAL_TARGET_FOR, 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::LOCAL_ID, 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::PERMANENT_ID, Index::Fields::PERMANENT_URL, Index::Fields::PLACEMENT_COMPANY_FACET, Index::Fields::POLICY_ROLE, Index::Fields::PRODUCT_FACET, Index::Fields::PUBLICATION_FACET, Index::Fields::PUBLISHER_FACET, Index::Fields::RESEARCH_HELP_CONTACT, Index::Fields::RESOURCE_ROLE, Index::Fields::SERIES_FACET, Index::Fields::SETTING_FACET, Index::Fields::SPATIAL_FACET, Index::Fields::STRUCT_MAPS, Index::Fields::SUBJECT_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_MEDIA_TYPE, Index::Fields::TECHMD_MODIFICATION_TIME, Index::Fields::TECHMD_PRONOM_IDENTIFIER, Index::Fields::TECHMD_VALID, Index::Fields::TECHMD_WELL_FORMED, Index::Fields::TITLE, Index::Fields::TONE_FACET, Index::Fields::TYPE_FACET, Index::Fields::WORKFLOW_STATE, Index::Fields::YEAR_FACET

Constants included from FileManagement

FileManagement::EXTERNAL_FILE_PERMISSIONS

Instance Method Summary collapse

Methods included from HasAdminMetadata

#assign_permanent_id!, #copy_resource_roles_from, #effective_license, #effective_permissions, #finding_aid, #grant_roles_to_creator, #inherited_license, #inherited_roles, #lock, #lock!, #locked?, #permanent_id_manager, #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, #create_external_file_path!, #external_datastream_file_paths, #external_datastreams, #generate_external_file_path

Methods included from FixityCheckable

#datastreams_to_validate, #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 AccessControllable

#copy_permissions_from, #set_initial_permissions

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



57
58
59
60
61
# File 'lib/ddr/models/base.rb', line 57

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

#association_query(association) ⇒ Object



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

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



35
36
37
38
39
# File 'lib/ddr/models/base.rb', line 35

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



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

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

#deaccessionObject



29
30
31
32
33
# File 'lib/ddr/models/base.rb', line 29

def deaccession
  run_callbacks :deaccession do
    delete
  end
end

#has_extracted_text?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/ddr/models/base.rb', line 63

def has_extracted_text?
  false
end

#legacy_authorizationObject



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

def legacy_authorization
  Ddr::Auth::LegacyAuthorization.new(self)
end

#model_pidObject

e.g., “Collection duke:1”



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

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

#move_first_identifier_to_local_id(replace: true) ⇒ Object

Moves the first (descriptive metadata) identifier into (administrative metadata) local_id according to the following rubric:

No existing local_id:

- Set local_id to first identifier value
- Remove first identifier value

Existing local_id:

Same as first identifier value
  - Remove first identifier value
Not same as first identifier value
  :replace option is true
    - Set local_id to first identifier value
    - Remove first identifier value
  :replace option is false
    - Do nothing

Returns true or false depending on whether the object was changed by this method



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/ddr/models/base.rb', line 91

def move_first_identifier_to_local_id(replace: true)
  moved = false
  identifiers = identifier.to_a
  first_id = identifiers.shift
  if first_id
    if local_id.blank?
      self.local_id = first_id
      self.identifier = identifiers
      moved = true
    else
      if local_id == first_id
        self.identifier = identifiers
        moved = true
      else
        if replace
          self.local_id = first_id
          self.identifier = identifiers
          moved = true
        end
      end
    end
  end
  moved
end

#publishable?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


116
117
118
# File 'lib/ddr/models/base.rb', line 116

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