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
data/lib/ru/fe_base.rb
ADDED
@@ -0,0 +1,105 @@
|
|
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/flowexpression'
|
42
|
+
require 'ru/fe_utils'
|
43
|
+
|
44
|
+
|
45
|
+
#
|
46
|
+
# base expressions like 'sequence' and 'concurrence'
|
47
|
+
#
|
48
|
+
|
49
|
+
module OpenWFEru
|
50
|
+
|
51
|
+
class SequenceExpression < FlowExpression
|
52
|
+
|
53
|
+
attr_accessor \
|
54
|
+
:current_child_fei
|
55
|
+
|
56
|
+
#
|
57
|
+
# apply / reply
|
58
|
+
|
59
|
+
def apply (workitem)
|
60
|
+
|
61
|
+
reply(workitem)
|
62
|
+
end
|
63
|
+
|
64
|
+
def reply (workitem)
|
65
|
+
|
66
|
+
@current_child_fei = next_fei()
|
67
|
+
|
68
|
+
#ldebug { "reply() next_fei is #{@current_child_fei}" }
|
69
|
+
|
70
|
+
if @current_child_fei
|
71
|
+
store_itself()
|
72
|
+
get_expression_pool().apply(@current_child_fei, workitem)
|
73
|
+
else
|
74
|
+
reply_to_parent(workitem)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def next_fei ()
|
81
|
+
if not @current_child_fei
|
82
|
+
return @children.each do |c|
|
83
|
+
return c if c.kind_of?(OpenWFE::FlowExpressionId)
|
84
|
+
end
|
85
|
+
return nil
|
86
|
+
end
|
87
|
+
found = false
|
88
|
+
@children.each do |c|
|
89
|
+
ldebug { "next_fei() considering #{c} (found ? #{found})" }
|
90
|
+
if found
|
91
|
+
return c if c.kind_of?(OpenWFE::FlowExpressionId)
|
92
|
+
next
|
93
|
+
end
|
94
|
+
if c.kind_of?(OpenWFE::FlowExpressionId) and \
|
95
|
+
c == @current_child_fei
|
96
|
+
|
97
|
+
found = true
|
98
|
+
end
|
99
|
+
end
|
100
|
+
return nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
@@ -0,0 +1,122 @@
|
|
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/rudefinitions'
|
42
|
+
require 'ru/ruutils'
|
43
|
+
|
44
|
+
|
45
|
+
#
|
46
|
+
# base expressions like 'sequence' and 'concurrence'
|
47
|
+
#
|
48
|
+
|
49
|
+
module OpenWFEru
|
50
|
+
|
51
|
+
class ConcurrenceExpression < SequenceExpression
|
52
|
+
|
53
|
+
attr_accessor \
|
54
|
+
:sync_expression
|
55
|
+
|
56
|
+
def apply (workitem)
|
57
|
+
|
58
|
+
sync = lookup_attribute(A_SYNC, workitem)
|
59
|
+
sync = "generic" if not sync
|
60
|
+
@sync_expression = get_expression_map().get_sync_class(sync).new()
|
61
|
+
|
62
|
+
#threads = []
|
63
|
+
|
64
|
+
@children.each do |child|
|
65
|
+
t = Thread.new do
|
66
|
+
begin
|
67
|
+
@sync_expression.apply_child(self, child, workitem)
|
68
|
+
rescue Exception => e
|
69
|
+
lwarn do
|
70
|
+
"apply() caught exception in concurrent child\n" +
|
71
|
+
OpenWFEru::exception_to_s(e)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#threads << t
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def reply (workitem)
|
81
|
+
done = @sync_expression.reply(self, workitem)
|
82
|
+
reply_to_parent(done) if done
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class SyncExpression
|
87
|
+
include Logging, MonitorMixin
|
88
|
+
|
89
|
+
#def initialize()
|
90
|
+
# super()
|
91
|
+
#end
|
92
|
+
end
|
93
|
+
|
94
|
+
class GenericSyncExpression < SyncExpression
|
95
|
+
|
96
|
+
def initialize ()
|
97
|
+
super()
|
98
|
+
@reply_count = 0
|
99
|
+
end
|
100
|
+
|
101
|
+
def apply_child (synchable, child, workitem)
|
102
|
+
synchronize do
|
103
|
+
@application_context = synchable.application_context
|
104
|
+
ldebug { "apply_child() #{child.to_debug_s}" }
|
105
|
+
synchable.get_expression_pool().apply(child, workitem.dup)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def reply (synchable, workitem)
|
110
|
+
synchronize do
|
111
|
+
@application_context = synchable.application_context
|
112
|
+
ldebug { "reply() #{workitem.lastExpressionId.to_debug_s}" }
|
113
|
+
@reply_count = @reply_count + 1
|
114
|
+
return workitem \
|
115
|
+
if @reply_count >= synchable.children.length
|
116
|
+
return nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
|
data/lib/ru/fe_define.rb
ADDED
@@ -0,0 +1,101 @@
|
|
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/flowexpression'
|
42
|
+
|
43
|
+
|
44
|
+
module OpenWFEru
|
45
|
+
|
46
|
+
class DefineExpression < FlowExpression
|
47
|
+
|
48
|
+
def evaluate (workitem)
|
49
|
+
|
50
|
+
#ldebug { "evaluate() #{@fei.to_s}" }
|
51
|
+
|
52
|
+
#
|
53
|
+
# spot the body of this expression
|
54
|
+
# define each sub-definition
|
55
|
+
|
56
|
+
body_fei = nil
|
57
|
+
|
58
|
+
@children.each do |fei|
|
59
|
+
|
60
|
+
#ldebug { "evaluate() looking at #{fei.to_debug_s}" }
|
61
|
+
|
62
|
+
rawchild = get_expression_pool().fetch(fei)
|
63
|
+
|
64
|
+
if not rawchild.is_definition?
|
65
|
+
body_fei = rawchild.fei if not body_fei
|
66
|
+
next
|
67
|
+
end
|
68
|
+
|
69
|
+
# then it's a definition
|
70
|
+
|
71
|
+
get_environment()[rawchild.definition_name()] = fei
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# store self
|
76
|
+
|
77
|
+
store_itself()
|
78
|
+
|
79
|
+
#
|
80
|
+
# return the id of the body
|
81
|
+
|
82
|
+
return body_fei
|
83
|
+
end
|
84
|
+
|
85
|
+
#
|
86
|
+
# apply / reply
|
87
|
+
|
88
|
+
def apply (workitem)
|
89
|
+
#
|
90
|
+
# apply the body
|
91
|
+
|
92
|
+
body_fei = evaluate(workitem)
|
93
|
+
get_expression_pool().apply(body_fei, workitem)
|
94
|
+
end
|
95
|
+
|
96
|
+
#def reply (workitem)
|
97
|
+
#end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
data/lib/ru/fe_misc.rb
ADDED
@@ -0,0 +1,96 @@
|
|
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/fe_utils'
|
42
|
+
|
43
|
+
|
44
|
+
module OpenWFEru
|
45
|
+
|
46
|
+
class PrintExpression < FlowExpression
|
47
|
+
|
48
|
+
#
|
49
|
+
# apply / reply
|
50
|
+
|
51
|
+
def apply (workitem)
|
52
|
+
|
53
|
+
escape = lookup_boolean_attribute('escape', workitem, false)
|
54
|
+
|
55
|
+
text = OpenWFEru::fetch_text_content(self, workitem, escape)
|
56
|
+
tracer = @application_context['__tracer']
|
57
|
+
|
58
|
+
if tracer
|
59
|
+
tracer << text
|
60
|
+
else
|
61
|
+
puts text
|
62
|
+
end
|
63
|
+
|
64
|
+
reply_to_parent(workitem)
|
65
|
+
end
|
66
|
+
|
67
|
+
#def reply (workitem)
|
68
|
+
#end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# Evals some Ruby code contained within the process definition
|
74
|
+
# or within the workitem
|
75
|
+
#
|
76
|
+
class RevalExpression < FlowExpression
|
77
|
+
|
78
|
+
def apply (workitem)
|
79
|
+
|
80
|
+
escape = lookup_boolean_attribute('escape', workitem, false)
|
81
|
+
|
82
|
+
code = OpenWFEru::lookup_vf_attribute(self, workitem, 'code')
|
83
|
+
|
84
|
+
code = OpenWFEru::fetch_text_content(self, workitem, escape) \
|
85
|
+
if not code
|
86
|
+
|
87
|
+
result = eval(code.to_s)
|
88
|
+
|
89
|
+
OpenWFEru::set_result(workitem, result) if result != nil
|
90
|
+
|
91
|
+
reply_to_parent(workitem)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
@@ -0,0 +1,75 @@
|
|
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/rudefinitions'
|
42
|
+
require 'ru/fe_utils'
|
43
|
+
|
44
|
+
|
45
|
+
#
|
46
|
+
# The participant expression, in its own file
|
47
|
+
#
|
48
|
+
|
49
|
+
module OpenWFEru
|
50
|
+
|
51
|
+
class ParticipantExpression < FlowExpression
|
52
|
+
|
53
|
+
#attr_accessor \
|
54
|
+
# :applied_workitem
|
55
|
+
|
56
|
+
#
|
57
|
+
# apply / reply
|
58
|
+
|
59
|
+
def apply (workitem)
|
60
|
+
|
61
|
+
#@applied_workitem = workitem
|
62
|
+
|
63
|
+
participant_name = \
|
64
|
+
OpenWFEru::lookup_vf_attribute(self, workitem, 'ref')
|
65
|
+
|
66
|
+
@application_context[S_PARTICIPANT_MAP]\
|
67
|
+
.dispatch(participant_name, workitem)
|
68
|
+
end
|
69
|
+
|
70
|
+
#def reply (workitem)
|
71
|
+
#end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
data/lib/ru/fe_raw.rb
ADDED
@@ -0,0 +1,173 @@
|
|
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 'rexml/document'
|
41
|
+
|
42
|
+
require 'otime'
|
43
|
+
require 'workitem'
|
44
|
+
require 'ru/engine'
|
45
|
+
require 'ru/rudefinitions'
|
46
|
+
require 'ru/flowexpression'
|
47
|
+
require 'ru/fe_base'
|
48
|
+
|
49
|
+
|
50
|
+
module OpenWFEru
|
51
|
+
|
52
|
+
class RawExpression < FlowExpression
|
53
|
+
|
54
|
+
attr_accessor \
|
55
|
+
:xml_element
|
56
|
+
|
57
|
+
def initialize \
|
58
|
+
(fei, parent_id, environment_id, application_context, xml_element)
|
59
|
+
|
60
|
+
super(fei, parent_id, environment_id, application_context, nil)
|
61
|
+
|
62
|
+
@xml_element = xml_element
|
63
|
+
|
64
|
+
new_environment() if not @environment_id
|
65
|
+
end
|
66
|
+
|
67
|
+
def apply (workitem)
|
68
|
+
#ldebug { "apply() parent is #{@parent_id}" }
|
69
|
+
|
70
|
+
attributes = extract_attributes()
|
71
|
+
|
72
|
+
#ldebug { "apply() expression_name is '#{expression_name()}'" }
|
73
|
+
#ldebug { "apply() expression_class is '#{expression_class()}'" }
|
74
|
+
|
75
|
+
template = lookup_variable(expression_name())
|
76
|
+
|
77
|
+
if template and template.kind_of? OpenWFE::FlowExpressionId
|
78
|
+
get_expression_pool().launch_template(\
|
79
|
+
self,
|
80
|
+
template,
|
81
|
+
workitem,
|
82
|
+
lookup_attributes(attributes, workitem))
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
eclass = expression_class()
|
87
|
+
raise "unknown expression '#{expression_name}'" if not eclass
|
88
|
+
|
89
|
+
expression = eclass.new(@fei, @parent_id, @environment_id, @application_context, attributes)
|
90
|
+
expression.children = extract_children()
|
91
|
+
|
92
|
+
expression.store_itself()
|
93
|
+
|
94
|
+
expression.apply(workitem)
|
95
|
+
end
|
96
|
+
|
97
|
+
#def reply (workitem)
|
98
|
+
#end
|
99
|
+
|
100
|
+
def is_expression? ()
|
101
|
+
return false if not @xml_element.kind_of?(REXML::XMLElement)
|
102
|
+
return expression_class() != nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def is_definition? ()
|
106
|
+
return get_expression_map.is_definition?(expression_name())
|
107
|
+
end
|
108
|
+
|
109
|
+
def expression_name ()
|
110
|
+
return @xml_element.name
|
111
|
+
end
|
112
|
+
|
113
|
+
def expression_class ()
|
114
|
+
return get_expression_map().get_class(expression_name())
|
115
|
+
end
|
116
|
+
|
117
|
+
def definition_name ()
|
118
|
+
#return @xml_element.attributes['name'].to_str
|
119
|
+
return @xml_element.attributes['name'].to_s
|
120
|
+
end
|
121
|
+
|
122
|
+
protected
|
123
|
+
|
124
|
+
def extract_attributes ()
|
125
|
+
result = {}
|
126
|
+
@xml_element.attributes.each_attribute do |a|
|
127
|
+
result[a.name] = a.value
|
128
|
+
end
|
129
|
+
return result
|
130
|
+
end
|
131
|
+
|
132
|
+
def extract_children ()
|
133
|
+
|
134
|
+
c = []
|
135
|
+
i = 0
|
136
|
+
|
137
|
+
@xml_element.each_child do |elt|
|
138
|
+
|
139
|
+
if elt.kind_of?(REXML::Element)
|
140
|
+
|
141
|
+
cfei = @fei.dup
|
142
|
+
pfei = @fei
|
143
|
+
|
144
|
+
efei = @environment_id
|
145
|
+
|
146
|
+
cfei.expressionName = elt.name
|
147
|
+
cfei.expressionId = "#{cfei.expressionId}.#{i}"
|
148
|
+
|
149
|
+
rawchild = RawExpression\
|
150
|
+
.new(cfei, pfei, efei, @application_context, elt)
|
151
|
+
|
152
|
+
get_expression_pool().update(rawchild)
|
153
|
+
c << rawchild.fei
|
154
|
+
|
155
|
+
i = i+1
|
156
|
+
|
157
|
+
elsif elt.kind_of?(REXML::Comment)
|
158
|
+
|
159
|
+
next
|
160
|
+
|
161
|
+
else
|
162
|
+
|
163
|
+
s = elt.to_s.strip
|
164
|
+
c << s if s.length > 0
|
165
|
+
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
return c
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|