Class: FedoraMigrate::ContentMover

Inherits:
Mover
  • Object
show all
Includes:
DatastreamVerification
Defined in:
lib/fedora_migrate/content_mover.rb

Defined Under Namespace

Classes: Report

Instance Attribute Summary

Attributes included from DatastreamVerification

#datastream

Attributes inherited from Mover

#report, #source, #target

Attributes included from MigrationOptions

#conversions, #options

Instance Method Summary collapse

Methods included from DatastreamVerification

#has_matching_checksums?, #has_matching_nokogiri_checksums?, #valid?

Methods inherited from Mover

#id_component, id_component, #initialize, #post_initialize, #save, #target_errors

Methods included from Hooks

#after_datastream_migration, #after_object_migration, #after_rdf_datastream_migration, #before_datastream_migration, #before_object_migration, #before_rdf_datastream_migration

Methods included from MigrationOptions

#application_creates_versions?, #conversion_options, #forced?, #not_forced?

Constructor Details

This class inherits a constructor from FedoraMigrate::Mover

Instance Method Details

#insert_date_created_by_applicationObject



38
39
40
41
42
# File 'lib/fedora_migrate/content_mover.rb', line 38

def insert_date_created_by_application
  result = perform_sparql_insert 
  report.original_date = source.createDate.iso8601
  report.error = "There was a problem with sparql #{result.status} #{result.body}" unless result.status == 204
end

#migrateObject



13
14
15
16
17
18
19
# File 'lib/fedora_migrate/content_mover.rb', line 13

def migrate
  return report if nil_source
  move_content
  report_results
  insert_date_created_by_application
  super
end

#move_contentObject



25
26
27
28
29
30
31
# File 'lib/fedora_migrate/content_mover.rb', line 25

def move_content
  target.content = source.content
  target.original_name = source.label.try(:gsub, /"/, '\"')
  target.mime_type = source.mimeType
  save
  report.error = "Failed checksum" unless valid?
end

#report_resultsObject



33
34
35
36
# File 'lib/fedora_migrate/content_mover.rb', line 33

def report_results
  report.name = target.original_name
  report.mime_type = target.mime_type
end

#results_reportObject



21
22
23
# File 'lib/fedora_migrate/content_mover.rb', line 21

def results_report
  Report.new
end

#sparql_insertObject



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fedora_migrate/content_mover.rb', line 44

def sparql_insert
<<-EOF
PREFIX premis: <http://www.loc.gov/premis/rdf/v1#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
DELETE WHERE { ?s premis:hasDateCreatedByApplication ?o } ;
INSERT {
  <> premis:hasDateCreatedByApplication "#{source.createDate.iso8601}"^^xsd:dateTime .
}
WHERE { }
EOF
end