lib/openwfe/worklist/storeparticipant.rb in openwferu-0.9.7 vs lib/openwfe/worklist/storeparticipant.rb in openwferu-0.9.8
- old
+ new
@@ -71,14 +71,18 @@
#
# Called by the engine (the participant expression) when handing
# out a workitem (to this participant).
#
+ # This method can also be used when delegating a workitem from
+ # one store participant to the other.
+ #
def consume (workitem)
self[workitem.flow_expression_id] = workitem
end
+ alias :push :consume
#
# Called by the participant expression when this participant is
# 'cancelled' within a flow. The workitem then gets removed.
#
@@ -110,20 +114,41 @@
def forward (workitem)
raise "Workitem not found in #{self.class}, cannot forward." \
unless self.has_key? workitem.flow_expression_id
- self.delete(workitem.flow_expression_id)
+ #self.delete(workitem.flow_expression_id)
+ self.delete(workitem)
+
reply_to_engine(workitem)
end
#
# 'proceed' is just an alias for 'forward'
#
alias :proceed :forward
#
+ # This delete() method accepts a workitem or simply its FlowExpressionId
+ # identifier.
+ #
+ def delete (wi_or_fei)
+ fei = wi_or_fei
+ fei = fei.fei if fei.is_a? InFlowWorkItem
+ super fei
+ end
+
+ #
+ # A convenience method for delegating a workitem to another
+ # store participant.
+ #
+ def delegate (wi_or_fei, other_store_participant)
+ wi = delete(wi_or_fei)
+ other_store_participant.push(wi)
+ end
+
+ #
# Returns all the workitems for a given workflow instance id.
# If no workflow_instance_id is given, all the workitems will be
# returned.
#
def list_workitems (workflow_instance_id=nil)
@@ -141,10 +166,10 @@
# Returns the first workitem at hand.
# As a StoreParticipant is usually implemented with a hash, two
# consecutive calls to this method might not return the same workitem
# (except if the store is empty or contains 1! workitem).
#
- def first_workitem ()
+ def first_workitem
result = nil
self.each_value do |workitem|
result = workitem