bpm_manager 0.3.5 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 841a0935ace1f14235c9dc2fa14bdca27e1f543e
4
- data.tar.gz: aa0675ebf62250bf9543908a0d80481815b20954
3
+ metadata.gz: 7e0c32b3f8f35c797fc808423a6ef8484ab43c00
4
+ data.tar.gz: 108c7f471962705828b55b5a1807ee4fe4bebddb
5
5
  SHA512:
6
- metadata.gz: 77d7b4f65eda3aaaac843c84baecfba17642ea2edcf3c71ae9de0fbb2d238e1fbe483c1c85b644dbd024451d36dbb4a2f991d4aa23200df76d2066bec7c7f54e
7
- data.tar.gz: 9b93335ee1160f34f271c6bb63b83fefe2aadc2bbacab9274d50448daa8ae5004cce1d9a75432bbab66f312d8de351537813f0a9877ccbc55262a42d0562cf3e
6
+ metadata.gz: 97969c19554e9fd7878f7d8ff4377105a89026a1825b3a148e2b3390d4528dcf734bdafc910843bf52ec216186797f8adc211bdc3e56c492b82d153d655aac2d
7
+ data.tar.gz: 9838036cb7e10a8ae882eee0d402a2c37e06bb08082a886c7cb977b647dd37d8d10c74c7eedf2864beb4781ce6b2087e29ba03b7df6e34c9484cd0a6876d8c45
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # BeatCoding BPM Manager Gem
2
- BPM Manager Gem for RedHat jBPM & Oracle BPM engines
2
+ BPM Manager Gem for Red Hat jBPM & Oracle BPM engines
3
3
 
4
4
  Feel free to fork, contribute & distribute
5
5
 
@@ -29,8 +29,7 @@ First configure properly the gem using the bpm_manager.rb file in 'config/initia
29
29
 
30
30
  ```ruby
31
31
  BpmManager.configure do |config|
32
- config.bpm_vendor => 'RedHat' # or 'Oracle'
33
- config.bpm_url => 'bpm.company.com' # without http:// or https://
32
+ config.bpm_url => 'bpm.server.com' # without http:// or https://
34
33
  config.bpm_url_suffix => '/business-central/rest' # could be also /jbpm-console/rest
35
34
  config.bpm_username => 'scott' # your server username
36
35
  config.bpm_passowrd => 'tiger' # your password
@@ -41,29 +40,32 @@ end
41
40
  Then make an API call like this:
42
41
 
43
42
  ```ruby
44
- result = BpmManager.deployments()
43
+ result = BpmManager::RedHat.deployments()
45
44
  ```
46
45
 
47
- ## Quick Examples
48
-
46
+ ## Quick Examples for Red Hat
49
47
 
50
48
  ```ruby
51
49
  # Get all the Deployments
52
- BpmManager.deployments
50
+ BpmManager::RedHat.deployments
53
51
 
54
52
  # Get all the Tasks for an User ID
55
- BpmManager.tasks('foo@bar.com')
53
+ BpmManager::RedHat.tasks('foo@bar.com')
56
54
 
57
55
  # Get all the Tasks with options (RedHat example). It supports all REST API options.
58
- BpmManager.tasks({:ownerId => 'foo@bar.com', :processInstanceId => 3})
56
+ BpmManager::RedHat.tasks({:ownerId => 'foo@bar.com', :processInstanceId => 3})
59
57
 
60
58
  # Get all the Process Instances
61
- BpmManager.process_instances
59
+ BpmManager::RedHat.process_instances
62
60
 
63
61
  # Get the Process Instance with ID = 3
64
- BpmManager.process_instance(3)
62
+ BpmManager::RedHat.process_instance(3)
65
63
  ```
66
64
 
65
+ ## Note
66
+
67
+ Tasks and Process structures includes a :data method in which returns the JSON raw data from server
68
+
67
69
  ## Contributing
68
70
 
69
71
  1. Fork it ( https://github.com/BeatCoding/bpm_manager/fork )
@@ -0,0 +1,89 @@
1
+ require "rest-client"
2
+ require "json"
3
+ require "ostruct"
4
+
5
+ module BpmManager
6
+ module RedHat
7
+ # Gets all server deployments
8
+ def self.deployments()
9
+ return JSON.parse(RestClient.get(BpmManager.uri('/deployment'), :accept => :json))
10
+ end
11
+
12
+ # Gets all tasks, optionally you could specify an user id
13
+ def self.tasks(user_id = "")
14
+ self.structure_task_data(JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (user_id.empty? ? '' : '?taskOwner=' + user_id)), :accept => :json)))
15
+ end
16
+
17
+ # Gets all tasks with options
18
+ def self.tasks_with_opts(opts = {})
19
+ self.structure_task_data(JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (opts.empty? ? '' : '?' + opts.map{|k,v| k.to_s + '=' + v.to_s}.join('&'))), :accept => :json)))
20
+ end
21
+
22
+ # Gets all Process Instances
23
+ def self.process_instances
24
+ JSON.parse(RestClient.get(BpmManager.uri('/history/instances'), :accept => :json))
25
+ end
26
+
27
+ # Gets a Process Instance
28
+ def self.process_instance(process_instance_id)
29
+ JSON.parse(RestClient.get(BpmManager.uri('/history/instance/' + process_instance_id.to_s), :accept => :json))
30
+ end
31
+
32
+ # Gets a Process Instance Variables
33
+ def self.process_instance_variables(deployment_id, process_instance_id)
34
+ JSON.parse(RestClient.get(BpmManager.uri('/runtime/' + deployment_id.to_s + '/withvars/process/instance/' + process_instance_id.to_s), :accept => :json))['variables']
35
+ end
36
+
37
+ # Assigns a Task for an User
38
+ def self.assign_task(task_id, user_id)
39
+ RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/delegate?targetEntityId=' + user_id.to_s)), :headers => {:content_type => :json, :accept => :json})
40
+ end
41
+
42
+ # Releases a Task
43
+ def self.release_task(task_id)
44
+ RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/release')), :headers => {:content_type => :json, :accept => :json})
45
+ end
46
+
47
+ # Completes a Task
48
+ def self.complete_task(task_id)
49
+ RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/complete')), :headers => {:content_type => :json, :accept => :json})
50
+ end
51
+
52
+ private
53
+ def self.structure_task_data(input)
54
+ tasks = []
55
+
56
+ unless input['taskSummaryList'].nil?
57
+ input['taskSummaryList'].each do |task|
58
+ my_task = OpenStruct.new
59
+ my_task.process = OpenStruct.new
60
+
61
+ my_task.id = task['task-summary']['status']
62
+ my_task.process_instance_id = task['task-summary']['process-instance-id']
63
+ my_task.parent_id = task['task-summary']['parent_id']
64
+ my_task.created_on = Time.at(task['task-summary']['created-on']/1000)
65
+ my_task.active_on = Time.at(task['task-summary']['activation-time']/1000)
66
+ my_task.name = task['task-summary']['name']
67
+ my_task.owner = task['task-summary']['actual-owner']
68
+ my_task.status = task['task-summary']['status']
69
+ my_task.subject = task['task-summary']['subject']
70
+ my_task.description = task['task-summary']['description']
71
+ my_task.data = task['task-summary']
72
+ my_task.process.data = self.process_instance(task['task-summary']['process-instance-id'])
73
+ my_task.process.deployment_id = task['task-summary']['deployment-id']
74
+ my_task.process.id = my_task.process.data['process-id']
75
+ my_task.process.instance_id = my_task.process.data['process-instance-id']
76
+ my_task.process.start_on = Time.at(my_task.process.data['start']/1000)
77
+ my_task.process.name = my_task.process.data['process-name']
78
+ my_task.process.version = my_task.process.data['process-version']
79
+ my_task.process.creator = my_task.process.data['identity']
80
+ my_task.process.variables = self.process_instance_variables(my_task.process.deployment_id, my_task.process.instance_id)
81
+
82
+ tasks << my_task
83
+ end
84
+ end
85
+
86
+ return tasks
87
+ end
88
+ end
89
+ end
@@ -1,3 +1,3 @@
1
1
  module BpmManager
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/bpm_manager.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "bpm_manager/version"
2
- require "rest-client"
3
- require "json"
2
+ require "bpm_manager/red_hat"
4
3
 
5
4
  module BpmManager
6
5
  class << self
@@ -36,49 +35,4 @@ module BpmManager
36
35
  ''
37
36
  end
38
37
  end
39
-
40
- # Gets all server deployments
41
- def self.deployments()
42
- return JSON.parse(RestClient.get(BpmManager.uri('/deployment'), :accept => :json))
43
- end
44
-
45
- # Gets all tasks, optionally you could specify an user id
46
- def self.tasks(user_id = "")
47
- return JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (user_id.empty? ? '' : '?taskOwner=' + user_id)), :accept => :json))
48
- end
49
-
50
- # Gets all tasks with options
51
- def self.tasks_with_opts(opts = {})
52
- return JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (opts.empty? ? '' : '?' + opts.map{|k,v| k.to_s + '=' + v.to_s}.join('&'))), :accept => :json))
53
- end
54
-
55
- # Gets all Process Instances
56
- def self.process_instances
57
- return JSON.parse(RestClient.get(BpmManager.uri('/history/instances'), :accept => :json))
58
- end
59
-
60
- # Gets a Process Instance
61
- def self.process_instance(process_instance_id)
62
- return JSON.parse(RestClient.get(BpmManager.uri('/history/instance/' + process_instance_id.to_s), :accept => :json))
63
- end
64
-
65
- # Gets a Process Instance Variables
66
- def self.process_instance_variables(deployment_id, process_instance_id)
67
- return JSON.parse(RestClient.get(BpmManager.uri('/runtime/' + deployment_id.to_s + '/withvars/process/instance/' + process_instance_id.to_s), :accept => :json))['variables']
68
- end
69
-
70
- # Assigns a Task for an User
71
- def self.assign_task(task_id, user_id)
72
- RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/delegate?targetEntityId=' + user_id.to_s)), :headers => {:content_type => :json, :accept => :json})
73
- end
74
-
75
- # Releases a Task
76
- def self.release_task(task_id)
77
- RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/release')), :headers => {:content_type => :json, :accept => :json})
78
- end
79
-
80
- # Completes a Task
81
- def self.complete_task(task_id)
82
- RestClient.post(URI.encode(BpmManager.uri('/task/' + task_id.to_s + '/complete')), :headers => {:content_type => :json, :accept => :json})
83
- end
84
38
  end
@@ -1,9 +1,6 @@
1
1
  BpmManager.configure do |config|
2
- # Sets the BPM engine vendor: [RedHat|Oracle]
3
- config.bpm_vendor = "RedHat"
4
-
5
2
  # Sets the BPM URL or IP address without the http:// or https://
6
- config.bpm_url = "bpm.company.com"
3
+ config.bpm_url = "bpm.server.com"
7
4
 
8
5
  # Sets the URL suffix like: '/business-central/rest' or '/jbpm-console/rest'
9
6
  config.bpm_url_suffix = "/jbpm-console/rest"
@@ -0,0 +1,175 @@
1
+ require 'spec_helper'
2
+
3
+ describe BpmManager do
4
+ before :all do
5
+ BpmManager.configure do |config|
6
+ config.bpm_url = "bpm.server.com"
7
+ config.bpm_url_suffix = "/jbpm-console/rest"
8
+ config.bpm_username = "scott"
9
+ config.bpm_password = "tiger"
10
+ config.bpm_use_ssl = false
11
+ end
12
+ end
13
+
14
+ describe "#uri" do
15
+ before :each do
16
+ @uri = BpmManager.uri('/test')
17
+ end
18
+
19
+ it "expect to be a String" do
20
+ expect(@uri).to be_an_instance_of String
21
+ end
22
+
23
+ it "expect to not be nil" do
24
+ expect(@uri).not_to eq(nil)
25
+ end
26
+ end
27
+
28
+ describe "#configuration" do
29
+ before :each do
30
+ @config = BpmManager.configuration
31
+ end
32
+
33
+ it "should be a class of type Configuration" do
34
+ expect(@config).to be_an_instance_of BpmManager::Configuration
35
+ end
36
+
37
+ it 'must have all the accesors' do
38
+ expect(@config.methods.include? :bpm_vendor).to be true
39
+ expect(@config.methods.include? :bpm_url).to be true
40
+ expect(@config.methods.include? :bpm_username).to be true
41
+ expect(@config.methods.include? :bpm_password).to be true
42
+ expect(@config.methods.include? :bpm_use_ssl).to be true
43
+ end
44
+ end
45
+
46
+ describe "RedHat" do
47
+ describe "#deployments" do
48
+ before :each do
49
+ @deployments = BpmManager::RedHat.deployments
50
+ end
51
+
52
+ it "must return something" do
53
+ expect(@deployments.length).to be > 0
54
+ end
55
+ end
56
+
57
+ describe "#tasks" do
58
+ before :each do
59
+ @tasks = BpmManager::RedHat.tasks('foo@bar.com')
60
+ end
61
+
62
+ it "task should include the all attributes" do
63
+ expect(@tasks.first.methods).to include(:id)
64
+ expect(@tasks.first.methods).to include(:process_instance_id)
65
+ expect(@tasks.first.methods).to include(:parent_id)
66
+ expect(@tasks.first.methods).to include(:created_on)
67
+ expect(@tasks.first.methods).to include(:active_on)
68
+ expect(@tasks.first.methods).to include(:name)
69
+ expect(@tasks.first.methods).to include(:owner)
70
+ expect(@tasks.first.methods).to include(:status)
71
+ expect(@tasks.first.methods).to include(:subject)
72
+ expect(@tasks.first.methods).to include(:description)
73
+ expect(@tasks.first.methods).to include(:data)
74
+
75
+ expect(@tasks.first.process.methods).to include(:id)
76
+ expect(@tasks.first.process.methods).to include(:deployment_id)
77
+ expect(@tasks.first.process.methods).to include(:instance_id)
78
+ expect(@tasks.first.process.methods).to include(:start_on)
79
+ expect(@tasks.first.process.methods).to include(:name)
80
+ expect(@tasks.first.process.methods).to include(:version)
81
+ expect(@tasks.first.process.methods).to include(:creator)
82
+ expect(@tasks.first.process.methods).to include(:data)
83
+ end
84
+ end
85
+
86
+ describe "#tasks_with_opts" do
87
+ before :each do
88
+ @tasks = BpmManager::RedHat.tasks_with_opts(:processInstanceId => 1)
89
+ end
90
+
91
+ it "task should include the all attributes" do
92
+ expect(@tasks.first.methods).to include(:id)
93
+ expect(@tasks.first.methods).to include(:process_instance_id)
94
+ expect(@tasks.first.methods).to include(:parent_id)
95
+ expect(@tasks.first.methods).to include(:created_on)
96
+ expect(@tasks.first.methods).to include(:active_on)
97
+ expect(@tasks.first.methods).to include(:name)
98
+ expect(@tasks.first.methods).to include(:owner)
99
+ expect(@tasks.first.methods).to include(:status)
100
+ expect(@tasks.first.methods).to include(:subject)
101
+ expect(@tasks.first.methods).to include(:description)
102
+ expect(@tasks.first.methods).to include(:data)
103
+
104
+ expect(@tasks.first.process.methods).to include(:id)
105
+ expect(@tasks.first.process.methods).to include(:deployment_id)
106
+ expect(@tasks.first.process.methods).to include(:instance_id)
107
+ expect(@tasks.first.process.methods).to include(:start_on)
108
+ expect(@tasks.first.process.methods).to include(:name)
109
+ expect(@tasks.first.process.methods).to include(:version)
110
+ expect(@tasks.first.process.methods).to include(:creator)
111
+ expect(@tasks.first.process.methods).to include(:data)
112
+ end
113
+ end
114
+
115
+ describe "#process_instances" do
116
+ before :each do
117
+ @processes = BpmManager::RedHat.process_instances
118
+ end
119
+
120
+ it "must return something" do
121
+ expect(@processes.length).to be > 0
122
+ end
123
+ end
124
+
125
+ describe "#process_instance" do
126
+ before :each do
127
+ @process = BpmManager::RedHat.process_instance(1)
128
+ end
129
+
130
+ it "must return something" do
131
+ expect(@process.length).to be > 0
132
+ end
133
+ end
134
+
135
+ describe "#process_instance_variables" do
136
+ before :each do
137
+ @variables = BpmManager::RedHat.process_instance_variables('com.beatcoding.simpletask:SimpleTask:1.0',1)
138
+ end
139
+
140
+ it "must return something" do
141
+ expect(@variables.length).to be > 0
142
+ end
143
+ end
144
+
145
+ describe "#assign_task" do
146
+ before :each do
147
+ @result = BpmManager::RedHat.assign_task(1,'foo@bar.com')
148
+ end
149
+
150
+ it "must return something" do
151
+ expect(@result.length).to be > 0
152
+ end
153
+ end
154
+
155
+ describe "#release_task" do
156
+ before :each do
157
+ @result = BpmManager::RedHat.release_task(1)
158
+ end
159
+
160
+ it "must return something" do
161
+ expect(@result.length).to be > 0
162
+ end
163
+ end
164
+
165
+ # describe "#complete_task" do
166
+ # before :each do
167
+ # @result = BpmManager::RedHat.complete_task(1)
168
+ # end
169
+
170
+ # it "must return something" do
171
+ # expect(@result.length).to be > 0
172
+ # end
173
+ # end
174
+ end
175
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bpm_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Presa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -81,10 +81,11 @@ files:
81
81
  - Rakefile
82
82
  - bpm_manager.gemspec
83
83
  - lib/bpm_manager.rb
84
+ - lib/bpm_manager/red_hat.rb
84
85
  - lib/bpm_manager/version.rb
85
86
  - lib/generators/bpm_manager/bpm_manager.rb
86
87
  - lib/generators/bpm_manager/install_generator.rb
87
- - spec/module_spec.rb
88
+ - spec/red_hat_spec.rb
88
89
  - spec/spec_helper.rb
89
90
  homepage: http://www.beatcoding.com
90
91
  licenses:
@@ -111,5 +112,5 @@ signing_key:
111
112
  specification_version: 4
112
113
  summary: BPM Manager Gem for RedHat jBPM & Oracle BPM engines.
113
114
  test_files:
114
- - spec/module_spec.rb
115
+ - spec/red_hat_spec.rb
115
116
  - spec/spec_helper.rb
data/spec/module_spec.rb DELETED
@@ -1,135 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "BpmManager" do
4
- before :all do
5
- BpmManager.configure do |config|
6
- config.bpm_vendor = "RedHat"
7
- config.bpm_url = "bpm.company.com"
8
- config.bpm_username = "scott"
9
- config.bpm_password = "tiger"
10
- config.bpm_use_ssl = false
11
- end
12
- end
13
-
14
- describe "#uri" do
15
- before :each do
16
- @uri = BpmManager.uri('/test')
17
- end
18
-
19
- it "expect to be a String" do
20
- expect(@uri).to be_an_instance_of String
21
- end
22
-
23
- it "expect to not be nil" do
24
- expect(@uri).not_to eq(nil)
25
- end
26
- end
27
-
28
- describe "#configuration" do
29
- before :each do
30
- @config = BpmManager.configuration
31
- end
32
-
33
- it "should be a class of type Configuration" do
34
- expect(@config).to be_an_instance_of BpmManager::Configuration
35
- end
36
-
37
- it 'must have all the accesors' do
38
- expect(@config.methods.include? :bpm_vendor).to be true
39
- expect(@config.methods.include? :bpm_url).to be true
40
- expect(@config.methods.include? :bpm_username).to be true
41
- expect(@config.methods.include? :bpm_password).to be true
42
- expect(@config.methods.include? :bpm_use_ssl).to be true
43
- end
44
- end
45
-
46
- describe "#deployments" do
47
- before :each do
48
- @deployments = BpmManager.deployments
49
- end
50
-
51
- it "must return something" do
52
- expect(@deployments.length).to be > 0
53
- end
54
- end
55
-
56
- describe "#tasks" do
57
- before :each do
58
- @tasks = BpmManager.tasks('foo@bar.com')
59
- end
60
-
61
- it "must return something" do
62
- expect(@tasks.length).to be > 0
63
- end
64
- end
65
-
66
- describe "#tasks_with_opts" do
67
- before :each do
68
- @tasks = BpmManager.tasks_with_opts(:ownerId => 'foo@bar.com', :taskId => 1)
69
- end
70
-
71
- it "must return something" do
72
- expect(@tasks.length).to be > 0
73
- end
74
- end
75
-
76
- describe "#process_instances" do
77
- before :each do
78
- @processes = BpmManager.process_instances
79
- end
80
-
81
- it "must return something" do
82
- expect(@processes.length).to be > 0
83
- end
84
- end
85
-
86
- describe "#process_instance" do
87
- before :each do
88
- @process = BpmManager.process_instance(1)
89
- end
90
-
91
- it "must return something" do
92
- expect(@process.length).to be > 0
93
- end
94
- end
95
-
96
- describe "#process_instance_variables" do
97
- before :each do
98
- @variables = BpmManager.process_instance_variables('package.process:1.0',1)
99
- end
100
-
101
- it "must return something" do
102
- expect(@variables.length).to be > 0
103
- end
104
- end
105
-
106
- describe "#assign_task" do
107
- before :each do
108
- @result = BpmManager.assign_task(1,'foo@bar.com')
109
- end
110
-
111
- it "must return something" do
112
- expect(@result.length).to be > 0
113
- end
114
- end
115
-
116
- describe "#release_task" do
117
- before :each do
118
- @result = BpmManager.release_task(1)
119
- end
120
-
121
- it "must return something" do
122
- expect(@result.length).to be > 0
123
- end
124
- end
125
-
126
- describe "#complete_task" do
127
- before :each do
128
- @result = BpmManager.complete_task(1)
129
- end
130
-
131
- it "must return something" do
132
- expect(@result.length).to be > 0
133
- end
134
- end
135
- end