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,60 +39,11 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- require 'ru/flowexpression'
43
- require 'ru/fe_utils'
42
+ require 'openwfe/expressions/flowexpression'
43
+ require 'openwfe/expressions/fe_utils'
44
44
 
45
45
 
46
- module OpenWFEru
47
-
48
- class PrintExpression < FlowExpression
49
-
50
- #
51
- # apply / reply
52
-
53
- def apply (workitem)
54
-
55
- escape = lookup_boolean_attribute('escape', workitem, false)
56
-
57
- text = OpenWFEru::fetch_text_content(self, workitem, escape)
58
- tracer = @application_context['__tracer']
59
-
60
- if tracer
61
- tracer << text
62
- else
63
- puts text
64
- end
65
-
66
- reply_to_parent(workitem)
67
- end
68
-
69
- #def reply (workitem)
70
- #end
71
-
72
- end
73
-
74
- #
75
- # Evals some Ruby code contained within the process definition
76
- # or within the workitem
77
- #
78
- class RevalExpression < FlowExpression
79
-
80
- def apply (workitem)
81
-
82
- escape = lookup_boolean_attribute('escape', workitem, false)
83
-
84
- code = OpenWFEru::lookup_vf_attribute(self, workitem, 'code')
85
-
86
- code = OpenWFEru::fetch_text_content(self, workitem, escape) \
87
- if not code
88
-
89
- result = eval(code.to_s)
90
-
91
- OpenWFEru::set_result(workitem, result) if result != nil
92
-
93
- reply_to_parent(workitem)
94
- end
95
- end
46
+ module OpenWFE
96
47
 
97
48
  #
98
49
  # Triggers the first (and supposedly unique child of this expression)
@@ -107,7 +58,7 @@ module OpenWFEru
107
58
  end
108
59
 
109
60
  def reply (workitem)
110
- # does nothing at all
61
+ get_expression_pool.remove(self)
111
62
  end
112
63
  end
113
64
 
@@ -115,7 +66,7 @@ module OpenWFEru
115
66
  # This method triggers its child (in its own thread) and then
116
67
  # forgets about it. It immediately replies to its parent expression.
117
68
  #
118
- class ForgetExpression < LoseExpression
69
+ class ForgetExpression < FlowExpression
119
70
 
120
71
  def apply (workitem)
121
72
 
@@ -125,11 +76,14 @@ module OpenWFEru
125
76
 
126
77
  Thread.new do
127
78
  begin
79
+ #child = get_expression_pool.fetch(@children[0])
80
+ #child.parent_id = nil
81
+ get_expression_pool.forget(@children[0])
128
82
  get_expression_pool.apply(@children[0], wi)
129
83
  rescue Exception => e
130
84
  lwarn do
131
85
  "apply() failed to apply child to forget "+
132
- OpenWFEru::exception_to_s(e)
86
+ OpenWFE::exception_to_s(e)
133
87
  end
134
88
  end
135
89
  end
@@ -137,6 +91,10 @@ module OpenWFEru
137
91
 
138
92
  reply_to_parent(wi)
139
93
  end
94
+
95
+ def reply (workitem)
96
+ # never gets called
97
+ end
140
98
  end
141
99
 
142
100
  end
@@ -0,0 +1,102 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2006-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 'openwfe/expressions/flowexpression'
43
+ require 'openwfe/expressions/fe_utils'
44
+
45
+
46
+ module OpenWFE
47
+
48
+ class PrintExpression < FlowExpression
49
+
50
+ #
51
+ # apply / reply
52
+
53
+ def apply (workitem)
54
+
55
+ escape = lookup_boolean_attribute('escape', workitem, false)
56
+
57
+ text = OpenWFE::fetch_text_content(self, workitem, escape)
58
+ text << "\n"
59
+
60
+ tracer = @application_context['__tracer']
61
+
62
+ if tracer
63
+ tracer << text
64
+ else
65
+ puts text
66
+ end
67
+
68
+ reply_to_parent(workitem)
69
+ end
70
+
71
+ #def reply (workitem)
72
+ #end
73
+
74
+ end
75
+
76
+ #
77
+ # <reval/>
78
+ #
79
+ # Evals some Ruby code contained within the process definition
80
+ # or within the workitem
81
+ #
82
+ class RevalExpression < FlowExpression
83
+
84
+ def apply (workitem)
85
+
86
+ escape = lookup_boolean_attribute('escape', workitem, false)
87
+
88
+ code = OpenWFE::lookup_vf_attribute(self, workitem, 'code')
89
+
90
+ code = OpenWFE::fetch_text_content(self, workitem, escape) \
91
+ if not code
92
+
93
+ result = eval(code.to_s)
94
+
95
+ OpenWFE::set_result(workitem, result) if result != nil
96
+
97
+ reply_to_parent(workitem)
98
+ end
99
+ end
100
+
101
+ end
102
+
@@ -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,34 +39,45 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- #require 'workitem'
43
- require 'ru/rudefinitions'
44
- require 'ru/fe_utils'
42
+ require 'openwfe/rudefinitions'
43
+ require 'openwfe/expressions/fe_utils'
45
44
 
46
45
 
47
46
  #
48
47
  # The participant expression, in its own file
49
48
  #
50
49
 
51
- module OpenWFEru
50
+ module OpenWFE
52
51
 
52
+ #
53
+ # Participants sit at the edge between the engine and the external
54
+ # world. The participant expression transmit the workitem applied
55
+ # to it to the Participant instance it looks up in the participant map
56
+ # tied to the engine.
57
+ #
53
58
  class ParticipantExpression < FlowExpression
54
59
 
55
- #attr_accessor \
56
- # :applied_workitem
60
+ attr_accessor \
61
+ :participant_name,
62
+ :applied_workitem
57
63
 
58
64
  #
59
65
  # apply / reply
60
66
 
61
67
  def apply (workitem)
62
68
 
63
- #@applied_workitem = workitem
69
+ @applied_workitem = workitem
70
+ #puts "apply() \n#{@applied_workitem}"
71
+ #ldebug { "apply() \n#{@applied_workitem}" }
64
72
 
65
- participant_name = \
66
- OpenWFEru::lookup_vf_attribute(self, workitem, 'ref')
73
+ @participant_name = OpenWFE::lookup_ref(self, workitem)
67
74
 
68
- @application_context[S_PARTICIPANT_MAP]\
69
- .dispatch(participant_name, workitem)
75
+ @participant_name = OpenWFE::fetch_text_content(self, workitem) \
76
+ unless @participant_name
77
+
78
+ store_itself()
79
+
80
+ get_participant_map.dispatch(participant_name, workitem)
70
81
  end
71
82
 
72
83
  #def reply (workitem)
@@ -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,29 +39,31 @@
39
39
  # John Mettraux at openwfe.org
40
40
  #
41
41
 
42
- require 'rexml/document'
42
+ #require 'rexml/document'
43
43
 
44
- require 'otime'
45
- require 'workitem'
46
- require 'ru/engine'
47
- require 'ru/rudefinitions'
48
- require 'ru/flowexpression'
49
- require 'ru/fe_base'
44
+ require 'openwfe/rudefinitions'
45
+ require 'openwfe/expressions/flowexpression'
50
46
 
51
47
 
52
- module OpenWFEru
48
+ module OpenWFE
53
49
 
50
+ #
51
+ # An 'abstract' class storing bits (trees) of process definitions just
52
+ # parsed. Upon application (apply()) these raw expressions get turned
53
+ # into real expressions.
54
+ # The first and classical extension of this class is XmlRawExpression.
55
+ #
54
56
  class RawExpression < FlowExpression
55
57
 
56
- attr_accessor \
57
- :xml_element
58
+ #attr_accessor \
59
+ # :raw_representation
58
60
 
59
61
  def initialize \
60
- (fei, parent_id, environment_id, application_context, xml_element)
62
+ (fei, parent_id, env_id, application_context, raw_representation)
61
63
 
62
- super(fei, parent_id, environment_id, application_context, nil)
64
+ super(fei, parent_id, env_id, application_context, nil)
63
65
 
64
- @xml_element = xml_element
66
+ @raw_representation = raw_representation
65
67
 
66
68
  new_environment() if not @environment_id
67
69
  end
@@ -74,6 +76,8 @@ module OpenWFEru
74
76
 
75
77
  raise "unknown expression '#{expression_name}'" if not eclass
76
78
 
79
+ ldebug { "instantiate_real_expression() eclass is #{eclass}" }
80
+
77
81
  expression = eclass.new(
78
82
  @fei,
79
83
  @parent_id,
@@ -101,89 +105,49 @@ module OpenWFEru
101
105
  end
102
106
 
103
107
  #def reply (workitem)
108
+ # no implementation necessary
104
109
  #end
105
110
 
106
- def is_expression? ()
107
- return false if not @xml_element.kind_of?(REXML::XMLElement)
108
- return expression_class() != nil
109
- end
110
-
111
111
  def is_definition? ()
112
112
  return get_expression_map.is_definition?(expression_name())
113
113
  end
114
114
 
115
- def expression_name ()
116
- return @xml_element.name
117
- end
118
-
119
115
  def expression_class ()
120
116
  return get_expression_map().get_class(expression_name())
121
117
  end
122
-
118
+
123
119
  def definition_name ()
124
- return @xml_element.attributes['name'].to_s
120
+ return raw_representation.attributes['name'].to_s
125
121
  end
126
122
 
123
+ def expression_name ()
124
+ return raw_representation.name
125
+ end
126
+
127
127
  protected
128
128
 
129
129
  def launch_template (template, workitem)
130
130
 
131
- attributes = extract_attributes()
131
+ @attributes = extract_attributes()
132
+
133
+ #require 'pp'
134
+ #pp attributes
135
+ #pp lookup_attributes(workitem, attributes)
132
136
 
133
- get_expression_pool().launch_template(\
137
+ get_expression_pool().launch_template(
134
138
  self,
135
139
  template,
136
140
  workitem,
137
- lookup_attributes(attributes, workitem))
141
+ lookup_attributes(workitem))
138
142
  end
139
143
 
140
- def extract_attributes ()
141
- result = {}
142
- @xml_element.attributes.each_attribute do |a|
143
- result[a.name] = a.value
144
- end
145
- return result
146
- end
147
-
148
- def extract_children ()
149
-
150
- c = []
151
- i = 0
152
-
153
- @xml_element.each_child do |elt|
154
-
155
- if elt.kind_of?(REXML::Element)
156
-
157
- cfei = @fei.dup
158
- pfei = @fei
159
-
160
- efei = @environment_id
161
-
162
- cfei.expressionName = elt.name
163
- cfei.expressionId = "#{cfei.expressionId}.#{i}"
164
-
165
- rawchild = RawExpression\
166
- .new(cfei, pfei, efei, @application_context, elt)
167
-
168
- get_expression_pool().update(rawchild)
169
- c << rawchild.fei
170
-
171
- i = i+1
172
-
173
- elsif elt.kind_of?(REXML::Comment)
174
-
175
- next
176
-
177
- else
178
-
179
- s = elt.to_s.strip
180
- c << s if s.length > 0
181
-
182
- end
183
- end
184
-
185
- return c
186
- end
144
+ #def extract_attributes ()
145
+ # raise "abstract method : not implemented here"
146
+ #end
147
+ #def extract_children ()
148
+ # raise "abstract method : not implemented here"
149
+ #end
187
150
  end
151
+
188
152
  end
189
153