Sha256: 58c44b03f3e6de97aa2da3dbe3d6983ef4bd17f6df59c1aafc91898c937f3d6e

Contents?: true

Size: 1.45 KB

Versions: 33

Compression:

Stored size: 1.45 KB

Contents

require 'tmpdir'

module Dor
  module Preservable
    extend ActiveSupport::Concern

    included do
      has_metadata :name => 'provenanceMetadata', :type => ActiveFedora::OmDatastream, :label => 'Provenance Metadata'
      has_metadata :name => 'technicalMetadata', :type => ActiveFedora::OmDatastream, :label => 'Technical Metadata', :control_group => 'M'
    end

    def build_provenanceMetadata_datastream(workflow_id, event_text)
      workflow_provenance = create_workflow_provenance(workflow_id, event_text)
      dsname = 'provenanceMetadata'
      ds = datastreams[dsname]
      ds.label = 'Provenance Metadata' unless datastreams.keys.include?(dsname)
      ds.ng_xml = workflow_provenance
      ds.content = ds.ng_xml.to_s
      ds.save
    end

    def build_technicalMetadata_datastream(ds = nil)
      TechnicalMetadataService.add_update_technical_metadata(self)
    end

    def sdr_ingest_transfer(agreement_id)
      SdrIngestService.transfer(self, agreement_id)
    end

    # @return [Nokogiri::Document]
    def create_workflow_provenance(workflow_id, event_text)
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.provenanceMetadata(:objectId => pid) {
          xml.agent(:name => 'DOR') {
            xml.what(:object => pid) {
              xml.event(:who => "DOR-#{workflow_id}", :when => Time.new.iso8601) {
                xml.text(event_text)
              }
            }
          }
        }
      end
      builder.doc
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
dor-services-5.15.1 lib/dor/models/preservable.rb
dor-services-5.15.0 lib/dor/models/preservable.rb
dor-services-5.14.2 lib/dor/models/preservable.rb
dor-services-5.14.1 lib/dor/models/preservable.rb
dor-services-5.14.0 lib/dor/models/preservable.rb
dor-services-5.13.0 lib/dor/models/preservable.rb
dor-services-5.12.0 lib/dor/models/preservable.rb
dor-services-5.11.1 lib/dor/models/preservable.rb
dor-services-5.11.0 lib/dor/models/preservable.rb
dor-services-5.10.4 lib/dor/models/preservable.rb
dor-services-5.10.3 lib/dor/models/preservable.rb
dor-services-5.10.2 lib/dor/models/preservable.rb
dor-services-5.10.1 lib/dor/models/preservable.rb
dor-services-5.10.0 lib/dor/models/preservable.rb
dor-services-5.9.1 lib/dor/models/preservable.rb
dor-services-5.9.0 lib/dor/models/preservable.rb
dor-services-5.8.2 lib/dor/models/preservable.rb
dor-services-5.8.1 lib/dor/models/preservable.rb
dor-services-5.8.0 lib/dor/models/preservable.rb
dor-services-5.7.0 lib/dor/models/preservable.rb