Module: BpmManager

Defined in:
lib/bpm_manager.rb,
lib/bpm_manager/version.rb,
lib/generators/bpm_manager/install_generator.rb

Defined Under Namespace

Classes: Configuration, InstallGenerator

Constant Summary collapse

VERSION =
"0.2.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



7
8
9
# File 'lib/bpm_manager.rb', line 7

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Generates a new configuration

Yields:



24
25
26
27
# File 'lib/bpm_manager.rb', line 24

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.deploymentsObject

Gets all server deployments



40
41
42
# File 'lib/bpm_manager.rb', line 40

def self.deployments()
  return JSON.parse(RestClient.get(BpmManager.uri('/deployment'), :accept => :json))
end

.process_instance(process_instance_id = 0) ⇒ Object

Gets a Process Instance



60
61
62
# File 'lib/bpm_manager.rb', line 60

def self.process_instance(process_instance_id = 0)
  return JSON.parse(RestClient.get(BpmManager.uri('/history/instance/' + process_instance_id.to_s), :accept => :json))
end

.process_instance_simplified(process_instance_id = 0) ⇒ Object

Gets a Process Instance –simplified



65
66
67
# File 'lib/bpm_manager.rb', line 65

def self.process_instance_simplified(process_instance_id = 0)
  return JSON.parse(RestClient.get(BpmManager.uri('/history/instance/' + process_instance_id.to_s), :accept => :json))['list'][0].first[1]
end

.process_instancesObject

Gets all Process Instances



55
56
57
# File 'lib/bpm_manager.rb', line 55

def self.process_instances
  return JSON.parse(RestClient.get(BpmManager.uri('/history/instances'), :accept => :json))
end

.tasks(user_id = "") ⇒ Object

Gets all tasks, optionally you could specify an user id



45
46
47
# File 'lib/bpm_manager.rb', line 45

def self.tasks(user_id = "")
  return JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (user_id.empty? ? '' : '?taskOwner=' + user_id)), :accept => :json))
end

.tasks_with_opts(opts = {}) ⇒ Object

Gets all tasks with options



50
51
52
# File 'lib/bpm_manager.rb', line 50

def self.tasks_with_opts(opts = {})
  return JSON.parse(RestClient.get(BpmManager.uri('/task/query' + (opts.empty? ? '' : '?' + opts.map{|k,v| k.to_s + '=' + v.to_s}.join('&'))), :accept => :json))
end

.uri(suffix = '') ⇒ Object

Returns the URI for the server plus a suffix



30
31
32
33
34
35
36
37
# File 'lib/bpm_manager.rb', line 30

def self.uri(suffix = '')
  case configuration.bpm_vendor.downcase
    when 'redhat'
      URI.encode('http' + (configuration.bpm_use_ssl ? 's' : '') + '://' + configuration.bpm_username + ':' + configuration.bpm_password + '@' + configuration.bpm_url + '/business-central/rest' + (suffix.nil? ? '' : suffix))
    else
      ''
  end
end