Class: OpenWFE::UndoExpression

Inherits:
FlowExpression show all
Defined in:
lib/openwfe/expressions/fe_do.rb

Overview

Every expression in OpenWFEru accepts a ‘tag’ attribute. This tag can later be referenced by an ‘undo’ or ‘redo’ expression. Tags are active as soon as an expression is applied and they vanish when the expression replies to its parent expression or is cancelled.

Calling for the undo of a non-existent tag throws no error, the flow simply resumes.

concurrence do
    sequence :tag => "side_job" do
        participant "alice"
        participant "bob"
    end
    sequence do
        participant "charly"
        undo :ref => "side_job"
    end
end

In this example, as soon as the participant charly is over, the sequence ‘side_job’ gets undone (cancelled). If the sequence ‘side_job’ was already over, the “undo” will have no effect.

Direct Known Subclasses

RedoExpression

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/openwfe/expressions/fe_do.rb', line 78

def apply (workitem)

    tag = lookup_tag(workitem)

    undo_self = false

    if tag
        #OpenWFE::call_in_thread(fei.expression_name, self) do
        process_tag tag
        #end

        undo_self = tag.fei.ancestor_of?(@fei)
    end

    reply_to_parent(workitem) unless undo_self
end

#process_tag(tag) ⇒ Object

Calls the expression pool cancel() method upon the tagged expression.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/openwfe/expressions/fe_do.rb', line 99

def process_tag (tag)

    ldebug do
        "process_tag() #{fei.to_debug_s} to undo #{tag.fei.to_debug_s}"
    end

    #get_expression_pool.cancel_and_reply_to_parent(
    #    tag.raw_expression.fei, tag.workitem)

    exp = get_expression_pool.fetch_expression(tag.raw_expression.fei)

    get_expression_pool.cancel(tag.raw_expression.fei)

    get_expression_pool.reply_to_parent(exp, tag.workitem, false)
        #
        # 'remove' is set to false, cancel already removed the
        # expression
end