openwferu 0.9.1 → 0.9.2
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 → README.txt} +16 -13
- data/bin/validate-workflow.rb +46 -22
- data/examples/README.txt +8 -0
- data/examples/homeworkreview.rb +66 -0
- data/examples/quotereporter.rb +154 -0
- data/lib/{openwferu.rb → openwfe.rb} +6 -8
- data/lib/{ru → openwfe}/contextual.rb +11 -3
- data/lib/{ru → openwfe/engine}/engine.rb +50 -36
- data/lib/{ru/participant.rb → openwfe/engine/file_persisted_engine.rb} +21 -22
- data/lib/openwfe/expool/expressionpool.rb +534 -0
- data/lib/openwfe/expool/expstorage.rb +184 -0
- data/lib/openwfe/expool/journalexpstorage.rb +312 -0
- data/lib/openwfe/expool/yamlexpstorage.rb +127 -0
- data/lib/{ru → openwfe/expressions}/environment.rb +19 -14
- data/lib/{ru → openwfe/expressions}/expressionmap.rb +48 -21
- data/lib/{ru → openwfe/expressions}/fe_concurrence.rb +111 -35
- data/lib/openwfe/expressions/fe_cursor.rb +236 -0
- data/lib/{ru → openwfe/expressions}/fe_define.rb +5 -5
- data/lib/openwfe/expressions/fe_fqv.rb +99 -0
- data/lib/openwfe/expressions/fe_iterator.rb +182 -0
- data/lib/{ru/fe_misc.rb → openwfe/expressions/fe_losfor.rb} +14 -56
- data/lib/openwfe/expressions/fe_misc.rb +102 -0
- data/lib/{ru → openwfe/expressions}/fe_participant.rb +25 -14
- data/lib/{ru → openwfe/expressions}/fe_raw.rb +39 -75
- data/lib/{ru/fe_base.rb → openwfe/expressions/fe_sequence.rb} +40 -35
- data/lib/{ru → openwfe/expressions}/fe_subprocess.rb +30 -14
- data/lib/{ru → openwfe/expressions}/fe_time.rb +59 -31
- data/lib/{ru → openwfe/expressions}/fe_utils.rb +42 -26
- data/lib/{ru → openwfe/expressions}/fe_value.rb +20 -14
- data/lib/openwfe/expressions/flowexpression.rb +434 -0
- data/lib/openwfe/expressions/raw_prog.rb +391 -0
- data/lib/openwfe/expressions/raw_xml.rb +128 -0
- data/lib/openwfe/flowexpressionid.rb +148 -0
- data/lib/{ru → openwfe}/logging.rb +10 -6
- data/lib/{osocket.rb → openwfe/osocket.rb} +36 -35
- data/lib/{otime.rb → openwfe/otime.rb} +71 -21
- data/lib/openwfe/participants/atomparticipants.rb +144 -0
- data/lib/openwfe/participants/enoparticipant.rb +73 -0
- data/lib/openwfe/participants/participant.rb +85 -0
- data/lib/{ru → openwfe/participants}/participantmap.rb +40 -12
- data/lib/{ru → openwfe/participants}/participants.rb +41 -12
- data/lib/openwfe/participants/soapparticipants.rb +96 -0
- data/lib/{controlclient.rb → openwfe/rest/controlclient.rb} +12 -13
- data/lib/{definitions.rb → openwfe/rest/definitions.rb} +3 -3
- data/lib/{exception.rb → openwfe/rest/exception.rb} +3 -3
- data/lib/{restclient.rb → openwfe/rest/restclient.rb} +13 -22
- data/lib/{worklistclient.rb → openwfe/rest/worklistclient.rb} +33 -46
- data/lib/openwfe/rest/xmlcodec.rb +575 -0
- data/lib/{ru → openwfe}/rudefinitions.rb +32 -4
- data/lib/{ru → openwfe}/service.rb +20 -8
- data/lib/openwfe/storage/yamlfilestorage.rb +159 -0
- data/lib/{ru → openwfe/util}/dollar.rb +10 -8
- data/lib/openwfe/util/lru_cache.rb +149 -0
- data/lib/{ru → openwfe/util}/scheduler.rb +18 -10
- data/lib/{ru → openwfe/util}/schedulers.rb +7 -7
- data/lib/{utils.rb → openwfe/utils.rb} +93 -9
- data/lib/openwfe/workitem.rb +366 -0
- data/lib/openwfe/worklist/worklists.rb +175 -0
- data/test/README.txt +27 -0
- data/test/atomtest.rb +99 -0
- data/test/crontest.rb +58 -0
- data/test/dollartest.rb +3 -3
- data/test/feitest.rb +42 -14
- data/test/file_persistence_test.rb +93 -0
- data/test/flowtestbase.rb +72 -26
- data/test/ft_0.rb +1 -97
- data/test/ft_0b_sequence.rb +33 -0
- data/test/ft_0c_testname.rb +29 -0
- data/test/ft_10_loop.rb +48 -0
- data/test/ft_11_ppd.rb +292 -0
- data/test/ft_12_blockparticipant.rb +45 -0
- data/test/ft_13_eno.rb +51 -0
- data/test/ft_14_subprocess.rb +90 -0
- data/test/ft_14b_subprocess.rb +40 -0
- data/test/ft_15_iterator.rb +70 -0
- data/test/ft_16_fqv.rb +57 -0
- data/test/ft_1_unset.rb +25 -1
- data/test/ft_2_concurrence.rb +10 -5
- data/test/ft_3_equals.rb +35 -1
- data/test/ft_4_misc.rb +16 -1
- data/test/ft_5_time.rb +26 -1
- data/test/ft_6_lambda.rb +2 -1
- data/test/{ft_7_losfor.rb → ft_7_lose.rb} +41 -35
- data/test/ft_8_forget.rb +46 -0
- data/test/ft_9_cursor.rb +94 -0
- data/test/journal_persistence_test.rb +147 -0
- data/test/misctest.rb +13 -9
- data/test/rake_ptest.rb +18 -0
- data/test/rake_qtest.rb +43 -0
- data/test/{fulltest.rb → rake_test.rb} +2 -2
- data/test/raw_prog_test.rb +236 -0
- data/test/rest_test.rb +189 -0
- data/test/rutest_utils.rb +1 -1
- data/test/timetest.rb +42 -34
- metadata +125 -82
- data/lib/codec.rb +0 -573
- data/lib/flowexpressionid.rb +0 -139
- data/lib/ru/expressionpool.rb +0 -382
- data/lib/ru/expressionstorage.rb +0 -99
- data/lib/ru/flowexpression.rb +0 -272
- data/lib/ru/ruutils.rb +0 -70
- data/lib/test.rb +0 -222
- data/lib/workitem.rb +0 -249
- data/test/quicktest.rb +0 -21
@@ -0,0 +1,575 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2005-2007, John Mettraux, 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: codec.rb 2865 2006-06-23 14:54:07Z jmettraux $
|
34
|
+
#
|
35
|
+
|
36
|
+
#
|
37
|
+
# "hecho en Costa Rica"
|
38
|
+
#
|
39
|
+
|
40
|
+
#require 'base64'
|
41
|
+
require 'rexml/document'
|
42
|
+
|
43
|
+
require 'definitions'
|
44
|
+
require 'utils'
|
45
|
+
require 'workitem'
|
46
|
+
require 'flowexpressionid'
|
47
|
+
|
48
|
+
|
49
|
+
module OpenWFE
|
50
|
+
|
51
|
+
class XmlCodec
|
52
|
+
|
53
|
+
#
|
54
|
+
# Takes as input some XML element and returns is decoded
|
55
|
+
# (as an instance)
|
56
|
+
#
|
57
|
+
def decode (xmlElt)
|
58
|
+
|
59
|
+
return nil if not xmlElt
|
60
|
+
|
61
|
+
#puts "decode() xmlElt.name is >#{xmlElt.name}<"
|
62
|
+
|
63
|
+
return decode_list(xmlElt) if xmlElt.name == STORES
|
64
|
+
return decode_store(xmlElt) if xmlElt.name == STORE
|
65
|
+
return decode_list(xmlElt) if xmlElt.name == HEADERS
|
66
|
+
return decode_header(xmlElt) if xmlElt.name == HEADER
|
67
|
+
|
68
|
+
return decode_launch_ok(xmlElt) if xmlElt.name == OK
|
69
|
+
|
70
|
+
return decode_list(xmlElt) if xmlElt.name == HISTORY
|
71
|
+
return decode_historyitem(xmlElt) if xmlElt.name == HISTORY_ITEM
|
72
|
+
|
73
|
+
return decode_list(xmlElt) \
|
74
|
+
if xmlElt.name == FLOW_EXPRESSION_IDS
|
75
|
+
return decode_fei(xmlElt) \
|
76
|
+
if xmlElt.name == FLOW_EXPRESSION_ID
|
77
|
+
|
78
|
+
return decode_inflowworkitem(xmlElt) \
|
79
|
+
if xmlElt.name == IN_FLOW_WORKITEM
|
80
|
+
|
81
|
+
return decode_list(xmlElt) if xmlElt.name == LAUNCHABLES
|
82
|
+
return decode_launchable(xmlElt) if xmlElt.name == LAUNCHABLE
|
83
|
+
|
84
|
+
return decode_list(xmlElt) if xmlElt.name == EXPRESSIONS
|
85
|
+
return decode_expression(xmlElt) if xmlElt.name == EXPRESSION
|
86
|
+
|
87
|
+
return decode_attribute(xmlElt.elements[1]) if xmlElt.name == ATTRIBUTES
|
88
|
+
|
89
|
+
#
|
90
|
+
# default
|
91
|
+
|
92
|
+
decode_attribute(xmlElt)
|
93
|
+
|
94
|
+
#raise \
|
95
|
+
# ArgumentError, \
|
96
|
+
# "Cannot decode : '"+xmlElt.name+"' "+xmlElt.to_s()
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# Takes some OpenWFE Ruby instance and returns it as XML
|
101
|
+
#
|
102
|
+
def encode (owfeData)
|
103
|
+
|
104
|
+
#puts "encode() #{owfeData.inspect}"
|
105
|
+
|
106
|
+
return encode_launchitem(owfeData) \
|
107
|
+
if owfeData.kind_of? LaunchItem
|
108
|
+
|
109
|
+
return encode_fei(owfeData) \
|
110
|
+
if owfeData.kind_of? FlowExpressionId
|
111
|
+
|
112
|
+
return encode_inflowworkitem(owfeData) \
|
113
|
+
if owfeData.kind_of? InFlowWorkItem
|
114
|
+
|
115
|
+
raise \
|
116
|
+
ArgumentError, \
|
117
|
+
"Cannot encode : "+owfeData.inspect()
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
#
|
123
|
+
# DECODE
|
124
|
+
#
|
125
|
+
|
126
|
+
def decode_list (xmlElt)
|
127
|
+
xmlElt.elements.collect { |elt| decode(elt) }
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def decode_launchable (xmlElt)
|
132
|
+
|
133
|
+
launchable = Launchable.new()
|
134
|
+
|
135
|
+
launchable.url = xmlElt.attributes[URL]
|
136
|
+
launchable.engine_id = xmlElt.attributes[ENGINE_ID]
|
137
|
+
|
138
|
+
return launchable
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def decode_expression (xmlElt)
|
143
|
+
|
144
|
+
exp = Expression.new()
|
145
|
+
|
146
|
+
#exp.id = decode(OpenWFE.first_element(xmlElt, "//"+FLOW_EXPRESSION_ID))
|
147
|
+
exp.id = decode(OpenWFE.first_element(xmlElt))
|
148
|
+
|
149
|
+
exp.apply_time = xmlElt.attributes[APPLY_TIME]
|
150
|
+
exp.state = xmlElt.attributes[STATE]
|
151
|
+
exp.state_since = xmlElt.attributes[STATE_SINCE]
|
152
|
+
|
153
|
+
return exp
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def decode_store (xmlElt)
|
158
|
+
|
159
|
+
store = Store.new()
|
160
|
+
|
161
|
+
store.name = xmlElt.attributes[NAME]
|
162
|
+
store.workitem_count = xmlElt.attributes[WORKITEM_COUNT]
|
163
|
+
store.workitem_count = Integer(store.workitem_count)
|
164
|
+
store.permissions = xmlElt.attributes[PERMISSIONS]
|
165
|
+
|
166
|
+
return store
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
def decode_header (xmlElt)
|
171
|
+
|
172
|
+
header = Header.new()
|
173
|
+
|
174
|
+
header.last_modified = xmlElt.attributes[A_LAST_MODIFIED]
|
175
|
+
header.locked = parse_boolean(xmlElt.attributes[A_LOCKED])
|
176
|
+
header.flow_expression_id = decode(OpenWFE.first_element(xmlElt, FLOW_EXPRESSION_ID))
|
177
|
+
header.attributes = decode(OpenWFE.first_element(xmlElt, ATTRIBUTES))
|
178
|
+
|
179
|
+
return header
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
def decode_fei (xmlElt)
|
184
|
+
|
185
|
+
fei = FlowExpressionId.new
|
186
|
+
|
187
|
+
fei.owfe_version = xmlElt.attributes[OWFE_VERSION]
|
188
|
+
fei.engine_id = xmlElt.attributes[ENGINE_ID]
|
189
|
+
fei.initial_engine_id = xmlElt.attributes[INITIAL_ENGINE_ID]
|
190
|
+
|
191
|
+
fei.workflow_definition_url = xmlElt.attributes[WORKFLOW_DEFINITION_URL]
|
192
|
+
fei.workflow_definition_name = xmlElt.attributes[WORKFLOW_DEFINITION_NAME]
|
193
|
+
fei.workflow_definition_revision = xmlElt.attributes[WORKFLOW_DEFINITION_REVISION]
|
194
|
+
|
195
|
+
fei.workflow_instance_id = xmlElt.attributes[WORKFLOW_INSTANCE_ID]
|
196
|
+
|
197
|
+
fei.expression_name = xmlElt.attributes[EXPRESSION_NAME]
|
198
|
+
fei.expression_id = xmlElt.attributes[EXPRESSION_ID]
|
199
|
+
|
200
|
+
#puts " ... fei.expressionName is >#{fei.expressionName}<"
|
201
|
+
#puts " ... fei.wfid is >#{fei.workflowInstanceId}<"
|
202
|
+
|
203
|
+
return fei
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
def decode_attribute (xmlElt)
|
208
|
+
|
209
|
+
#puts "decodeAttribute() '#{xmlElt.name}' --> '#{xmlElt.text}'"
|
210
|
+
|
211
|
+
#
|
212
|
+
# atomic types
|
213
|
+
|
214
|
+
return xmlElt.text if xmlElt.name == E_STRING
|
215
|
+
return Integer(xmlElt.text) if xmlElt.name == E_INTEGER
|
216
|
+
return Integer(xmlElt.text) if xmlElt.name == E_LONG
|
217
|
+
return Float(xmlElt.text) if xmlElt.name == E_DOUBLE
|
218
|
+
return parseBoolean(xmlElt.text) if xmlElt.name == E_BOOLEAN
|
219
|
+
|
220
|
+
return xmlElt if xmlElt.name == E_XML
|
221
|
+
|
222
|
+
return Base64Attribute.new(xmlElt.txt) if xmlElt.name == E_BASE64
|
223
|
+
|
224
|
+
#
|
225
|
+
# composite types
|
226
|
+
|
227
|
+
return decodeList(xmlElt) if xmlElt.name == E_LIST
|
228
|
+
|
229
|
+
if xmlElt.name == E_SMAP or xmlElt.name == E_MAP
|
230
|
+
|
231
|
+
map = {}
|
232
|
+
map[MAP_TYPE] = xmlElt.name
|
233
|
+
|
234
|
+
#xmlElt.elements.each("//"+M_ENTRY) do |e|
|
235
|
+
xmlElt.elements.each(M_ENTRY) do |e|
|
236
|
+
#puts "decodeAttribute() >#{e}<"
|
237
|
+
decode_entry(e, map)
|
238
|
+
end
|
239
|
+
|
240
|
+
return map
|
241
|
+
end
|
242
|
+
|
243
|
+
#puts xmldoc_to_string(xmlElt.document())
|
244
|
+
|
245
|
+
raise \
|
246
|
+
ArgumentError, \
|
247
|
+
"Cannot decode <#{xmlElt.name}/> in \n"+\
|
248
|
+
xmldoc_to_string(xmlElt.document())
|
249
|
+
end
|
250
|
+
|
251
|
+
def decode_entry (xmlElt, map)
|
252
|
+
|
253
|
+
key = xmlElt.elements[1]
|
254
|
+
val = xmlElt.elements[2]
|
255
|
+
|
256
|
+
#
|
257
|
+
# this parse method supports the old style and the [new] light
|
258
|
+
# style/schema
|
259
|
+
#
|
260
|
+
|
261
|
+
key = key.elements[1] if key.name == M_KEY
|
262
|
+
val = val.elements[1] if val.name == M_VALUE
|
263
|
+
|
264
|
+
key = decode(key)
|
265
|
+
val = decode(val)
|
266
|
+
|
267
|
+
#puts "decodeEntry() k >#{key}< v >#{val}<"
|
268
|
+
#puts "decodeEntry() subject '#{val}'" if key == '__subject__'
|
269
|
+
|
270
|
+
map[key] = val
|
271
|
+
end
|
272
|
+
|
273
|
+
def parse_boolean (string)
|
274
|
+
|
275
|
+
return string.strip.downcase == 'true'
|
276
|
+
end
|
277
|
+
|
278
|
+
def decode_historyitem (xmlElt)
|
279
|
+
|
280
|
+
hi = HistoryItem.new
|
281
|
+
|
282
|
+
hi.author = xmlElt.attributes[A_AUTHOR]
|
283
|
+
hi.date = xmlElt.attributes[A_DATE]
|
284
|
+
hi.host = xmlElt.attributes[A_HOST]
|
285
|
+
hi.text = xmlElt.text
|
286
|
+
|
287
|
+
hi.wfd_name = xmlElt.attributes[WORKFLOW_DEFINITION_NAME]
|
288
|
+
hi.wfd_revision = xmlElt.attributes[WORKFLOW_DEFINITION_REVISION]
|
289
|
+
hi.wf_instance_id = xmlElt.attributes[WORKFLOW_INSTANCE_ID]
|
290
|
+
hi.expression_id = xmlElt.attributes[EXPRESSION_ID]
|
291
|
+
|
292
|
+
return hi
|
293
|
+
end
|
294
|
+
|
295
|
+
|
296
|
+
def decode_launch_ok (xmlElt)
|
297
|
+
|
298
|
+
sFei = xmlElt.attributes[A_FLOW_ID]
|
299
|
+
|
300
|
+
return true if not sFei
|
301
|
+
|
302
|
+
FlowExpressionId.to_fei(sFei)
|
303
|
+
end
|
304
|
+
|
305
|
+
|
306
|
+
def decode_inflowworkitem (xmlElt)
|
307
|
+
|
308
|
+
wi = InFlowWorkItem.new()
|
309
|
+
|
310
|
+
wi.last_modified = xmlElt.attributes[A_LAST_MODIFIED]
|
311
|
+
wi.attributes = decode(OpenWFE.first_element(xmlElt, ATTRIBUTES))
|
312
|
+
|
313
|
+
wi.participant_name = xmlElt.attributes[A_PARTICIPANT_NAME]
|
314
|
+
wi.flow_expression_id = decode(OpenWFE.first_element(OpenWFE.first_element(xmlElt, E_LAST_EXPRESSION_ID), FLOW_EXPRESSION_ID))
|
315
|
+
|
316
|
+
wi.dispatch_time = xmlElt.attributes[A_DISPATCH_TIME]
|
317
|
+
|
318
|
+
# TODO : decode filter
|
319
|
+
|
320
|
+
wi.history = decode(OpenWFE.first_element(xmlElt, HISTORY))
|
321
|
+
|
322
|
+
return wi
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
#
|
327
|
+
# ENCODE
|
328
|
+
#
|
329
|
+
|
330
|
+
|
331
|
+
def encode_item (item, elt)
|
332
|
+
|
333
|
+
elt.attributes[A_LAST_MODIFIED] = item.last_modified
|
334
|
+
|
335
|
+
eAttributes = REXML::Element.new(ATTRIBUTES)
|
336
|
+
|
337
|
+
eAttributes << encode_attribute(item.attributes)
|
338
|
+
|
339
|
+
elt << eAttributes
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
def encode_launchitem (launchitem)
|
344
|
+
|
345
|
+
doc = REXML::Document.new()
|
346
|
+
|
347
|
+
root = REXML::Element.new(E_LAUNCHITEM)
|
348
|
+
|
349
|
+
encode_item(launchitem, root)
|
350
|
+
|
351
|
+
root.attributes[WORKFLOW_DEFINITION_URL] = \
|
352
|
+
launchitem.workflow_definition_url
|
353
|
+
|
354
|
+
# TODO :
|
355
|
+
#
|
356
|
+
# - encode descriptionMap
|
357
|
+
#
|
358
|
+
# - replyTo is not necessary
|
359
|
+
|
360
|
+
doc << root
|
361
|
+
|
362
|
+
OpenWFE.xmldoc_to_string(doc)
|
363
|
+
end
|
364
|
+
|
365
|
+
|
366
|
+
def encode_inflowitem (item, elt)
|
367
|
+
|
368
|
+
encode_item(item, elt)
|
369
|
+
|
370
|
+
elt.attributes[A_PARTICIPANT_NAME] = item.participant_name
|
371
|
+
|
372
|
+
eLastExpressionId = REXML::Element.new(E_LAST_EXPRESSION_ID)
|
373
|
+
|
374
|
+
eLastExpressionId << encode_fei(item.last_expression_id)
|
375
|
+
|
376
|
+
elt << eLastExpressionId
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
def encode_inflowworkitem (item)
|
381
|
+
|
382
|
+
doc = REXML::Document.new()
|
383
|
+
|
384
|
+
root = REXML::Element.new(IN_FLOW_WORKITEM)
|
385
|
+
|
386
|
+
encode_inflowitem(item, root)
|
387
|
+
|
388
|
+
root.attributes[A_DISPATCH_TIME] = item.dispatch_time
|
389
|
+
|
390
|
+
# add filter ? no
|
391
|
+
|
392
|
+
encode_history(item, root)
|
393
|
+
|
394
|
+
doc << root
|
395
|
+
|
396
|
+
s = OpenWFE.xmldoc_to_string(doc)
|
397
|
+
#puts "encoded :\n#{s}"
|
398
|
+
return s
|
399
|
+
end
|
400
|
+
|
401
|
+
|
402
|
+
def encode_history (item, elt)
|
403
|
+
|
404
|
+
eHistory = REXML::Element.new(HISTORY)
|
405
|
+
|
406
|
+
item.history.each do |hi|
|
407
|
+
|
408
|
+
ehi = REXML::Element.new(HISTORY_ITEM)
|
409
|
+
|
410
|
+
ehi.attributes[A_AUTHOR] = hi.author
|
411
|
+
ehi.attributes[A_DATE] = hi.date
|
412
|
+
ehi.attributes[A_HOST] = hi.host
|
413
|
+
|
414
|
+
ehi.attributes[WORKFLOW_DEFINITION_NAME] = hi.wfd_name
|
415
|
+
ehi.attributes[WORKFLOW_DEFINITION_REVISION] = hi.wfd_revision
|
416
|
+
ehi.attributes[WORKFLOW_INSTANCE_ID] = hi.wf_instance_id
|
417
|
+
ehi.attributes[EXPRESSION_ID] = hi.expression_id
|
418
|
+
|
419
|
+
eHistory << ehi
|
420
|
+
end
|
421
|
+
|
422
|
+
elt << eHistory
|
423
|
+
end
|
424
|
+
|
425
|
+
|
426
|
+
def encode_attribute (att)
|
427
|
+
|
428
|
+
#puts "encodeAttribute() att.class is #{att.class}"
|
429
|
+
|
430
|
+
return encode_atomicattribute(E_STRING, att) \
|
431
|
+
if att.kind_of? String
|
432
|
+
return encode_atomicattribute(E_INTEGER, att) \
|
433
|
+
if att.kind_of? Fixnum
|
434
|
+
return encode_atomicattribute(E_DOUBLE, att) \
|
435
|
+
if att.kind_of? Float
|
436
|
+
|
437
|
+
return encode_xmlattribute(att) \
|
438
|
+
if att.kind_of? REXML::Element
|
439
|
+
|
440
|
+
return encode_atomicattribute(E_BOOLEAN, true) \
|
441
|
+
if att.kind_of? TrueClass
|
442
|
+
return encode_atomicattribute(E_BOOLEAN, false) \
|
443
|
+
if att.kind_of? FalseClass
|
444
|
+
|
445
|
+
return encode_base64attribute(att) \
|
446
|
+
if att.kind_of? Base64Attribute
|
447
|
+
|
448
|
+
return encode_mapattribute(att) if att.kind_of? Hash
|
449
|
+
return encode_listattribute(att) if att.kind_of? Array
|
450
|
+
|
451
|
+
#
|
452
|
+
# default
|
453
|
+
|
454
|
+
encode_atomicattribute(E_STRING, att)
|
455
|
+
|
456
|
+
#raise \
|
457
|
+
# ArgumentError, \
|
458
|
+
# "Cannot encode attribute of class '#{att.class}'"
|
459
|
+
end
|
460
|
+
|
461
|
+
|
462
|
+
def encode_xmlattribute (elt)
|
463
|
+
|
464
|
+
return elt if elt.name == E_XML
|
465
|
+
|
466
|
+
#
|
467
|
+
# else, wrap within <raw-xml>...</raw-xml>
|
468
|
+
|
469
|
+
e = REXML::Element.new(E_XML)
|
470
|
+
e << elt
|
471
|
+
|
472
|
+
return e
|
473
|
+
end
|
474
|
+
|
475
|
+
|
476
|
+
def encode_base64attribute (att)
|
477
|
+
|
478
|
+
e = REXML::Element.new(E_BASE64)
|
479
|
+
e.text = att.content
|
480
|
+
|
481
|
+
return e
|
482
|
+
end
|
483
|
+
|
484
|
+
|
485
|
+
def encode_atomicattribute (name, value)
|
486
|
+
|
487
|
+
elt = REXML::Element.new(name)
|
488
|
+
#elt << REXML::Text.new(value.to_s())
|
489
|
+
elt.add_text(value.to_s())
|
490
|
+
|
491
|
+
return elt
|
492
|
+
end
|
493
|
+
|
494
|
+
|
495
|
+
def encode_listattribute (list)
|
496
|
+
|
497
|
+
elt = REXML::Element.new(E_LIST)
|
498
|
+
|
499
|
+
list.each do |e|
|
500
|
+
elt << encode_attribute(e)
|
501
|
+
end
|
502
|
+
|
503
|
+
return elt
|
504
|
+
end
|
505
|
+
|
506
|
+
|
507
|
+
def encode_mapattribute (hash)
|
508
|
+
|
509
|
+
name = hash[MAP_TYPE]
|
510
|
+
name = 'map' if name == nil
|
511
|
+
|
512
|
+
elt = REXML::Element.new(name)
|
513
|
+
|
514
|
+
hash.each_key do |key|
|
515
|
+
|
516
|
+
next if key == MAP_TYPE
|
517
|
+
|
518
|
+
eEntry = REXML::Element.new(M_ENTRY)
|
519
|
+
|
520
|
+
val = hash[key]
|
521
|
+
|
522
|
+
eEntry << encode_attribute(key)
|
523
|
+
eEntry << encode_attribute(val)
|
524
|
+
|
525
|
+
elt << eEntry
|
526
|
+
end
|
527
|
+
|
528
|
+
return elt
|
529
|
+
end
|
530
|
+
|
531
|
+
|
532
|
+
def encode_fei (fei)
|
533
|
+
|
534
|
+
elt = REXML::Element.new(FLOW_EXPRESSION_ID)
|
535
|
+
|
536
|
+
elt.attributes[OWFE_VERSION] = fei.owfe_version
|
537
|
+
elt.attributes[ENGINE_ID] = fei.engine_id
|
538
|
+
elt.attributes[INITIAL_ENGINE_ID] = fei.initial_engine_id
|
539
|
+
|
540
|
+
elt.attributes[WORKFLOW_DEFINITION_URL] = fei.workflow_definition_url
|
541
|
+
elt.attributes[WORKFLOW_DEFINITION_NAME] = fei.workflow_definition_name
|
542
|
+
elt.attributes[WORKFLOW_DEFINITION_REVISION] = fei.workflow_definition_revision
|
543
|
+
elt.attributes[WORKFLOW_INSTANCE_ID] = fei.workflow_instance_id
|
544
|
+
|
545
|
+
elt.attributes[EXPRESSION_NAME] = fei.expression_name
|
546
|
+
elt.attributes[EXPRESSION_ID] = fei.expression_id
|
547
|
+
|
548
|
+
return elt
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
XMLCODEC = XmlCodec.new
|
553
|
+
|
554
|
+
def OpenWFE.xml_decode (xmlelt)
|
555
|
+
XMLCODEC.decode(xmlelt)
|
556
|
+
end
|
557
|
+
|
558
|
+
def OpenWFE.xml_encode (owfedata)
|
559
|
+
XMLCODEC.encode(owfedata)
|
560
|
+
end
|
561
|
+
|
562
|
+
def OpenWFE.xmldoc_to_string (xml, decl=true)
|
563
|
+
|
564
|
+
s = ""
|
565
|
+
|
566
|
+
if decl and xml[0].kind_of? REXML::XMLDecl
|
567
|
+
xml << REXML::XMLDecl.new()
|
568
|
+
end
|
569
|
+
|
570
|
+
xml.write(s, 0)
|
571
|
+
return s
|
572
|
+
end
|
573
|
+
|
574
|
+
end
|
575
|
+
|