openwferu 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +47 -0
- data/lib/codec.rb +571 -0
- data/lib/controlclient.rb +115 -0
- data/lib/definitions.rb +112 -0
- data/lib/exception.rb +60 -0
- data/lib/flowexpressionid.rb +137 -0
- data/lib/openwferu.rb +43 -0
- data/lib/osocket.rb +138 -0
- data/lib/otime.rb +171 -0
- data/lib/restclient.rb +155 -0
- data/lib/ru/contextual.rb +63 -0
- data/lib/ru/dollar.rb +163 -0
- data/lib/ru/engine.rb +130 -0
- data/lib/ru/environment.rb +140 -0
- data/lib/ru/expressionmap.rb +120 -0
- data/lib/ru/expressionpool.rb +339 -0
- data/lib/ru/expressionstorage.rb +97 -0
- data/lib/ru/fe_base.rb +105 -0
- data/lib/ru/fe_concurrence.rb +122 -0
- data/lib/ru/fe_define.rb +101 -0
- data/lib/ru/fe_misc.rb +96 -0
- data/lib/ru/fe_participant.rb +75 -0
- data/lib/ru/fe_raw.rb +173 -0
- data/lib/ru/fe_subprocess.rb +84 -0
- data/lib/ru/fe_time.rb +135 -0
- data/lib/ru/fe_utils.rb +123 -0
- data/lib/ru/fe_value.rb +225 -0
- data/lib/ru/flowexpression.rb +250 -0
- data/lib/ru/logging.rb +85 -0
- data/lib/ru/participant.rb +67 -0
- data/lib/ru/participantmap.rb +93 -0
- data/lib/ru/participants.rb +74 -0
- data/lib/ru/rudefinitions.rb +70 -0
- data/lib/ru/ruutils.rb +68 -0
- data/lib/ru/scheduler.rb +478 -0
- data/lib/ru/schedulers.rb +63 -0
- data/lib/ru/service.rb +64 -0
- data/lib/test.rb +220 -0
- data/lib/utils.rb +94 -0
- data/lib/workitem.rb +250 -0
- data/lib/worklistclient.rb +276 -0
- data/test/dollartest.rb +79 -0
- data/test/feitest.rb +130 -0
- data/test/flowtestbase.rb +86 -0
- data/test/ft_0.rb +161 -0
- data/test/ft_1_unset.rb +152 -0
- data/test/ft_2_concurrence.rb +34 -0
- data/test/ft_3_equals.rb +84 -0
- data/test/ft_4_misc.rb +128 -0
- data/test/ft_5_time.rb +56 -0
- data/test/misctest.rb +46 -0
- data/test/runtest.rb +21 -0
- data/test/rutest_utils.rb +15 -0
- data/test/timetest.rb +111 -0
- metadata +100 -0
@@ -0,0 +1,250 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'ru/rudefinitions'
|
41
|
+
require 'ru/contextual'
|
42
|
+
require 'ru/dollar'
|
43
|
+
require 'ru/logging'
|
44
|
+
|
45
|
+
|
46
|
+
module OpenWFEru
|
47
|
+
|
48
|
+
#
|
49
|
+
# FlowExpression
|
50
|
+
#
|
51
|
+
|
52
|
+
class FlowExpression
|
53
|
+
include Contextual, Logging
|
54
|
+
|
55
|
+
attr_accessor \
|
56
|
+
:fei, \
|
57
|
+
:parent_id, \
|
58
|
+
:environment_id, \
|
59
|
+
:attributes, \
|
60
|
+
:children, \
|
61
|
+
:apply_time
|
62
|
+
|
63
|
+
def initialize (fei, parent_id, env_id, app_context, attributes)
|
64
|
+
|
65
|
+
@fei = fei
|
66
|
+
@parent_id = parent_id
|
67
|
+
@environment_id = env_id
|
68
|
+
@application_context = app_context
|
69
|
+
@attributes = attributes
|
70
|
+
|
71
|
+
@apply_time = nil
|
72
|
+
|
73
|
+
#ldebug do
|
74
|
+
# "initialize()\n"+
|
75
|
+
# "self : #{@fei}\n"+
|
76
|
+
# "parent : #{@parent_id}"
|
77
|
+
#end
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# the two most important methods for flow expressions
|
82
|
+
|
83
|
+
def apply (workitem)
|
84
|
+
get_parent().reply(workitem) if @parent_id
|
85
|
+
end
|
86
|
+
|
87
|
+
def reply (workitem)
|
88
|
+
#
|
89
|
+
# a default implementation
|
90
|
+
#
|
91
|
+
reply_to_parent(workitem)
|
92
|
+
end
|
93
|
+
|
94
|
+
def reply_to_parent (workitem)
|
95
|
+
get_expression_pool.reply_to_parent(self, workitem)
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# some convenience methods
|
100
|
+
|
101
|
+
def get_parent ()
|
102
|
+
get_expression_pool().fetch(@parent_id)
|
103
|
+
end
|
104
|
+
|
105
|
+
def get_expression_pool ()
|
106
|
+
@application_context[S_EXPRESSION_POOL]
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_expression_map ()
|
110
|
+
@application_context[S_EXPRESSION_MAP]
|
111
|
+
end
|
112
|
+
|
113
|
+
def store_itself ()
|
114
|
+
get_expression_pool().update(self)
|
115
|
+
end
|
116
|
+
|
117
|
+
def get_environment ()
|
118
|
+
return nil if not @environment_id
|
119
|
+
return get_expression_pool().fetch(@environment_id)
|
120
|
+
end
|
121
|
+
|
122
|
+
#
|
123
|
+
# Returns true if the expression's environment was generated
|
124
|
+
# for itself (usually DefineExpression do have such envs)
|
125
|
+
#
|
126
|
+
def owns_its_environment? ()
|
127
|
+
|
128
|
+
#ldebug { "owns_its_environment?() #{@fei.to_debug_s}" }
|
129
|
+
|
130
|
+
return false if not @environment_id
|
131
|
+
|
132
|
+
ei = @fei.dup()
|
133
|
+
vi = @environment_id.dup()
|
134
|
+
|
135
|
+
ei.expressionName = "neutral"
|
136
|
+
vi.expressionName = "neutral"
|
137
|
+
|
138
|
+
#ldebug do
|
139
|
+
# "owns_its_environment?()\n"+
|
140
|
+
# " exp #{ei.to_debug_s}\n"+
|
141
|
+
# " env #{vi.to_debug_s}"
|
142
|
+
#end
|
143
|
+
|
144
|
+
return ei == vi
|
145
|
+
end
|
146
|
+
|
147
|
+
def set_variable (varname, value)
|
148
|
+
get_environment()[varname] = value
|
149
|
+
end
|
150
|
+
|
151
|
+
def lookup_variable (varname)
|
152
|
+
return get_environment()[varname]
|
153
|
+
end
|
154
|
+
|
155
|
+
def delete_variable (varname)
|
156
|
+
get_environment().delete(varname)
|
157
|
+
end
|
158
|
+
|
159
|
+
def lookup_attribute (attname, workitem)
|
160
|
+
text = @attributes[attname]
|
161
|
+
return nil if not text
|
162
|
+
return OpenWFEru::dosub(text, self, workitem)
|
163
|
+
end
|
164
|
+
|
165
|
+
def lookup_boolean_attribute (attname, workitem, default=false)
|
166
|
+
value = lookup_attribute(attname, workitem)
|
167
|
+
return default if not value
|
168
|
+
return value.downcase == 'true'
|
169
|
+
end
|
170
|
+
|
171
|
+
def lookup_attributes (attributes, workitem)
|
172
|
+
result = {}
|
173
|
+
attributes.each do |k, v|
|
174
|
+
result[k] = OpenWFEru::dosub(v, self, workitem)
|
175
|
+
end
|
176
|
+
return result
|
177
|
+
end
|
178
|
+
|
179
|
+
def list_attributes (workitem)
|
180
|
+
result = {}
|
181
|
+
@attributes.each do |k, v|
|
182
|
+
result[k] = OpenWFEru::dosub(v, self, workitem)
|
183
|
+
ldebug { "list_attributes() added '#{k}' -> '#{result[k]}'" }
|
184
|
+
end
|
185
|
+
return result
|
186
|
+
end
|
187
|
+
|
188
|
+
#
|
189
|
+
# creates a new environment just for this expression
|
190
|
+
#
|
191
|
+
def new_environment ()
|
192
|
+
|
193
|
+
ldebug { "new_environment() for #{@fei.to_debug_s}" }
|
194
|
+
|
195
|
+
@environment_id = @fei.dup
|
196
|
+
@environment_id.expressionName = EN_ENVIRONMENT
|
197
|
+
|
198
|
+
parent_fei = nil
|
199
|
+
parent = nil
|
200
|
+
parent = get_expression_pool().fetch(@parent_id) if @parent_id
|
201
|
+
parent_fei = parent.environment_id if parent
|
202
|
+
|
203
|
+
env = Environment\
|
204
|
+
.new(@environment_id, parent_fei, nil, @application_context, nil)
|
205
|
+
|
206
|
+
ldebug { "new_environment() is #{env.fei.to_debug_s}" }
|
207
|
+
|
208
|
+
env.store_itself()
|
209
|
+
end
|
210
|
+
|
211
|
+
#
|
212
|
+
# takes care of removing all the children
|
213
|
+
#
|
214
|
+
def clean_children
|
215
|
+
@children.each do |children_fei|
|
216
|
+
get_expression_pool.remove(children_fei)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
#
|
221
|
+
# some eye candy
|
222
|
+
#
|
223
|
+
def to_s
|
224
|
+
s = "* #{@fei.to_debug_s}"
|
225
|
+
|
226
|
+
if @parent_id
|
227
|
+
s << "\n `--p--> #{@parent_id.to_debug_s}"
|
228
|
+
end
|
229
|
+
|
230
|
+
if @environment_id
|
231
|
+
s << "\n `--e--> #{@environment_id.to_debug_s}"
|
232
|
+
end
|
233
|
+
|
234
|
+
if @children
|
235
|
+
@children.each do |c|
|
236
|
+
sc = if c.kind_of?(OpenWFE::FlowExpressionId)
|
237
|
+
c.to_debug_s
|
238
|
+
else
|
239
|
+
">#{c.to_s}<"
|
240
|
+
end
|
241
|
+
s << "\n `--c--> #{sc}"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
return s
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
data/lib/ru/logging.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'logger'
|
41
|
+
require 'ru/rudefinitions'
|
42
|
+
|
43
|
+
module OpenWFEru
|
44
|
+
|
45
|
+
module Logging
|
46
|
+
|
47
|
+
def init_default_logging (filename)
|
48
|
+
log = Logger.new(filename)
|
49
|
+
@application_context[S_LOGGER] = log
|
50
|
+
end
|
51
|
+
|
52
|
+
def ldebug (&block)
|
53
|
+
log = get_logger
|
54
|
+
log.debug(who(), &block) if log
|
55
|
+
end
|
56
|
+
|
57
|
+
def linfo (&block)
|
58
|
+
log = get_logger
|
59
|
+
log.info(who(), &block) if log
|
60
|
+
end
|
61
|
+
|
62
|
+
def lwarn (&block)
|
63
|
+
log = get_logger
|
64
|
+
log.warn(who(), &block) if log
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def get_logger
|
70
|
+
return @application_context[S_LOGGER] if @application_context
|
71
|
+
return Logger.new(STDOUT)
|
72
|
+
end
|
73
|
+
|
74
|
+
def who
|
75
|
+
if respond_to?(:service_name)
|
76
|
+
"#{self.class} '#{self.service_name}'"
|
77
|
+
else
|
78
|
+
"#{self.class}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'ru/contextual'
|
41
|
+
|
42
|
+
|
43
|
+
module OpenWFEru
|
44
|
+
|
45
|
+
#
|
46
|
+
# The 'participant' concept is displayed as a module, so that
|
47
|
+
# other pieces of code may easily 'mix it in'.
|
48
|
+
#
|
49
|
+
module Participant
|
50
|
+
include Contextual
|
51
|
+
|
52
|
+
#
|
53
|
+
# a participant will be receiving workitems via this method
|
54
|
+
#
|
55
|
+
def consume (workitem)
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# when the workflow engine is cancelling a workflow branch, the
|
60
|
+
# already activated participants are notified via this method
|
61
|
+
#
|
62
|
+
def cancel (cancelitem)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'workitem'
|
41
|
+
require 'ru/service'
|
42
|
+
|
43
|
+
|
44
|
+
module OpenWFEru
|
45
|
+
|
46
|
+
class ParticipantMap < Service
|
47
|
+
|
48
|
+
attr_accessor \
|
49
|
+
:participants
|
50
|
+
|
51
|
+
def initialize (service_name, application_context)
|
52
|
+
super(service_name, application_context)
|
53
|
+
|
54
|
+
@participants = []
|
55
|
+
end
|
56
|
+
|
57
|
+
def register_participant (regex, participant)
|
58
|
+
|
59
|
+
regex = Regexp.new(regex) if not regex.kind_of? Regexp
|
60
|
+
|
61
|
+
participant.application_context = @application_context
|
62
|
+
|
63
|
+
@participants << [ regex, participant ]
|
64
|
+
end
|
65
|
+
|
66
|
+
def lookup_participant (participant_name)
|
67
|
+
|
68
|
+
@participants.each do |tuple|
|
69
|
+
return tuple[1] if tuple[0].match(participant_name)
|
70
|
+
end
|
71
|
+
|
72
|
+
return nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def dispatch (participant_name, workitem)
|
76
|
+
|
77
|
+
participant = lookup_participant(participant_name)
|
78
|
+
|
79
|
+
raise "Didn't find participant named '#{participant_name}'" \
|
80
|
+
if not participant
|
81
|
+
|
82
|
+
workitem.participantName = participant_name
|
83
|
+
|
84
|
+
if workitem.kind_of? OpenWFE::CancelItem
|
85
|
+
participant.cancel(workitem)
|
86
|
+
else
|
87
|
+
participant.consume(workitem)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
require 'ru/participant'
|
41
|
+
require 'ru/rudefinitions'
|
42
|
+
|
43
|
+
|
44
|
+
#
|
45
|
+
# some base participant implementations
|
46
|
+
|
47
|
+
module OpenWFEru
|
48
|
+
|
49
|
+
class LocalParticipant
|
50
|
+
include Participant
|
51
|
+
|
52
|
+
def reply_to_engine (workitem)
|
53
|
+
@application_context[S_EXPRESSION_POOL]\
|
54
|
+
.reply(workitem.lastExpressionId, workitem)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class PrintParticipant < LocalParticipant
|
59
|
+
|
60
|
+
def consume (workitem)
|
61
|
+
|
62
|
+
tracer = @application_context['__tracer']
|
63
|
+
|
64
|
+
if tracer
|
65
|
+
tracer << workitem.participantName
|
66
|
+
else
|
67
|
+
puts workitem.participantName
|
68
|
+
end
|
69
|
+
|
70
|
+
reply_to_engine(workitem)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# "made in Japan"
|
36
|
+
#
|
37
|
+
|
38
|
+
module OpenWFEru
|
39
|
+
|
40
|
+
OPENWFE_VERSION = '1.7.2pre17'
|
41
|
+
|
42
|
+
#
|
43
|
+
# service names
|
44
|
+
|
45
|
+
S_LOGGER = 'logger'
|
46
|
+
|
47
|
+
S_EXPRESSION_MAP = 'expressionMap'
|
48
|
+
S_EXPRESSION_POOL = 'expressionPool'
|
49
|
+
S_EXPRESSION_STORAGE = 'expressionStorage'
|
50
|
+
S_PARTICIPANT_MAP = 'participantMap'
|
51
|
+
S_SCHEDULER = 'scheduler'
|
52
|
+
|
53
|
+
#
|
54
|
+
# some field names
|
55
|
+
|
56
|
+
FIELD_RESULT = '__result__'
|
57
|
+
|
58
|
+
#
|
59
|
+
# some special expression names
|
60
|
+
|
61
|
+
EN_ENVIRONMENT = 'environment'
|
62
|
+
|
63
|
+
#
|
64
|
+
# some expression attribute names
|
65
|
+
|
66
|
+
A_SYNC = 'sync'
|
67
|
+
A_FORGET = 'forget'
|
68
|
+
|
69
|
+
end
|
70
|
+
|
data/lib/ru/ruutils.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 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: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
|
+
#
|
33
|
+
|
34
|
+
#
|
35
|
+
# made somewhere over Japan
|
36
|
+
#
|
37
|
+
# John Mettraux at openwfe.org
|
38
|
+
#
|
39
|
+
|
40
|
+
|
41
|
+
module OpenWFEru
|
42
|
+
|
43
|
+
#
|
44
|
+
# Returns true if the given string starts with the 'start' string.
|
45
|
+
#
|
46
|
+
def OpenWFEru.starts_with (string, start)
|
47
|
+
#
|
48
|
+
# my favourite way of doing that would be by adding this
|
49
|
+
# method to the String class, but that could be intrusive
|
50
|
+
# (as OpenWFEru is meant at first as an embeddable workflow engine).
|
51
|
+
#
|
52
|
+
return false if not string
|
53
|
+
return false if string.length < start.length
|
54
|
+
return string[0, start.length] == start
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Attempts at displaying a nice stack trace
|
59
|
+
#
|
60
|
+
def OpenWFEru.exception_to_s (exception)
|
61
|
+
s = ""
|
62
|
+
s << "#{exception}\n"
|
63
|
+
s << exception.backtrace.join("\n")
|
64
|
+
return s
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|