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::ASPACE_ID, Index::Fields::BOX_NUMBER_FACET, Index::Fields::COLLECTION_FACET, Index::Fields::COLLECTION_URI, Index::Fields::CONTENT_CONTROL_GROUP, 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::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_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::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::POLICY_ROLE, Index::Fields::PUBLISHER_FACET, Index::Fields::RESEARCH_HELP_CONTACT, Index::Fields::RESOURCE_ROLE, Index::Fields::SERIES_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_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::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, #permanent_id_manager, #research_help, #roles, #workflow

Methods included from Indexing

#admin_set_facet, #all_identifiers, #associated_collection, #collection_facet, 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



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

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

#association_query(association) ⇒ Object



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

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



24
25
26
27
28
# File 'lib/ddr/models/base.rb', line 24

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



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

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

#has_extracted_text?Boolean

Returns:

  • (Boolean)


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

def has_extracted_text?
  false
end

#legacy_authorizationObject



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

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

#model_pidObject

e.g., “Collection duke:1”



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

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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/ddr/models/base.rb', line 80

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