lib/openwfe/expressions/fe_raw.rb in openwferu-0.9.7 vs lib/openwfe/expressions/fe_raw.rb in openwferu-0.9.8
- old
+ new
@@ -79,16 +79,19 @@
# "instantiate_real_expression() exp_class is #{exp_class}"
#end
attributes = extract_attributes() unless attributes
+
expression = exp_class.new(
@fei,
@parent_id,
@environment_id,
@application_context,
attributes)
+
+ consider_tag(workitem, expression)
handle_descriptions()
expression.children = extract_children()
@@ -115,21 +118,23 @@
unless template
exp_name = OpenWFE::to_underscore(exp_name)
template = get_participant_map.lookup_participant(exp_name)
end
end
- #
- # is it a directly a participant ?
+ #
+ # is it a directly a participant ?
if template
if template.kind_of? OpenWFE::FlowExpressionId
- launch_template(template, workitem)
- return
- end
- if template.kind_of? OpenWFE::Participant
+ exp_class = OpenWFE::SubProcessRefExpression
+ attributes = extract_attributes()
+ attributes["ref"] = exp_name
+
+ elsif template.kind_of? OpenWFE::Participant
+
exp_class = OpenWFE::ParticipantExpression
attributes = extract_attributes()
attributes["ref"] = exp_name
end
end
@@ -161,23 +166,23 @@
#def reply (workitem)
# no implementation necessary
#end
def is_definition? ()
- return get_expression_map.is_definition?(expression_name())
+ get_expression_map.is_definition?(expression_name())
end
def expression_class ()
- return get_expression_map.get_class(expression_name())
+ get_expression_map.get_class(expression_name())
end
def definition_name ()
- return raw_representation.attributes['name'].to_s
+ raw_representation.attributes['name'].to_s
end
def expression_name ()
- return raw_representation.name
+ raw_representation.name
end
protected
#
@@ -204,32 +209,24 @@
set_variable "description", ds[0][1] \
unless default
end
- def launch_template (template, workitem)
+ #def launch_template (template, workitem)
+ # @attributes = extract_attributes()
+ # params = lookup_attributes(workitem)
+ # extract_text_children.each_with_index do |value, index|
+ # params[index.to_s] = value
+ # end
+ # get_expression_pool().launch_template(
+ # self,
+ # get_next_sub_id,
+ # template,
+ # workitem,
+ # params)
+ #end
- @attributes = extract_attributes()
-
- #require 'pp'
- #pp attributes
- #pp lookup_attributes(workitem, attributes)
-
- params = lookup_attributes(workitem)
-
- extract_text_children.each_with_index do |value, index|
- params[index.to_s] = value
- end
-
- get_expression_pool().launch_template(
- self,
- 0,
- template,
- workitem,
- params)
- end
-
def extract_attributes ()
raise NotImplementedError.new("'abstract method' sorry")
end
def extract_children ()
raise NotImplementedError.new("'abstract method' sorry")
@@ -240,9 +237,52 @@
def extract_parameters ()
raise NotImplementedError.new("'abstract method' sorry")
end
def extract_text_children ()
raise NotImplementedError.new("'abstract method' sorry")
+ end
+
+ #
+ # Expressions can get tagged. Tagged expressions can easily
+ # be cancelled (undone) or redone.
+ #
+ def consider_tag (workitem, new_expression)
+
+ tagname = new_expression.lookup_attribute(:tag, workitem)
+
+ return unless tagname
+
+ ldebug { "consider_tag() tag is '#{tagname}'" }
+
+ set_variable(tagname, Tag.new(self, workitem))
+ #
+ # keep copy of raw expression and workitem as applied
+
+ new_expression.attributes["tag"] = tagname
+ #
+ # making sure that the value of tag doesn't change anymore
+ end
+
+ #
+ # A small class wrapping a tag (a raw expression and the workitem
+ # it received at apply time.
+ #
+ class Tag
+
+ attr_reader \
+ :raw_expression,
+ :workitem
+
+ def flow_expression_id
+ @raw_expression.fei
+ end
+ alias :fei :flow_expression_id
+
+ def initialize (raw_expression, workitem)
+
+ @raw_expression = raw_expression.dup
+ @workitem = workitem.dup
+ end
end
#
# Encapsulating
# <parameter field="x" default="y" type="z" match="m" />