Class: OpenWFE::SubProcessRefExpression
- Inherits:
-
FlowExpression
- Object
- ObjectWithMeta
- FlowExpression
- OpenWFE::SubProcessRefExpression
- Includes:
- ConditionMixin
- Defined in:
- lib/openwfe/expressions/fe_subprocess.rb
Overview
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...
Instance Attribute Summary collapse
-
#subprocess_fei ⇒ Object
Returns the value of attribute subprocess_fei.
Attributes inherited from FlowExpression
#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation
Attributes included from Contextual
Instance Method Summary collapse
- #apply(workitem) ⇒ Object
-
#cancel ⇒ Object
Takes care of cancelling the subprocess as well if any.
Methods included from ConditionMixin
#determine_condition_attribute, #eval_condition
Methods inherited from FlowExpression
#clean_children, #delete_variable, #dup_environment, #fetch_environment, #fetch_text_content, #get_binding, #get_environment, #get_parent, #get_root_environment, #has_attribute, #initialize, is_definition, is_definition?, #lookup_attribute, #lookup_attributes, #lookup_boolean_attribute, #lookup_comma_list_attribute, #lookup_downcase_attribute, #lookup_ref, #lookup_string_attribute, #lookup_sym_attribute, #lookup_value, #lookup_variable, #lookup_vf_attribute, names, #new_environment, new_exp, #owns_its_environment?, #paused?, #remove_child, #reply, #reply_to_parent, #set_variable, #store_itself, #synchronize, #to_s, #to_yaml_properties
Methods included from Contextual
#get_work_directory, #init_service, #lookup
Methods included from Logging
#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn
Methods included from OwfeServiceLocator
#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator
Methods inherited from ObjectWithMeta
#class_def, meta_def, meta_eval, metaclass
Constructor Details
This class inherits a constructor from OpenWFE::FlowExpression
Instance Attribute Details
#subprocess_fei ⇒ Object
Returns the value of attribute subprocess_fei.
104 105 106 |
# File 'lib/openwfe/expressions/fe_subprocess.rb', line 104 def subprocess_fei @subprocess_fei end |
Instance Method Details
#apply(workitem) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/openwfe/expressions/fe_subprocess.rb', line 107 def apply (workitem) conditional = eval_condition(:if, workitem, :unless) 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 template_uri = OpenWFE::parse_known_uri(ref) template = template_uri || lookup_variable(ref) raise "did not find any subprocess named '#{ref}'" \ if not template forget = lookup_boolean_attribute(:forget, workitem) 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(', ')}" sub_fei = get_expression_pool.launch_template( requester, nil, get_next_sub_id, template, workitem, params) if forget reply_to_parent(workitem.dup) else @subprocess_fei = sub_fei.dup store_itself # to keep track of @subprocess_fei end end |
#cancel ⇒ Object
Takes care of cancelling the subprocess as well if any
156 157 158 159 160 |
# File 'lib/openwfe/expressions/fe_subprocess.rb', line 156 def cancel return nil unless @subprocess_fei get_expression_pool.cancel @subprocess_fei end |