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)


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

def 
  raise StandardError, 'not implemented'
end

#build_for_exporterObject



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

def build_for_exporter
  
rescue RSolr::Error::Http, CollectionsCreatedError => e
  raise e
rescue StandardError => e
  set_status_info(e)
else
  set_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



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

def filename(file_set)
  # NOTE: Will this work with Valkyrie?
  return if file_set.original_file.blank?
  fn = file_set.original_file.file_name.first
  mime = ::Marcel::MimeType.for(file_set.original_file.mime_type)
  ext_mime = ::Marcel::MimeType.for(file_set.original_file.file_name)
  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



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

def hyrax_record
  @hyrax_record ||= Bulkrax.object_factory.find(self.identifier)
end