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.
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,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -39,68 +39,73 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- require 'workitem'
43
- require 'ru/flowexpression'
44
- require 'ru/fe_utils'
42
+ require 'openwfe/expressions/flowexpression'
43
+ require 'openwfe/expressions/fe_utils'
45
44
 
46
45
 
47
46
  #
48
- # base expressions like 'sequence' and 'concurrence'
47
+ # The 'sequence' expression implementation
49
48
  #
50
49
 
51
- module OpenWFEru
50
+ module OpenWFE
52
51
 
52
+ #
53
+ # This expression sequentially executes each of its children expression.
54
+ # For a more sophisticated version of it, see the 'cursor' expression
55
+ # (fe_cursor.rb).
56
+ #
53
57
  class SequenceExpression < FlowExpression
54
58
 
55
59
  attr_accessor \
56
- :current_child_fei
60
+ :current_child_id
57
61
 
58
62
  #
59
63
  # apply / reply
60
64
 
61
65
  def apply (workitem)
62
66
 
67
+ @current_child_id = -1
68
+
63
69
  reply(workitem)
64
70
  end
65
71
 
66
72
  def reply (workitem)
67
73
 
68
- @current_child_fei = next_fei()
69
-
70
- #ldebug { "reply() next_fei is #{@current_child_fei}" }
74
+ cfei = get_to_next_child()
71
75
 
72
- if @current_child_fei
73
- store_itself()
74
- get_expression_pool().apply(@current_child_fei, workitem)
75
- else
76
+ if not cfei
76
77
  reply_to_parent(workitem)
78
+ return
77
79
  end
80
+
81
+ #ldebug do
82
+ # "reply() self : \n#{self.to_s}\n" + \
83
+ # "reply() next is #{@current_child_id} : #{cfei.to_debug_s}"
84
+ #end
85
+
86
+ store_itself()
87
+
88
+ get_expression_pool().apply(cfei, workitem)
78
89
  end
79
90
 
80
91
  protected
81
92
 
82
- def next_fei ()
83
- if not @current_child_fei
84
- return @children.each do |c|
85
- return c if c.kind_of?(OpenWFE::FlowExpressionId)
86
- end
87
- return nil
88
- end
89
- found = false
90
- @children.each do |c|
91
- #ldebug { "next_fei() considering #{c} (found ? #{found})" }
92
- ldebug { "next_fei() considering #{c}" }
93
- if found
94
- return c if c.kind_of?(OpenWFE::FlowExpressionId)
95
- next
96
- end
97
- if c.kind_of?(OpenWFE::FlowExpressionId) and \
98
- c == @current_child_fei
99
-
100
- found = true
101
- end
93
+ def get_to_next_child ()
94
+
95
+ return nil if @children.length < 1
96
+
97
+ @current_child_id = @current_child_id + 1
98
+
99
+ @children[@current_child_id..-1].each do |c|
100
+
101
+ return c if c.kind_of? OpenWFE::FlowExpressionId
102
+
103
+ @current_child_id = @current_child_id + 1
102
104
  end
103
- return nil
105
+
106
+ return nil
107
+ #
108
+ # did not find any child expression
104
109
  end
105
110
  end
106
111
 
@@ -1,6 +1,6 @@
1
1
  #
2
- #<tt>
3
- # Copyright (c) 2006, John Mettraux, OpenWFE.org
2
+ #--
3
+ # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
28
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
- #</tt>
31
+ #++
32
32
  #
33
33
  # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
34
  #
@@ -39,25 +39,40 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- #require 'workitem'
43
- #require 'ru/flowexpression'
44
- #require 'ru/fe_utils'
42
+ require 'openwfe/expressions/fe_utils'
45
43
 
46
44
 
47
45
  #
48
46
  # the subprocess expression
49
47
  #
50
48
 
51
- module OpenWFEru
52
-
53
- class SubprocessRefExpression < FlowExpression
49
+ module OpenWFE
50
+
51
+ #
52
+ # This expression is used to launch/call a subprocess.
53
+ #
54
+ # For example :
55
+ #
56
+ # <process-definition name="subtest0" revision="0">
57
+ # <sequence>
58
+ # <subprocess ref="sub0" a="A" b="B" c="C" />
59
+ # <sub0 a="A" b="B" c="C" />
60
+ # </sequence>
61
+ #
62
+ # <process-definition name="sub0">
63
+ # <print>${a}${b}${c}</print>
64
+ # </process-definition>
65
+ #
66
+ # </process-definition>
67
+ #
68
+ class SubProcessRefExpression < FlowExpression
54
69
 
55
70
  #
56
71
  # apply / reply
57
72
 
58
73
  def apply (workitem)
59
74
 
60
- ref = OpenWFEru::lookup_ref(self, workitem)
75
+ ref = OpenWFE::lookup_ref(self, workitem)
61
76
 
62
77
  raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" if not ref
63
78
 
@@ -66,13 +81,14 @@ module OpenWFEru
66
81
  raise "did not find any subprocess named '#{ref}'" \
67
82
  if not template_fei
68
83
 
69
- sForget = lookup_attribute(A_FORGET, workitem)
84
+ forget = lookup_boolean_attribute(:forget, workitem)
70
85
 
71
86
  requester = @fei
72
- requester = @fei.workflowInstanceId \
73
- if sForget and sForget.downcase == 'true'
87
+ requester = @fei.workflowInstanceId if forget
88
+
89
+ params = lookup_attributes(workitem)
74
90
 
75
- params = list_attributes(workitem)
91
+ #puts " ... params are #{params.to_s}"
76
92
 
77
93
  get_expression_pool()\
78
94
  .launch_template(requester, template_fei, workitem, params)
@@ -1,6 +1,6 @@
1
1
  #
2
- #<tt>
3
- # Copyright (c) 2006, John Mettraux, OpenWFE.org
2
+ #--
3
+ # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
28
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
- #</tt>
31
+ #++
32
32
  #
33
33
  # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
34
  #
@@ -39,16 +39,16 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- require 'otime'
43
- require 'ru/scheduler'
44
- require 'ru/rudefinitions'
42
+ require 'openwfe/otime'
43
+ require 'openwfe/rudefinitions'
44
+ require 'openwfe/util/scheduler'
45
45
 
46
46
 
47
47
  #
48
48
  # expressions like 'sleep' and 'cron'
49
49
  #
50
50
 
51
- module OpenWFEru
51
+ module OpenWFE
52
52
 
53
53
  #
54
54
  # A parent class for CronExpression and SleepExpression, is never
@@ -58,9 +58,28 @@ module OpenWFEru
58
58
  #
59
59
  class TimeExpression < FlowExpression
60
60
 
61
+ attr_accessor \
62
+ :scheduler_job_id
63
+
61
64
  def get_scheduler
62
65
  return @application_context[S_SCHEDULER]
63
66
  end
67
+
68
+ #
69
+ # Makes sure to cancel any scheduler job associated with this
70
+ # expression
71
+ #
72
+ def cancel ()
73
+ synchronize do
74
+
75
+ ldebug { "cancel() @scheduler_job_id is #{@scheduler_job_id}" }
76
+
77
+ get_scheduler.unschedule(@scheduler_job_id) \
78
+ if @scheduler_job_id
79
+
80
+ return super()
81
+ end
82
+ end
64
83
  end
65
84
 
66
85
  #
@@ -83,38 +102,41 @@ module OpenWFEru
83
102
  :awakening_time
84
103
 
85
104
  def apply (workitem)
105
+ synchronize do
86
106
 
87
- sfor = lookup_attribute("for", workitem)
88
- suntil = lookup_attribute("until", workitem)
107
+ sfor = lookup_attribute(:for, workitem)
108
+ suntil = lookup_attribute(:until, workitem)
89
109
 
90
- tuntil = nil
110
+ tuntil = nil
91
111
 
92
- if suntil
93
- tuntil = suntil
94
- elsif sfor
95
- tfor = OpenWFE::parse_time_string(sfor)
96
- now = Time.new
97
- #tuntil = now.to_f + now.gmt_offset + tfor
98
- tuntil = now.to_f + tfor
99
- end
112
+ if suntil
113
+ tuntil = suntil
114
+ elsif sfor
115
+ tfor = OpenWFE::parse_time_string(sfor)
116
+ ldebug { "apply() tfor is '#{tfor}'" }
117
+ tuntil = Time.new.to_f + tfor
118
+ end
100
119
 
101
- if not tuntil
102
- reply_to_parent(workitem)
103
- return
104
- end
120
+ if not tuntil
121
+ reply_to_parent(workitem)
122
+ return
123
+ end
124
+
125
+ @awakening_time = tuntil
126
+ @sleeping_workitem = workitem.dup
105
127
 
106
- @awakening_time = tuntil
107
- @sleeping_workitem = workitem.dup
128
+ ldebug do
129
+ "apply() " +
130
+ "will sleep until '#{tuntil}' " +
131
+ "(#{OpenWFE::to_iso8601_date(tuntil)})"
132
+ end
108
133
 
109
- store_itself()
134
+ @scheduler_job_id = get_scheduler.schedule_at(tuntil, self, nil)
110
135
 
111
- #ldebug do
112
- # "apply() " +
113
- # "will sleep until '#{tuntil}' " +
114
- # "(#{OpenWFE::to_iso_date(tuntil)})"
115
- #end
136
+ ldebug { "apply() @scheduler_job_id is #{@scheduler_job_id}" }
116
137
 
117
- get_scheduler.schedule_at(tuntil, self, nil)
138
+ store_itself()
139
+ end
118
140
  end
119
141
 
120
142
  #def reply (workitem)
@@ -126,10 +148,16 @@ module OpenWFEru
126
148
  # over
127
149
  #
128
150
  def trigger (params)
151
+ ldebug do
152
+ "trigger() #{@fei.to_debug_s} waking up (#{Time.new.to_f})"
153
+ end
129
154
  reply_to_parent(@sleeping_workitem)
130
155
  end
131
156
  end
132
157
 
158
+ #
159
+ # TODO #6929 : implement me
160
+ #
133
161
  class CronExpression < TimeExpression
134
162
  end
135
163
 
@@ -1,6 +1,6 @@
1
1
  #
2
- #<tt>
3
- # Copyright (c) 2006, John Mettraux, OpenWFE.org
2
+ #--
3
+ # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -28,7 +28,7 @@
28
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
- #</tt>
31
+ #++
32
32
  #
33
33
  # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
34
  #
@@ -39,19 +39,19 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- require 'ru/fe_raw'
43
- require 'ru/dollar'
44
- require 'ru/rudefinitions'
42
+ require 'openwfe/rudefinitions'
43
+ require 'openwfe/util/dollar'
44
+ require 'openwfe/expressions/fe_raw'
45
45
 
46
46
  #
47
47
  # a few help methods for expressions
48
48
 
49
- module OpenWFEru
49
+ module OpenWFE
50
50
 
51
51
  #
52
52
  # Returns the text stored as the children of the given expression
53
53
  #
54
- def OpenWFEru.fetch_text_content (expression, workitem, escape=false)
54
+ def OpenWFE.fetch_text_content (expression, workitem, escape=false)
55
55
 
56
56
  text = ""
57
57
 
@@ -61,7 +61,7 @@ module OpenWFEru
61
61
  else
62
62
  text << child.to_s
63
63
  end
64
- text << "\n"
64
+ #text << "\n"
65
65
  end
66
66
 
67
67
  text = dosub(text, expression, workitem) \
@@ -74,9 +74,9 @@ module OpenWFEru
74
74
  # looks up for 'value', 'variable-value' and then for 'field-value'
75
75
  # if necessary.
76
76
  #
77
- def OpenWFEru.lookup_value (flow_expression, workitem, prefix='')
77
+ def OpenWFE.lookup_value (flow_expression, workitem, prefix='')
78
78
 
79
- return OpenWFEru\
79
+ return OpenWFE\
80
80
  .lookup_vf_attribute(flow_expression, workitem, 'value', prefix)
81
81
  end
82
82
 
@@ -84,39 +84,55 @@ module OpenWFEru
84
84
  # looks up for 'ref', 'variable-ref' and then for 'field-ref'
85
85
  # if necessary.
86
86
  #
87
- def OpenWFEru.lookup_ref (flow_expression, workitem, prefix='')
87
+ def OpenWFE.lookup_ref (flow_expression, workitem, prefix='')
88
88
 
89
- return OpenWFEru\
89
+ return OpenWFE\
90
90
  .lookup_vf_attribute(flow_expression, workitem, 'ref', prefix)
91
91
  end
92
92
 
93
93
  #
94
- # looks up for value attributes like 'field-ref' or 'variable-value'
94
+ # Looks up for value attributes like 'field-ref' or 'variable-value'
95
95
  #
96
- def OpenWFEru.lookup_vf_attribute \
96
+ def OpenWFE.lookup_vf_attribute \
97
97
  (flow_expression, workitem, att_name, prefix='')
98
98
 
99
- prefix = "#{prefix}-" if prefix != ''
99
+ prefix = "#{prefix.to_s}-" if prefix != ''
100
100
 
101
101
  v = flow_expression.lookup_attribute("#{prefix}#{att_name}", workitem)
102
102
 
103
- if not v
104
- v = flow_expression\
105
- .lookup_attribute("#{prefix}variable-#{att_name}", workitem)
106
- end
103
+ return v if v
107
104
 
108
- if not v
109
- v = flow_expression\
110
- .lookup_attribute("#{prefix}field-#{att_name}", workitem)
111
- end
105
+ v = flow_expression\
106
+ .lookup_attribute("#{prefix}variable-#{att_name}", workitem)
107
+
108
+ return flow_expression.lookup_variable(v) if v
109
+
110
+ v = flow_expression\
111
+ .lookup_attribute("#{prefix}field-#{att_name}", workitem)
112
112
 
113
- return v
113
+ return workitem.attributes[v] if v
114
+
115
+ return nil
114
116
  end
115
117
 
118
+ #
119
+ # Looks up for a value, a variable or a field (in that order).
120
+ #
121
+ #def OpenWFE.lookup_vvf_attribute (flow_expression, workitem, prefix)
122
+ # raise "missing prefix" unless prefix
123
+ # v = flow_expression.lookup_attribute("#{prefix}-value", workitem)
124
+ # return v if v
125
+ # v = flow_expression.lookup_attribute("#{prefix}-variable", workitem)
126
+ # return flow_expression.lookup_variable(v) if v
127
+ # v = flow_expression.lookup_attribute("#{prefix}-field", workitem)
128
+ # return workitem.attributes[v] if v
129
+ # return nil
130
+ #end
131
+
116
132
  #
117
133
  # sets the '__result__' field of the workitem
118
134
  #
119
- def OpenWFEru.set_result (workitem, result)
135
+ def OpenWFE.set_result (workitem, result)
120
136
 
121
137
  workitem.attributes[FIELD_RESULT] = result
122
138
  end