Class: DorIndexing::Indexers::WorkflowProcessIndexer

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

Overview

Creates solr doc fields (and values) for a process for a workflow (which is for an object)

Instance Method Summary collapse

Constructor Details

#initialize(solr_doc:, workflow_name:, process:) ⇒ WorkflowProcessIndexer

Returns a new instance of WorkflowProcessIndexer.

Parameters:

  • solr_doc (WorkflowSolrDocument)
  • workflow_name (String)
  • process (Dor::Workflow::Response::Process)

    containing data for a process in a workflow for an object



17
18
19
20
21
# File 'lib/dor_indexing/indexers/workflow_process_indexer.rb', line 17

def initialize(solr_doc:, workflow_name:, process:)
  @solr_doc = solr_doc
  @workflow_name = workflow_name
  @process = process
end

Instance Method Details

#to_solrHash

rubocop:disable Metrics/AbcSize

Returns:

  • (Hash)

    the partial solr document for a single workflow process



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dor_indexing/indexers/workflow_process_indexer.rb', line 25

def to_solr
  return unless status

  # add a record of the robot having operated on this item, so we can track robot activity
  solr_doc.add_process_time(workflow_name, name, Time.parse(process.datetime)) if time?

  index_error_message

  # workflow name, process status then process name
  solr_doc.add_wsp("#{workflow_name}:#{status}", "#{workflow_name}:#{status}:#{name}")

  # workflow name, process name then process status
  solr_doc.add_wps("#{workflow_name}:#{name}", "#{workflow_name}:#{name}:#{status}")

  # process status, workflowname then process name
  solr_doc.add_swp(process.status.to_s, "#{status}:#{workflow_name}", "#{status}:#{workflow_name}:#{name}")
end