openwferu 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/{README → README.txt} +16 -13
  2. data/bin/validate-workflow.rb +46 -22
  3. data/examples/README.txt +8 -0
  4. data/examples/homeworkreview.rb +66 -0
  5. data/examples/quotereporter.rb +154 -0
  6. data/lib/{openwferu.rb → openwfe.rb} +6 -8
  7. data/lib/{ru → openwfe}/contextual.rb +11 -3
  8. data/lib/{ru → openwfe/engine}/engine.rb +50 -36
  9. data/lib/{ru/participant.rb → openwfe/engine/file_persisted_engine.rb} +21 -22
  10. data/lib/openwfe/expool/expressionpool.rb +534 -0
  11. data/lib/openwfe/expool/expstorage.rb +184 -0
  12. data/lib/openwfe/expool/journalexpstorage.rb +312 -0
  13. data/lib/openwfe/expool/yamlexpstorage.rb +127 -0
  14. data/lib/{ru → openwfe/expressions}/environment.rb +19 -14
  15. data/lib/{ru → openwfe/expressions}/expressionmap.rb +48 -21
  16. data/lib/{ru → openwfe/expressions}/fe_concurrence.rb +111 -35
  17. data/lib/openwfe/expressions/fe_cursor.rb +236 -0
  18. data/lib/{ru → openwfe/expressions}/fe_define.rb +5 -5
  19. data/lib/openwfe/expressions/fe_fqv.rb +99 -0
  20. data/lib/openwfe/expressions/fe_iterator.rb +182 -0
  21. data/lib/{ru/fe_misc.rb → openwfe/expressions/fe_losfor.rb} +14 -56
  22. data/lib/openwfe/expressions/fe_misc.rb +102 -0
  23. data/lib/{ru → openwfe/expressions}/fe_participant.rb +25 -14
  24. data/lib/{ru → openwfe/expressions}/fe_raw.rb +39 -75
  25. data/lib/{ru/fe_base.rb → openwfe/expressions/fe_sequence.rb} +40 -35
  26. data/lib/{ru → openwfe/expressions}/fe_subprocess.rb +30 -14
  27. data/lib/{ru → openwfe/expressions}/fe_time.rb +59 -31
  28. data/lib/{ru → openwfe/expressions}/fe_utils.rb +42 -26
  29. data/lib/{ru → openwfe/expressions}/fe_value.rb +20 -14
  30. data/lib/openwfe/expressions/flowexpression.rb +434 -0
  31. data/lib/openwfe/expressions/raw_prog.rb +391 -0
  32. data/lib/openwfe/expressions/raw_xml.rb +128 -0
  33. data/lib/openwfe/flowexpressionid.rb +148 -0
  34. data/lib/{ru → openwfe}/logging.rb +10 -6
  35. data/lib/{osocket.rb → openwfe/osocket.rb} +36 -35
  36. data/lib/{otime.rb → openwfe/otime.rb} +71 -21
  37. data/lib/openwfe/participants/atomparticipants.rb +144 -0
  38. data/lib/openwfe/participants/enoparticipant.rb +73 -0
  39. data/lib/openwfe/participants/participant.rb +85 -0
  40. data/lib/{ru → openwfe/participants}/participantmap.rb +40 -12
  41. data/lib/{ru → openwfe/participants}/participants.rb +41 -12
  42. data/lib/openwfe/participants/soapparticipants.rb +96 -0
  43. data/lib/{controlclient.rb → openwfe/rest/controlclient.rb} +12 -13
  44. data/lib/{definitions.rb → openwfe/rest/definitions.rb} +3 -3
  45. data/lib/{exception.rb → openwfe/rest/exception.rb} +3 -3
  46. data/lib/{restclient.rb → openwfe/rest/restclient.rb} +13 -22
  47. data/lib/{worklistclient.rb → openwfe/rest/worklistclient.rb} +33 -46
  48. data/lib/openwfe/rest/xmlcodec.rb +575 -0
  49. data/lib/{ru → openwfe}/rudefinitions.rb +32 -4
  50. data/lib/{ru → openwfe}/service.rb +20 -8
  51. data/lib/openwfe/storage/yamlfilestorage.rb +159 -0
  52. data/lib/{ru → openwfe/util}/dollar.rb +10 -8
  53. data/lib/openwfe/util/lru_cache.rb +149 -0
  54. data/lib/{ru → openwfe/util}/scheduler.rb +18 -10
  55. data/lib/{ru → openwfe/util}/schedulers.rb +7 -7
  56. data/lib/{utils.rb → openwfe/utils.rb} +93 -9
  57. data/lib/openwfe/workitem.rb +366 -0
  58. data/lib/openwfe/worklist/worklists.rb +175 -0
  59. data/test/README.txt +27 -0
  60. data/test/atomtest.rb +99 -0
  61. data/test/crontest.rb +58 -0
  62. data/test/dollartest.rb +3 -3
  63. data/test/feitest.rb +42 -14
  64. data/test/file_persistence_test.rb +93 -0
  65. data/test/flowtestbase.rb +72 -26
  66. data/test/ft_0.rb +1 -97
  67. data/test/ft_0b_sequence.rb +33 -0
  68. data/test/ft_0c_testname.rb +29 -0
  69. data/test/ft_10_loop.rb +48 -0
  70. data/test/ft_11_ppd.rb +292 -0
  71. data/test/ft_12_blockparticipant.rb +45 -0
  72. data/test/ft_13_eno.rb +51 -0
  73. data/test/ft_14_subprocess.rb +90 -0
  74. data/test/ft_14b_subprocess.rb +40 -0
  75. data/test/ft_15_iterator.rb +70 -0
  76. data/test/ft_16_fqv.rb +57 -0
  77. data/test/ft_1_unset.rb +25 -1
  78. data/test/ft_2_concurrence.rb +10 -5
  79. data/test/ft_3_equals.rb +35 -1
  80. data/test/ft_4_misc.rb +16 -1
  81. data/test/ft_5_time.rb +26 -1
  82. data/test/ft_6_lambda.rb +2 -1
  83. data/test/{ft_7_losfor.rb → ft_7_lose.rb} +41 -35
  84. data/test/ft_8_forget.rb +46 -0
  85. data/test/ft_9_cursor.rb +94 -0
  86. data/test/journal_persistence_test.rb +147 -0
  87. data/test/misctest.rb +13 -9
  88. data/test/rake_ptest.rb +18 -0
  89. data/test/rake_qtest.rb +43 -0
  90. data/test/{fulltest.rb → rake_test.rb} +2 -2
  91. data/test/raw_prog_test.rb +236 -0
  92. data/test/rest_test.rb +189 -0
  93. data/test/rutest_utils.rb +1 -1
  94. data/test/timetest.rb +42 -34
  95. metadata +125 -82
  96. data/lib/codec.rb +0 -573
  97. data/lib/flowexpressionid.rb +0 -139
  98. data/lib/ru/expressionpool.rb +0 -382
  99. data/lib/ru/expressionstorage.rb +0 -99
  100. data/lib/ru/flowexpression.rb +0 -272
  101. data/lib/ru/ruutils.rb +0 -70
  102. data/lib/test.rb +0 -222
  103. data/lib/workitem.rb +0 -249
  104. data/test/quicktest.rb +0 -21
@@ -0,0 +1,175 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # . Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ #
12
+ # . Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
+ # used to endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ #++
32
+ #
33
+ # $Id: worklistclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
+ #
35
+
36
+ #
37
+ # Nicolas Modrzyk at openwfe.org
38
+ #
39
+
40
+ module OpenWFE
41
+
42
+ class Worklist
43
+
44
+ att_reader: :stores, :locks, :launchables
45
+
46
+ #
47
+ # Returns the list of stores of the worklist
48
+ #
49
+ def list_stores ()
50
+ raise "Not Implemented Yet"
51
+ end
52
+
53
+ #
54
+ # A synonym for listStores()
55
+ #
56
+ def getStoreNames ()
57
+ return listStores()
58
+ end
59
+
60
+ #
61
+ # Returns the headers of a given store.
62
+ #
63
+ def getHeaders (storeName, limit=1000)
64
+ raise "Not Implemented Yet"
65
+ end
66
+
67
+ def findFlowInstance (storeName, workflowInstanceId)
68
+ raise "Not Implemented Yet"
69
+ end
70
+
71
+ #
72
+ # Launches a flow (on a given engine and with a given launchitem).
73
+ # The 'engineId' corresponds to an engine's participant name
74
+ # (see etc/engine/participant-map.xml)
75
+ #
76
+ def launchFlow (engineId, launchitem)
77
+ raise "Not Implemented Yet"
78
+ end
79
+
80
+ #
81
+ # Returns a workitem (but doesn't put a lock on it, thus modifications
82
+ # to it cannot be communicated with saveWorkitem() or forwardWorkitem()
83
+ # to the worklist)
84
+ #
85
+ def getWorkitem (storeName, flowExpressionId)
86
+ raise "Not Implemented Yet"
87
+ end
88
+
89
+ #
90
+ # Returns a workitem and makes sure it's locked in the worklist. Thus,
91
+ # the usage of the methods saveWorkitem() and forwardWorkitem() is
92
+ # possible.
93
+ #
94
+ def getAndLockWorkitem (storeName, flowExpressionId)
95
+ raise "Not Implemented Yet"
96
+ end
97
+
98
+ #
99
+ # Given a queryMap (a dict of keys and values), locks and returns
100
+ # the first workitem matching.
101
+ #
102
+ def queryAndLockWorkitem (storeName, queryMap)
103
+ raise "Not Implemented Yet"
104
+ end
105
+
106
+ #
107
+ # Notifies the worklist that the given workitem has to be unlocked
108
+ # any local (client-side) modification to it are ignored.
109
+ #
110
+ def releaseWorkitem (workitem)
111
+ raise "Not Implemented Yet"
112
+ end
113
+
114
+ #
115
+ # Saves back the workitem in the worklist (and releases it)
116
+ #
117
+ def saveWorkitem (workitem)
118
+ raise "Not Implemented Yet"
119
+ end
120
+
121
+ #
122
+ # Returns the workitem to the worklist so that it can resume
123
+ # its flow (changes to the workitem are saved).
124
+ #
125
+ def proceedWorkitem (workitem)
126
+ raise "Not Implemented Yet"
127
+ end
128
+
129
+ #
130
+ # Returns the list of flow URLs the user owning this session may
131
+ # launch.
132
+ #
133
+ def listLaunchables ()
134
+ raise "Not Implemented Yet"
135
+ end
136
+
137
+ #
138
+ # Delegate the workitem (transfer it to another store).
139
+ #
140
+ def delegate (workitem, targetStoreName)
141
+ raise "Not Implemented Yet"
142
+ end
143
+
144
+ #
145
+ # Delegate the workitem (ask the worklist to deliver it to
146
+ # another participant).
147
+ #
148
+ def delegateToParticipant (workitem, targetParticipantName)
149
+ raise "Not Implemented Yet"
150
+ end
151
+
152
+ def queryStore (storeName, query)
153
+ raise "Not Implemented Yet"
154
+ end
155
+
156
+ alias list_stores listStores
157
+ alias get_store_names getStoreNames
158
+ alias get_headers getHeaders
159
+ alias find_flow_instance findFlowInstance
160
+ alias launch_flow launchFlow
161
+ alias get_workitem getWorkitem
162
+ alias get_and_lock_workitem getAndLockWorkitem
163
+ alias query_and_lock_workitem queryAndLockWorkitem
164
+ alias release_workitem releaseWorkitem
165
+ alias save_workitem saveWorkitem
166
+ alias proceed_workitem proceedWorkitem
167
+ alias forwardWorkitem proceedWorkitem
168
+ alias forward_workitem proceedWorkitem
169
+ alias list_launchables listLaunchables
170
+ alias delegate_to_participant delegateToParticipant
171
+
172
+ end
173
+
174
+ end
175
+
@@ -0,0 +1,27 @@
1
+ = OpenWFEru - about the unit tests
2
+
3
+ There are three tests triggerable by Rake :
4
+
5
+ rake test
6
+ rake qtest
7
+ rake ptest
8
+
9
+ These 3 tests correspond to the following unit test files *
10
+
11
+ test/rake_test.rb
12
+ test/rake_qtest.rb
13
+ test/rake_ptest.rb
14
+
15
+ == test/rake_test.rb
16
+
17
+ Triggers 'quicktests' and time based tests. Running "rake test" takes 10 seconds more than "rake qtest". These are the 10 seconds necessary to test some time and scheduling aspects of OpenWFEru.
18
+
19
+ == test/rake_qtest.rb
20
+
21
+ Runs only 'quick' tests.
22
+
23
+ == test/rake_ptest.rb
24
+
25
+ Runs the quicktest but with persistence on. Persistence stores its work file under the work/ directory.
26
+ This set of tests takes care of wiping fresh the work/ directory before beginning the tests.
27
+
@@ -0,0 +1,99 @@
1
+ #
2
+ # Testing OpenWFE
3
+ #
4
+ # John Mettraux at openwfe.org
5
+ #
6
+ # Sun Oct 29 15:41:44 JST 2006
7
+ #
8
+ # Kita Yokohama
9
+ #
10
+
11
+ require 'test/unit'
12
+
13
+ require 'openwfe/workitem'
14
+ require 'openwfe/engine/engine'
15
+ require 'openwfe/expressions/raw_prog'
16
+ require 'openwfe/participants/atomparticipants'
17
+
18
+ include OpenWFE
19
+
20
+
21
+ class AtomTest < Test::Unit::TestCase
22
+
23
+ def setup
24
+ @engine = Engine.new()
25
+ end
26
+
27
+ #def teardown
28
+ #end
29
+
30
+ #
31
+ # test atom 0
32
+
33
+ class Atom0Definition < ProcessDefinition
34
+ def make
35
+ process_definition :name => "atom0", :revision => "0" do
36
+ sequence do
37
+
38
+ set \
39
+ :field => "atom_entry_title",
40
+ :value => "#{$run_index}"
41
+ set \
42
+ :field => "colour",
43
+ :value => "blue"
44
+ participant :ref => "feed0-alpha"
45
+
46
+ set \
47
+ :field => "atom_entry_title",
48
+ :value => "#{$run_index}"
49
+ set \
50
+ :field => "colour",
51
+ :value => "red"
52
+ participant :ref => "feed1-bravo"
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ def test_atom_0
59
+
60
+ feed0 = AtomParticipant.new(7,
61
+ """
62
+ <p>
63
+ <h1>${f:colour}</h1>
64
+ </p>
65
+ """)
66
+
67
+
68
+ feed1 = AtomParticipant.new(7) do |fe, participant, workitem|
69
+
70
+ t = Time.new.to_s
71
+ """
72
+ <p>
73
+ <h1>${f:colour}</h1>
74
+ <ul>
75
+ <li>flowexpression : #{fe.fei.to_s}</li>
76
+ <li>participant class : #{participant.class}</li>
77
+ <li>workitem att count : #{workitem.attributes.length}</li>
78
+ <li>now : #{t}</li>
79
+ <li>entry title : ${f:atom_entry_title}</li>
80
+ </ul>
81
+ </p>
82
+ """
83
+ end
84
+
85
+ @engine.register_participant("feed0-.*", feed0)
86
+ @engine.register_participant("feed1-.*", feed1)
87
+
88
+ $run_index = "first run"
89
+ @engine.launch(LaunchItem.new(Atom0Definition))
90
+
91
+ $run_index = "second run"
92
+ @engine.launch(LaunchItem.new(Atom0Definition))
93
+
94
+ $run_index = "third and last run"
95
+ @engine.launch(LaunchItem.new(Atom0Definition))
96
+ end
97
+
98
+ end
99
+
@@ -0,0 +1,58 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Sun Oct 29 16:18:25 JST 2006
8
+ #
9
+
10
+ require 'test/unit'
11
+ require 'otime'
12
+ require 'ru/util/scheduler'
13
+
14
+ #
15
+ # testing otime and the scheduler
16
+ #
17
+
18
+ class TimeTest < Test::Unit::TestCase
19
+
20
+ #def setup
21
+ #end
22
+
23
+ #def teardown
24
+ #end
25
+
26
+ def test_cron_0
27
+ $var = 0
28
+
29
+ scheduler = OpenWFE::Scheduler.new()
30
+ scheduler.start
31
+
32
+ sid = scheduler.schedule('* * * * *', CounterSchedulable.new, nil)
33
+
34
+ assert \
35
+ sid,
36
+ "scheduler did not return a job id"
37
+
38
+ sleep(120)
39
+ scheduler.stop
40
+
41
+ #puts ">#{$var}<"
42
+
43
+ assert \
44
+ ($var == 2),
45
+ "cron_0 failed, $var is #{$var}"
46
+ end
47
+
48
+ protected
49
+
50
+ class CounterSchedulable
51
+ include OpenWFE::Schedulable
52
+
53
+ def trigger (params)
54
+ $var = $var + 1
55
+ end
56
+ end
57
+
58
+ end
@@ -1,6 +1,6 @@
1
1
 
2
2
  #
3
- # Testing OpenWFEru
3
+ # Testing OpenWFE
4
4
  #
5
5
  # John Mettraux at openwfe.org
6
6
  #
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  require 'test/unit'
11
- require 'ru/dollar'
11
+ require 'openwfe/util/dollar'
12
12
 
13
13
  #
14
14
  # testing the 'dollar notation'
@@ -67,7 +67,7 @@ class DollarTest < Test::Unit::TestCase
67
67
  end
68
68
 
69
69
  def dotest (text, dict, target)
70
- result = OpenWFEru::dsub(text, dict)
70
+ result = OpenWFE::dsub(text, dict)
71
71
  #puts "..>#{text}<"
72
72
  #puts "...->"
73
73
  #puts "..>#{result}<"
@@ -1,6 +1,6 @@
1
1
 
2
2
  #
3
- # Testing OpenWFEru
3
+ # Testing OpenWFE
4
4
  #
5
5
  # John Mettraux at openwfe.org
6
6
  #
@@ -8,8 +8,9 @@
8
8
  #
9
9
 
10
10
  require 'test/unit'
11
- require 'workitem'
12
- require 'ru/rudefinitions'
11
+ require 'openwfe/workitem'
12
+ require 'openwfe/flowexpressionid'
13
+ require 'openwfe/rudefinitions'
13
14
 
14
15
 
15
16
  class FeiTest < Test::Unit::TestCase
@@ -44,7 +45,7 @@ class FeiTest < Test::Unit::TestCase
44
45
  fei1 = new_fei()
45
46
 
46
47
  fei2 = new_fei()
47
- fei2.expressionName = OpenWFEru::EN_ENVIRONMENT
48
+ fei2.expression_name = OpenWFE::EN_ENVIRONMENT
48
49
 
49
50
  assert \
50
51
  fei1.object_id != fei2.object_id, \
@@ -95,26 +96,53 @@ class FeiTest < Test::Unit::TestCase
95
96
  fei0 == fei1,
96
97
  "feis should be equal"
97
98
 
98
- fei1.expressionName = OpenWFEru::EN_ENVIRONMENT
99
+ fei1.expression_name = OpenWFE::EN_ENVIRONMENT
99
100
 
100
101
  assert \
101
102
  fei0 != fei1,
102
103
  "feis should not be equal"
103
104
  end
104
105
 
106
+ def test_parse_unparse
107
+ fei0 = new_fei()
108
+ s = fei0.to_s
109
+ fei1 = OpenWFE::FlowExpressionId.to_fei(s)
110
+
111
+ puts "\n#{s}\n#{fei1.to_s}" if fei0 != fei1
112
+
113
+ assert \
114
+ fei0 == fei1,
115
+ "fei .to_s() and .str_to_fei(s) are not working"
116
+ end
117
+
118
+ def test_parent_wfid
119
+
120
+ fei = new_fei
121
+
122
+ assert \
123
+ fei.parent_workflow_instance_id == "123456",
124
+ "failure 0"
125
+
126
+ fei.workflow_instance_id = "123456.0.0"
127
+
128
+ assert \
129
+ fei.parent_workflow_instance_id == "123456",
130
+ "failure 1"
131
+ end
132
+
105
133
  protected
106
134
 
107
135
  def new_fei ()
108
136
  fei = OpenWFE::FlowExpressionId.new()
109
- fei.owfeVersion = OpenWFEru::OPENWFE_VERSION
110
- fei.engineId = 'this'
111
- fei.initialEngineId = 'that'
112
- fei.workflowDefinitionUrl = 'http://test/test.xml'
113
- fei.workflowDefinitionName = 'test'
114
- fei.workflowDefinitionRevision = '1.0'
115
- fei.workflowInstanceId = '123456'
116
- fei.expressionName = 'do-test'
117
- fei.expressionId = '0.0'
137
+ fei.owfe_version = OpenWFE::OPENWFE_VERSION
138
+ fei.engine_id = 'this'
139
+ fei.initial_engine_id = 'that'
140
+ fei.workflow_definition_url = 'http://test/test.xml'
141
+ fei.workflow_definition_name = 'test'
142
+ fei.workflow_definition_revision = '1.0'
143
+ fei.workflow_instance_id = '123456'
144
+ fei.expression_name = 'do-test'
145
+ fei.expression_id = '0.0'
118
146
  return fei
119
147
  end
120
148