Class | OpenWFE::SubProcessRefExpression |
In: |
lib/openwfe/expressions/fe_subprocess.rb
|
Parent: | FlowExpression |
This expression is used to launch/call a subprocess.
For example :
<process-definition name="subtest0" revision="0"> <sequence> <subprocess ref="sub0" a="A" b="B" c="C" /> <sub0 a="A" b="B" c="C" /> </sequence> <process-definition name="sub0"> <print>${a}${b}${c}</print> </process-definition> </process-definition>
It‘s totally OK to have URLs as referenced processes :
require 'openwfe/def' class AnotherDefinition0 < OpenWFE::ProcessDefinition def make sequence do participant ref => "toto" subprocess ref => "http://company.process.server/def0.rb" end end end
The ‘subprocess’ expression accepts a ‘forget’ attribute :
class AnotherDefinition1 < OpenWFE::ProcessDefinition sequence do subprocess :ref => "my_subprocess", :forget => true participant :ref => "ringo" end process-definition :name => "my_subprocess" do participant :ref => "fake steve jobs" end end
The ‘subprocess’ expression accepts an ‘if’ (or ‘unless’) attribute :
subprocess :ref => "interview_process", :if => "${f:screened}" # will trigger the subprocess only if the field screened # contains the string 'true' or the boolean 'true' interview_process :if => "${f:screened}" # idem interview_process :unless => "${f:has_had_problem_with_justice_?}" # well...
subprocess_fei | [RW] |
# File lib/openwfe/expressions/fe_subprocess.rb, line 107 107: def apply (workitem) 108: 109: conditional = eval_condition(:if, workitem, :unless) 110: 111: return reply_to_parent(workitem) \ 112: if conditional == false 113: 114: ref = lookup_ref workitem 115: 116: raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref 117: 118: template_uri = OpenWFE::parse_known_uri ref 119: 120: template = template_uri || lookup_variable(ref) 121: 122: raise "did not find any subprocess named '#{ref}'" \ 123: if not template 124: 125: forget = lookup_boolean_attribute :forget, workitem 126: 127: requester = if forget 128: @fei.workflow_instance_id 129: else 130: @fei 131: end 132: 133: params = lookup_attributes workitem 134: 135: text = fetch_text_content workitem, false 136: params["0"] = text if text 137: 138: #puts 139: #puts " ... params are #{params.keys.join(', ')}" 140: #puts " ... values are #{params.values.join(', ')}" 141: 142: sub_fei = get_expression_pool.launch_template( 143: requester, nil, get_next_sub_id, template, workitem, params) 144: 145: if forget 146: reply_to_parent workitem.dup 147: else 148: @subprocess_fei = sub_fei.dup 149: store_itself # to keep track of @subprocess_fei 150: end 151: end