Class: OpenWFE::FilterExpression

Inherits:
FlowExpression show all
Includes:
FilterMixin
Defined in:
lib/openwfe/expressions/fe_filter.rb

Overview

This expression applies a filter to the workitem used by the process segment nested within it.

class TestFilter48a0 < ProcessDefinition
    sequence do

        set :field => "readable", :value => "bible"
        set :field => "writable", :value => "sand"
        set :field => "randw", :value => "notebook"
        set :field => "hidden", :value => "playboy"

        alice

        filter :name => "filter0" do
            sequence do
                bob
                charly
            end
        end

        doug
    end

    filter_definition :name => "filter0" do
        field :regex => "readable", :permissions => "r"
        field :regex => "writable", :permissions => "w"
        field :regex => "randw", :permissions => "rw"
        field :regex => "hidden", :permissions => ""
    end
end

In this example, the filter ‘filter0’ is applied upon entering bob and charly’s sequence.

Please note that the filter will not be enforced between bob and charly, it is enforced just before entering the sequence and just after leaving it.

Note also that the ParticipantExpression accepts a ‘filter’ attribute, thus :

<filter name="filter0">
    <participant ref="toto" />
</filter>

can be simplified to :

<participant ref="toto" filter="filter0" />

Instance Attribute Summary collapse

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 included from FilterMixin

#filter_in, #filter_out

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_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

#applied_workitemObject

Returns the value of attribute applied_workitem.



102
103
104
# File 'lib/openwfe/expressions/fe_filter.rb', line 102

def applied_workitem
  @applied_workitem
end

#filterObject

Returns the value of attribute filter.



102
103
104
# File 'lib/openwfe/expressions/fe_filter.rb', line 102

def filter
  @filter
end

Instance Method Details

#apply(workitem) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/openwfe/expressions/fe_filter.rb', line 105

def apply workitem

    if @children.length < 1
        reply_to_parent workitem
        return
    end

    @applied_workitem = workitem.dup
    filter_in workitem, :name

    store_itself

    get_expression_pool.apply @children[0], workitem
end

#reply(workitem) ⇒ Object



120
121
122
123
124
125
# File 'lib/openwfe/expressions/fe_filter.rb', line 120

def reply workitem

    filter_out workitem

    reply_to_parent workitem
end