Class: Dor::WorkflowSolrDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/models/workflow_solr_document.rb

Overview

Represents that part of the solr document that holds workflow data

Constant Summary collapse

WORKFLOW_SOLR =
'wf_ssim'
WORKFLOW_WPS_SOLR =

field that indexes workflow name, process status then process name

'wf_wps_ssim'
WORKFLOW_WSP_SOLR =

field that indexes workflow name, process name then process status

'wf_wsp_ssim'
WORKFLOW_SWP_SOLR =

field that indexes process status, workflowname then process name

'wf_swp_ssim'
WORKFLOW_ERROR_SOLR =
'wf_error_ssim'
WORKFLOW_STATUS_SOLR =
'workflow_status_ssim'
KEYS_TO_MERGE =
[
  WORKFLOW_SOLR,
  WORKFLOW_WPS_SOLR,
  WORKFLOW_WSP_SOLR,
  WORKFLOW_SWP_SOLR,
  WORKFLOW_STATUS_SOLR,
  WORKFLOW_ERROR_SOLR
].freeze

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ WorkflowSolrDocument

Returns a new instance of WorkflowSolrDocument.

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
# File 'lib/dor/models/workflow_solr_document.rb', line 25

def initialize
  @data = empty_document
  yield self if block_given?
end

Instance Method Details

#add_process_time(wf_name, process_name, time) ⇒ Object

Add the processes data_time attribute to the solr document

Parameters:

  • wf_name (String)
  • process_name (String)
  • time (Time)


63
64
65
# File 'lib/dor/models/workflow_solr_document.rb', line 63

def add_process_time(wf_name, process_name, time)
  data["wf_#{wf_name}_#{process_name}_dttsi"] = time.utc.iso8601
end

#add_swp(*messages) ⇒ Object

Add to the field that indexes process status, workflow name then process name



55
56
57
# File 'lib/dor/models/workflow_solr_document.rb', line 55

def add_swp(*messages)
  data[WORKFLOW_SWP_SOLR] += messages
end

#add_wps(*messages) ⇒ Object

Add to the field that indexes workflow name, process status then process name



45
46
47
# File 'lib/dor/models/workflow_solr_document.rb', line 45

def add_wps(*messages)
  data[WORKFLOW_WPS_SOLR] += messages
end

#add_wsp(*messages) ⇒ Object

Add to the field that indexes workflow name, process name then process status



50
51
52
# File 'lib/dor/models/workflow_solr_document.rb', line 50

def add_wsp(*messages)
  data[WORKFLOW_WSP_SOLR] += messages
end

#error=(message) ⇒ Object



40
41
42
# File 'lib/dor/models/workflow_solr_document.rb', line 40

def error=(message)
  data[WORKFLOW_ERROR_SOLR] += [message]
end

#merge!(doc) ⇒ Object

Parameters:



75
76
77
78
79
80
81
82
83
# File 'lib/dor/models/workflow_solr_document.rb', line 75

def merge!(doc)
  # This is going to get the date fields, e.g. `wf_assemblyWF_jp2-create_dttsi'
  @data.merge!(doc.except(*KEYS_TO_MERGE))

  # Combine the non-unique fields together
  KEYS_TO_MERGE.each do |k|
    data[k] += doc[k]
  end
end

#name=(wf_name) ⇒ Object



30
31
32
33
34
# File 'lib/dor/models/workflow_solr_document.rb', line 30

def name=(wf_name)
  data[WORKFLOW_SOLR] += [wf_name]
  data[WORKFLOW_WPS_SOLR] += [wf_name]
  data[WORKFLOW_WSP_SOLR] += [wf_name]
end

#status=(status) ⇒ Object



36
37
38
# File 'lib/dor/models/workflow_solr_document.rb', line 36

def status=(status)
  data[WORKFLOW_STATUS_SOLR] += [status]
end

#to_hObject



67
68
69
70
# File 'lib/dor/models/workflow_solr_document.rb', line 67

def to_h
  KEYS_TO_MERGE.each { |k| data[k].uniq! }
  data
end