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

Methods

Constants

FIELDS = [ :owfe_version, :engine_id, #:initial_engine_id, :workflow_definition_url, :workflow_definition_name, :workflow_definition_revision, :workflow_instance_id, :expression_name, :expression_id

External Aliases

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=

Public Class methods

Rebuilds a FlowExpressionId from its Hash representation.

[Source]

     # 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

An alias for to_fei(string)

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 333
333:         def self.from_s (string)
334: 
335:             to_fei string
336:         end

Splits the web fei into the workflow instance id and the expression id.

[Source]

     # 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

[Source]

     # 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

If wfid is already a ‘parent wfid’ (no sub id), returns it. Else returns the parent wfid (whatever is before the first ".").

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 342
342:         def self.to_parent_wfid (wfid)
343: 
344:             i = wfid.index(".")
345:             return wfid unless i
346:             wfid[0..i-1]
347:         end

[Source]

     # 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

Public Instance methods

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 182
182:         def dup
183: 
184:             OpenWFE::fulldup(self)
185:         end
eql?(other)

Alias for #==

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 132
132:         def hash
133: 
134:             to_s.hash
135:         end

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # 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
parent_wfid()

Returns the workflow instance id without any subflow indices. For example, if the wfid is "1234.0.1", this method will return "1234".

[Source]

     # 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)

[Source]

     # 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

[Source]

     # 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.

[Source]

     # 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.

[Source]

     # 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

Overrides the classical to_s()

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 109
109:         def to_s
110:             "(fei #{@owfe_version} #{@engine_id} #{wfurl} #{wfname} #{wfrevision} #{wfid} #{expname} #{expid})"
111:         end

Returns a very short string representation (fei wfid expid expname).

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 196
196:         def to_short_s
197:             "(fei #{wfid} #{expid} #{expname})"
198:         end

Returns a URI escaped string with just the wfid and the expid, like ‘20070917-dupibodasa__0.0.1‘

Useful for unique identifier in URIs.

[Source]

     # File lib/openwfe/flowexpressionid.rb, line 206
206:         def to_web_s
207: 
208:             eid = expid.gsub("\.", "_")
209: 
210:             URI.escape "#{wfid}__#{eid}"
211:         end

def to_yaml (opts={})

    @s = to_s
    super

end def to_yaml_properties

    [ "@s" ]

end

[Source]

    # File lib/openwfe/storage/yamlcustom.rb, line 84
84:         def to_yaml (opts={})
85: 
86:             YAML::quick_emit(self.object_id, opts) do |out|
87:                 out.map(taguri) do |map|
88:                     map.add("s", to_s)
89:                 end
90:             end
91:         end

This method return @workflow_instance_id. If parent is set to true, if will return the same result as parent_workflow_instance_id().

[Source]

    # 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

[Validate]