Class: DorIndexing::Indexers::WorkflowIndexer

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

Overview

Indexes the object’s state for each process in a single workflow

Instance Method Summary collapse

Constructor Details

#initialize(workflow:, workflow_client:) ⇒ WorkflowIndexer

Returns a new instance of WorkflowIndexer.

Parameters:

  • workflow (Workflow::Response::Workflow)

    the workflow document to index



8
9
10
11
# File 'lib/dor_indexing/indexers/workflow_indexer.rb', line 8

def initialize(workflow:, workflow_client:)
  @workflow = workflow
  @workflow_client = workflow_client
end

Instance Method Details

#to_solrHash

Returns the partial solr document for all the workflow processes.

Returns:

  • (Hash)

    the partial solr document for all the workflow processes



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dor_indexing/indexers/workflow_indexer.rb', line 14

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|
      WorkflowProcessIndexer.new(solr_doc:, workflow_name:, process:).to_solr
      errors += 1 if process.status == 'error'
    end
    solr_doc.status = [workflow_name, workflow_status, errors].join('|')
  end
end