public
Description: RESTful workflow / bpm engine based on Sinatra and OpenWFEru
Homepage: http://openwferu.rubyforge.org
Clone URL: git://github.com/jmettraux/ruote-rest.git
Search Repo:
switched to vanilla Sinatra (gem 0.2.2)
jmettraux (author)
Thu Apr 17 01:12:53 -0700 2008
commit  a597e301f39341c68bf611225cf9c0973e229e10
tree    298d400316bf17d412bc6cde3dd407f346eb4a80
parent  398f334b66ac3a35b7e99106cc0b2dae9f7e8ea3
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+
0
+= ruote-rest CHANGELOG.txt
0
+
0
+== ruote-rest - 0.9.18 not yet released
...
12
13
14
15
 
16
17
 
18
19
20
...
12
13
14
 
15
16
 
17
18
19
20
0
@@ -12,9 +12,9 @@
0
     git clone git://github.com/jmettraux/ruote-rest.git
0
 
0
 
0
-To get Sinatra :
0
+== dependencies
0
 
0
- git clone git://github.com/jmettraux/sinatra.git
0
+ [sudo] gem install -y sinatra
0
 
0
 
0
 == interface
...
4
5
6
7
8
 
 
9
10
11
...
4
5
6
 
 
7
8
9
10
11
0
@@ -4,8 +4,8 @@
0
 $:.unshift "#{dir}/../lib"
0
 $:.unshift "#{dir}/../conf"
0
 
0
-#require 'rubygems'
0
-$:.unshift "~/sinatra/lib"
0
+require 'rubygems'
0
+#$:.unshift "~/sinatra/lib"
0
 $:.unshift "~/ruote/lib"
0
 
0
 load 'ruote_rest.rb'
...
47
48
49
 
50
 
51
52
 
 
53
54
 
 
55
56
57
58
59
...
59
60
61
 
62
 
63
64
65
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
68
69
70
71
72
73
...
81
82
83
84
85
86
87
 
 
88
 
 
 
 
 
 
 
 
 
 
89
90
91
92
93
 
94
95
 
 
 
 
 
 
 
 
 
96
 
97
98
99
...
47
48
49
50
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
104
105
106
 
 
 
 
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 
 
 
122
123
 
124
125
126
127
128
129
130
131
132
133
134
135
136
137
0
@@ -47,11 +47,16 @@
0
 def render_expressions_xml (es)
0
 
0
     builder do |xml|
0
+
0
         xml.instruct!
0
+
0
         xml.expressions :count => es.size do
0
- es.each do |fexp|
0
+
0
+ es.sort_by { |e| e.fei.expid }.each do |fexp|
0
                 _render_expression_xml xml, fexp
0
             end
0
+
0
+ xml.process_representation es.representation.to_json
0
         end
0
     end
0
 end
0
0
0
@@ -59,11 +64,29 @@
0
 def render_expression_xml (e)
0
 
0
     builder do |xml|
0
+
0
         xml.instruct!
0
+
0
         _render_expression_xml xml, e, true
0
     end
0
 end
0
 
0
+def _expression_link (xml, tagname, fei, env=false)
0
+
0
+ return unless fei
0
+
0
+ expid = fei.expid
0
+ expid += "e" if env
0
+
0
+ xml.tag!(
0
+ tagname,
0
+ fei.to_s,
0
+ :link => request.link(
0
+ :expressions,
0
+ fei.wfid,
0
+ swapdots(expid)))
0
+end
0
+
0
 def _render_expression_xml (xml, e, detailed=false)
0
 
0
     params = {}
0
0
0
0
0
@@ -81,19 +104,34 @@
0
 
0
             OpenWFE::Xml._fei_to_xml(xml, e.fei)
0
 
0
- xml.parent(
0
- e.parent_id.to_s,
0
- :link => request.link(
0
- :expressions, e.parent_id.wfid, swapdots(e.parent_id.expid)))
0
+ #
0
+ # parent id
0
 
0
+ _expression_link(xml, 'parent', e.parent_id)
0
+
0
+ #
0
+ # environment id
0
+
0
+ _expression_link(xml, 'environment', e.environment_id)
0
+
0
+ #
0
+ # children
0
+
0
             xml.children do
0
                 e.children.each do |c|
0
- xml.child(
0
- c.to_s, :link => request.link(
0
- :expressions, c.wfid, swapdots(c.expid)))
0
+ _expression_link(xml, 'child', c)
0
                 end
0
- end
0
+ end if e.children
0
+
0
+ #
0
+ # process/expression representations
0
+
0
+ xml.raw_representation(e.raw_representation.to_json) \
0
+ if e.raw_representation
0
+ xml.raw_rep_updated(e.raw_rep_updated.to_json) \
0
+ if e.raw_rep_updated
0
         else
0
+
0
             xml.fei e.fei.to_s
0
         end
0
     end
...
81
82
83
84
85
86
87
88
...
111
112
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
115
116
...
81
82
83
 
 
84
85
86
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
0
@@ -81,8 +81,6 @@
0
 
0
         xml.branches p.branches
0
 
0
- xml.errors :count => p.errors.size
0
-
0
         if detailed
0
 
0
             xml.variables do
0
@@ -111,6 +109,20 @@
0
                             :expressions, fei.wfid, swapdots(fei.expid)))
0
                 end
0
             end
0
+
0
+ xml.errors :count => p.errors.size do
0
+ p.errors.each do |k, v|
0
+ xml.error do
0
+ #xml.stacktrace do
0
+ # xml.cdata! "\n#{v.stacktrace}\n"
0
+ #end
0
+ xml.fei v.fei.to_s
0
+ xml.message v.stacktrace.split("\n")[0]
0
+ end
0
+ end
0
+ end
0
+ else
0
+ xml.errors :count => p.errors.size
0
         end
0
     end
0
 end
...
45
46
47
48
49
50
51
52
53
54
...
55
56
57
 
58
 
 
 
 
 
59
60
 
 
 
 
61
62
63
...
45
46
47
 
 
48
49
50
51
52
...
53
54
55
56
57
58
59
60
61
62
63
 
64
65
66
67
68
69
70
0
@@ -45,8 +45,6 @@
0
 
0
     throw :halt, [ 404, "no process #{wfid}" ] unless es
0
 
0
- es = es.sort_by { |e| e.fei.expid }
0
-
0
     header 'Content-Type' => 'application/xml'
0
     render_expressions_xml es
0
 end
0
0
0
@@ -55,9 +53,18 @@
0
 
0
     wfid = params[:wfid]
0
     expid = swapdots params[:expid]
0
+ env = false
0
 
0
+ if expid[-1, 1] == "e"
0
+ expid = expid[0..-2]
0
+ env = true
0
+ end
0
+
0
     es = $engine.process_stack wfid, true
0
- e = es.find { |e| e.fei.expid == expid }
0
+
0
+ e = es.find do |e|
0
+ (e.fei.expid == expid) and (env or ( ! e.is_a?(OpenWFE::Environment)))
0
+ end
0
 
0
     throw :halt, [ 404, "no expression #{expid} in process #{wfid}" ] unless e
0
 
...
53
54
55
56
 
57
58
59
...
53
54
55
 
56
57
58
59
0
@@ -53,7 +53,7 @@
0
 #
0
 post "/processes" do
0
 
0
- xml = request.env["rack.request.form_vars"]
0
+ xml = request.env["rack.input"].read
0
 
0
     li = OpenWFE::Xml.launchitem_from_xml xml
0
 
...
7
8
9
 
 
10
 
 
11
12
13
14
...
48
49
50
 
 
 
 
 
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
54
55
...
7
8
9
10
11
12
13
14
15
16
17
18
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
0
@@ -7,7 +7,11 @@
0
 # Mon Apr 14 15:45:00 JST 2008
0
 #
0
 
0
+
0
+
0
 #require 'test/unit'
0
+
0
+require 'rubygems'
0
 require 'sinatra'
0
 require 'sinatra/test/unit'
0
 
0
0
@@ -48,9 +52,27 @@
0
         assert_not_nil @response.body.index(' count="5"')
0
 
0
         get_it "/expressions/#{fei.wfid}/0_0"
0
+
0
+ assert_not_nil @response.body.index(
0
+ '<class>OpenWFE::SequenceExpression</class>')
0
+
0
+ get_it "/expressions/#{fei.wfid}/0e"
0
         puts
0
         puts @response.body
0
         puts
0
+
0
+ assert_not_nil @response.body.index(
0
+ '<class>OpenWFE::Environment</class>')
0
+
0
+ #
0
+ # cancel process
0
+
0
+ delete_it "/processes/#{fei.wfid}"
0
+ assert_equal 204, @response.status
0
+
0
+ sleep 0.350
0
+
0
+ # done.
0
     end
0
 end
...
43
44
45
 
 
 
 
 
46
47
48
49
 
50
51
52
53
...
62
63
64
 
65
 
66
67
68
...
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
57
58
...
67
68
69
70
71
72
73
74
75
0
@@ -43,10 +43,15 @@
0
                 end
0
             end
0
         EOS
0
+ #li.attributes.merge!(
0
+ # "customer" => "toto", "amount" => 5, "discount" => false )
0
+ #puts
0
+ #puts OpenWFE::Xml.launchitem_to_xml(li, 2)
0
+ #puts
0
 
0
         post_it(
0
             "/processes",
0
- OpenWFE::Xml.launchitem_to_xml(li),
0
+ OpenWFE::Xml.launchitem_to_xml(li, 2),
0
             { "CONTENT_TYPE" => "application/xml" })
0
 
0
         fei = OpenWFE::Xml.fei_from_xml @response.body
0
0
@@ -62,7 +67,9 @@
0
         assert_not_nil @response.body.index(fei.wfid)
0
 
0
         get_it "/processes/#{fei.wfid}"
0
+ #puts
0
         #puts @response.body
0
+ #puts
0
 
0
         assert_not_nil @response.body.index("<wfid>#{fei.wfid}</wfid>")
0
 

Comments

    No one has commented yet.