openwferu 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/README +47 -0
  2. data/lib/codec.rb +571 -0
  3. data/lib/controlclient.rb +115 -0
  4. data/lib/definitions.rb +112 -0
  5. data/lib/exception.rb +60 -0
  6. data/lib/flowexpressionid.rb +137 -0
  7. data/lib/openwferu.rb +43 -0
  8. data/lib/osocket.rb +138 -0
  9. data/lib/otime.rb +171 -0
  10. data/lib/restclient.rb +155 -0
  11. data/lib/ru/contextual.rb +63 -0
  12. data/lib/ru/dollar.rb +163 -0
  13. data/lib/ru/engine.rb +130 -0
  14. data/lib/ru/environment.rb +140 -0
  15. data/lib/ru/expressionmap.rb +120 -0
  16. data/lib/ru/expressionpool.rb +339 -0
  17. data/lib/ru/expressionstorage.rb +97 -0
  18. data/lib/ru/fe_base.rb +105 -0
  19. data/lib/ru/fe_concurrence.rb +122 -0
  20. data/lib/ru/fe_define.rb +101 -0
  21. data/lib/ru/fe_misc.rb +96 -0
  22. data/lib/ru/fe_participant.rb +75 -0
  23. data/lib/ru/fe_raw.rb +173 -0
  24. data/lib/ru/fe_subprocess.rb +84 -0
  25. data/lib/ru/fe_time.rb +135 -0
  26. data/lib/ru/fe_utils.rb +123 -0
  27. data/lib/ru/fe_value.rb +225 -0
  28. data/lib/ru/flowexpression.rb +250 -0
  29. data/lib/ru/logging.rb +85 -0
  30. data/lib/ru/participant.rb +67 -0
  31. data/lib/ru/participantmap.rb +93 -0
  32. data/lib/ru/participants.rb +74 -0
  33. data/lib/ru/rudefinitions.rb +70 -0
  34. data/lib/ru/ruutils.rb +68 -0
  35. data/lib/ru/scheduler.rb +478 -0
  36. data/lib/ru/schedulers.rb +63 -0
  37. data/lib/ru/service.rb +64 -0
  38. data/lib/test.rb +220 -0
  39. data/lib/utils.rb +94 -0
  40. data/lib/workitem.rb +250 -0
  41. data/lib/worklistclient.rb +276 -0
  42. data/test/dollartest.rb +79 -0
  43. data/test/feitest.rb +130 -0
  44. data/test/flowtestbase.rb +86 -0
  45. data/test/ft_0.rb +161 -0
  46. data/test/ft_1_unset.rb +152 -0
  47. data/test/ft_2_concurrence.rb +34 -0
  48. data/test/ft_3_equals.rb +84 -0
  49. data/test/ft_4_misc.rb +128 -0
  50. data/test/ft_5_time.rb +56 -0
  51. data/test/misctest.rb +46 -0
  52. data/test/runtest.rb +21 -0
  53. data/test/rutest_utils.rb +15 -0
  54. data/test/timetest.rb +111 -0
  55. metadata +100 -0
data/lib/test.rb ADDED
@@ -0,0 +1,220 @@
1
+ #
2
+ # Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # . Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # . Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without
17
+ # specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # $Id: test.rb 3454 2006-10-08 16:51:00Z jmettraux $
32
+ #
33
+
34
+ #
35
+ # "hecho en Costa Rica"
36
+ #
37
+
38
+ require 'optparse'
39
+
40
+ require 'worklistclient'
41
+ require 'controlclient'
42
+
43
+
44
+ #
45
+ # PARSING OPTS
46
+ #
47
+
48
+ @has_options = false
49
+ @test_worklist = true
50
+ @test_control = true
51
+
52
+ def flush_options ()
53
+ if not @has_options
54
+ @test_worklist = false
55
+ @test_control = false
56
+ end
57
+ @has_options = true
58
+ end
59
+
60
+ opts = OptionParser.new()
61
+
62
+ opts.banner = "Usage: test.sh [options]"
63
+ opts.separator("")
64
+ opts.separator("options:")
65
+
66
+ opts.on("-w", "--worklist", "tests the ruby lib to the worklist iface") do
67
+ flush_options()
68
+ @test_worklist = true
69
+ end
70
+
71
+ opts.on("-c", "--control", "tests the ruby lib to the control iface") do
72
+ flush_options()
73
+ @test_control = true
74
+ end
75
+
76
+ opts.on("-h", "--help", "displays this help/usage message") do
77
+ puts
78
+ puts opts.to_s()
79
+ puts
80
+ exit 0
81
+ end
82
+
83
+ #opts_rest = opts.parse(ARGV)
84
+ #questions = Integer(opts_rest[0]) if opts_rest.length > 0
85
+
86
+ opts.parse(ARGV)
87
+
88
+
89
+ puts
90
+ puts " testing worklist : #{@test_worklist}"
91
+ puts " testing control : #{@test_control}"
92
+ puts
93
+
94
+
95
+ #
96
+ # TESTING THE WORKLIST IFACE
97
+ #
98
+
99
+ if @test_worklist
100
+
101
+ client = OpenWFE::WorklistClient\
102
+ .new("http://127.0.0.1:5080/worklist", "alice", "alice")
103
+
104
+ puts "sessionId : #{client.sessionId}"
105
+
106
+ #puts client.get('getstorenames', nil, nil)
107
+
108
+ puts "Stores :"
109
+ l = client.listStores()
110
+ l.each do |s|
111
+ puts " - store name : '#{s.name}' wi count : #{s.workitemCount} permissions : #{s.permissions}"
112
+ end
113
+
114
+ puts
115
+
116
+ puts "launching a flow"
117
+ li = OpenWFE::LaunchItem.new()
118
+ li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
119
+ li.attributes["__subject__"] = "openwfe-ruby"
120
+
121
+ fei = client.launchFlow("mainEngine", li)
122
+ puts fei
123
+
124
+ puts
125
+
126
+ feiToFetch = nil
127
+
128
+ puts "Store.alpha's headers :"
129
+ l = client.getHeaders("Store.alpha")
130
+ l.each do |h|
131
+ puts " - header lastModified : #{h.lastModified} locked : #{h.locked} ac : #{h.attributes.length}"
132
+ puts " fei : #{h.flowExpressionId}"
133
+
134
+ feiToFetch = h.flowExpressionId
135
+ end
136
+
137
+ puts "Fetching the first workitem :"
138
+ wi = client.getWorkitem("Store.alpha", feiToFetch)
139
+
140
+ #puts wi.inspect()
141
+ puts
142
+
143
+ puts "Fetching (and locking) the first workitem :"
144
+ wi = client.getAndLockWorkitem("Store.alpha", feiToFetch)
145
+
146
+ puts wi.inspect()
147
+
148
+ puts
149
+
150
+ puts "Releasing the workitem :"
151
+ puts "ok" if client.releaseWorkitem(wi)
152
+
153
+ puts
154
+
155
+ puts "Listing launchables :"
156
+ client.listLaunchables().each do |l|
157
+ puts " - launchable #{l.engineId} :: #{l.url}"
158
+ end
159
+
160
+ puts
161
+
162
+ puts "Closing worklist worksession"
163
+ puts client.close()
164
+
165
+ end
166
+
167
+
168
+ #
169
+ # TESTING THE CONTROL IFACE
170
+ #
171
+
172
+ if @test_control
173
+
174
+ def display_expressions (exps)
175
+ i = 0
176
+ exps.each do |exp|
177
+ print " - exp #{i} : #{exp.id}"
178
+ print " / #{exp.applyTime}" if exp.applyTime
179
+ print "\n"
180
+ i = i+1
181
+ end
182
+ end
183
+
184
+ puts "Testing the control interface..."
185
+
186
+ #
187
+ # launching a test flow
188
+
189
+ #TEST_NAME = '-- testing ruby control (0) --'
190
+
191
+ #client = OpenWFE::WorklistClient\
192
+ # .new("http://127.0.0.1:5080/worklist", "alice", "alice")
193
+
194
+ #li = OpenWFE::LaunchItem.new()
195
+ #li.workflowDefinitionUrl = "http://localhost:7079/flow__1.0.xml"
196
+ #li.attributes["__subject__"] = TEST_NAME
197
+
198
+ #fei = client.launchFlow("mainEngine", li)
199
+ #puts "launched : #{fei}"
200
+
201
+ #client.close()
202
+
203
+ #
204
+ # controlling the test flow
205
+
206
+ client = OpenWFE::ControlClient\
207
+ .new("http://127.0.0.1:6080/engine", "admin", "admin")
208
+
209
+ puts "sessionId : #{client.sessionId}"
210
+
211
+ puts
212
+
213
+ puts "listing expressions :"
214
+ exps = client.listExpressions()
215
+ display_expressions(exps)
216
+
217
+ client.close()
218
+
219
+ end
220
+
data/lib/utils.rb ADDED
@@ -0,0 +1,94 @@
1
+ #
2
+ # Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # . Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # . Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without
17
+ # specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # $Id: utils.rb 3454 2006-10-08 16:51:00Z jmettraux $
32
+ #
33
+
34
+ #
35
+ # "hecho en Costa Rica"
36
+ #
37
+ # john.mettraux@openwfe.org
38
+ #
39
+
40
+ module OpenWFE
41
+
42
+ #
43
+ # Returns the first subelt of xmlElt that matches the given xpath.
44
+ # If xpath is null, the first elt will be returned.
45
+ #
46
+ def OpenWFE.firstElement (xmlElt, elementName=nil)
47
+
48
+ return nil if not xmlElt
49
+
50
+ return xmlElt.elements[1] if not elementName
51
+
52
+ xmlElt.elements.each do |elt|
53
+ return elt if elt.name == elementName
54
+ end
55
+
56
+ return nil
57
+ end
58
+
59
+ #
60
+ # Used in tests, is equivalent to Perl's die() method.
61
+ #
62
+ def OpenWFE.die (text)
63
+ puts text
64
+ exit 1
65
+ end
66
+
67
+ #
68
+ # Attempts a deep cloning of the object
69
+ #
70
+ def OpenWFE.copy (object)
71
+
72
+ return nil if object == nil
73
+
74
+ if object.kind_of?(Array)
75
+ result = []
76
+ object.each do |i|
77
+ result << copy(i)
78
+ end
79
+ return result
80
+ end
81
+
82
+ if object.kind_of?(Hash)
83
+ result = {}
84
+ object.each do |k, v|
85
+ result[copy(k)] = copy(v)
86
+ end
87
+ return result
88
+ end
89
+
90
+ return object.dup
91
+ end
92
+
93
+ end
94
+
data/lib/workitem.rb ADDED
@@ -0,0 +1,250 @@
1
+ #
2
+ # Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
3
+ # All rights reserved.
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+ #
8
+ # . Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ #
11
+ # . Redistributions in binary form must reproduce the above copyright notice,
12
+ # this list of conditions and the following disclaimer in the documentation
13
+ # and/or other materials provided with the distribution.
14
+ #
15
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without
17
+ # specific prior written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
+ # POSSIBILITY OF SUCH DAMAGE.
30
+ #
31
+ # $Id: workitem.rb 3556 2006-11-13 04:15:52Z jmettraux $
32
+ #
33
+
34
+ #
35
+ # "hecho en Costa Rica"
36
+ #
37
+ # john.mettraux@openwfe.org
38
+ #
39
+
40
+ require 'base64'
41
+
42
+ require 'definitions'
43
+ require 'utils'
44
+
45
+
46
+ module OpenWFE
47
+
48
+ #
49
+ # WORKITEMS
50
+ #
51
+
52
+ class WorkItem
53
+
54
+ attr_accessor :lastModified, :attributes
55
+
56
+ def initialize ()
57
+
58
+ @lastModified = nil
59
+
60
+ @attributes = {}
61
+ @attributes[MAP_TYPE] = E_SMAP
62
+ end
63
+
64
+ def copy ()
65
+ raise "not implemented"
66
+ end
67
+ end
68
+
69
+ class InFlowItem < WorkItem
70
+
71
+ attr_accessor :flowExpressionId, :participantName
72
+
73
+ def lastExpressionId
74
+ return @flowExpressionId
75
+ end
76
+
77
+ def lastExpressionId= (fei)
78
+ @flowExpressionId = fei
79
+ end
80
+ end
81
+
82
+ class InFlowWorkItem < InFlowItem
83
+
84
+ attr_accessor :dispatchTime, :filter, :history
85
+
86
+ attr_accessor :store
87
+ #
88
+ # special : added by the ruby lib, not given by the worklist
89
+
90
+ def dup
91
+ c = InFlowWorkItem.new
92
+ c.lastModified = OpenWFE::copy(@lastModified)
93
+ c.attributes = OpenWFE::copy(@attributes)
94
+ c.flowExpressionId = OpenWFE::copy(@flowExpressionId)
95
+ c.participantName = OpenWFE::copy(@participantName)
96
+ c.dispatchTime = OpenWFE::copy(@dispatchTime)
97
+ c.filter = OpenWFE::copy(@filter)
98
+ c.history = OpenWFE::copy(@history)
99
+ c.store = OpenWFE::copy(@store)
100
+ return c
101
+ end
102
+ end
103
+
104
+ class CancelItem < InFlowItem
105
+ end
106
+
107
+ class LaunchItem < WorkItem
108
+
109
+ attr_accessor :workflowDefinitionUrl
110
+ #, :descriptionMap
111
+ end
112
+
113
+
114
+ #
115
+ # HISTORY ITEM
116
+ #
117
+
118
+ class HistoryItem
119
+
120
+ attr_accessor \
121
+ :date, \
122
+ :author, \
123
+ :host, \
124
+ :text, \
125
+ :wfdName, \
126
+ :wfdRevision, \
127
+ :wfInstanceId, \
128
+ :expressionId
129
+ end
130
+
131
+
132
+ #
133
+ # STORES
134
+ #
135
+
136
+ #
137
+ # Models the information about a store as viewed by the current user
138
+ # (upon calling the listStores or getStoreNames methods)
139
+ #
140
+ class Store
141
+
142
+ attr_accessor :name, :workitemCount, :permissions
143
+
144
+ def initialize ()
145
+ @name = nil
146
+ @workitemCount = nil
147
+ @permissions = nil
148
+ end
149
+
150
+ #
151
+ # Returns true if the current user may read headers and workitems
152
+ # from this store
153
+ #
154
+ def mayRead? ()
155
+ return @permissions.index('r') > -1
156
+ end
157
+
158
+ #
159
+ # Returns true if the current user may modify workitems (and at least
160
+ # proceed/forward them) in this store
161
+ #
162
+ def mayWrite? ()
163
+ return @permissions.index('w') > -1
164
+ end
165
+
166
+ #
167
+ # Returns true if the current user may browse the headers of this
168
+ # store
169
+ #
170
+ def mayBrowse? ()
171
+ return @permissions.index('b') > -1
172
+ end
173
+
174
+ #
175
+ # Returns true if the current user may delegate workitems to this store
176
+ #
177
+ def mayDelegate? ()
178
+ return @permissions.index('d') > -1
179
+ end
180
+ end
181
+
182
+ #
183
+ # A header is a summary of a workitem, returned by the getHeader
184
+ # worklist method
185
+ #
186
+ class Header
187
+
188
+ attr_accessor :lastModified, :locked, :flowExpressionId, :attributes
189
+ end
190
+
191
+
192
+ #
193
+ # MISC ATTRIBUTES
194
+ #
195
+ # in openwfe-ruby, OpenWFE attributes are immediately mapped to
196
+ # Ruby instances, but some attributes still deserve their own class
197
+ #
198
+
199
+ #
200
+ # a wrapper for some binary content
201
+ #
202
+ class Base64Attribute
203
+
204
+ attr_accessor :content
205
+
206
+ def initialize (base64content)
207
+
208
+ @content = base64content
209
+ end
210
+
211
+ #
212
+ # dewraps (decode) the current content and returns it
213
+ #
214
+ def dewrap ()
215
+
216
+ return Base64.decode64(@content)
217
+ end
218
+
219
+ #
220
+ # wraps some binary content and stores it in this attribute
221
+ # (class method)
222
+ #
223
+ def Base64Attribute.wrap (binaryData)
224
+
225
+ return Base64Attribute.new(Base64.encode64(binaryData))
226
+ end
227
+ end
228
+
229
+
230
+ #
231
+ # LAUNCHABLE
232
+ #
233
+
234
+ class Launchable
235
+
236
+ attr_accessor :url, :engineId
237
+ end
238
+
239
+
240
+ #
241
+ # EXPRESSION (for the control iface)
242
+ #
243
+
244
+ class Expression
245
+
246
+ attr_accessor :id, :applyTime, :state, :stateSince
247
+ end
248
+
249
+ end
250
+