lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.15 vs lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.16
- old
+ new
@@ -99,19 +99,19 @@
class SubProcessRefExpression < FlowExpression
include ConditionMixin
names :subprocess
+ attr_accessor :subprocess_fei
+
def apply (workitem)
conditional = eval_condition(:if, workitem, :unless)
- if conditional == false
- reply_to_parent workitem
- return
- end
+ return reply_to_parent(workitem) \
+ if conditional == false
ref = lookup_ref(workitem)
raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref
@@ -122,29 +122,43 @@
raise "did not find any subprocess named '#{ref}'" \
if not template
forget = lookup_boolean_attribute(:forget, workitem)
- requester = @fei
- requester = @fei.workflow_instance_id if forget
+ requester = if forget
+ @fei.workflow_instance_id
+ else
+ @fei
+ end
params = lookup_attributes(workitem)
text = fetch_text_content(workitem, false)
params["0"] = text if text
#puts
#puts " ... params are #{params.keys.join(', ')}"
#puts " ... values are #{params.values.join(', ')}"
- get_expression_pool.launch_template(
+ sub_fei = get_expression_pool.launch_template(
requester, get_next_sub_id, template, workitem, params)
- reply_to_parent(workitem) if forget
+ if forget
+ reply_to_parent(workitem.dup)
+ else
+ @subprocess_fei = sub_fei.dup
+ store_itself # to keep track of @subprocess_fei
+ end
end
- #def reply (workitem)
- #end
+ #
+ # Takes care of cancelling the subprocess as well if any
+ #
+ def cancel
+
+ return nil unless @subprocess_fei
+ get_expression_pool.cancel @subprocess_fei
+ end
end
end