Class: OpenWFE::DefinedExpression

Inherits:
FlowExpression show all
Includes:
LookupMixin
Defined in:
lib/openwfe/expressions/fe_equals.rb

Overview

This expression class actually implements ‘defined’ and ‘undefined’.

They are some kind of ‘equals’ for validating the presence or not of a variable or a workitem field (attribute).

<if>
    <defined field="customer">
    <!-- then -->
    <subprocess ref="call_customer" />
</if>

Since OpenWFEru 0.9.17, ‘defined’ and ‘undefined’ can be easily replaced by the “is [not ]set” suffix in the dollar notation :

<if test="${f:customer_name} is set">
    <!-- then -->
    <subprocess ref="call_customer" />
</if>

Instance Attribute Summary

Attributes inherited from FlowExpression

#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation

Attributes included from Contextual

#application_context

Instance Method Summary collapse

Methods inherited from FlowExpression

#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, #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

#apply(workitem) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/openwfe/expressions/fe_equals.rb', line 251

def apply (workitem)

    fname = lookup_field(workitem, 'value') || lookup_field(workitem)

    fmatch = lookup_string_attribute(:field_match, workitem)

    vname = lookup_var(workitem, 'value') || lookup_var(workitem)

    result = if fname
        workitem.has_attribute?(fname)
    elsif vname
        lookup_variable(vname) != nil
    elsif fmatch
        field_match?(workitem, fmatch)
    else
        false # when in doubt, say 'no' (even when 'undefined' ?)
    end

    result = ( ! result) \
        if result != nil and fei.expression_name == 'undefined'

    workitem.set_result result

    reply_to_parent workitem
end