class VcoWorkflows::WorkflowPresentation
WorkflowPresentation
is a helper class for Workflow
and is primarily used internally to apply additional constraints to WorkflowParameters. Currently WorkflowPresentation
examines the presentation JSON from vCO to determine whether input parameters for the workflow are required or not.
Attributes
Accessor for the data structure @return [Hash] parsed JSON
Get the list of required parameters for the workflow @return [String Array of strings (names of parameters)
Public Class Methods
Create a new WorkflowPresentation
@param [VcoWorkflows::WorkflowService] workflow_service workflow service to use @param [String] workflow_id workflow GUID @return [VcoWorkflows::WorkflowPresentation]
# File lib/vcoworkflows/workflowpresentation.rb, line 29 def initialize(workflow_service, workflow_id) @required = [] @presentation_data = JSON.parse(workflow_service.get_presentation(workflow_id)) # Determine if there are any required input parameters # We're parsing this because we specifically want to know if any of # the input parameters are marked as required. This is very specifically # in the array of hashes in: # presentation_data[:steps][0][:step][:elements][0][:fields] fields = @presentation_data['steps'][0]['step']['elements'][0]['fields'] fields.each do |attribute| next unless attribute.key?('constraints') attribute['constraints'].each do |const| if const.key?('@type') && const['@type'].eql?('mandatory') @required << attribute['id'] end end end end
Public Instance Methods
JSON document @return [String] JSON Document
# File lib/vcoworkflows/workflowpresentation.rb, line 57 def to_json JSON.pretty_generate(@presentation_data) end
String representation of the presentation @return [String]
# File lib/vcoworkflows/workflowpresentation.rb, line 51 def to_s @presentation_data.to_s end