Class: Dor::WorkflowIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/indexers/workflow_indexer.rb

Overview

Indexes the objects position in workflows

Instance Method Summary collapse

Constructor Details

#initialize(workflow:) ⇒ WorkflowIndexer

Returns a new instance of WorkflowIndexer.

Parameters:

  • workflow (Workflow::Response::Workflow)

    the workflow document to index



7
8
9
# File 'lib/dor/indexers/workflow_indexer.rb', line 7

def initialize(workflow:)
  @workflow = workflow
end

Instance Method Details

#to_solrHash

Returns the partial solr document for the workflow document.

Returns:

  • (Hash)

    the partial solr document for the workflow document



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dor/indexers/workflow_indexer.rb', line 12

def to_solr
  WorkflowSolrDocument.new do |solr_doc|
    solr_doc.name = workflow_name

    errors = 0 # The error count is used by the Report class in Argo
    processes.each do |process|
      ProcessIndexer.new(solr_doc: solr_doc, workflow_name: workflow_name, process: process).to_solr
      errors += 1 if process.status == 'error'
    end
    solr_doc.status = [workflow_name, workflow_status, errors, repository].join('|')
  end
end