Sha256: f90553818a1c0841d00d4bb9ced89b0e78696a21c7227121cfc690434534974e

Contents?: true

Size: 912 Bytes

Versions: 29

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module Dor
  module Workflow
    module Response
      # The response from asking the server about all workflows for an item
      class Workflows
        def initialize(xml:)
          @xml = xml
        end

        def pid
          ng_xml.at_xpath('/workflows/@objectId').text
        end

        def workflows
          @workflows ||= ng_xml.xpath('/workflows/workflow').map do |node|
            Workflow.new(xml: node.to_xml)
          end
        end

        # @return [Array<String>] returns a list of errors for any process for the current version
        def errors_for(version:)
          ng_xml.xpath("//workflow/process[@version='#{version}' and @status='error']/@errorMessage")
                .map(&:text)
        end

        attr_reader :xml

        private

        def ng_xml
          @ng_xml ||= Nokogiri::XML(@xml)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
dor-workflow-client-7.6.1 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.6.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.5.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.4.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.3.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.2.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.1.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.0.2 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.0.1 lib/dor/workflow/response/workflows.rb
dor-workflow-client-7.0.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-6.0.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-5.1.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-5.0.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-4.1.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-4.0.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-3.24.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-3.23.1 lib/dor/workflow/response/workflows.rb
dor-workflow-client-3.23.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-3.22.0 lib/dor/workflow/response/workflows.rb
dor-workflow-client-3.21.0 lib/dor/workflow/response/workflows.rb