lib/ru/fe_raw.rb in openwferu-0.9.0 vs lib/ru/fe_raw.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 $ # # @@ -62,40 +64,44 @@ @xml_element = xml_element new_environment() if not @environment_id end - def apply (workitem) - #ldebug { "apply() parent is #{@parent_id}" } + def instantiate_real_expression (workitem) attributes = extract_attributes() - #ldebug { "apply() expression_name is '#{expression_name()}'" } - #ldebug { "apply() expression_class is '#{expression_class()}'" } - - template = lookup_variable(expression_name()) - - if template and template.kind_of? OpenWFE::FlowExpressionId - get_expression_pool().launch_template(\ - self, - template, - workitem, - lookup_attributes(attributes, workitem)) - return - end - eclass = expression_class() + raise "unknown expression '#{expression_name}'" if not eclass - expression = eclass.new(@fei, @parent_id, @environment_id, @application_context, attributes) + expression = eclass.new( + @fei, + @parent_id, + @environment_id, + @application_context, + attributes) + expression.children = extract_children() expression.store_itself() - expression.apply(workitem) + return expression end + def apply (workitem) + + template = lookup_variable(expression_name()) + + if template and template.kind_of? OpenWFE::FlowExpressionId + launch_template(template, workitem) + else + expression = instantiate_real_expression(workitem) + expression.apply(workitem) + end + end + #def reply (workitem) #end def is_expression? () return false if not @xml_element.kind_of?(REXML::XMLElement) @@ -113,14 +119,24 @@ def expression_class () return get_expression_map().get_class(expression_name()) end def definition_name () - #return @xml_element.attributes['name'].to_str return @xml_element.attributes['name'].to_s end protected + + def launch_template (template, workitem) + + attributes = extract_attributes() + + get_expression_pool().launch_template(\ + self, + template, + workitem, + lookup_attributes(attributes, workitem)) + end def extract_attributes () result = {} @xml_element.attributes.each_attribute do |a| result[a.name] = a.value