lib/openwfe/flowexpressionid.rb in openwferu-0.9.15 vs lib/openwfe/flowexpressionid.rb in openwferu-0.9.16
- old
+ new
@@ -44,20 +44,21 @@
#
# A FlowExpressionId is a unique identifier for a FlowExpression (an atomic
# piece of a process instance).
#
# As workitems move through a workflow among the expressions and are emitted
- # outside of the business process engine via 'participant expressions', these
- # workitems are identified by the FlowExpressionId of the participant
- # expression that pushed them out (and is waiting for them to come back).
+ # outside of the business process engine via 'participant expressions',
+ # these workitems are identified by the FlowExpressionId of the participant
+ # expression that pushed them out (and is usually waiting for them
+ # to come back).
#
class FlowExpressionId
FIELDS = [
:owfe_version,
:engine_id,
- :initial_engine_id,
+ #:initial_engine_id,
:workflow_definition_url,
:workflow_definition_name,
:workflow_definition_revision,
:workflow_instance_id,
:expression_name,
@@ -78,20 +79,33 @@
alias :expname :expression_name
alias :wfname :workflow_definition_name
alias :wfrevision :workflow_definition_revision
#
+ # the old 'initial_engine_id' is now deprecated, the methods
+ # are still around though.
+ #
+ def initial_engine_id= (s)
+
+ # silently discard
+ end
+ def initial_engine_id
+
+ @engine_id
+ end
+
+ #
# Overrides the classical to_s()
#
- def to_s ()
- "(fei #{@owfe_version} #{@engine_id}/#{@initial_engine_id} #{@workflow_definition_url} #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_name} #{@expression_id})"
+ def to_s
+ "(fei #{@owfe_version} #{@engine_id} #{@workflow_definition_url} #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_name} #{@expression_id})"
end
#
# Returns a hash version of this FlowExpressionId instance.
#
- def to_h ()
+ def to_h
h = {}
FIELDS.each { |f| h[f] = instance_eval("@#{f.to_s}") }
h
end
@@ -105,10 +119,11 @@
FIELDS.each { |f| fei.instance_variable_set("@#{f}", h[f]) }
fei
end
def hash ()
+
to_s().hash()
end
def == (other)
@@ -122,14 +137,14 @@
@workflow_definition_url == other.workflow_definition_url and
@workflow_definition_revision == other.workflow_definition_revision and
@workflow_definition_name == other.workflow_definition_name and
@expression_name == other.expression_name and
@owfe_version == other.owfe_version and
- @engine_id == other.engine_id and
- @initial_engine_id == other.initial_engine_id
+ @engine_id == other.engine_id
+ #@initial_engine_id == other.initial_engine_id
#
- # Make sure to put on top of the 'and' the things that
+ # Made sure to put on top of the 'and' the things that
# change the most...
end
#
# Returns true if this other FlowExpressionId is nested within
@@ -188,19 +203,21 @@
#
# Yet another debugging method. Just returns the sub_instance_id and
# the expression_id, in a string.
#
def to_env_s
+
"i#{sub_instance_id} #{@expression_id}"
end
#
# Returns the workflow instance id without any subflow indices.
# For example, if the wfid is "1234.0.1", this method will
# return "1234".
#
def parent_workflow_instance_id
+
i = workflow_instance_id.index(".")
return workflow_instance_id unless i
workflow_instance_id[0..i-1]
end
@@ -211,46 +228,74 @@
# returns something like ".0" or ".1.3" if this exp id belongs to
# an expression in a subprocess.
# (Only used in some unit tests for now)
#
def sub_instance_id
+
i = workflow_instance_id.index(".")
return "" unless i
workflow_instance_id[i..-1]
end
#
+ # If this flow expression id belongs to a sub instance, a call to
+ # this method will return the last number of the sub instanceid.
+ #
+ # For example, in the case of the instance "20071114-dukikomino.1", "1"
+ # will be returned. For "20071114-dukikomino.1.0", "0" will be returned.
+ #
+ # If the flow expression id doesn't belong to a sub instance, nil
+ # will be returned.
+ #
+ def last_sub_instance_id
+
+ i = workflow_instance_id.rindex(".")
+ return nil unless i
+ workflow_instance_id[i+1..-1]
+ end
+
+ #
+ # Returns true if this flow expression id belongs to a process
+ # which is not a subprocess.
+ #
+ def is_in_parent_process?
+
+ (sub_instance_id == "")
+ end
+
+ #
# Returns the last part of the expression_id. For example, if
# the expression_id is "0.1.0.4", "4" will be returned.
#
# This method is used in "concurrence" when merging workitems coming
# backing from the children expressions.
#
def child_id
+
i = @expression_id.rindex(".")
return @expression_id unless i
@expression_id[i+1..-1]
end
#
# This class method parses a string into a FlowExpressionId instance
#
- def FlowExpressionId.to_fei (string)
+ def self.to_fei (string)
- fei = FlowExpressionId.new()
+ fei = FlowExpressionId.new
ss = string.split(" ")
#require 'pp'; puts; pp ss
ss = ss[1..-1] if ss[0] == "("
fei.owfe_version = ss[1]
ssRawEngineId = ss[2].split("/")
- fei.engine_id= ssRawEngineId[0]
- fei.initial_engine_id= ssRawEngineId[1]
+ fei.engine_id = ssRawEngineId[0]
+ #fei.initial_engine_id = ssRawEngineId[1]
fei.workflow_definition_url = ss[3]
fei.workflow_definition_name = ss[4]
fei.workflow_definition_revision = ss[5]
fei.workflow_instance_id = ss[6]
@@ -264,11 +309,12 @@
end
#
# An alias for to_fei(string)
#
- def FlowExpressionId.from_s (string)
- FlowExpressionId.to_fei(string)
+ def self.from_s (string)
+
+ to_fei string
end
end
end