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

#matching_checksums?, #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?, #blacklist, #conversion_options, #forced?, #not_forced?

Constructor Details

This class inherits a constructor from FedoraMigrate::Mover

Instance Method Details

#insert_date_created_by_applicationObject



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

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



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

def migrate
  return report if nil_source
  move_content
  report_results
  insert_date_created_by_application
  super
end

#move_contentObject



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

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



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

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

#results_reportObject



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

def results_report
  Report.new
end

#sparql_insertObject



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

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