Class: Ddr::Models::Base
Constant Summary
collapse
- SAVE_NOTIFICATION =
"save.base.models.ddr"
Index::Fields::ACCESS_ROLE, Index::Fields::ACTIVE_FEDORA_MODEL, Index::Fields::ADMIN_SET, Index::Fields::ADMIN_SET_FACET, Index::Fields::ALL_TEXT, Index::Fields::ASPACE_ID, Index::Fields::ATTACHED_FILES, Index::Fields::ATTACHED_FILES_HAVING_CONTENT, Index::Fields::BOX_NUMBER_FACET, Index::Fields::COLLECTION_FACET, Index::Fields::COLLECTION_URI, 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::FCREPO3_PID, Index::Fields::FORMAT_FACET, Index::Fields::HAS_MODEL, Index::Fields::ID, Index::Fields::IDENTIFIER_ALL, 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_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::ORIGINAL_FILENAME, 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_MESSAGE, 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::UNIQUE_ID, Index::Fields::WORKFLOW_STATE, Index::Fields::YEAR_FACET
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Relation
having_local_id, in_collection
#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, #all_identifiers, #associated_collection, #collection_facet, const_missing, #date_sort, #index_fields, #title_display, #to_solr, #year_facet
const_missing, descmd, get, techmd
#add_file
#events, #has_events?, #notify_event, #update_events
#copy_thumbnail_from, #thumbnail_changed?
Methods included from Governable
#copy_admin_policy_from
Class Method Details
.find_by_unique_id(unique_id) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/ddr/models/base.rb', line 30
def self.find_by_unique_id(unique_id)
if result = where(Ddr::Index::Fields::UNIQUE_ID => unique_id).first
result
else
raise ActiveFedora::ObjectNotFoundError,
"#{self} not found having unique id #{unique_id.inspect}."
end
end
|
Instance Method Details
71
72
73
|
# File 'lib/ddr/models/base.rb', line 71
def admin_metadata
@admin_metadata ||= AdministrativeMetadata.new(self)
end
|
66
67
68
69
|
# File 'lib/ddr/models/base.rb', line 66
def adminMetadata
Deprecation.warn(Base, "`adminMetadata` is deprecated; use `admin_metadata` instead.")
admin_metadata
end
|
#attached_files_having_content ⇒ Object
147
148
149
150
151
152
153
|
# File 'lib/ddr/models/base.rb', line 147
def attached_files_having_content
Hash.new.tap do |h|
attached_files.each do |file_id, file|
h[file_id] = file if !file.destroyed? && file.has_content?
end
end
end
|
#attached_files_profile ⇒ Object
129
130
131
|
# File 'lib/ddr/models/base.rb', line 129
def attached_files_profile
AttachedFilesProfile.new(self)
end
|
#check_fixity ⇒ Object
Also known as:
fixity_check
159
160
161
162
163
164
165
166
|
# File 'lib/ddr/models/base.rb', line 159
def check_fixity
FixityCheckResults.new.tap do |results|
attached_files_having_content.each_with_object(results) do |(file_id, file), memo|
results[file_id] = !!file.check_fixity
end
notify_event(:fixity_check, results: results)
end
end
|
#copy_admin_policy_or_roles_from(other) ⇒ Object
133
134
135
|
# File 'lib/ddr/models/base.rb', line 133
def copy_admin_policy_or_roles_from(other)
copy_admin_policy_from(other) || copy_resource_roles_from(other)
end
|
#datastreams_to_validate ⇒ Object
141
142
143
144
145
|
# File 'lib/ddr/models/base.rb', line 141
def datastreams_to_validate
Deprecation.warn(FixityCheckable, "`datastreams_to_validate` is deprecated." \
" Use `attached_files_having_content` instead.")
attached_files_having_content
end
|
80
81
82
|
# File 'lib/ddr/models/base.rb', line 80
def desc_metadata
@desc_metadata ||= DescriptiveMetadata.new(self)
end
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/ddr/models/base.rb', line 84
def desc_metadata_terms(*args)
return DescriptiveMetadata.unqualified_names.sort if args.empty?
arg = args.pop
terms = case arg.to_sym
when :empty
desc_metadata_terms.select { |t| desc_metadata.values(t).empty? }
when :present
desc_metadata_terms.select { |t| desc_metadata.values(t).present? }
when :defined_attributes
desc_metadata_terms & MetadataMapping.dc11.unqualified_names
when :required
desc_metadata_terms(:defined_attributes).select {|t| required? t}
when :dcterms
MetadataMapping.dc11.unqualified_names +
(MetadataMapping.dcterms.unqualified_names - MetadataMapping.dc11.unqualified_names)
when :dcterms_elements11
Ddr::Vocab::Vocabulary.term_names(::RDF::DC11)
when :duke
Ddr::Vocab::Vocabulary.term_names(Ddr::Vocab::DukeTerms)
else
raise ArgumentError, "Invalid argument: #{arg.inspect}"
end
if args.empty?
terms
else
terms | desc_metadata_terms(*args)
end
end
|
113
114
115
116
|
# File 'lib/ddr/models/base.rb', line 113
def desc_metadata_values(term)
Deprecation.warn(Base, "`desc_metadata_values` is deprecated; use `desc_metadata.values` instead.")
desc_metadata.values(term)
end
|
75
76
77
78
|
# File 'lib/ddr/models/base.rb', line 75
def descMetadata
Deprecation.warn(Base, "`descMetadata` is deprecated; use `desc_metadata` instead.")
desc_metadata
end
|
137
138
139
|
# File 'lib/ddr/models/base.rb', line 137
def
false
end
|
#inspect ⇒ Object
43
44
45
|
# File 'lib/ddr/models/base.rb', line 43
def inspect
"#<#{model_and_id}, uri: \"#{uri}\">"
end
|
#last_fixity_check ⇒ Object
170
171
172
|
# File 'lib/ddr/models/base.rb', line 170
def last_fixity_check
fixity_checks.last
end
|
#last_fixity_check_on ⇒ Object
174
175
176
|
# File 'lib/ddr/models/base.rb', line 174
def last_fixity_check_on
last_fixity_check && last_fixity_check.event_date_time
end
|
#last_fixity_check_outcome ⇒ Object
178
179
180
|
# File 'lib/ddr/models/base.rb', line 178
def last_fixity_check_outcome
last_fixity_check && last_fixity_check.outcome
end
|
#model_and_id ⇒ Object
57
58
59
|
# File 'lib/ddr/models/base.rb', line 57
def model_and_id
"#{self.class} id: #{id.inspect || '[NEW]'}"
end
|
#model_pid ⇒ Object
61
62
63
64
|
# File 'lib/ddr/models/base.rb', line 61
def model_pid
Deprecation.warn(Base, "`model_pid` is deprecated; use `model_and_id` instead.")
model_and_id
end
|
#permanent_id_suffix ⇒ Object
47
48
49
|
# File 'lib/ddr/models/base.rb', line 47
def permanent_id_suffix
permanent_id && permanent_id.sub(/\Aark:\/\d+\//, "")
end
|
#publishable? ⇒ Boolean
182
183
184
|
# File 'lib/ddr/models/base.rb', line 182
def publishable?
raise NotImplementedError, "Must be implemented by subclasses"
end
|
Update all desc_metadata terms with values in hash Note that term not having key in hash will be set to nil!
125
126
127
|
# File 'lib/ddr/models/base.rb', line 125
def set_desc_metadata(term_values_hash)
desc_metadata_terms.each { |t| desc_metadata.set_values(t, term_values_hash[t]) }
end
|
118
119
120
121
|
# File 'lib/ddr/models/base.rb', line 118
def set_desc_metadata_values(term, values)
Deprecation.warn(Base, "`set_desc_metadata_values` is deprecated; use `desc_metadata.set_values` instead.")
desc_metadata.set_values(term, values)
end
|
#unique_ids ⇒ Object
39
40
41
|
# File 'lib/ddr/models/base.rb', line 39
def unique_ids
[id, permanent_id, permanent_id_suffix].compact
end
|
#version_name ⇒ Object
189
190
191
|
# File 'lib/ddr/models/base.rb', line 189
def version_name
"version.#{Time.now.utc.strftime('%Y%m%d%H%M%S.%N')}"
end
|