Class: DorIndexing::WorkflowSolrDocument
- Inherits:
-
Object
- Object
- DorIndexing::WorkflowSolrDocument
- Defined in:
- lib/dor_indexing/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
-
#add_process_time(wf_name, process_name, time) ⇒ Object
Add the processes data_time attribute to the solr document.
-
#add_swp(*messages) ⇒ Object
Add to the field that indexes process status, workflow name then process name.
-
#add_wps(*messages) ⇒ Object
Add to the field that indexes workflow name, process status then process name.
-
#add_wsp(*messages) ⇒ Object
Add to the field that indexes workflow name, process name then process status.
- #error=(message) ⇒ Object
-
#initialize {|_self| ... } ⇒ WorkflowSolrDocument
constructor
A new instance of WorkflowSolrDocument.
- #merge!(doc) ⇒ Object
- #name=(wf_name) ⇒ Object
- #status=(status) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ WorkflowSolrDocument
Returns a new instance of WorkflowSolrDocument.
25 26 27 28 |
# File 'lib/dor_indexing/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
63 64 65 |
# File 'lib/dor_indexing/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_indexing/workflow_solr_document.rb', line 55 def add_swp(*) data[WORKFLOW_SWP_SOLR] += end |
#add_wps(*messages) ⇒ Object
Add to the field that indexes workflow name, process status then process name
45 46 47 |
# File 'lib/dor_indexing/workflow_solr_document.rb', line 45 def add_wps(*) data[WORKFLOW_WPS_SOLR] += end |
#add_wsp(*messages) ⇒ Object
Add to the field that indexes workflow name, process name then process status
50 51 52 |
# File 'lib/dor_indexing/workflow_solr_document.rb', line 50 def add_wsp(*) data[WORKFLOW_WSP_SOLR] += end |
#error=(message) ⇒ Object
40 41 42 |
# File 'lib/dor_indexing/workflow_solr_document.rb', line 40 def error=() data[WORKFLOW_ERROR_SOLR] += [] end |
#merge!(doc) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/dor_indexing/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_indexing/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_indexing/workflow_solr_document.rb', line 36 def status=(status) data[WORKFLOW_STATUS_SOLR] += [status] end |
#to_h ⇒ Object
67 68 69 70 |
# File 'lib/dor_indexing/workflow_solr_document.rb', line 67 def to_h KEYS_TO_MERGE.each { |k| data[k].uniq! } data end |