| Class | OpenWFE::FlowExpressionId |
| In: |
lib/openwfe/flowexpressionid.rb
lib/openwfe/storage/yamlcustom.rb |
| Parent: | Object |
making sure that the FlowExpressionId is serialized as a unique String
| FIELDS | = | [ :owfe_version, :engine_id, #:initial_engine_id, :workflow_definition_url, :workflow_definition_name, :workflow_definition_revision, :workflow_instance_id, :expression_name, :expression_id |
| expression_id | -> | expid |
| expression_id= | -> | expid= |
| expression_name | -> | expname |
| workflow_definition_url | -> | wfurl |
| workflow_definition_name | -> | wfname |
| workflow_definition_revision | -> | wfrevision |
| workflow_instance_id= | -> | wfid= |
Rebuilds a FlowExpressionId from its Hash representation.
# File lib/openwfe/flowexpressionid.rb, line 124
124: def FlowExpressionId.from_h (h)
125:
126: FIELDS.inject FlowExpressionId.new do |fei, f|
127: fei.instance_variable_set("@#{f}", h[f] || h[f.to_s])
128: fei
129: end
130: end
Splits the web fei into the workflow instance id and the expression id.
# File lib/openwfe/flowexpressionid.rb, line 217
217: def self.split_web_s (s)
218:
219: i = s.rindex("__")
220:
221: [ s[0..i-1], s[i+2..-1].gsub("\_", ".") ]
222: end
This class method parses a string into a FlowExpressionId instance
# File lib/openwfe/flowexpressionid.rb, line 301
301: def self.to_fei (string)
302:
303: fei = FlowExpressionId.new
304:
305: ss = string.split(" ")
306:
307: #require 'pp'; puts; pp ss
308:
309: ss = ss[1..-1] if ss[0] == "("
310:
311: fei.owfe_version = ss[1]
312:
313: ssRawEngineId = ss[2].split("/")
314: fei.engine_id = ssRawEngineId[0]
315: #fei.initial_engine_id = ssRawEngineId[1]
316:
317: fei.workflow_definition_url = ss[3]
318: fei.workflow_definition_name = ss[4]
319: fei.workflow_definition_revision = ss[5]
320: fei.workflow_instance_id = ss[6]
321: fei.expression_name = ss[7]
322: fei.expression_id = ss[8][0..-2]
323:
324: fei.expression_id = fei.expression_id[0..-2] \
325: if fei.expression_id[-1, 1] == ")"
326:
327: fei
328: end
# File lib/openwfe/storage/yamlcustom.rb, line 93
93: def FlowExpressionId.yaml_new (klass, tag, val)
94:
95: s = val["s"]
96: begin
97: FlowExpressionId.to_fei(s)
98: rescue Exception => e
99: raise "failed to decode FlowExpressionId out of '#{s}'"
100: end
101: end
# File lib/openwfe/flowexpressionid.rb, line 137
137: def == (other)
138:
139: return false if not other.kind_of?(FlowExpressionId)
140:
141: #return self.to_s == other.to_s
142: # no perf gain
143:
144: @workflow_instance_id == other.workflow_instance_id and
145: @expression_id == other.expression_id and
146: @workflow_definition_url == other.workflow_definition_url and
147: @workflow_definition_revision == other.workflow_definition_revision and
148: @workflow_definition_name == other.workflow_definition_name and
149: @expression_name == other.expression_name and
150: @owfe_version == other.owfe_version and
151: @engine_id == other.engine_id
152: #@initial_engine_id == other.initial_engine_id
153: #
154: # Made sure to put on top of the 'and' the things that
155: # change the most...
156: end
Returns true if this other FlowExpressionId is nested within this one.
For example (fei TestTag 3 20070331-goyunodabu 0.0.0 sequence) is an ancestor of (fei TestTag 3 20070331-goyunodabu 0.0.0.1 redo)
This current implementation doesn‘t cross the subprocesses boundaries.
# File lib/openwfe/flowexpressionid.rb, line 168
168: def ancestor_of? (other_fei)
169:
170: o = other_fei.dup
171: o.expression_name = @expression_name
172: o.expression_id = @expression_id
173:
174: return false unless self == o
175:
176: OpenWFE::starts_with other_fei.expression_id, @expression_id
177: 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.
# File lib/openwfe/flowexpressionid.rb, line 291
291: def child_id
292:
293: i = @expression_id.rindex(".")
294: return @expression_id unless i
295: @expression_id[i+1..-1]
296: end
Returns a deep copy of this FlowExpressionId instance.
# File lib/openwfe/flowexpressionid.rb, line 182
182: def dup
183:
184: OpenWFE::fulldup(self)
185: end
# File lib/openwfe/flowexpressionid.rb, line 101
101: def initial_engine_id
102:
103: @engine_id
104: end
the old ‘initial_engine_id’ is now deprecated, the methods are still around though.
# File lib/openwfe/flowexpressionid.rb, line 97
97: def initial_engine_id= (s)
98:
99: # silently discard
100: end
Returns true if this flow expression id belongs to a process which is not a subprocess.
# File lib/openwfe/flowexpressionid.rb, line 279
279: def is_in_parent_process?
280:
281: (sub_instance_id == "")
282: 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.
# File lib/openwfe/flowexpressionid.rb, line 268
268: def last_sub_instance_id
269:
270: i = workflow_instance_id.rindex(".")
271: return nil unless i
272: workflow_instance_id[i+1..-1]
273: end
Returns the workflow instance id without any subflow indices. For example, if the wfid is "1234.0.1", this method will return "1234".
# File lib/openwfe/flowexpressionid.rb, line 238
238: def parent_workflow_instance_id
239:
240: FlowExpressionId.to_parent_wfid workflow_instance_id
241: end
Returns "" if this expression id belongs to a top process, 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)
# File lib/openwfe/flowexpressionid.rb, line 251
251: def sub_instance_id
252:
253: i = workflow_instance_id.index(".")
254: return "" unless i
255: workflow_instance_id[i..-1]
256: end
# File lib/openwfe/flowexpressionid.rb, line 189
189: def to_debug_s
190: "(fei #{wfname} #{wfrevision} #{wfid} #{expid} #{expname})"
191: end
Yet another debugging method. Just returns the sub_instance_id and the expression_id, in a string.
# File lib/openwfe/flowexpressionid.rb, line 228
228: def to_env_s
229:
230: "i#{sub_instance_id} #{@expression_id}"
231: end
Returns a hash version of this FlowExpressionId instance.
# File lib/openwfe/flowexpressionid.rb, line 116
116: def to_h
117:
118: FIELDS.inject({}) { |r, f| r[f] = instance_eval("@#{f.to_s}"); r }
119: end
This method return @workflow_instance_id. If parent is set to true, if will return the same result as parent_workflow_instance_id().
# File lib/openwfe/flowexpressionid.rb, line 83
83: def wfid (parent=false)
84:
85: if parent
86: parent_workflow_instance_id
87: else
88: workflow_instance_id
89: end
90: end