Module: Bulkrax::ExportBehavior

Extended by:
ActiveSupport::Concern
Included in:
BagitParser, CsvParser, Entry
Defined in:
app/models/concerns/bulkrax/export_behavior.rb

Instance Method Summary collapse

Instance Method Details

#build_export_metadataObject

Raises:

  • (StandardError)


18
19
20
# File 'app/models/concerns/bulkrax/export_behavior.rb', line 18

def 
  raise StandardError, 'not implemented'
end

#build_for_exporterObject



8
9
10
11
12
13
14
15
16
# File 'app/models/concerns/bulkrax/export_behavior.rb', line 8

def build_for_exporter
  
rescue RSolr::Error::Http, CollectionsCreatedError => e
  raise e
rescue StandardError => e
  status_info(e)
else
  status_info
end

#filename(file_set) ⇒ Object

Prepend the file_set id to ensure a unique filename and also one that is not longer than 255 characters



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/concerns/bulkrax/export_behavior.rb', line 27

def filename(file_set)
  return if file_set.original_file.blank?
  fn = file_set.original_file.file_name.first
  mime = Mime::Type.lookup(file_set.original_file.mime_type)
  ext_mime = MIME::Types.of(file_set.original_file.file_name).first
  if fn.include?(file_set.id) || importerexporter.
    filename = "#{fn}.#{mime.to_sym}"
    filename = fn if mime.to_s == ext_mime.to_s
  else
    filename = "#{file_set.id}_#{fn}.#{mime.to_sym}"
    filename = "#{file_set.id}_#{fn}" if mime.to_s == ext_mime.to_s
  end
  # Remove extention truncate and reattach
  ext = File.extname(filename)
  "#{File.basename(filename, ext)[0...(220 - ext.length)]}#{ext}"
end

#hyrax_recordObject



22
23
24
# File 'app/models/concerns/bulkrax/export_behavior.rb', line 22

def hyrax_record
  @hyrax_record ||= ActiveFedora::Base.find(self.identifier)
end