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.
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
@@ -0,0 +1,140 @@
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/flowexpression'
41
+ require 'ru/ruutils'
42
+
43
+
44
+ module OpenWFEru
45
+
46
+ #
47
+ # An environment is a store for variables.
48
+ # It's an expression as it's storable in the expression pool.
49
+ #
50
+ class Environment < FlowExpression
51
+
52
+ attr_accessor \
53
+ :variables
54
+
55
+ def initialize \
56
+ (id, parent, environment_id, application_context, attributes)
57
+
58
+ super(id, parent, environment_id, application_context, attributes)
59
+
60
+ @variables = {}
61
+ end
62
+
63
+ def [] (key)
64
+ if OpenWFEru::starts_with(key, "//")
65
+ return get_expression_pool()\
66
+ .get_engine_environment()[key[2..-1]]
67
+ end
68
+ if OpenWFEru::starts_with(key, "/")
69
+ return get_root_environment()[key[1..-1]]
70
+ end
71
+
72
+ value = @variables[key]
73
+
74
+ return value \
75
+ if @variables.has_key?(key) or is_engine_environment?
76
+ #if value or is_engine_environment?
77
+
78
+ return get_parent()[key] if @parentId
79
+
80
+ return get_expression_pool().fetch_engine_environment()[key]
81
+ end
82
+
83
+ def []= (key, value)
84
+ if OpenWFEru::starts_with(key, "//")
85
+ key = key[2..-1]
86
+ get_expression_pool().fetch_engine_environment()[key] = value
87
+ elsif OpenWFEru::starts_with(key, "/")
88
+ key = key[1..-1]
89
+ get_root_environment()[key] = value
90
+ else
91
+ @variables[key] = value
92
+ store_itself()
93
+
94
+ ldebug { "[]= #{@fei.to_debug_s} : '#{key}' -> '#{value}'" }
95
+ end
96
+ end
97
+
98
+ def delete (key)
99
+ if OpenWFEru::starts_with(key, "//")
100
+ key = key[2..-1]
101
+ get_expression_pool().fetch_engine_environment().delete(key)
102
+ elsif OpenWFEru::starts_with(key, "/")
103
+ key = key[1..-1]
104
+ get_root_environment().delete(key)
105
+ else
106
+ @variables.delete(key)
107
+ end
108
+ end
109
+
110
+ #
111
+ # This method is usually called before the environment gets wiped
112
+ # out of the expression pool.
113
+ # It takes care of removing subprocess templates pointed at by
114
+ # variables in this environment.
115
+ #
116
+ def unbind ()
117
+ @variables.each do |key, value|
118
+ get_expression_pool().remove(value) \
119
+ if value.kind_of? OpenWFE::FlowExpressionId
120
+ end
121
+ end
122
+
123
+ #
124
+ # Returns true if this environment is the engine environment
125
+ #
126
+ def is_engine_environment?
127
+ return @fei == get_expression_pool().engine_environment_id
128
+ end
129
+
130
+ protected
131
+
132
+ def get_root_environment ()
133
+ #ldebug { "get_root_environment()\n#{self}" }
134
+ return self if not @parent_id
135
+ return get_parent().get_root_environment()
136
+ end
137
+ end
138
+
139
+ end
140
+
@@ -0,0 +1,120 @@
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/service'
41
+ require 'ru/fe_define'
42
+ require 'ru/fe_base'
43
+ require 'ru/fe_misc'
44
+ require 'ru/fe_value'
45
+ require 'ru/fe_subprocess'
46
+ require 'ru/fe_concurrence'
47
+ require 'ru/fe_participant'
48
+ require 'ru/fe_time'
49
+
50
+
51
+ module OpenWFEru
52
+
53
+ #
54
+ # The mapping between expression names like 'sequence', 'participant', etc
55
+ # and classes like 'ParticipantExpression', 'SequenceExpression', etc.
56
+ #
57
+ class ExpressionMap < Service
58
+
59
+ #attr_accessor \
60
+ # :applicationContext
61
+
62
+ SYNC_PREFIX = "sync::"
63
+
64
+ def initialize (serviceName, applicationContext)
65
+ super(serviceName, applicationContext)
66
+
67
+ @map = {}
68
+
69
+ @map["process-definition"] = DefineExpression
70
+ @map["workflow-definition"] = DefineExpression
71
+ @map["define"] = DefineExpression
72
+
73
+ @map["sequence"] = SequenceExpression
74
+ @map["participant"] = ParticipantExpression
75
+
76
+ @map["concurrence"] = ConcurrenceExpression
77
+ @map["#{SYNC_PREFIX}generic"] = GenericSyncExpression
78
+
79
+ @map["subprocess"] = SubprocessRefExpression
80
+
81
+ @map["set"] = SetValueExpression
82
+ @map["unset"] = UnsetValueExpression
83
+
84
+ @map["if"] = IfExpression
85
+ @map["equals"] = EqualsExpression
86
+
87
+ @map["sleep"] = SleepExpression
88
+ @map["cron"] = CronExpression
89
+
90
+ @map["reval"] = RevalExpression
91
+ @map["print"] = PrintExpression
92
+ end
93
+
94
+ #
95
+ # Returns the expression class corresponding to the given
96
+ # expression name
97
+ #
98
+ def get_class (expressionname)
99
+ return @map[expressionname]
100
+ end
101
+
102
+ def get_sync_class (expressionname)
103
+ return @map["#{SYNC_PREFIX}#{expressionname}"]
104
+ end
105
+
106
+ #
107
+ # Returns true if the given expression name ('sequence',
108
+ # 'process-definition', ...) is a DefineExpression.
109
+ #
110
+ def is_definition? (expressionname)
111
+ c = get_class(expressionname)
112
+ return \
113
+ (c == OpenWFEru::DefineExpression or
114
+ c == OpenWFEru::SetValueExpression)
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
@@ -0,0 +1,339 @@
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 'uri'
41
+ require 'monitor'
42
+ require 'net/http'
43
+
44
+ require 'flowexpressionid'
45
+ require 'ru/service'
46
+ require 'ru/environment'
47
+ require 'ru/fe_raw'
48
+ require 'ru/rudefinitions'
49
+
50
+
51
+ module OpenWFEru
52
+
53
+ class ExpressionPool < Service
54
+ include MonitorMixin
55
+
56
+ @@last_given_instance_id = -1
57
+ #
58
+ # storing at class level the last workflow instance id given
59
+
60
+ #def initialize (serviceName, applicationContext)
61
+ # super(serviceName, applicationContext)
62
+ #end
63
+
64
+ #
65
+ # Instantiates a workflow definition and launches it.
66
+ #
67
+ def launch (launchitem)
68
+
69
+ wi = build_workitem(launchitem)
70
+ xmldef = fetch_definition(launchitem)
71
+
72
+ fei = new_fei(launchitem.workflowDefinitionUrl, xmldef)
73
+
74
+ rawExpression = RawExpression\
75
+ .new(fei, nil, nil, @application_context, xmldef)
76
+
77
+ rawExpression.apply(wi)
78
+ end
79
+
80
+ #
81
+ # launches a subprocess
82
+ #
83
+ def launch_template \
84
+ (requesting_expression, template_fei, workitem, params)
85
+
86
+ ldebug { "launch() request for #{template_fei.to_debug_s}" }
87
+
88
+ rawexp = fetch(template_fei)
89
+ rawexp = rawexp.dup()
90
+ rawexp.fei = rawexp.fei.dup()
91
+
92
+ if requesting_expression.kind_of? OpenWFE::FlowExpressionId
93
+ rawexp.parent_id = requesting_expression
94
+ rawexp.fei.workflowInstanceId = \
95
+ "#{requesting_expression.workflowInstanceId}.0"
96
+ elsif requesting_expression.kind_of? String
97
+ rawexp.parent_id = nil
98
+ rawexp.fei.workflowInstanceId = \
99
+ "#{requesting_expression}.0"
100
+ else # kind is FlowExpression
101
+ rawexp.parent_id = requesting_expression.fei
102
+ rawexp.fei.workflowInstanceId = \
103
+ "#{requesting_expression.fei.workflowInstanceId}.0"
104
+ end
105
+
106
+ #ldebug do
107
+ # "launch_template() spawning wfid " +
108
+ # "#{rawexp.fei.workflowInstanceId.to_s}"
109
+ #end
110
+
111
+ env = rawexp.new_environment()
112
+ params.each { |k, v| env[k] = v } if params
113
+ #
114
+ # the new scope gets its own environment
115
+
116
+ rawexp.store_itself()
117
+
118
+ rawexp.apply(workitem)
119
+ end
120
+
121
+ #
122
+ # Applies a given expression (id)
123
+ #
124
+ def apply (flowExpressionId, workitem)
125
+
126
+ ldebug { "apply() #{flowExpressionId.to_debug_s}" }
127
+
128
+ workitem.lastExpressionId = flowExpressionId
129
+
130
+ exp = fetch(flowExpressionId)
131
+ exp.apply(workitem)
132
+ end
133
+
134
+ #
135
+ # Replies to the parent of the given expression.
136
+ #
137
+ def reply_to_parent (flowExpression, workitem)
138
+
139
+ workitem.lastExpressionId = flowExpression.fei
140
+
141
+ remove(flowExpression)
142
+
143
+ if flowExpression.parent_id
144
+ reply(flowExpression.parent_id, workitem)
145
+ else
146
+ ldebug do
147
+ "reply_to_parent() process #{flowExpression.fei.workflowInstanceId} terminated"
148
+ #get_expression_storage().to_s
149
+ end
150
+ end
151
+ end
152
+
153
+ #
154
+ # Triggers the reply expression of the expression given by its id.
155
+ #
156
+ def reply (flowExpressionId, workitem)
157
+ ldebug { "reply() #{flowExpressionId.to_debug_s}" }
158
+ exp = fetch(flowExpressionId)
159
+ exp.reply(workitem)
160
+ end
161
+
162
+ #
163
+ # Adds or updates a flow expression in this pool
164
+ #
165
+ def update (flowExpression)
166
+
167
+ get_expression_storage()[flowExpression.fei] = flowExpression
168
+
169
+ #ldebug do
170
+ # "update() sz #{get_expression_storage.length} "+
171
+ # "#{flowExpression.fei.to_debug_s}"
172
+ #end
173
+
174
+ #ldebug do
175
+ # "update() sz #{get_expression_storage.length} "+
176
+ # "#{flowExpression.fei.to_s}\n"+
177
+ # get_expression_storage().to_s
178
+ #end
179
+
180
+ #ldebug { "update()\n" + get_expression_storage().to_s }
181
+ end
182
+
183
+ #
184
+ # Fetches a flowExpression from the pool
185
+ #
186
+ def fetch (flowExpressionId)
187
+
188
+ exp = get_expression_storage()[flowExpressionId]
189
+
190
+ #ldebug { "fetch() did not find #{flowExpressionId.to_debug_s}" } \
191
+ # if not exp
192
+
193
+ return exp
194
+ end
195
+
196
+ def fetch_engine_environment ()
197
+ synchronize do
198
+ eei = engine_environment_id
199
+ ee = fetch(eei)
200
+
201
+ if not ee
202
+ ee = Environment\
203
+ .new(eei, nil, nil, @application_context, nil)
204
+ ee.store_itself()
205
+ end
206
+
207
+ ldebug { "fetch_engine_environment() stored new ee" }
208
+
209
+ return ee
210
+ end
211
+ end
212
+
213
+ #
214
+ # Removes a flow expression from the pool
215
+ # (This method is mainly called from the pool itself)
216
+ #
217
+ def remove (flowExpression)
218
+
219
+ if flowExpression.kind_of? OpenWFE::FlowExpressionId
220
+ ldebug { "remove() fei #{flowExpression.to_debug_s}" }
221
+ flowExpression = fetch(flowExpression)
222
+ end
223
+
224
+ return if not flowExpression
225
+
226
+ ldebug { "remove() fe #{flowExpression.fei.to_debug_s}" }
227
+
228
+ #ldebug do
229
+ # "remove() #{flowExpression.fei.to_debug_s}"
230
+ # #"remove() sz before #{get_expression_storage.length}\n" +
231
+ # #get_expression_storage().to_s
232
+ #end
233
+
234
+ get_expression_storage().delete(flowExpression.fei)
235
+
236
+ if flowExpression.owns_its_environment?
237
+ remove_environment(flowExpression.environment_id)
238
+ end
239
+
240
+ #ldebug do
241
+ # "remove() sz after #{get_expression_storage.length}\n" +
242
+ # get_expression_storage().to_s
243
+ #end
244
+ end
245
+
246
+ def engine_environment_id ()
247
+ synchronize do
248
+ return @eei if @eei
249
+ @eei = OpenWFE::FlowExpressionId.new
250
+ @eei.owfeVersion = OPENWFE_VERSION
251
+ @eei.engineId = lookup(Engine).service_name
252
+ @eei.initialEngineId = @eei.engineId
253
+ @eei.workflowDefinitionUrl = 'ee'
254
+ @eei.workflowDefinitionName = 'ee'
255
+ @eei.workflowDefinitionRevision = '0'
256
+ @eei.workflowInstanceId = '0'
257
+ @eei.expressionName = EN_ENVIRONMENT
258
+ @eei.expressionId = '0'
259
+ return @eei
260
+ end
261
+ end
262
+
263
+ def get_expression_storage ()
264
+ return @application_context[S_EXPRESSION_STORAGE]
265
+ end
266
+
267
+ protected
268
+
269
+ def remove_environment (environment_id)
270
+ env = fetch(environment_id)
271
+ env.unbind()
272
+ get_expression_storage().delete(environment_id)
273
+ end
274
+
275
+ def build_workitem (launchitem)
276
+
277
+ wi = OpenWFE::InFlowWorkItem.new()
278
+
279
+ wi.attributes = launchitem.attributes.dup()
280
+
281
+ return wi
282
+ end
283
+
284
+ def fetch_definition (launchitem)
285
+
286
+ wfdUrl = launchitem.workflowDefinitionUrl
287
+
288
+ #ldebug { "wfdUrl is '#{wfdUrl}'" }
289
+
290
+ sDefinition = nil
291
+
292
+ if wfdUrl[0..5] == 'field:'
293
+ sDefinition = launchitem.attributes[wfdUrl[6..-1]]
294
+ else
295
+ sDefinition = NET::HTTP.get(URI.parse(wfdUrl))
296
+ end
297
+
298
+ #ldebug { "sDefinition is \n#{sDefinition}" }
299
+
300
+ return REXML::Document.new(sDefinition).root
301
+ end
302
+
303
+ def new_fei (flow_url, xml_element)
304
+
305
+ fei = OpenWFE::FlowExpressionId.new
306
+
307
+ fei.owfeVersion = OPENWFE_VERSION
308
+
309
+ fei.engineId = lookup(Engine).service_name
310
+ fei.initialEngineId = fei.engineId
311
+
312
+ fei.workflowDefinitionUrl = flow_url
313
+
314
+ fei.workflowDefinitionName = \
315
+ xml_element.attributes['name'].to_str
316
+ fei.workflowDefinitionRevision = \
317
+ xml_element.attributes['revision'].to_str
318
+
319
+ fei.workflowInstanceId = new_workflow_instance_id()
320
+
321
+ fei.expressionId = "0"
322
+ fei.expressionName = xml_element.name
323
+
324
+ return fei
325
+ end
326
+
327
+ def new_workflow_instance_id ()
328
+ synchronize do
329
+ wfid = OpenWFE::current_time_millis()
330
+ wfid = wfid + 1 if wfid == @@last_given_instance_id
331
+ @@last_given_instance_id = wfid
332
+ return wfid.to_s
333
+ end
334
+ end
335
+
336
+ end
337
+
338
+ end
339
+
@@ -0,0 +1,97 @@
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
+
41
+ require 'ru/service'
42
+
43
+
44
+ module OpenWFEru
45
+
46
+ #
47
+ # In OpenWFEja, an ExpressionStorage is called an ExpressionStore
48
+ # I prefer the 'storage' concept.
49
+ #
50
+ class InMemoryExpressionStorage < Hash
51
+ include ServiceMixin
52
+
53
+ def initialize (service_name, application_context)
54
+ super()
55
+ @service_name = service_name
56
+ @application_context = application_context
57
+ end
58
+
59
+ #def []= (k, v)
60
+ # super(k.to_s, v)
61
+ #end
62
+ #def delete (k)
63
+ # super(k.to_s)
64
+ #end
65
+ #def [] (k)
66
+ # result = super(k)
67
+ # return result if result
68
+ # ldebug do
69
+ # result = ""
70
+ # self.each do |kk, vv|
71
+ # result << "\n#{k} ?= #{kk} : #{k == kk}"
72
+ # end
73
+ # result
74
+ # end
75
+ # return nil
76
+ #end
77
+
78
+ def to_s
79
+ s = "\n\n==== #{self.class} ===="
80
+ each do |k, v|
81
+ s << "\n"
82
+ if v.kind_of?(RawExpression)
83
+ s << "*raw"
84
+ else
85
+ s << " "
86
+ end
87
+ s << v.to_s
88
+ s << " key/value mismatch !" if k != v.fei
89
+ end
90
+ s << "\n==== . ====\n"
91
+ return s
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+