Class: MigrateFilesToValkyrieJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/migrate_files_to_valkyrie_job.rb

Overview

Responsible for conditionally enqueuing the file and thumbnail migration logic of an ActiveFedora object.

Instance Method Summary collapse

Instance Method Details

#attribute_mappingObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/jobs/migrate_files_to_valkyrie_job.rb', line 20

def attribute_mapping
  return @attribute_mapping if @attribute_mapping
  @attribute_mapping = %w[
    aspect_ratio bit_depth bit_rate byte_order capture_device channels character_count character_set
    checksum color_map color_space compression creator data_format duration exif_version file_title
    fits_version format_label frame_rate gps_timestamp graphics_count height image_producer language
    latitude line_count longitude markup_basis markup_language offset orientation page_count
    paragraph_count profile_name profile_version recorded_size sample_rate scanning_software
    table_count well_formed width word_count ].inject({}) { |j, i| j[i] = i; j}
  @attribute_mapping['recorded_size'] = 'file_size'
  @attribute_mapping['channels'] = 'alpha_channels'
  @attribute_mapping['checksum'] = 'original_checksum'
  @attribute_mapping
end

#loggerObject

Define a logger for this job



6
7
8
9
# File 'app/jobs/migrate_files_to_valkyrie_job.rb', line 6

def logger
  FileUtils.mkdir_p(Hyrax.config.working_path)
  @logger ||= Logger.new(Hyrax.config.working_path.join('migrate_files_to_valkyrie_job.log'))
end

#perform(resource) ⇒ Object

Parameters:



13
14
15
16
17
18
# File 'app/jobs/migrate_files_to_valkyrie_job.rb', line 13

def perform(resource)
  migrate_derivatives!(resource:)
  # need to reload file_set to get the derivative ids
  resource = Hyrax.query_service.find_by(id: resource.id)
  migrate_files!(resource: resource)
end