openwferu 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +50 -2
- data/bin/validate-workflow.rb +64 -0
- data/lib/codec.rb +2 -0
- data/lib/controlclient.rb +19 -0
- data/lib/definitions.rb +2 -0
- data/lib/exception.rb +2 -0
- data/lib/flowexpressionid.rb +7 -5
- data/lib/openwferu.rb +2 -0
- data/lib/osocket.rb +2 -0
- data/lib/otime.rb +2 -0
- data/lib/restclient.rb +2 -0
- data/lib/ru/contextual.rb +2 -0
- data/lib/ru/dollar.rb +2 -0
- data/lib/ru/engine.rb +2 -0
- data/lib/ru/environment.rb +2 -0
- data/lib/ru/expressionmap.rb +5 -0
- data/lib/ru/expressionpool.rb +49 -6
- data/lib/ru/expressionstorage.rb +3 -1
- data/lib/ru/fe_base.rb +4 -1
- data/lib/ru/fe_concurrence.rb +82 -10
- data/lib/ru/fe_define.rb +2 -0
- data/lib/ru/fe_misc.rb +47 -0
- data/lib/ru/fe_participant.rb +2 -0
- data/lib/ru/fe_raw.rb +35 -19
- data/lib/ru/fe_subprocess.rb +2 -0
- data/lib/ru/fe_time.rb +2 -0
- data/lib/ru/fe_utils.rb +2 -0
- data/lib/ru/fe_value.rb +23 -12
- data/lib/ru/flowexpression.rb +26 -4
- data/lib/ru/logging.rb +2 -0
- data/lib/ru/participant.rb +2 -0
- data/lib/ru/participantmap.rb +2 -0
- data/lib/ru/participants.rb +2 -0
- data/lib/ru/rudefinitions.rb +9 -2
- data/lib/ru/ruutils.rb +3 -1
- data/lib/ru/scheduler.rb +2 -0
- data/lib/ru/schedulers.rb +2 -0
- data/lib/ru/service.rb +2 -0
- data/lib/test.rb +2 -0
- data/lib/utils.rb +49 -0
- data/lib/workitem.rb +9 -10
- data/lib/worklistclient.rb +18 -8
- data/test/flowtestbase.rb +7 -0
- data/test/ft_2_concurrence.rb +14 -2
- data/test/ft_6_lambda.rb +40 -0
- data/test/ft_7_losfor.rb +123 -0
- data/test/fulltest.rb +14 -0
- data/test/misctest.rb +30 -0
- data/test/{runtest.rb → quicktest.rb} +2 -2
- data/test/timetest.rb +2 -2
- metadata +54 -41
data/README
CHANGED
@@ -7,7 +7,10 @@ Ruby 1.8.0 or later
|
|
7
7
|
TODO
|
8
8
|
|
9
9
|
== Installation
|
10
|
-
|
10
|
+
Installation can be handled by Ruby gems. This will pull in any libraries
|
11
|
+
you will need to install
|
12
|
+
|
13
|
+
gem install -y openwferu
|
11
14
|
|
12
15
|
== Overview
|
13
16
|
OpenWFEru is a Ruby port of the OpenWFE workflow engine
|
@@ -29,11 +32,56 @@ These are mostly stolen from the unit tests
|
|
29
32
|
|
30
33
|
Creating an workflow engine instance
|
31
34
|
|
35
|
+
require 'pp'
|
32
36
|
require 'openwferu'
|
33
37
|
|
34
|
-
engine
|
38
|
+
# Create an engine to launch the flow
|
39
|
+
engine = OpenWFEru::Engine.new
|
35
40
|
engine.register_participant('test-.*',
|
36
41
|
OpenWFEru::PrintParticipant.new())
|
42
|
+
# Create a flow definition and assign to a new instance
|
43
|
+
flow = '''<process-definition name="equals_0" revision="0">
|
44
|
+
<sequence>
|
45
|
+
<equals value="a" other-value="a" />
|
46
|
+
<print>${field:__result__}</print>
|
47
|
+
</sequence>
|
48
|
+
</process-definition>'''
|
49
|
+
li = OpenWFE::LaunchItem.new
|
50
|
+
li.workflowDefinitionUrl = "field:__definition"
|
51
|
+
li.attributes['__definition'] = flow
|
52
|
+
# Launch the instance
|
53
|
+
engine.launch(li)
|
54
|
+
# Examine it
|
55
|
+
exp_storage = engine.application_context[OpenWFEru::S_EXPRESSION_STORAGE]
|
56
|
+
pp exp_storage
|
57
|
+
|
58
|
+
== How to help
|
59
|
+
|
60
|
+
If you want to help hacking on openwferu you'll probably want the following
|
61
|
+
libraries:
|
62
|
+
[+rake+] Handle builds, generating documentation, and running unit tests
|
63
|
+
[rubygems] Handles creation of the gems
|
64
|
+
[rote] A framework being used to help with managing the offline written docs
|
65
|
+
[redcloth] Openwferu uses textile-markup for its docs. Redcloth provides an engine for it.
|
66
|
+
[tidy] General cleanup
|
67
|
+
[libxml-ruby] Allows XSD validation
|
68
|
+
|
69
|
+
It's best if you use gems to install these as the process can get rather
|
70
|
+
tedious by hand.
|
71
|
+
|
72
|
+
=== Prerequisites
|
73
|
+
You'll need libxml2-dev in order to compile the native libraries
|
74
|
+
for libxml. Please check your your packaging system for the appropriate
|
75
|
+
name.
|
76
|
+
|
77
|
+
On Ubuntu you can install libxml2 with:
|
78
|
+
sudo apt-get install libxml2-dev
|
79
|
+
|
80
|
+
=== Ruby Libraries Install
|
81
|
+
1. gem install -r rake
|
82
|
+
2. gem install -r rote redcloth
|
83
|
+
3. gem install -r tidy
|
84
|
+
4. gem install -r libxml-ruby
|
37
85
|
|
38
86
|
== Documentation
|
39
87
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Program Name: validate-workflow.rb
|
4
|
+
# Purpose: A helper script that validates a workflow document against
|
5
|
+
# a XML Schema
|
6
|
+
# Author: Alain Hoang
|
7
|
+
# Version: 0.1
|
8
|
+
# Notes: Uses Ruby's libxml library to handle the parsing
|
9
|
+
|
10
|
+
# Stdlib
|
11
|
+
require 'net/http'
|
12
|
+
require 'uri'
|
13
|
+
# From the gems archive
|
14
|
+
require 'rubygems'
|
15
|
+
require 'xml/libxml'
|
16
|
+
|
17
|
+
|
18
|
+
module OpenWFEru
|
19
|
+
# Validates a workflow definition against the Workflow XML Schema
|
20
|
+
# defined at http://www.openwfe.org/flowdef.xsd
|
21
|
+
class WorkflowValidator
|
22
|
+
OPENWFE_FLOWDEF_URL='http://www.openwfe.org/flowdef.xsd'
|
23
|
+
|
24
|
+
# Class method for validating a xml file against the
|
25
|
+
# OpenWFE XML Schema
|
26
|
+
def WorkflowValidator.validate(file)
|
27
|
+
# Should only be initialized once during the lifetime
|
28
|
+
# of the program
|
29
|
+
if not defined? @@schema
|
30
|
+
xsd_str = Net::HTTP.get URI.parse(OPENWFE_FLOWDEF_URL)
|
31
|
+
@@schema = XML::Schema.from_string(xsd_str)
|
32
|
+
end
|
33
|
+
xmldoc = XML::Document.file(file)
|
34
|
+
xmldoc.validate_schema(@@schema)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def usage
|
40
|
+
print "Usage: #{$0} <workflow def> [workflow def] [workflow def] ...\n"
|
41
|
+
print " <workflow def> - workflow definition file\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
def main
|
45
|
+
# Make sure we have at least one argument or bail
|
46
|
+
if ARGV.length == 0
|
47
|
+
usage
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
|
51
|
+
# Loop through all arguments and validate the file
|
52
|
+
ARGV.each do |f|
|
53
|
+
print "Trying to validate #{f}... "
|
54
|
+
if OpenWFEru::WorkflowValidator.validate(f)
|
55
|
+
print "PASSED\n"
|
56
|
+
else
|
57
|
+
print "FAILED\n"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
if $0 == __FILE__
|
63
|
+
main
|
64
|
+
end
|
data/lib/codec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: codec.rb 2865 2006-06-23 14:54:07Z jmettraux $
|
32
34
|
#
|
data/lib/controlclient.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: controlclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
|
32
34
|
#
|
@@ -64,6 +66,19 @@ module OpenWFE
|
|
64
66
|
return decode(r)
|
65
67
|
end
|
66
68
|
|
69
|
+
#
|
70
|
+
# Returns the list of expressions currently applied for a given
|
71
|
+
# workflow instance
|
72
|
+
#
|
73
|
+
def get_flow_position (workflowInstanceId)
|
74
|
+
|
75
|
+
params = {}
|
76
|
+
params['id'] = workflowInstanceId
|
77
|
+
|
78
|
+
r = self.get('getflowposition', nil, params)
|
79
|
+
return decode(r)
|
80
|
+
end
|
81
|
+
|
67
82
|
#
|
68
83
|
# Cancels a given expression (and potentially its whole subtree)
|
69
84
|
#
|
@@ -100,6 +115,10 @@ module OpenWFE
|
|
100
115
|
return decode(self.post('unfreezeexpression', nil, params, fei))
|
101
116
|
end
|
102
117
|
|
118
|
+
alias list_expressions listExpressions
|
119
|
+
alias cancel_expression cancelExpression
|
120
|
+
alias freeze_expression freezeExpression
|
121
|
+
alias unfreeze_expression unfreezeExpression
|
103
122
|
|
104
123
|
protected
|
105
124
|
|
data/lib/definitions.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 3454 2006-10-08 16:51:00Z jmettraux $
|
32
34
|
#
|
data/lib/exception.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: exception.rb 3454 2006-10-08 16:51:00Z jmettraux $
|
32
34
|
#
|
data/lib/flowexpressionid.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: workitem.rb 3555 2006-11-13 00:47:53Z jmettraux $
|
32
34
|
#
|
@@ -65,7 +67,7 @@ module OpenWFE
|
|
65
67
|
# overrides the classical to_s()
|
66
68
|
#
|
67
69
|
def to_s ()
|
68
|
-
return "(fei #{@owfeVersion} #{@engineId}/#{@initialEngineId} #{@workflowDefinitionUrl} #{@workflowDefinitionName} #{@workflowDefinitionRevision} #{@workflowInstanceId} #{@expressionName} #{@expressionId}
|
70
|
+
return "(fei #{@owfeVersion} #{@engineId}/#{@initialEngineId} #{@workflowDefinitionUrl} #{@workflowDefinitionName} #{@workflowDefinitionRevision} #{@workflowInstanceId} #{@expressionName} #{@expressionId})"
|
69
71
|
end
|
70
72
|
|
71
73
|
#
|
@@ -127,10 +129,10 @@ module OpenWFE
|
|
127
129
|
|
128
130
|
alias eql? ==
|
129
131
|
|
130
|
-
|
131
|
-
def to_debug_s
|
132
|
-
|
133
|
-
end
|
132
|
+
alias to_debug_s to_s
|
133
|
+
#def to_debug_s
|
134
|
+
# "#{to_s} (h#{hash}) (i#{object_id})"
|
135
|
+
#end
|
134
136
|
end
|
135
137
|
|
136
138
|
end
|
data/lib/openwferu.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
#++
|
32
34
|
#
|
data/lib/osocket.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: codec.rb 2515 2006-04-26 18:38:39Z jmettraux $
|
32
34
|
#
|
data/lib/otime.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: otime.rb 3509 2006-10-21 12:00:52Z jmettraux $
|
32
34
|
#
|
data/lib/restclient.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2005-2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: restclient.rb 3454 2006-10-08 16:51:00Z jmettraux $
|
32
34
|
#
|
data/lib/ru/contextual.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
data/lib/ru/dollar.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
data/lib/ru/engine.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
data/lib/ru/environment.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#<tt>
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#</tt>
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
data/lib/ru/expressionmap.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
@@ -89,6 +91,9 @@ module OpenWFEru
|
|
89
91
|
|
90
92
|
@map["reval"] = RevalExpression
|
91
93
|
@map["print"] = PrintExpression
|
94
|
+
|
95
|
+
@map["lose"] = LoseExpression
|
96
|
+
@map["forget"] = ForgetExpression
|
92
97
|
end
|
93
98
|
|
94
99
|
#
|
data/lib/ru/expressionpool.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
@@ -119,18 +121,40 @@ module OpenWFEru
|
|
119
121
|
end
|
120
122
|
|
121
123
|
#
|
122
|
-
#
|
124
|
+
# Evaluates a raw definition expression and
|
125
|
+
# returns its body fei
|
123
126
|
#
|
124
|
-
def
|
127
|
+
def evaluate (rawExpression, workitem)
|
128
|
+
exp = rawExpression.instantiate_real_expression(workitem)
|
129
|
+
fei = exp.evaluate(workitem)
|
130
|
+
remove(rawExpression)
|
131
|
+
return fei
|
132
|
+
end
|
125
133
|
|
126
|
-
|
134
|
+
#
|
135
|
+
# Applies a given expression (id or expression)
|
136
|
+
#
|
137
|
+
def apply (exp, workitem)
|
127
138
|
|
128
|
-
|
139
|
+
exp = fetch(exp) if exp.kind_of? OpenWFE::FlowExpressionId
|
140
|
+
|
141
|
+
ldebug { "apply() #{exp.fei.to_debug_s}" }
|
142
|
+
|
143
|
+
workitem.lastExpressionId = exp.fei
|
129
144
|
|
130
|
-
exp = fetch(flowExpressionId)
|
131
145
|
exp.apply(workitem)
|
132
146
|
end
|
133
147
|
|
148
|
+
#
|
149
|
+
# Cancels the given expression
|
150
|
+
#
|
151
|
+
def cancel (exp)
|
152
|
+
exp = fetch(exp) if exp.kind_of? OpenWFE::FlowExpressionId
|
153
|
+
inflowitem = exp.cancel()
|
154
|
+
remove(exp)
|
155
|
+
return inflowitem
|
156
|
+
end
|
157
|
+
|
134
158
|
#
|
135
159
|
# Replies to the parent of the given expression.
|
136
160
|
#
|
@@ -154,8 +178,23 @@ module OpenWFEru
|
|
154
178
|
# Triggers the reply expression of the expression given by its id.
|
155
179
|
#
|
156
180
|
def reply (flowExpressionId, workitem)
|
157
|
-
|
181
|
+
|
182
|
+
ldebug { "reply() to #{flowExpressionId.to_debug_s}" }
|
183
|
+
ldebug { "reply() from #{workitem.last_expression_id}" }
|
184
|
+
|
158
185
|
exp = fetch(flowExpressionId)
|
186
|
+
|
187
|
+
if not exp
|
188
|
+
#raise \
|
189
|
+
# "cannot reply to missing expression " +
|
190
|
+
# flowExpressionId.to_debug_s
|
191
|
+
lwarn do
|
192
|
+
"reply() cannot reply to missing "+
|
193
|
+
flowExpressionId.to_debug_s
|
194
|
+
end
|
195
|
+
return
|
196
|
+
end
|
197
|
+
|
159
198
|
exp.reply(workitem)
|
160
199
|
end
|
161
200
|
|
@@ -266,6 +305,10 @@ module OpenWFEru
|
|
266
305
|
|
267
306
|
protected
|
268
307
|
|
308
|
+
def evaluate_definition (raw_definition, workitem)
|
309
|
+
expression = raw_definition.instantiate(workitem)
|
310
|
+
end
|
311
|
+
|
269
312
|
def remove_environment (environment_id)
|
270
313
|
env = fetch(environment_id)
|
271
314
|
env.unbind()
|
data/lib/ru/expressionstorage.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
@@ -82,7 +84,7 @@ module OpenWFEru
|
|
82
84
|
if v.kind_of?(RawExpression)
|
83
85
|
s << "*raw"
|
84
86
|
else
|
85
|
-
s << "
|
87
|
+
s << " "
|
86
88
|
end
|
87
89
|
s << v.to_s
|
88
90
|
s << " key/value mismatch !" if k != v.fei
|
data/lib/ru/fe_base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
@@ -86,7 +88,8 @@ module OpenWFEru
|
|
86
88
|
end
|
87
89
|
found = false
|
88
90
|
@children.each do |c|
|
89
|
-
ldebug { "next_fei() considering #{c} (found ? #{found})" }
|
91
|
+
#ldebug { "next_fei() considering #{c} (found ? #{found})" }
|
92
|
+
ldebug { "next_fei() considering #{c}" }
|
90
93
|
if found
|
91
94
|
return c if c.kind_of?(OpenWFE::FlowExpressionId)
|
92
95
|
next
|
data/lib/ru/fe_concurrence.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#
|
2
|
+
#--
|
2
3
|
# Copyright (c) 2006, John Mettraux, OpenWFE.org
|
3
4
|
# All rights reserved.
|
4
5
|
#
|
@@ -27,6 +28,7 @@
|
|
27
28
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
30
32
|
#
|
31
33
|
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
32
34
|
#
|
@@ -37,6 +39,7 @@
|
|
37
39
|
# John Mettraux at openwfe.org
|
38
40
|
#
|
39
41
|
|
42
|
+
require 'monitor'
|
40
43
|
require 'ru/flowexpression'
|
41
44
|
require 'ru/rudefinitions'
|
42
45
|
require 'ru/ruutils'
|
@@ -57,14 +60,20 @@ module OpenWFEru
|
|
57
60
|
|
58
61
|
sync = lookup_attribute(A_SYNC, workitem)
|
59
62
|
sync = "generic" if not sync
|
60
|
-
|
63
|
+
|
64
|
+
@sync_expression = \
|
65
|
+
get_expression_map().get_sync_class(sync).new(@attributes)
|
61
66
|
|
62
67
|
#threads = []
|
63
68
|
|
69
|
+
@children.each do |child|
|
70
|
+
@sync_expression.add_child(child)
|
71
|
+
end
|
72
|
+
|
64
73
|
@children.each do |child|
|
65
74
|
t = Thread.new do
|
66
75
|
begin
|
67
|
-
|
76
|
+
get_expression_pool().apply(child, workitem.dup)
|
68
77
|
rescue Exception => e
|
69
78
|
lwarn do
|
70
79
|
"apply() caught exception in concurrent child\n" +
|
@@ -93,29 +102,92 @@ module OpenWFEru
|
|
93
102
|
|
94
103
|
class GenericSyncExpression < SyncExpression
|
95
104
|
|
96
|
-
|
105
|
+
attr_accessor \
|
106
|
+
:remaining_children,
|
107
|
+
:count,
|
108
|
+
:reply_count,
|
109
|
+
:cancel_remaining
|
110
|
+
|
111
|
+
def initialize (attributes)
|
112
|
+
|
97
113
|
super()
|
114
|
+
|
115
|
+
@remaining_children = []
|
98
116
|
@reply_count = 0
|
117
|
+
|
118
|
+
@count = determine_count(attributes)
|
119
|
+
@cancel_remaining = determine_remaining(attributes)
|
99
120
|
end
|
100
121
|
|
101
|
-
def
|
102
|
-
|
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
|
122
|
+
def add_child (child)
|
123
|
+
@remaining_children << child
|
107
124
|
end
|
108
125
|
|
109
126
|
def reply (synchable, workitem)
|
110
127
|
synchronize do
|
128
|
+
|
111
129
|
@application_context = synchable.application_context
|
130
|
+
#
|
131
|
+
# ldebug uses the application context
|
132
|
+
|
112
133
|
ldebug { "reply() #{workitem.lastExpressionId.to_debug_s}" }
|
134
|
+
|
113
135
|
@reply_count = @reply_count + 1
|
136
|
+
|
137
|
+
@remaining_children.delete(workitem.last_expression_id)
|
138
|
+
|
114
139
|
return workitem \
|
115
|
-
if @
|
140
|
+
if @remaining_children.length <= 0
|
141
|
+
|
142
|
+
if @count > 0 and @reply_count >= @count
|
143
|
+
treat_remaining_children(synchable)
|
144
|
+
return workitem
|
145
|
+
end
|
146
|
+
|
116
147
|
return nil
|
117
148
|
end
|
118
149
|
end
|
150
|
+
|
151
|
+
protected
|
152
|
+
|
153
|
+
def treat_remaining_children (synchable)
|
154
|
+
|
155
|
+
expool = synchable.get_expression_pool
|
156
|
+
|
157
|
+
@remaining_children.each do |child|
|
158
|
+
if @cancel_remaining
|
159
|
+
expool.cancel(child)
|
160
|
+
else
|
161
|
+
expool.remove(child)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def determine_remaining (attributes)
|
167
|
+
return attributes[A_REMAINING] == REM_CANCEL
|
168
|
+
end
|
169
|
+
|
170
|
+
def determine_count (attributes)
|
171
|
+
s = attributes[A_COUNT]
|
172
|
+
return -1 if not s
|
173
|
+
i = s.to_i
|
174
|
+
return -1 if i < 1
|
175
|
+
return i
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
#
|
180
|
+
# Merges a workitem (source) into another (target).
|
181
|
+
# If inPlace is left to false, a brand new workitem is returned,
|
182
|
+
# else the merge occurs directly into the target workitem.
|
183
|
+
#
|
184
|
+
def merge (wiTarget, wiSource, inPlace=false)
|
185
|
+
|
186
|
+
wiTarget = wiTarget.dup if not inPlace
|
187
|
+
|
188
|
+
wiSource.attributes.each do | k, v |
|
189
|
+
wiTarget.attributes[k.dup] = v.dup
|
190
|
+
end
|
119
191
|
end
|
120
192
|
|
121
193
|
end
|