openwferu 0.9.12 → 0.9.12.863
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/engine_template.rb +30 -0
- data/lib/openwfe/contextual.rb +21 -0
- data/lib/openwfe/engine/engine.rb +24 -24
- data/lib/openwfe/expool/errorjournal.rb +1 -3
- data/lib/openwfe/expool/expressionpool.rb +29 -24
- data/lib/openwfe/expool/history.rb +1 -3
- data/lib/openwfe/expool/journal.rb +1 -3
- data/lib/openwfe/expool/wfidgen.rb +1 -3
- data/lib/openwfe/expool/yamlexpstorage.rb +7 -7
- data/lib/openwfe/expressions/environment.rb +17 -6
- data/lib/openwfe/expressions/expressionmap.rb +1 -2
- data/lib/openwfe/expressions/fe_command.rb +227 -0
- data/lib/openwfe/expressions/fe_concurrence.rb +8 -6
- data/lib/openwfe/expressions/fe_cursor.rb +3 -157
- data/lib/openwfe/expressions/fe_define.rb +6 -5
- data/lib/openwfe/expressions/fe_if.rb +8 -2
- data/lib/openwfe/expressions/fe_iterator.rb +141 -35
- data/lib/openwfe/expressions/fe_subprocess.rb +3 -29
- data/lib/openwfe/expressions/fe_value.rb +1 -4
- data/lib/openwfe/expressions/flowexpression.rb +0 -5
- data/lib/openwfe/expressions/raw.rb +0 -2
- data/lib/openwfe/expressions/raw_prog.rb +15 -15
- data/lib/openwfe/flowexpressionid.rb +3 -3
- data/lib/openwfe/listeners/listeners.rb +2 -6
- data/lib/openwfe/participants/enoparticipants.rb +1 -2
- data/lib/openwfe/participants/participantmap.rb +0 -2
- data/lib/openwfe/participants/participants.rb +95 -4
- data/lib/openwfe/participants/soapparticipants.rb +15 -8
- data/lib/openwfe/rest/osocket.rb +2 -3
- data/lib/openwfe/rest/xmlcodec.rb +0 -2
- data/lib/openwfe/rudefinitions.rb +0 -17
- data/lib/openwfe/storage/yamlfilestorage.rb +3 -8
- data/lib/openwfe/util/observable.rb +4 -2
- data/lib/openwfe/util/otime.rb +10 -9
- data/lib/openwfe/util/safe.rb +9 -6
- data/lib/openwfe/util/scheduler.rb +60 -9
- data/lib/openwfe/util/schedulers.rb +1 -1
- data/lib/openwfe/util/workqueue.rb +0 -3
- data/lib/openwfe/utils.rb +27 -11
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/workitem.rb +29 -3
- data/lib/openwfe/worklist/storeparticipant.rb +1 -5
- data/test/console_test.rb +1 -4
- data/test/file_persisted_engine_test.rb +64 -0
- data/test/file_persistence_test.rb +22 -1
- data/test/ft_15_iterator.rb +55 -1
- data/test/ft_20_cron.rb +0 -1
- data/test/ft_21_cron.rb +0 -1
- data/test/ft_26c_load.rb +4 -10
- data/test/ft_32_journal.rb +2 -2
- data/test/ft_61_elsub.rb +51 -0
- data/test/ft_62_procparticipant.rb +65 -0
- data/test/ft_tests.rb +3 -1
- data/test/hparticipant_test.rb +3 -3
- data/test/misc_test.rb +1 -1
- data/test/obs_test.rb +27 -0
- data/test/rake_qtest.rb +4 -3
- data/test/safely_test.rb +6 -1
- data/test/scheduler_test.rb +85 -2
- data/test/sec_test.rb +9 -7
- metadata +6 -14
- data/lib/openwfe/listeners/sqslisteners.rb +0 -145
- data/lib/openwfe/participants/atomparticipants.rb +0 -181
- data/lib/openwfe/participants/csvparticipants.rb +0 -127
- data/lib/openwfe/participants/sqsparticipants.rb +0 -121
- data/lib/openwfe/storage/yamlextras.rb +0 -115
- data/lib/openwfe/util/csvtable.rb +0 -448
- data/lib/openwfe/util/sqs.rb +0 -581
- data/test/atom_test.rb +0 -100
- data/test/csv_test.rb +0 -342
- data/test/ft_19_csv.rb +0 -65
- data/test/rest_test.rb +0 -189
- data/test/sqs_test.rb +0 -103
@@ -1,145 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
-
# list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
-
# used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
#++
|
32
|
-
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
|
-
|
36
|
-
#
|
37
|
-
# "made in Japan"
|
38
|
-
#
|
39
|
-
# John Mettraux at openwfe.org
|
40
|
-
#
|
41
|
-
|
42
|
-
require 'yaml'
|
43
|
-
require 'base64'
|
44
|
-
require 'monitor'
|
45
|
-
|
46
|
-
require 'openwfe/service'
|
47
|
-
#require 'openwfe/rudefinitions'
|
48
|
-
require 'openwfe/util/scheduler'
|
49
|
-
require 'openwfe/listeners/listener'
|
50
|
-
|
51
|
-
require 'openwfe/util/sqs'
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
# some base listener implementations
|
56
|
-
#
|
57
|
-
module OpenWFE
|
58
|
-
|
59
|
-
#
|
60
|
-
# Polls an Amazon SQS queue for workitems
|
61
|
-
#
|
62
|
-
# Workitems can be instances of InFlowWorkItem or LaunchItem.
|
63
|
-
#
|
64
|
-
# require 'openwfe/listeners/sqslisteners'
|
65
|
-
#
|
66
|
-
# ql = OpenWFE::SqsListener("workqueue1", engine.application_context)
|
67
|
-
#
|
68
|
-
# engine.add_workitem_listener(ql, "2m30s")
|
69
|
-
# #
|
70
|
-
# # thus, the engine will poll our "workqueue1" SQS queue
|
71
|
-
# # every 2 minutes and 30 seconds
|
72
|
-
#
|
73
|
-
class SqsListener < Service
|
74
|
-
include MonitorMixin, WorkItemListener, Schedulable
|
75
|
-
|
76
|
-
attr_reader :queue_name
|
77
|
-
|
78
|
-
def initialize (queue_name, application_context)
|
79
|
-
|
80
|
-
@queue_name = queue_name.to_s
|
81
|
-
|
82
|
-
service_name = "#{self.class}::#{@queue_name}"
|
83
|
-
|
84
|
-
super(service_name, application_context)
|
85
|
-
|
86
|
-
linfo { "new() queue is '#{@queue_name}'" }
|
87
|
-
end
|
88
|
-
|
89
|
-
#
|
90
|
-
# Will 'find' files in the work directory (by default ./work/in/),
|
91
|
-
# extract the workitem in them and feed it back to the engine.
|
92
|
-
#
|
93
|
-
def trigger (params)
|
94
|
-
synchronize do
|
95
|
-
|
96
|
-
ldebug { "trigger()" }
|
97
|
-
|
98
|
-
qs = SQS::QueueService.new
|
99
|
-
|
100
|
-
qs.create_queue(@queue_name)
|
101
|
-
# just to be sure it is there
|
102
|
-
|
103
|
-
while true
|
104
|
-
|
105
|
-
l = qs.get_messages(
|
106
|
-
@queue_name, :timeout => 0, :count => 255)
|
107
|
-
|
108
|
-
break if l.length < 1
|
109
|
-
|
110
|
-
l.each do |msg|
|
111
|
-
|
112
|
-
o = decode_object(msg)
|
113
|
-
|
114
|
-
handle_object(o)
|
115
|
-
|
116
|
-
msg.delete
|
117
|
-
|
118
|
-
ldebug do
|
119
|
-
"trigger() " +
|
120
|
-
"handled successfully msg #{msg.message_id}"
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
#
|
128
|
-
# Extracts a workitem from the message's body.
|
129
|
-
#
|
130
|
-
# By default, this listeners assumes the workitem is stored in
|
131
|
-
# its "hash form" (not directly as a Ruby InFlowWorkItem instance).
|
132
|
-
#
|
133
|
-
# LaunchItem instances (as hash as well) are also accepted.
|
134
|
-
#
|
135
|
-
def decode_object (message)
|
136
|
-
|
137
|
-
o = Base64.decode64(message.message_body)
|
138
|
-
o = YAML.load(o)
|
139
|
-
o = OpenWFE::workitem_from_h(o)
|
140
|
-
o
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
end
|
145
|
-
|
@@ -1,181 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
-
# list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
-
# used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
#++
|
32
|
-
#
|
33
|
-
# $Id$
|
34
|
-
#
|
35
|
-
|
36
|
-
#
|
37
|
-
# "made in Japan"
|
38
|
-
#
|
39
|
-
# John Mettraux at openwfe.org
|
40
|
-
#
|
41
|
-
|
42
|
-
#
|
43
|
-
# this participant requires atom-tools from
|
44
|
-
#
|
45
|
-
# http://code.necronomicorp.com/trac/atom-tools
|
46
|
-
#
|
47
|
-
# The license is X11/MIT
|
48
|
-
#
|
49
|
-
|
50
|
-
require 'monitor'
|
51
|
-
|
52
|
-
require 'rubygems'
|
53
|
-
require 'atom/collection'
|
54
|
-
|
55
|
-
require 'openwfe/participants/participant'
|
56
|
-
|
57
|
-
|
58
|
-
module OpenWFE
|
59
|
-
|
60
|
-
#
|
61
|
-
# Stores the incoming workitem into an 'atom feed'
|
62
|
-
#
|
63
|
-
# An example :
|
64
|
-
#
|
65
|
-
# feed0 = AtomParticipant.new(
|
66
|
-
# 20, # no more than 20 entries are kept
|
67
|
-
# """
|
68
|
-
# <p>
|
69
|
-
# <h1>${f:colour}</h1>
|
70
|
-
# </p>
|
71
|
-
# """) # the template for each entry
|
72
|
-
#
|
73
|
-
# The 'template' parameter may contain an instance of File instead of
|
74
|
-
# an instance of String.
|
75
|
-
#
|
76
|
-
# feed0 = AtomParticipant.new(
|
77
|
-
# 20, File.new("path/to/my/atom/template.txt")
|
78
|
-
#
|
79
|
-
# The template can be passed as the second parameter (after the max entry
|
80
|
-
# count) or as a block :
|
81
|
-
#
|
82
|
-
# feed1 = AtomParticipant.new(20) do |flow_expression, atom_participant, workitem|
|
83
|
-
# #
|
84
|
-
# # usually only the workitem parameter is used
|
85
|
-
# # but the other two allow for advanced tricks...
|
86
|
-
#
|
87
|
-
# atom_participant.content_type = "xml"
|
88
|
-
# # by default, it's "xhtml"
|
89
|
-
#
|
90
|
-
# s = "<task>"
|
91
|
-
# s << "<name>#{workitem.task_name}</name>"
|
92
|
-
# s << "<assignee>#{workitem.task_assignee}</assignee>"
|
93
|
-
# s << "<duedate>#{workitem.task_duedate}</duedate>"
|
94
|
-
# s << "</task>"
|
95
|
-
#
|
96
|
-
# # the block is supposed to 'return' a string which is the
|
97
|
-
# # effective template
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# This participant uses
|
101
|
-
# "atom-tools" from http://code.necronomicorp.com/trac/atom-tools
|
102
|
-
#
|
103
|
-
#
|
104
|
-
class AtomParticipant
|
105
|
-
include LocalParticipant, MonitorMixin
|
106
|
-
|
107
|
-
attr_accessor \
|
108
|
-
:content_type # blocks may manipulate them
|
109
|
-
|
110
|
-
def initialize (max_item_count, template=nil, &block)
|
111
|
-
|
112
|
-
super()
|
113
|
-
|
114
|
-
@template = template
|
115
|
-
@max_item_count = max_item_count
|
116
|
-
@block_template = block
|
117
|
-
|
118
|
-
@feed = Atom::Collection.new("http://localhost")
|
119
|
-
@content_type = "xhtml"
|
120
|
-
end
|
121
|
-
|
122
|
-
def consume (workitem)
|
123
|
-
|
124
|
-
e = Atom::Entry.new
|
125
|
-
|
126
|
-
e.id = \
|
127
|
-
"#{workitem.fei.workflow_instance_id}--" +
|
128
|
-
"#{workitem.fei.expression_id}"
|
129
|
-
|
130
|
-
e.title = workitem.atom_entry_title
|
131
|
-
e.content = render(workitem)
|
132
|
-
|
133
|
-
e.content["type"] = @content_type
|
134
|
-
|
135
|
-
@feed << e
|
136
|
-
|
137
|
-
@feed = @feed[0, @max_item_count] \
|
138
|
-
if @feed.length > @max_item_count
|
139
|
-
|
140
|
-
publish workitem
|
141
|
-
|
142
|
-
reply_to_engine workitem
|
143
|
-
end
|
144
|
-
|
145
|
-
protected
|
146
|
-
|
147
|
-
def render (workitem)
|
148
|
-
|
149
|
-
fe = get_flow_expression(workitem)
|
150
|
-
|
151
|
-
template = if @block_template
|
152
|
-
#@block_template.call(fe, self, workitem)
|
153
|
-
call_block @block_template, workitem
|
154
|
-
elsif @template
|
155
|
-
if @template.kind_of? File
|
156
|
-
@template.readlines
|
157
|
-
else
|
158
|
-
@template.to_s
|
159
|
-
end
|
160
|
-
else
|
161
|
-
"(no template given)"
|
162
|
-
end
|
163
|
-
|
164
|
-
OpenWFE::dosub(template, fe, workitem)
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# For the moment, just dumps the feed into a file.
|
169
|
-
#
|
170
|
-
def publish (workitem)
|
171
|
-
synchronize do
|
172
|
-
filename = "work/atom_#{workitem.participant_name}.xml"
|
173
|
-
f = File.open(filename, "w")
|
174
|
-
f << @feed.to_s
|
175
|
-
f.close()
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
@@ -1,127 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
-
# list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
-
# used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
#++
|
32
|
-
#
|
33
|
-
# $Id$
|
34
|
-
#
|
35
|
-
|
36
|
-
#
|
37
|
-
# "made in Japan"
|
38
|
-
#
|
39
|
-
# John Mettraux at openwfe.org
|
40
|
-
#
|
41
|
-
|
42
|
-
require 'openwfe/utils'
|
43
|
-
require 'openwfe/util/dollar'
|
44
|
-
require 'openwfe/util/csvtable'
|
45
|
-
require 'openwfe/participants/participant'
|
46
|
-
|
47
|
-
include OpenWFE
|
48
|
-
|
49
|
-
|
50
|
-
module OpenWFE
|
51
|
-
|
52
|
-
#
|
53
|
-
# Using CSV files to transform workitems
|
54
|
-
# This concept is called "decision participant" in OpenWFEja, here
|
55
|
-
# it's simply called "csv participant".
|
56
|
-
#
|
57
|
-
# See CsvTable for an explanation of the core concept behind a
|
58
|
-
# CsvParticipant
|
59
|
-
#
|
60
|
-
# An example :
|
61
|
-
#
|
62
|
-
# class TestDefinition0 < ProcessDefinition
|
63
|
-
# def make
|
64
|
-
# process_definition :name => "test0", :revision => "0" do
|
65
|
-
# sequence do
|
66
|
-
# set :field => "weather", :value => "cloudy"
|
67
|
-
# set :field => "month", :value => "may"
|
68
|
-
# decision
|
69
|
-
# _print "${f:take_umbrella?}"
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
# end
|
73
|
-
# end
|
74
|
-
#
|
75
|
-
#
|
76
|
-
# csvParticipant = CsvParticipant.new(
|
77
|
-
# """
|
78
|
-
# in:weather, in:month, out:take_umbrella?
|
79
|
-
# ,,
|
80
|
-
# raining, , yes
|
81
|
-
# sunny, , no
|
82
|
-
# cloudy, june, yes
|
83
|
-
# cloudy, may, yes
|
84
|
-
# cloudy, , no
|
85
|
-
# """)
|
86
|
-
#
|
87
|
-
# engine.register_participant("decision", csvParticipant)
|
88
|
-
#
|
89
|
-
# # ...
|
90
|
-
#
|
91
|
-
# engine.launch(new OpenWFE::LaunchItem(TestDefinition0)
|
92
|
-
#
|
93
|
-
# Note that the CsvParticipant constructor also accepts a block.
|
94
|
-
#
|
95
|
-
class CsvParticipant
|
96
|
-
include LocalParticipant
|
97
|
-
|
98
|
-
attr_accessor \
|
99
|
-
:csv_table
|
100
|
-
|
101
|
-
#
|
102
|
-
# Builds a new CsvParticipant instance, csv_data or the block
|
103
|
-
# may contain a File instance, a String or an Array of Array of
|
104
|
-
# String instances.
|
105
|
-
#
|
106
|
-
def initialize (csv_data=nil, &block)
|
107
|
-
|
108
|
-
super()
|
109
|
-
|
110
|
-
csv_data = block.call if block
|
111
|
-
|
112
|
-
@csv_table = CsvTable.new(csv_data)
|
113
|
-
end
|
114
|
-
|
115
|
-
#
|
116
|
-
# This is the method called by the engine (actually the
|
117
|
-
# ParticipantExpression) when handling a workitem to this participant.
|
118
|
-
#
|
119
|
-
def consume (workitem)
|
120
|
-
fe = get_flow_expression(workitem)
|
121
|
-
workitem = @csv_table.transform_wi(fe, workitem)
|
122
|
-
reply_to_engine(workitem)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
-
# list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
-
# used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
#++
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
#
|
36
|
-
# "made in Japan"
|
37
|
-
#
|
38
|
-
# John Mettraux at openwfe.org
|
39
|
-
#
|
40
|
-
|
41
|
-
require 'yaml'
|
42
|
-
require 'base64'
|
43
|
-
|
44
|
-
#require 'openwfe/utils'
|
45
|
-
#require 'openwfe/rudefinitions'
|
46
|
-
require 'openwfe/participants/participant'
|
47
|
-
|
48
|
-
|
49
|
-
module OpenWFE
|
50
|
-
|
51
|
-
#
|
52
|
-
# This participant dispatches its workitem to an Amazon SQS queue.
|
53
|
-
#
|
54
|
-
# If the queue doesn't exist, the participant will create it.
|
55
|
-
#
|
56
|
-
# a small example :
|
57
|
-
#
|
58
|
-
# # ...
|
59
|
-
# engine.register_participant(:sqs0, SqsParticipant.new("workqueue0"))
|
60
|
-
# # ...
|
61
|
-
#
|
62
|
-
# For more details about SQS :
|
63
|
-
# http://aws.amazon.com
|
64
|
-
#
|
65
|
-
class SqsParticipant
|
66
|
-
include LocalParticipant
|
67
|
-
|
68
|
-
attr_reader :queue, :queue_service
|
69
|
-
|
70
|
-
#
|
71
|
-
# Builds an SqsParticipant instance pointing to a given queue.
|
72
|
-
# (Refer to the SQS service on how to set up AWS key ids).
|
73
|
-
#
|
74
|
-
# By default the host_name is 'queue.amazonaws.com'
|
75
|
-
#
|
76
|
-
def initialize (queue_name, host_name=nil)
|
77
|
-
|
78
|
-
@queue_name = queue_name
|
79
|
-
|
80
|
-
@queue_service = SQS::QueueService.new(host_name)
|
81
|
-
|
82
|
-
@queue_service.create_queue(@queue_name)
|
83
|
-
# make sure the queue exists
|
84
|
-
|
85
|
-
@queue = @queue_service.get_queue(@queue_name)
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# The method called by the engine when it has a workitem for this
|
90
|
-
# participant.
|
91
|
-
#
|
92
|
-
def consume (workitem)
|
93
|
-
|
94
|
-
msg = encode_workitem(workitem)
|
95
|
-
|
96
|
-
msg_id = @queue_service.put_message(@queue, msg)
|
97
|
-
|
98
|
-
ldebug do
|
99
|
-
"consume() msg sent to queue #{@queue.path} id is #{msg_id}"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
protected
|
104
|
-
|
105
|
-
#
|
106
|
-
# Turns the workitem into a Hash, pass it through YAML and
|
107
|
-
# encode64 the result.
|
108
|
-
#
|
109
|
-
# Override this method as needed.
|
110
|
-
#
|
111
|
-
# Something of 'text/plain' flavour should be returned.
|
112
|
-
#
|
113
|
-
def encode_workitem (wi)
|
114
|
-
|
115
|
-
msg = wi.to_h
|
116
|
-
msg = YAML.dump(msg)
|
117
|
-
msg = Base64.encode64(msg)
|
118
|
-
msg
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#
|
2
|
-
#--
|
3
|
-
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions are met:
|
8
|
-
#
|
9
|
-
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
-
# list of conditions and the following disclaimer.
|
11
|
-
#
|
12
|
-
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
-
# this list of conditions and the following disclaimer in the documentation
|
14
|
-
# and/or other materials provided with the distribution.
|
15
|
-
#
|
16
|
-
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
-
# used to endorse or promote products derived from this software without
|
18
|
-
# specific prior written permission.
|
19
|
-
#
|
20
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
-
#++
|
32
|
-
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
|
-
|
36
|
-
#
|
37
|
-
# "made in Japan"
|
38
|
-
#
|
39
|
-
# John Mettraux at openwfe.org
|
40
|
-
#
|
41
|
-
|
42
|
-
require 'yaml'
|
43
|
-
|
44
|
-
|
45
|
-
module OpenWFE
|
46
|
-
|
47
|
-
#
|
48
|
-
# reopening some classes in order to facilitate their
|
49
|
-
# yaml serialization
|
50
|
-
#
|
51
|
-
|
52
|
-
#
|
53
|
-
# opening for tuning yaml persistence
|
54
|
-
#
|
55
|
-
class FlowExpression
|
56
|
-
|
57
|
-
def to_yaml_properties
|
58
|
-
|
59
|
-
l = super()
|
60
|
-
|
61
|
-
l.delete("@application_context")
|
62
|
-
|
63
|
-
#l.delete("@timeout_job_id")
|
64
|
-
#l.delete("@scheduler_job_id")
|
65
|
-
# scheduler ids should not get persisted
|
66
|
-
|
67
|
-
l
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# making sure that the FlowExpressionId is serialized as a unique String
|
73
|
-
#
|
74
|
-
class FlowExpressionId
|
75
|
-
|
76
|
-
yaml_as "tag:ruby.yaml.org,2002:#{self}"
|
77
|
-
|
78
|
-
#def to_yaml (opts={})
|
79
|
-
# @s = to_s
|
80
|
-
# super
|
81
|
-
#end
|
82
|
-
#def to_yaml_properties
|
83
|
-
# [ "@s" ]
|
84
|
-
#end
|
85
|
-
|
86
|
-
def to_yaml (opts={})
|
87
|
-
YAML::quick_emit(self.object_id, opts) do |out|
|
88
|
-
out.map(taguri) do |map|
|
89
|
-
map.add("s", to_s)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def FlowExpressionId.yaml_new (klass, tag, val)
|
95
|
-
s = val["s"]
|
96
|
-
begin
|
97
|
-
FlowExpressionId.to_fei(s)
|
98
|
-
rescue Exception => e
|
99
|
-
raise "failed to decode FlowExpressionId out of '#{s}'"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
#
|
105
|
-
# opening for tuning yaml persistence
|
106
|
-
#
|
107
|
-
class XmlRawExpression
|
108
|
-
def to_yaml_properties
|
109
|
-
l = super()
|
110
|
-
l.delete("@raw_representation")
|
111
|
-
l
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|