class Ddr::Managers::TechnicalMetadataManager
Constants
- FITS_141_TIMESTAMP_FORMAT
- FITS_150_TIMESTAMP_FORMAT
- FITS_TIMESTAMP_FORMATS
Public Instance Methods
checksum_digest()
click to toggle source
Ddr::File currently implements the 'digest' attribute as a set (array) of Ddr::Digest objects. This method (and the 'checksum_value' method that follows) assumes there is only one checksum associated with a file (as was the case in ddr-models). The current implementation simply picks the first checksum, unless/until we decide on a different approach.
# File lib/ddr/managers/technical_metadata_manager.rb, line 77 def checksum_digest content&.digest&.first&.type end
checksum_value()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 81 def checksum_value content&.digest&.first&.value end
creation_time()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 101 def creation_time created.map { |datestr| coerce_to_time(datestr) }.compact end
file_human_size()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 61 def file_human_size file_size.map do |fs| "%s (%s bytes)" % [ ActiveSupport::NumberHelper.number_to_human_size(fs), ActiveSupport::NumberHelper.number_to_delimited(fs) ] end end
file_size()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 57 def file_size extent.map(&:to_i) end
fits()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 30 def fits if object.fits_file.present? Ddr::Fits.new(Nokogiri::XML(object.fits_file.file)) else Ddr::Fits.new(Ddr::Fits.xml_template) end end
fits?()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 38 def fits? !fits_version.nil? end
fits_datetime()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 46 def fits_datetime if fits_timestamp = fits.timestamp.first parsed = nil FITS_TIMESTAMP_FORMATS.each do |format| parsed = Time.zone.strptime(fits_timestamp, format) rescue nil break if parsed end parsed end end
fits_version()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 42 def fits_version fits.version.first end
ill_formed?()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 93 def ill_formed? well_formed.any? { |v| v == "false" } end
invalid?()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 85 def invalid? valid.any? { |v| v == "false" } end
md5()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 68 def md5 fits.md5.first end
modification_time()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 105 def modification_time modified.map { |datestr| coerce_to_time(datestr) }.compact end
valid?()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 89 def valid? !invalid? end
well_formed?()
click to toggle source
# File lib/ddr/managers/technical_metadata_manager.rb, line 97 def well_formed? !ill_formed? end
Private Instance Methods
coerce_to_time(datestr)
click to toggle source
DDRevo #######################################################
Holding off on this until we address indexing more generally, perhaps in the context of the ddr-admin staff app.
DDRevo #######################################################
def index_fields
{ Ddr::Index::Fields::TECHMD_FITS_VERSION => fits_version, Ddr::Index::Fields::TECHMD_FITS_DATETIME => Ddr::Utils.solr_date(fits_datetime), Ddr::Index::Fields::TECHMD_CREATION_TIME => Ddr::Utils.solr_dates(creation_time), Ddr::Index::Fields::TECHMD_MODIFICATION_TIME => Ddr::Utils.solr_dates(modification_time), Ddr::Index::Fields::TECHMD_COLOR_SPACE => color_space, Ddr::Index::Fields::TECHMD_CREATING_APPLICATION => creating_application, Ddr::Index::Fields::TECHMD_FILE_SIZE => file_size, Ddr::Index::Fields::TECHMD_FORMAT_LABEL => format_label, Ddr::Index::Fields::TECHMD_FORMAT_VERSION => format_version, Ddr::Index::Fields::TECHMD_ICC_PROFILE_NAME => icc_profile_name, Ddr::Index::Fields::TECHMD_ICC_PROFILE_VERSION => icc_profile_version, Ddr::Index::Fields::TECHMD_IMAGE_HEIGHT => image_height, Ddr::Index::Fields::TECHMD_IMAGE_WIDTH => image_width, Ddr::Index::Fields::TECHMD_MD5 => md5, Ddr::Index::Fields::TECHMD_MEDIA_TYPE => media_type, Ddr::Index::Fields::TECHMD_PRONOM_IDENTIFIER => pronom_identifier, Ddr::Index::Fields::TECHMD_VALID => valid, Ddr::Index::Fields::TECHMD_WELL_FORMED => well_formed, }
end
# File lib/ddr/managers/technical_metadata_manager.rb, line 137 def coerce_to_time(datestr) datestr.sub! /\A(\d+):(\d+):(\d+)/, '\1-\2-\3' DateTime.parse(datestr).to_time rescue ArgumentError nil end