Class: OpenWFE::SetValueExpression
- Inherits:
-
FlowExpression
- Object
- ObjectWithMeta
- FlowExpression
- OpenWFE::SetValueExpression
- Includes:
- ValueMixin
- Defined in:
- lib/openwfe/expressions/fe_set.rb
Overview
The ‘set’ expression is used to set the value of a (process) variable or a (workitem) field.
<set field="price" value="CHF 12.00" />
<set variable="/stage" value="3" />
<set variable="/stage" field-value="f_stage" />
<set field="stamp" value="${r:Time.now.to_i}" />
(Notice the usage of the dollar notation in the last exemple).
‘set’ expressions may be placed outside of a process-definition body, they will be evaluated sequentially before the body gets applied (executed).
Shorter attributes are OK :
<set f="price" val="CHF 12.00" />
<set v="/stage" val="3" />
<set v="/stage" field-val="f_stage" />
<set f="stamp" val="${r:Time.now.to_i}" />
set :f => "price", :val => "USD 12.50"
set :v => "toto", :val => "elvis"
In case you need the value not to be evaluated if it contains dollar expressions, you can do
set :v => "v0", :val => "my ${template} thing", :escape => true
to prevent evaluation (i.e. to escape).
Instance Attribute Summary
Attributes inherited from FlowExpression
#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation
Attributes included from Contextual
Instance Method Summary collapse
Methods included from ValueMixin
#apply, #lookup_field_attribute, #lookup_variable_attribute
Methods inherited from FlowExpression
#apply, #cancel, #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_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 Method Details
#reply(workitem) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/openwfe/expressions/fe_set.rb', line 88 def reply (workitem) vkey = lookup_variable_attribute(workitem) fkey = lookup_field_attribute(workitem) value = workitem.attributes[FIELD_RESULT] #puts "value is '#{value}'" if vkey set_variable vkey, value elsif fkey workitem.set_attribute fkey, value else raise "'variable' or 'field' attribute missing from 'set' expression" end reply_to_parent(workitem) end |