lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.13 vs lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.14

- old
+ new

@@ -70,17 +70,49 @@ # 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... + # class SubProcessRefExpression < FlowExpression + include ConditionMixin names :subprocess def apply (workitem) + conditional = eval_condition(:if, workitem, :unless) + + if conditional == false + reply_to_parent workitem + return + end + ref = lookup_ref(workitem) raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref template_uri = OpenWFE::parse_known_uri(ref) @@ -104,9 +136,11 @@ #puts " ... params are #{params.keys.join(', ')}" #puts " ... values are #{params.values.join(', ')}" get_expression_pool.launch_template( requester, get_next_sub_id, template, workitem, params) + + reply_to_parent(workitem) if forget end #def reply (workitem) #end end