Class: ProcessEngine::ProcessQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/process_engine/process_query.rb

Class Method Summary collapse

Class Method Details

.process_definition_get_allObject



47
48
49
# File 'app/models/process_engine/process_query.rb', line 47

def process_definition_get_all()
  ProcessEngine::ProcessDefinition.all
end

.process_instance_start(process_defintion_slug, creator) ⇒ Object



41
42
43
44
45
# File 'app/models/process_engine/process_query.rb', line 41

def process_instance_start(process_defintion_slug, creator)
  pd = ProcessEngine::ProcessDefinition.find_by(slug: process_defintion_slug)
  pi = pd.process_instances.create(creator: creator)
  pi.start
end

.task_accessible?(task_id, user, groups = []) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'app/models/process_engine/process_query.rb', line 33

def task_accessible?(task_id, user, groups = [])
  options = {
    user_or_groups: [user, groups]
  }

  task_get_all(options).where(id: task_id).count > 0
end

.task_complete(task_id, options = {}) ⇒ Object

available options: :finisher, :verified_state, :data



5
6
7
8
9
10
# File 'app/models/process_engine/process_query.rb', line 5

def task_complete(task_id, options = {})
  task = ProcessEngine::ProcessTask.find(task_id)
  raise ProcessEngine::Error::FalseTaskState if options[:verified_state] && (task.state != options[:verified_state])

  task.complete(options)
end

.task_get_all(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/process_engine/process_query.rb', line 12

def task_get_all(options = {})
  taks = ProcessEngine::ProcessTask.all

  taks = taks.by_assignee(options[:assignee]) if options[:assignee]

  taks = taks.by_candidate_user(options[:candidate_user]) if options[:candidate_user]
  taks = taks.by_all_candidate_users(options[:all_candidate_users]) if options[:all_candidate_users]
  taks = taks.by_any_candidate_users(options[:any_candidate_users]) if options[:any_candidate_users]

  taks = taks.by_candidate_group(options[:candidate_group]) if options[:candidate_group]
  taks = taks.by_all_candidate_groups(options[:all_candidate_groups]) if options[:all_candidate_groups]
  taks = taks.by_any_candidate_groups(options[:any_candidate_groups]) if options[:any_candidate_groups]

  taks = taks.by_user(options[:user]) if options[:user]
  # e.g. options[:user_or_groups] = ["assignee123", ['cg1']]
  taks = taks.by_user_or_groups(*options[:user_or_groups]) if options[:user_or_groups]

  taks = taks.by_status(options[:status]) if options[:status]
  taks
end