public
Description: the [OpenWFEru] workflow and BPM engine (ruby)
Homepage: http://openwferu.rubyforge.org
Clone URL: git://github.com/jmettraux/ruote.git
todo #20221 : added engine.process_representation(wfid) method
jmettraux (author)
Tue May 20 18:35:50 -0700 2008
commit  65dcec6140eb29ef8744b94f08d2a3ce0cd2b658
tree    eefeefff5993faf3f3025926071240227ac5fd42
parent  68c08ec0484b93c26212bfaecb0573c1a89bf908
...
4
5
6
 
7
8
9
...
4
5
6
7
8
9
10
0
@@ -4,6 +4,7 @@
0
 
0
 == OpenWFEru - 0.9.18 not yet released
0
 
0
+- todo #20221 : added engine.process_representation(wfid) method
0
 - todo #20244 : 'description' is now an expression like any other
0
 - todo #20228 : made sure removed expressions did not appear in
0
                  process_stack.representation()
...
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
74
75
76
...
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
0
@@ -71,6 +71,18 @@ module OpenWFE
0
         alias :get_flow_stack :process_stack
0
 
0
         #
0
+ # A shortcut for process_stack(wfid, true).representation
0
+ #
0
+ # Returns the representation (tree) for the actual version of the
0
+ # given process instance (returns the tree as running, modifications
0
+ # included).
0
+ #
0
+ def process_representation (workflow_instance_id)
0
+
0
+ process_stack(workflow_instance_id, true).representation
0
+ end
0
+
0
+ #
0
         # Lists all workflow (process) instances currently in the expool (in
0
         # the engine).
0
         # This method will return a list of "process-definition" expressions
...
2
3
4
5
6
 
 
7
8
 
9
10
11
12
13
 
 
 
 
14
15
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
 
 
 
 
 
 
 
 
 
 
30
31
32
...
36
37
38
39
 
40
41
42
...
84
85
86
87
88
89
90
...
129
130
131
132
 
133
134
 
135
136
137
138
 
139
140
141
142
143
144
 
 
145
146
147
...
192
193
194
195
196
 
 
197
198
199
 
200
201
202
...
245
246
247
248
 
249
250
251
...
258
259
260
261
 
262
263
264
...
287
288
289
290
 
291
292
293
...
326
327
328
329
 
330
331
332
...
369
370
371
372
 
373
374
375
...
381
382
383
384
 
385
386
387
...
404
405
406
407
 
408
409
410
411
412
413
414
415
416
 
 
 
 
417
418
419
...
450
451
452
453
 
454
455
456
...
491
492
493
494
 
495
496
497
...
607
608
609
610
 
611
612
613
614
615
616
 
617
618
 
619
620
 
621
622
 
623
624
625
626
 
 
627
628
629
...
641
642
643
644
 
645
646
647
...
700
701
702
703
 
704
705
706
...
2
3
4
 
 
5
6
7
 
8
9
 
 
 
 
10
11
12
13
14
 
15
16
17
18
 
 
 
 
 
 
 
 
 
 
 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
36
37
38
 
39
40
41
42
...
84
85
86
 
87
88
89
...
128
129
130
 
131
132
 
133
134
135
136
 
137
138
139
140
141
 
 
142
143
144
145
146
...
191
192
193
 
 
194
195
196
197
 
198
199
200
201
...
244
245
246
 
247
248
249
250
...
257
258
259
 
260
261
262
263
...
286
287
288
 
289
290
291
292
...
325
326
327
 
328
329
330
331
...
368
369
370
 
371
372
373
374
...
380
381
382
 
383
384
385
386
...
403
404
405
 
406
407
408
409
410
411
 
 
 
 
412
413
414
415
416
417
418
...
449
450
451
 
452
453
454
455
...
490
491
492
 
493
494
495
496
...
606
607
608
 
609
610
611
612
613
614
 
615
616
 
617
618
 
619
620
 
621
622
623
 
 
624
625
626
627
628
...
640
641
642
 
643
644
645
646
...
699
700
701
 
702
703
704
705
0
@@ -2,31 +2,31 @@
0
 #--
0
 # Copyright (c) 2007-2008, John Mettraux, Tomaso Tosolini OpenWFE.org
0
 # All rights reserved.
0
-#
0
-# Redistribution and use in source and binary forms, with or without
0
+#
0
+# Redistribution and use in source and binary forms, with or without
0
 # modification, are permitted provided that the following conditions are met:
0
-#
0
+#
0
 # . Redistributions of source code must retain the above copyright notice, this
0
-# list of conditions and the following disclaimer.
0
-#
0
-# . Redistributions in binary form must reproduce the above copyright notice,
0
-# this list of conditions and the following disclaimer in the documentation
0
+# list of conditions and the following disclaimer.
0
+#
0
+# . Redistributions in binary form must reproduce the above copyright notice,
0
+# this list of conditions and the following disclaimer in the documentation
0
 # and/or other materials provided with the distribution.
0
-#
0
+#
0
 # . Neither the name of the "OpenWFE" nor the names of its contributors may be
0
 # used to endorse or promote products derived from this software without
0
 # specific prior written permission.
0
-#
0
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0
+#
0
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0
 # POSSIBILITY OF SUCH DAMAGE.
0
 #++
0
 #
0
@@ -36,7 +36,7 @@
0
 #
0
 # John Mettraux at openwfe.org
0
 # Tomaso Tosolini
0
-#
0
+#
0
 
0
 #require 'rubygems'
0
 
0
@@ -84,7 +84,6 @@ module Extras
0
 
0
                 t.column :yattributes, :text
0
                     # when using compact_workitems, attributes are stored here
0
-
0
             end
0
             add_index :workitems, :fei, :unique => true
0
             add_index :workitems, :wfid
0
@@ -129,19 +128,19 @@ module Extras
0
     # wl = OpenWFE::Extras::Workitem.find_all_by_participant_name("toto")
0
     # puts "found #{wl.size} workitems for participant 'toto'"
0
     #
0
- # These workitems are not OpenWFEru workitems directly. But the conversion
0
+ # These workitems are not OpenWFEru workitems directly. But the conversion
0
     # is pretty easy.
0
- # Note that you probaly won't need to do the conversion by yourself,
0
+ # Note that you probaly won't need to do the conversion by yourself,
0
     # except for certain advanced scenarii.
0
     #
0
     # awi = OpenWFE::Extras::Workitem.find_by_participant_name("toto")
0
- # #
0
+ # #
0
     # # returns the first workitem in the database whose participant
0
     # # name is 'toto'.
0
     #
0
     # owi = awi.as_owfe_workitem
0
- # #
0
- # # Now we have a copy of the reference as a OpenWFEru
0
+ # #
0
+ # # Now we have a copy of the reference as a OpenWFEru
0
     # # InFlowWorkItem instance.
0
     #
0
     # awi = OpenWFE::Extras::Workitem.from_owfe_workitem(owi)
0
@@ -192,11 +191,11 @@ module Extras
0
 
0
                 i.store_name = store_name
0
 
0
-
0
- # This is a field set by the active participant immediately
0
+
0
+ # This is a field set by the active participant immediately
0
                 # before calling this method.
0
                 # the default behavior is "use field method"
0
-
0
+
0
                 if wi.attributes["compact_workitems"]
0
 
0
                     wi.attributes.delete("compact_workitems")
0
@@ -245,7 +244,7 @@ module Extras
0
 
0
             return self.yattributes if self.yattributes
0
 
0
- fields.inject({}) do |r, f|
0
+ fields.inject({}) do |r, f|
0
                 r[f.fkey] = f.value
0
                 r
0
             end
0
@@ -258,7 +257,7 @@ module Extras
0
         #
0
         def replace_fields (fhash)
0
 
0
- if self.yattributes
0
+ if self.yattributes
0
 
0
                 self.yattributes = fhash
0
 
0
@@ -287,7 +286,7 @@ module Extras
0
         # wi.field :customer_name
0
         #
0
         def field (key)
0
-
0
+
0
             if self.yattributes
0
                 return self.yattributes[key.to_s]
0
             end
0
@@ -326,7 +325,7 @@ module Extras
0
         #
0
         class OpenWFE::Engine
0
 
0
- alias :oldreply :reply
0
+ alias :oldreply :reply
0
 
0
             def reply (workitem)
0
 
0
@@ -369,7 +368,7 @@ module Extras
0
         # == Note
0
         #
0
         # when this is used on compact_workitems, it will not be able to search
0
- # info within the fields, because they aren't used by this kind of
0
+ # info within the fields, because they aren't used by this kind of
0
         # workitems. In this case the search will be limited to participant_name
0
         #
0
         def self.search (search_string, storename_list=nil)
0
@@ -381,7 +380,7 @@ module Extras
0
             # participant_name
0
 
0
             result = find(
0
- :all,
0
+ :all,
0
                 :conditions => conditions(
0
                     "participant_name", search_string, storename_list),
0
                 :order => "participant_name")
0
@@ -404,16 +403,16 @@ module Extras
0
         #
0
         # Not really about 'just launched', but rather about finding the first
0
         # workitem for a given process instance (wfid) and a participant.
0
- # It deserves its own method because the workitem could be in a
0
+ # It deserves its own method because the workitem could be in a
0
         # subprocess, thus escaping the vanilla find_by_wfid_and_participant()
0
         #
0
         def self.find_just_launched (wfid, participant_name)
0
 
0
             find(
0
- :first,
0
- :conditions => [
0
- "wfid LIKE ? AND participant_name = ?",
0
- "#{wfid}%",
0
+ :first,
0
+ :conditions => [
0
+ "wfid LIKE ? AND participant_name = ?",
0
+ "#{wfid}%",
0
                     participant_name ])
0
         end
0
 
0
@@ -450,7 +449,7 @@ module Extras
0
     end
0
 
0
     #
0
- # A workaround is in place for some classes when then have to get
0
+ # A workaround is in place for some classes when then have to get
0
     # serialized. The names of thoses classes are listed in this array.
0
     #
0
     SPECIAL_FIELD_CLASSES = [ 'Time', 'Date', 'DateTime' ]
0
@@ -491,7 +490,7 @@ module Extras
0
 
0
             if v.is_a?(String) and v.length <= limit
0
 
0
- self.svalue = v
0
+ self.svalue = v
0
 
0
             elsif SPECIAL_FIELD_CLASSES.include?(v.class.to_s)
0
 
0
@@ -607,23 +606,23 @@ module Extras
0
     # # give some slack to the engine, it's asynchronous after all
0
     #
0
     # wi = OpenWFE::Extras::Workitem.find_by_participant_name("active0")
0
- #
0
+ #
0
     # # ...
0
     # end
0
     #
0
     # == Compact workitems
0
     #
0
- # It is possible to save all the workitem data into a single table,
0
+ # It is possible to save all the workitem data into a single table,
0
     # the workitems table, without
0
- # splitting info between workitems and fields tables.
0
+ # splitting info between workitems and fields tables.
0
     #
0
- # You can configure the "compact_workitems" behavior by adding to the
0
+ # You can configure the "compact_workitems" behavior by adding to the
0
     # previous lines:
0
- #
0
+ #
0
     # active0 = engine.register_participant(
0
     # :active0, OpenWFE::Extras::ActiveParticipant)
0
- #
0
- # active0.compact_workitems = true
0
+ #
0
+ # active0.compact_workitems = true
0
     #
0
     # This behaviour is determined participant per participant, it's ok to
0
     # have a participant instance that compacts will there is another that
0
@@ -641,7 +640,7 @@ module Extras
0
         attr :compact_workitems, true
0
 
0
         #
0
- # This is the method called by the OpenWFEru engine to hand a
0
+ # This is the method called by the OpenWFEru engine to hand a
0
         # workitem to this participant.
0
         #
0
         def consume (workitem)
0
@@ -700,7 +699,7 @@ module Extras
0
         end
0
 
0
         #
0
- # This is the method called by the OpenWFEru engine to hand a
0
+ # This is the method called by the OpenWFEru engine to hand a
0
         # workitem to this participant.
0
         #
0
         def consume (workitem)
...
122
123
124
 
 
 
 
125
126
127
...
122
123
124
125
126
127
128
129
130
131
0
@@ -122,6 +122,10 @@ class PsRepresentationTest < Test::Unit::TestCase
0
         assert_equal(
0
             ["process-definition", {"name"=>"Test", "revision"=>"1"}, [["description", {}, ["interference of the description"]], ["sequence", {}, [["alpha", {"ref"=>"alpha"}, []]]]]],
0
             ps.representation)
0
+
0
+ assert_equal(
0
+ ["process-definition", {"name"=>"Test", "revision"=>"1"}, [["description", {}, ["interference of the description"]], ["sequence", {}, [["alpha", {"ref"=>"alpha"}, []]]]]],
0
+ @engine.process_representation(fei.wfid))
0
     end
0
 
0
     # see also test/ft_84_updateexp.rb

Comments

    No one has commented yet.