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:
prepared launch tool
jmettraux (author)
Thu Apr 24 18:02:27 -0700 2008
commit  b30ab65884cdafb3a3177bcae8721a1c78534532
tree    19b3e01d1e09a30404dbd3eae61479f901099d7f
parent  ea0426390613715412f5528e32ed360a391d5532
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
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
97
98
99
0
@@ -1 +1,100 @@
0
+
0
+$:.unshift "~/ruote/lib"
0
+
0
+require 'rubygems'
0
+
0
+require 'optparse'
0
+
0
+require 'json'
0
+
0
+require 'openwfe/workitem'
0
+require 'openwfe/util/xml'
0
+
0
+
0
+#
0
+# OPTIONS
0
+
0
+json = false
0
+url = nil
0
+launch = false
0
+
0
+
0
+opts = OptionParser.new
0
+
0
+opts.banner = "Usage: ruby #{$0} [options]"
0
+opts.separator("")
0
+opts.separator("options:")
0
+
0
+opts.on(
0
+ "-j", "--json",
0
+ "outputs the launchitem in JSON (default is XML)") do
0
+
0
+ json = true
0
+end
0
+
0
+opts.on(
0
+ "-x", "--xml",
0
+ "outputs the launchitem in XML (already the default)") do
0
+
0
+ json = false
0
+end
0
+
0
+opts.on(
0
+ "-u", "--url {url}",
0
+ "points to the URL of a process defintion") do |u|
0
+
0
+ url = u
0
+end
0
+
0
+opts.on(
0
+ "-l", "--launch",
0
+ "generates the launchitem and use it to launch a process locally") do
0
+
0
+ launch = true
0
+end
0
+
0
+# help
0
+
0
+opts.on("-h", "--help", "display this help content") do
0
+ puts
0
+ puts opts.to_s()
0
+ puts
0
+ exit 0
0
+end
0
+
0
+opts_rest = opts.parse(ARGV)
0
+
0
+
0
+#
0
+# MAIN
0
+
0
+li = OpenWFE::LaunchItem.new
0
+li.workflow_definition_url = url
0
+li.attributes.merge!({
0
+ 'my_field' => 'my_value',
0
+ 'my_other_field' => 1234567,
0
+ 'yet_another?' => true
0
+})
0
+
0
+sli = if json
0
+ li.to_h.to_json
0
+else
0
+ OpenWFE::Xml.launchitem_to_xml li, 2
0
+end
0
+
0
+unless launch
0
+ puts sli
0
+ exit 0
0
+end
0
+
0
+# launch
0
+
0
+require 'rufus/verbs'
0
+
0
+res = Rufus::Verbs::post "http://localhost:4567/processes" do |request|
0
+ request['Content-Type'] = json ? 'application/json' : 'application/xml'
0
+ sli
0
+end
0
+
0
+puts res.body
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,61 +1 @@
0
-
0
-$:.unshift "~/ruote/lib"
0
-
0
-require 'rubygems'
0
-
0
-require 'optparse'
0
-
0
-require 'json'
0
-
0
-require 'openwfe/workitem'
0
-require 'openwfe/util/xml'
0
-
0
-
0
-#
0
-# OPTIONS
0
-
0
-json = false
0
-url = nil
0
-
0
-
0
-opts = OptionParser.new
0
-
0
-opts.banner = "Usage: ruby tools/print_launchitem.rb [options]"
0
-opts.separator("")
0
-opts.separator("options:")
0
-
0
-opts.on("-j", "--json", "outputs the launchitem in JSON (default is XML)") do
0
- json = true
0
-end
0
-
0
-opts.on("-x", "--xml", "outputs the launchitem in XML (already the default)") do
0
- json = false
0
-end
0
-
0
-opts.on("-u", "--url {url}", "points to the URL of a process defintion") do |u|
0
- url = u
0
-end
0
-
0
-opts.on("-h", "--help", "display this help content") do
0
- puts
0
- puts opts.to_s()
0
- puts
0
- exit 0
0
-end
0
-
0
-opts_rest = opts.parse(ARGV)
0
-
0
-
0
-#
0
-# MAIN
0
-
0
-li = OpenWFE::LaunchItem.new
0
-li.workflow_definition_url = url
0
-li.attributes["my_key"] = "my_value"
0
-
0
-if json
0
- puts li.to_h.to_json
0
-else
0
- puts OpenWFE::Xml.launchitem_to_xml(li, 2)
0
-end

Comments

    No one has commented yet.