Class: Dor::Workflow::Client::Queues
- Inherits:
-
Object
- Object
- Dor::Workflow::Client::Queues
- Defined in:
- lib/dor/workflow/client/queues.rb
Overview
Makes requests relating to the workflow queues
Instance Method Summary collapse
-
#initialize(requestor:) ⇒ Queues
constructor
A new instance of Queues.
-
#lane_ids(workflow, process) ⇒ Array<String>
Returns all the distinct laneIds for a given workflow step.
-
#objects_erroring_at_workstep(error, options = {}) ⇒ Array<String>
Returns a list of druids from the workflow service that meet the criteria of the passed in error param.
-
#objects_for_workstep(completed, waiting, lane_id = 'default', options = {}) ⇒ Array<String>
Returns a list of druids from the workflow service that meet the criteria of the passed in completed and waiting params.
Constructor Details
#initialize(requestor:) ⇒ Queues
Returns a new instance of Queues.
8 9 10 |
# File 'lib/dor/workflow/client/queues.rb', line 8 def initialize(requestor:) @requestor = requestor end |
Instance Method Details
#lane_ids(workflow, process) ⇒ Array<String>
Returns all the distinct laneIds for a given workflow step
17 18 19 20 21 |
# File 'lib/dor/workflow/client/queues.rb', line 17 def lane_ids(workflow, process) uri = "workflow_queue/lane_ids?step=#{workflow}:#{process}" doc = Nokogiri::XML(requestor.request(uri)) doc.xpath('/lanes/lane').map { |n| n['id'] } end |
#objects_erroring_at_workstep(error, options = {}) ⇒ Array<String>
Returns a list of druids from the workflow service that meet the criteria of the passed in error param
93 94 95 96 97 98 99 100 |
# File 'lib/dor/workflow/client/queues.rb', line 93 def objects_erroring_at_workstep(error, = {}) uri_string = "workflow_queue?error=#{error}" uri_string += "&limit=#{[:limit].to_i}" if [:limit]&.to_i&.positive? resp = requestor.request uri_string Nokogiri::XML(resp).xpath('//object[@id]').map { |n| n[:id] } end |
#objects_for_workstep(completed, waiting, lane_id = 'default', options = {}) ⇒ Array<String>
Returns a list of druids from the workflow service that meet the criteria of the passed in completed and waiting params
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dor/workflow/client/queues.rb', line 56 def objects_for_workstep(completed, waiting, lane_id = 'default', = {}) waiting_param = qualify_step([:default_workflow], waiting) uri_string = "workflow_queue?waiting=#{waiting_param}" if completed Array(completed).each do |step| completed_param = qualify_step([:default_workflow], step) uri_string += "&completed=#{completed_param}" end end uri_string += "&limit=#{[:limit].to_i}" if [:limit]&.to_i&.positive? uri_string += "&lane-id=#{lane_id}" resp = requestor.request uri_string # # response looks like: # <objects count="2"> # <object id="druid:ab123de4567"/> # <object id="druid:ab123de9012"/> # </objects> # # convert into: # ['druid:ab123de4567', 'druid:ab123de9012'] # Nokogiri::XML(resp).xpath('//object[@id]').map { |n| n[:id] } end |