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(document:) ⇒ WorkflowIndexer

Returns a new instance of WorkflowIndexer.

Parameters:

  • document (Dor::WorkflowDocument)

    the workflow document to index



14
15
16
# File 'lib/dor/indexers/workflow_indexer.rb', line 14

def initialize(document:)
  @document = document
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



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dor/indexers/workflow_indexer.rb', line 19

def to_solr
  WorkflowSolrDocument.new do |solr_doc|
    wf_name = document.workflowId.first
    solr_doc.name = wf_name
    errors = processes.count(&:error?)

    repo = document.repository.first
    solr_doc.status = [wf_name, workflow_status, errors, repo].join('|')

    processes.each do |process|
      index_process(solr_doc, wf_name, process)
    end
  end
end