lib/ru/expressionpool.rb in openwferu-0.9.0 vs lib/ru/expressionpool.rb in openwferu-0.9.1

- old
+ new

@@ -1,6 +1,7 @@ # +#-- # Copyright (c) 2006, John Mettraux, OpenWFE.org # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -25,10 +26,11 @@ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +#++ # # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $ # # @@ -117,23 +119,45 @@ rawexp.apply(workitem) end # - # Applies a given expression (id) + # Evaluates a raw definition expression and + # returns its body fei # - def apply (flowExpressionId, workitem) + def evaluate (rawExpression, workitem) + exp = rawExpression.instantiate_real_expression(workitem) + fei = exp.evaluate(workitem) + remove(rawExpression) + return fei + end - ldebug { "apply() #{flowExpressionId.to_debug_s}" } + # + # Applies a given expression (id or expression) + # + def apply (exp, workitem) - workitem.lastExpressionId = flowExpressionId + exp = fetch(exp) if exp.kind_of? OpenWFE::FlowExpressionId - exp = fetch(flowExpressionId) + ldebug { "apply() #{exp.fei.to_debug_s}" } + + workitem.lastExpressionId = exp.fei + exp.apply(workitem) end # + # Cancels the given expression + # + def cancel (exp) + exp = fetch(exp) if exp.kind_of? OpenWFE::FlowExpressionId + inflowitem = exp.cancel() + remove(exp) + return inflowitem + end + + # # Replies to the parent of the given expression. # def reply_to_parent (flowExpression, workitem) workitem.lastExpressionId = flowExpression.fei @@ -152,12 +176,27 @@ # # Triggers the reply expression of the expression given by its id. # def reply (flowExpressionId, workitem) - ldebug { "reply() #{flowExpressionId.to_debug_s}" } + + ldebug { "reply() to #{flowExpressionId.to_debug_s}" } + ldebug { "reply() from #{workitem.last_expression_id}" } + exp = fetch(flowExpressionId) + + if not exp + #raise \ + # "cannot reply to missing expression " + + # flowExpressionId.to_debug_s + lwarn do + "reply() cannot reply to missing "+ + flowExpressionId.to_debug_s + end + return + end + exp.reply(workitem) end # # Adds or updates a flow expression in this pool @@ -263,9 +302,13 @@ def get_expression_storage () return @application_context[S_EXPRESSION_STORAGE] end protected + + def evaluate_definition (raw_definition, workitem) + expression = raw_definition.instantiate(workitem) + end def remove_environment (environment_id) env = fetch(environment_id) env.unbind() get_expression_storage().delete(environment_id)