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
@@ -1,99 +0,0 @@
1
- #
2
- #--
3
- # Copyright (c) 2006, 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
-
36
- #
37
- # "made in Japan"
38
- #
39
- # John Mettraux at openwfe.org
40
- #
41
-
42
-
43
- require 'ru/service'
44
-
45
-
46
- module OpenWFEru
47
-
48
- #
49
- # In OpenWFEja, an ExpressionStorage is called an ExpressionStore
50
- # I prefer the 'storage' concept.
51
- #
52
- class InMemoryExpressionStorage < Hash
53
- include ServiceMixin
54
-
55
- def initialize (service_name, application_context)
56
- super()
57
- @service_name = service_name
58
- @application_context = application_context
59
- end
60
-
61
- #def []= (k, v)
62
- # super(k.to_s, v)
63
- #end
64
- #def delete (k)
65
- # super(k.to_s)
66
- #end
67
- #def [] (k)
68
- # result = super(k)
69
- # return result if result
70
- # ldebug do
71
- # result = ""
72
- # self.each do |kk, vv|
73
- # result << "\n#{k} ?= #{kk} : #{k == kk}"
74
- # end
75
- # result
76
- # end
77
- # return nil
78
- #end
79
-
80
- def to_s
81
- s = "\n\n==== #{self.class} ===="
82
- each do |k, v|
83
- s << "\n"
84
- if v.kind_of?(RawExpression)
85
- s << "*raw"
86
- else
87
- s << " "
88
- end
89
- s << v.to_s
90
- s << " key/value mismatch !" if k != v.fei
91
- end
92
- s << "\n==== . ====\n"
93
- return s
94
- end
95
-
96
- end
97
-
98
- end
99
-
@@ -1,272 +0,0 @@
1
- #
2
- #--
3
- # Copyright (c) 2006, 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
-
36
- #
37
- # "made in Japan"
38
- #
39
- # John Mettraux at openwfe.org
40
- #
41
-
42
- require 'ru/rudefinitions'
43
- require 'ru/contextual'
44
- require 'ru/dollar'
45
- require 'ru/logging'
46
-
47
-
48
- module OpenWFEru
49
-
50
- #
51
- # FlowExpression
52
- #
53
-
54
- class FlowExpression
55
- include Contextual, Logging
56
-
57
- attr_accessor \
58
- :fei, \
59
- :parent_id, \
60
- :environment_id, \
61
- :attributes, \
62
- :children, \
63
- :apply_time
64
-
65
- def initialize (fei, parent_id, env_id, app_context, attributes)
66
-
67
- @fei = fei
68
- @parent_id = parent_id
69
- @environment_id = env_id
70
- @application_context = app_context
71
- @attributes = attributes
72
-
73
- @apply_time = nil
74
-
75
- #ldebug do
76
- # "initialize()\n"+
77
- # "self : #{@fei}\n"+
78
- # "parent : #{@parent_id}"
79
- #end
80
- end
81
-
82
- #
83
- # the two most important methods for flow expressions
84
-
85
- #
86
- # this default implementation immediately replies to the
87
- # parent expression
88
- #
89
- def apply (workitem)
90
- get_parent().reply(workitem) if @parent_id
91
- end
92
-
93
- #
94
- # this default implementation immediately replies to the
95
- # parent expression
96
- #
97
- def reply (workitem)
98
- reply_to_parent(workitem)
99
- end
100
-
101
- def reply_to_parent (workitem)
102
- get_expression_pool.reply_to_parent(self, workitem)
103
- end
104
-
105
- #
106
- # a default implementation for cancel :
107
- # cancels all the children
108
- # Attempts to return an InFlowWorkItem
109
- #
110
- def cancel ()
111
- return nil if not @children
112
- inflowitem = nil
113
- @children.each do |child|
114
- i = get_expression_pool().cancel(child)
115
- inflowitem = i if not inflowitem
116
- end
117
- return inflowitem
118
- end
119
-
120
- #
121
- # some convenience methods
122
-
123
- def get_parent ()
124
- get_expression_pool().fetch(@parent_id)
125
- end
126
-
127
- def get_expression_pool ()
128
- @application_context[S_EXPRESSION_POOL]
129
- end
130
-
131
- def get_expression_map ()
132
- @application_context[S_EXPRESSION_MAP]
133
- end
134
-
135
- def store_itself ()
136
- get_expression_pool().update(self)
137
- end
138
-
139
- def get_environment ()
140
- return nil if not @environment_id
141
- return get_expression_pool().fetch(@environment_id)
142
- end
143
-
144
- #
145
- # Returns true if the expression's environment was generated
146
- # for itself (usually DefineExpression do have such envs)
147
- #
148
- def owns_its_environment? ()
149
-
150
- #ldebug { "owns_its_environment?() #{@fei.to_debug_s}" }
151
-
152
- return false if not @environment_id
153
-
154
- ei = @fei.dup()
155
- vi = @environment_id.dup()
156
-
157
- ei.expressionName = "neutral"
158
- vi.expressionName = "neutral"
159
-
160
- #ldebug do
161
- # "owns_its_environment?()\n"+
162
- # " exp #{ei.to_debug_s}\n"+
163
- # " env #{vi.to_debug_s}"
164
- #end
165
-
166
- return ei == vi
167
- end
168
-
169
- def set_variable (varname, value)
170
- get_environment()[varname] = value
171
- end
172
-
173
- def lookup_variable (varname)
174
- return get_environment()[varname]
175
- end
176
-
177
- def delete_variable (varname)
178
- get_environment().delete(varname)
179
- end
180
-
181
- def lookup_attribute (attname, workitem)
182
- text = @attributes[attname]
183
- return nil if not text
184
- return OpenWFEru::dosub(text, self, workitem)
185
- end
186
-
187
- def lookup_boolean_attribute (attname, workitem, default=false)
188
- value = lookup_attribute(attname, workitem)
189
- return default if not value
190
- return value.downcase == 'true'
191
- end
192
-
193
- def lookup_attributes (attributes, workitem)
194
- result = {}
195
- attributes.each do |k, v|
196
- result[k] = OpenWFEru::dosub(v, self, workitem)
197
- end
198
- return result
199
- end
200
-
201
- def list_attributes (workitem)
202
- result = {}
203
- @attributes.each do |k, v|
204
- result[k] = OpenWFEru::dosub(v, self, workitem)
205
- ldebug { "list_attributes() added '#{k}' -> '#{result[k]}'" }
206
- end
207
- return result
208
- end
209
-
210
- #
211
- # creates a new environment just for this expression
212
- #
213
- def new_environment ()
214
-
215
- ldebug { "new_environment() for #{@fei.to_debug_s}" }
216
-
217
- @environment_id = @fei.dup
218
- @environment_id.expressionName = EN_ENVIRONMENT
219
-
220
- parent_fei = nil
221
- parent = nil
222
- parent = get_expression_pool().fetch(@parent_id) if @parent_id
223
- parent_fei = parent.environment_id if parent
224
-
225
- env = Environment\
226
- .new(@environment_id, parent_fei, nil, @application_context, nil)
227
-
228
- ldebug { "new_environment() is #{env.fei.to_debug_s}" }
229
-
230
- env.store_itself()
231
- end
232
-
233
- #
234
- # takes care of removing all the children
235
- #
236
- def clean_children
237
- @children.each do |children_fei|
238
- get_expression_pool.remove(children_fei)
239
- end
240
- end
241
-
242
- #
243
- # some eye candy
244
- #
245
- def to_s
246
- s = "* #{@fei.to_debug_s}"
247
-
248
- if @parent_id
249
- s << "\n `--p--> #{@parent_id.to_debug_s}"
250
- end
251
-
252
- if @environment_id
253
- s << "\n `--e--> #{@environment_id.to_debug_s}"
254
- end
255
-
256
- if @children
257
- @children.each do |c|
258
- sc = if c.kind_of?(OpenWFE::FlowExpressionId)
259
- c.to_debug_s
260
- else
261
- ">#{c.to_s}<"
262
- end
263
- s << "\n `--c--> #{sc}"
264
- end
265
- end
266
-
267
- return s
268
- end
269
- end
270
-
271
- end
272
-
@@ -1,70 +0,0 @@
1
- #
2
- #<tt>
3
- # Copyright (c) 2006, 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
- #</tt>
32
- #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
-
36
- #
37
- # made somewhere over Japan
38
- #
39
- # John Mettraux at openwfe.org
40
- #
41
-
42
-
43
- module OpenWFEru
44
-
45
- #
46
- # Returns true if the given string starts with the 'start' string.
47
- #
48
- def OpenWFEru.starts_with (string, start)
49
- #
50
- # my favourite way of doing that would be by adding this
51
- # method to the String class, but that could be intrusive
52
- # (as OpenWFEru is meant at first as an embeddable workflow engine).
53
- #
54
- return false if not string
55
- return false if string.length < start.length
56
- return string[0, start.length] == start
57
- end
58
-
59
- #
60
- # Attempts at displaying a nice stack trace
61
- #
62
- def OpenWFEru.exception_to_s (exception)
63
- s = ""
64
- s << "#{exception}\n"
65
- s << exception.backtrace.join("\n")
66
- return s
67
- end
68
-
69
- end
70
-
@@ -1,222 +0,0 @@
1
- #
2
- #<tt>
3
- # Copyright (c) 2005-2006, 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
- #</tt>
32
- #
33
- # $Id: test.rb 3454 2006-10-08 16:51:00Z jmettraux $
34
- #
35
-
36
- #
37
- # "hecho en Costa Rica"
38
- #
39
-
40
- require 'optparse'
41
-
42
- require 'worklistclient'
43
- require 'controlclient'
44
-
45
-
46
- #
47
- # PARSING OPTS
48
- #
49
-
50
- @has_options = false
51
- @test_worklist = true
52
- @test_control = true
53
-
54
- def flush_options ()
55
- if not @has_options
56
- @test_worklist = false
57
- @test_control = false
58
- end
59
- @has_options = true
60
- end
61
-
62
- opts = OptionParser.new()
63
-
64
- opts.banner = "Usage: test.sh [options]"
65
- opts.separator("")
66
- opts.separator("options:")
67
-
68
- opts.on("-w", "--worklist", "tests the ruby lib to the worklist iface") do
69
- flush_options()
70
- @test_worklist = true
71
- end
72
-
73
- opts.on("-c", "--control", "tests the ruby lib to the control iface") do
74
- flush_options()
75
- @test_control = true
76
- end
77
-
78
- opts.on("-h", "--help", "displays this help/usage message") do
79
- puts
80
- puts opts.to_s()
81
- puts
82
- exit 0
83
- end
84
-
85
- #opts_rest = opts.parse(ARGV)
86
- #questions = Integer(opts_rest[0]) if opts_rest.length > 0
87
-
88
- opts.parse(ARGV)
89
-
90
-
91
- puts
92
- puts " testing worklist : #{@test_worklist}"
93
- puts " testing control : #{@test_control}"
94
- puts
95
-
96
-
97
- #
98
- # TESTING THE WORKLIST IFACE
99
- #
100
-
101
- if @test_worklist
102
-
103
- client = OpenWFE::WorklistClient\
104
- .new("http://127.0.0.1:5080/worklist", "alice", "alice")
105
-
106
- puts "sessionId : #{client.sessionId}"
107
-
108
- #puts client.get('getstorenames', nil, nil)
109
-
110
- puts "Stores :"
111
- l = client.listStores()
112
- l.each do |s|
113
- puts " - store name : '#{s.name}' wi count : #{s.workitemCount} permissions : #{s.permissions}"
114
- end
115
-
116
- puts
117
-
118
- puts "launching a flow"
119
- li = OpenWFE::LaunchItem.new()
120
- li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
121
- li.attributes["__subject__"] = "openwfe-ruby"
122
-
123
- fei = client.launchFlow("mainEngine", li)
124
- puts fei
125
-
126
- puts
127
-
128
- feiToFetch = nil
129
-
130
- puts "Store.alpha's headers :"
131
- l = client.getHeaders("Store.alpha")
132
- l.each do |h|
133
- puts " - header lastModified : #{h.lastModified} locked : #{h.locked} ac : #{h.attributes.length}"
134
- puts " fei : #{h.flowExpressionId}"
135
-
136
- feiToFetch = h.flowExpressionId
137
- end
138
-
139
- puts "Fetching the first workitem :"
140
- wi = client.getWorkitem("Store.alpha", feiToFetch)
141
-
142
- #puts wi.inspect()
143
- puts
144
-
145
- puts "Fetching (and locking) the first workitem :"
146
- wi = client.getAndLockWorkitem("Store.alpha", feiToFetch)
147
-
148
- puts wi.inspect()
149
-
150
- puts
151
-
152
- puts "Releasing the workitem :"
153
- puts "ok" if client.releaseWorkitem(wi)
154
-
155
- puts
156
-
157
- puts "Listing launchables :"
158
- client.listLaunchables().each do |l|
159
- puts " - launchable #{l.engineId} :: #{l.url}"
160
- end
161
-
162
- puts
163
-
164
- puts "Closing worklist worksession"
165
- puts client.close()
166
-
167
- end
168
-
169
-
170
- #
171
- # TESTING THE CONTROL IFACE
172
- #
173
-
174
- if @test_control
175
-
176
- def display_expressions (exps)
177
- i = 0
178
- exps.each do |exp|
179
- print " - exp #{i} : #{exp.id}"
180
- print " / #{exp.applyTime}" if exp.applyTime
181
- print "\n"
182
- i = i+1
183
- end
184
- end
185
-
186
- puts "Testing the control interface..."
187
-
188
- #
189
- # launching a test flow
190
-
191
- #TEST_NAME = '-- testing ruby control (0) --'
192
-
193
- #client = OpenWFE::WorklistClient\
194
- # .new("http://127.0.0.1:5080/worklist", "alice", "alice")
195
-
196
- #li = OpenWFE::LaunchItem.new()
197
- #li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
198
- #li.attributes["__subject__"] = TEST_NAME
199
-
200
- #fei = client.launchFlow("mainEngine", li)
201
- #puts "launched : #{fei}"
202
-
203
- #client.close()
204
-
205
- #
206
- # controlling the test flow
207
-
208
- client = OpenWFE::ControlClient\
209
- .new("http://127.0.0.1:6080/engine", "admin", "admin")
210
-
211
- puts "sessionId : #{client.sessionId}"
212
-
213
- puts
214
-
215
- puts "listing expressions :"
216
- exps = client.listExpressions()
217
- display_expressions(exps)
218
-
219
- client.close()
220
-
221
- end
222
-