openwferu 0.9.1 → 0.9.2

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