class FedoraMigrate::ContentMover
Public Instance Methods
insert_date_created_by_application()
click to toggle source
# 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
migrate()
click to toggle source
Calls superclass method
# 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_content()
click to toggle source
# File lib/fedora_migrate/content_mover.rb, line 24 def move_content target.content = StringIO.new(source.content) target.original_name = source.label.try(:gsub, /"/, '\"') target.mime_type = source.mimeType save report.error = "Failed checksum" unless valid? end
report_results()
click to toggle source
# 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_report()
click to toggle source
# File lib/fedora_migrate/content_mover.rb, line 20 def results_report Report.new end
sparql_insert()
click to toggle source
# 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
Private Instance Methods
nil_source()
click to toggle source
# File lib/fedora_migrate/content_mover.rb, line 61 def nil_source return unless source.content.nil? report.error = "Nil source -- it's probably defined in the target but not present in the source" true end
perform_sparql_insert()
click to toggle source
# File lib/fedora_migrate/content_mover.rb, line 57 def perform_sparql_insert ActiveFedora.fedora.connection.patch(target.metadata.metadata_uri, sparql_insert, "Content-Type" => "application/sparql-update") end