rails_workflow 0.2.0 → 0.2.1
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 +4 -4
- data/Rakefile +1 -1
- data/app/assets/javascripts/{workflow → rails_workflow}/application.js +0 -0
- data/app/assets/stylesheets/{workflow → rails_workflow}/application.css +0 -0
- data/app/concerns/{workflow → rails_workflow}/operation_status.rb +2 -2
- data/app/concerns/{workflow → rails_workflow}/operation_templates/assignments.rb +4 -4
- data/app/concerns/{workflow → rails_workflow}/operation_templates/default_builder.rb +3 -3
- data/app/concerns/{workflow → rails_workflow}/operation_templates/dependencies.rb +1 -2
- data/app/concerns/{workflow → rails_workflow}/operations/assignments.rb +3 -4
- data/app/concerns/{workflow → rails_workflow}/operations/default_runner.rb +8 -8
- data/app/concerns/{workflow → rails_workflow}/operations/dependencies.rb +2 -2
- data/app/concerns/{workflow → rails_workflow}/process_status.rb +2 -2
- data/app/concerns/{workflow → rails_workflow}/process_templates/default_builder.rb +2 -2
- data/app/concerns/{workflow → rails_workflow}/processes/default_runner.rb +2 -3
- data/app/concerns/{workflow → rails_workflow}/processes/dependency_resolver.rb +2 -3
- data/app/concerns/{workflow → rails_workflow}/user/assignment.rb +2 -3
- data/app/controllers/rails_workflow/application_controller.rb +10 -0
- data/app/controllers/{workflow → rails_workflow}/errors_controller.rb +2 -2
- data/app/controllers/{workflow → rails_workflow}/operation_templates_controller.rb +5 -6
- data/app/controllers/{workflow → rails_workflow}/operations_controller.rb +5 -5
- data/app/controllers/{workflow → rails_workflow}/process_templates_controller.rb +4 -5
- data/app/controllers/{workflow → rails_workflow}/processes_controller.rb +10 -11
- data/app/decorators/{workflow → rails_workflow}/context_decorator.rb +1 -1
- data/app/decorators/{workflow → rails_workflow}/decorator.rb +1 -1
- data/app/decorators/{workflow → rails_workflow}/operation_decorator.rb +3 -3
- data/app/decorators/{workflow → rails_workflow}/operation_helper_decorator.rb +1 -2
- data/app/decorators/{workflow → rails_workflow}/operation_template_decorator.rb +1 -2
- data/app/decorators/{workflow → rails_workflow}/paginating_decorator.rb +1 -1
- data/app/decorators/{workflow → rails_workflow}/process_decorator.rb +1 -4
- data/app/decorators/{workflow → rails_workflow}/process_template_decorator.rb +4 -5
- data/app/decorators/{workflow → rails_workflow}/status_decorator.rb +1 -2
- data/app/helpers/{workflow → rails_workflow}/application_helper.rb +1 -1
- data/app/managers/{workflow → rails_workflow}/process_manager.rb +3 -4
- data/app/models/{workflow → rails_workflow}/context.rb +1 -1
- data/app/models/{workflow → rails_workflow}/error.rb +14 -14
- data/app/models/{workflow → rails_workflow}/operation.rb +6 -7
- data/app/models/{workflow → rails_workflow}/operation_template.rb +7 -8
- data/app/models/{workflow → rails_workflow}/process.rb +8 -9
- data/app/models/{workflow → rails_workflow}/process_template.rb +3 -4
- data/app/models/{workflow → rails_workflow}/user_by_group_operation.rb +1 -2
- data/app/models/{workflow → rails_workflow}/user_by_role_operation.rb +1 -2
- data/app/views/layouts/{workflow → rails_workflow}/application.html.slim +3 -3
- data/app/views/{workflow → rails_workflow}/operation_templates/_default_form.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operation_templates/_user_group_form.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operation_templates/_user_role_form.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operation_templates/edit.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operation_templates/index.html.slim +1 -1
- data/app/views/{workflow → rails_workflow}/operation_templates/new.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operation_templates/show.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operations/index.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/operations/show.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/process_templates/_form.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/process_templates/edit.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/process_templates/index.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/process_templates/new.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/process_templates/show.html.slim +1 -1
- data/app/views/{workflow → rails_workflow}/processes/_form.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/processes/edit.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/processes/index.html.slim +6 -6
- data/app/views/{workflow → rails_workflow}/processes/new.html.slim +0 -0
- data/app/views/{workflow → rails_workflow}/processes/show.html.slim +0 -0
- data/app/workers/{workflow → rails_workflow}/error_worker.rb +5 -5
- data/app/workers/{workflow → rails_workflow}/operation_worker.rb +1 -1
- data/config/initializers/{workflow.rb → rails_workflow.rb} +8 -8
- data/config/routes.rb +1 -1
- data/db/migrate/20150210070051_change_namespace.rb +10 -0
- data/lib/generators/{workflow → rails_workflow}/install/install_generator.rb +1 -1
- data/lib/generators/{workflow → rails_workflow}/install/templates/create_workflow_processes.rb +22 -12
- data/lib/{workflow → rails_workflow}/engine.rb +2 -8
- data/lib/rails_workflow/version.rb +3 -0
- data/lib/{workflow.rb → rails_workflow.rb} +9 -9
- data/lib/tasks/{workflow_tasks.rake → rails_workflow_tasks.rake} +0 -0
- data/spec/controllers/{workflow → rails_workflow}/operation_templates_controller_spec.rb +6 -6
- data/spec/controllers/{workflow → rails_workflow}/operations_controller_spec.rb +2 -2
- data/spec/controllers/{workflow → rails_workflow}/process_templates_controller_spec.rb +2 -2
- data/spec/controllers/{workflow → rails_workflow}/processes_controller_spec.rb +2 -2
- data/spec/core/{worklow → rails_workflow}/process_manager_spec.rb +11 -11
- data/spec/dummy/app/controllers/sales_contacts_controller.rb +1 -1
- data/spec/dummy/app/models/bad_operation.rb +1 -1
- data/spec/dummy/app/models/bad_operation_template.rb +1 -1
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/initializers/workflow.rb +1 -1
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/db/schema.rb +34 -34
- data/spec/dummy/log/development.log +1324 -0
- data/spec/dummy/log/test.log +7697 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0aeea3efe13c49227e4f05894224629b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/17093127c2a964b159dacb6baee0c707 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/844434b6c7324d1785e26864aee28316 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ab0c70eaae03da94a23f832513ff652b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d8f3150c250e5b7c730f1c8b883bf033 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f794c7b05987535f7000622afe6630d1 +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/factories/context.rb +1 -1
- data/spec/factories/operation_templates.rb +1 -1
- data/spec/factories/operations.rb +3 -3
- data/spec/factories/process_templates.rb +1 -1
- data/spec/factories/processes.rb +2 -2
- data/spec/factories/workflow_errors.rb +1 -1
- data/spec/features/process_template_spec.rb +0 -1
- data/spec/models/{workflow → rails_workflow}/context_spec.rb +4 -4
- data/spec/models/{workflow → rails_workflow}/error_spec.rb +1 -1
- data/spec/models/{workflow → rails_workflow}/operation_spec.rb +19 -19
- data/spec/models/{workflow → rails_workflow}/operation_template_spec.rb +5 -5
- data/spec/models/{workflow → rails_workflow}/process_spec.rb +1 -1
- data/spec/models/{workflow → rails_workflow}/process_template_spec.rb +3 -3
- data/spec/rails_helper.rb +2 -2
- data/spec/support/{workflow → rails_workflow}/custom_operation.rb +1 -1
- data/spec/support/{workflow → rails_workflow}/custom_operation_template.rb +1 -1
- metadata +111 -96
- data/app/controllers/workflow/application_controller.rb +0 -10
- data/lib/workflow/version.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ac3a84ad941c246c8df3fa39aba0491cd9d50636
|
|
4
|
+
data.tar.gz: be6312031bb63bd474de3e1ba91fae69d449369a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d41b114ed5f230764084eee2dae4b42846be1474e322c857438b31de3f4be40cf242a89175131ef2007d819b29567536b2d8c80f9f44f50d7fe528eadf8b029
|
|
7
|
+
data.tar.gz: 905e89cf1acddec238fcff6af3a0517589c7d9266becbc4b665f23867a17503e89f289da74d75fcfb5f7a9c15c732f26047e256c4deef79e303311c70dd9c6a2
|
data/Rakefile
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
module
|
|
1
|
+
|
|
2
|
+
module RailsWorkflow
|
|
3
3
|
module OperationTemplates
|
|
4
4
|
module Assignments
|
|
5
5
|
extend ActiveSupport::Concern
|
|
@@ -8,10 +8,10 @@ module Workflow
|
|
|
8
8
|
belongs_to :assignment, polymorphic: true
|
|
9
9
|
scope :for_user, -> (user) {
|
|
10
10
|
|
|
11
|
-
keys =
|
|
11
|
+
keys = RailsWorkflow.config.assignment_by.select{|k| user.respond_to? k }
|
|
12
12
|
|
|
13
13
|
assignment_condition = keys.map{|key|
|
|
14
|
-
"
|
|
14
|
+
"rails_workflow_operation_templates.#{key} = ?" }.join(" or ")
|
|
15
15
|
|
|
16
16
|
where(
|
|
17
17
|
assignment_condition,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module RailsWorkflow
|
|
2
2
|
module OperationTemplates
|
|
3
3
|
module DefaultBuilder
|
|
4
4
|
extend ActiveSupport::Concern
|
|
@@ -29,13 +29,13 @@ module Workflow
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
operation = operation_class.create(attrs) do |op|
|
|
32
|
-
op.context =
|
|
32
|
+
op.context = RailsWorkflow::OperationTemplate.build_context! op, completed_dependencies
|
|
33
33
|
|
|
34
34
|
build_operation op
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
if child_process.present?
|
|
38
|
-
operation.child_process =
|
|
38
|
+
operation.child_process = RailsWorkflow::ProcessManager.
|
|
39
39
|
build_process(
|
|
40
40
|
child_process.id,
|
|
41
41
|
operation.context.data
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
module Operations
|
|
4
3
|
module Assignments
|
|
5
4
|
extend ActiveSupport::Concern
|
|
@@ -7,8 +6,8 @@ module Workflow
|
|
|
7
6
|
included do
|
|
8
7
|
belongs_to :assignment, polymorphic: true
|
|
9
8
|
|
|
10
|
-
scope :by_role, -> (role) { joins(:template).where(
|
|
11
|
-
scope :by_group, -> (group) { joins(:template).where(
|
|
9
|
+
scope :by_role, -> (role) { joins(:template).where(rails_workflow_operation_templates: { role: role })}
|
|
10
|
+
scope :by_group, -> (group) { joins(:template).where(rails_workflow_operation_templates: { group: group })}
|
|
12
11
|
scope :unassigned, -> { where(assignment_id: nil) }
|
|
13
12
|
|
|
14
13
|
scope :waiting, -> { where( status: Operation.user_ready_statuses ) }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
module
|
|
1
|
+
|
|
2
|
+
module RailsWorkflow
|
|
3
3
|
module Operations
|
|
4
4
|
#
|
|
5
5
|
# = Workflow::Operations::DefaultRunner contains operation starting,
|
|
@@ -19,14 +19,14 @@ module Workflow
|
|
|
19
19
|
def start
|
|
20
20
|
can_start? ? starting : waiting
|
|
21
21
|
rescue => exception
|
|
22
|
-
|
|
22
|
+
RailsWorkflow::Error.create_from exception, parent: self
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def starting
|
|
26
26
|
|
|
27
27
|
update_attribute(:status, self.class::IN_PROGRESS)
|
|
28
28
|
|
|
29
|
-
is_background &&
|
|
29
|
+
is_background && RailsWorkflow.config.sidekiq_enabled ?
|
|
30
30
|
OperationWorker.perform_async(id) :
|
|
31
31
|
OperationWorker.new.perform(id)
|
|
32
32
|
|
|
@@ -44,7 +44,7 @@ module Workflow
|
|
|
44
44
|
update_attribute(:status, self.class::WAITING)
|
|
45
45
|
start_waiting if respond_to? :start_waiting
|
|
46
46
|
rescue => exception
|
|
47
|
-
|
|
47
|
+
RailsWorkflow::Error.create_from exception, parent: self
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def execute_in_transaction
|
|
@@ -72,7 +72,7 @@ module Workflow
|
|
|
72
72
|
# In case of rollback exception we do nothing -
|
|
73
73
|
# this may be caused by usual validations
|
|
74
74
|
rescue => exception
|
|
75
|
-
|
|
75
|
+
RailsWorkflow::Error.create_from(
|
|
76
76
|
exception, {
|
|
77
77
|
parent: self,
|
|
78
78
|
target: self,
|
|
@@ -93,7 +93,7 @@ module Workflow
|
|
|
93
93
|
|
|
94
94
|
def can_complete?
|
|
95
95
|
child_process.present? ?
|
|
96
|
-
child_process.status ==
|
|
96
|
+
child_process.status == RailsWorkflow::Process::DONE :
|
|
97
97
|
true
|
|
98
98
|
end
|
|
99
99
|
|
|
@@ -109,7 +109,7 @@ module Workflow
|
|
|
109
109
|
manager.operation_complete self
|
|
110
110
|
end
|
|
111
111
|
rescue => exception
|
|
112
|
-
|
|
112
|
+
RailsWorkflow::Error.create_from(
|
|
113
113
|
exception, {
|
|
114
114
|
parent: self,
|
|
115
115
|
target: self,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'active_support/concern'
|
|
2
|
-
module
|
|
2
|
+
module RailsWorkflow
|
|
3
3
|
module ProcessTemplates
|
|
4
4
|
# = DefaultBuilder
|
|
5
5
|
#
|
|
@@ -52,7 +52,7 @@ module Workflow
|
|
|
52
52
|
|
|
53
53
|
operation
|
|
54
54
|
rescue => exception
|
|
55
|
-
|
|
55
|
+
RailsWorkflow::Error.create_from(
|
|
56
56
|
exception, {
|
|
57
57
|
parent: process,
|
|
58
58
|
target: process.template,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
module Processes
|
|
4
3
|
#= DefaultRunner
|
|
5
4
|
#
|
|
@@ -17,7 +16,7 @@ module Workflow
|
|
|
17
16
|
def start
|
|
18
17
|
if can_start?
|
|
19
18
|
update_attribute(:status, self.class::IN_PROGRESS)
|
|
20
|
-
self.operations.where(status:
|
|
19
|
+
self.operations.where(status: RailsWorkflow::Operation::NOT_STARTED).map(&:start)
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
module Processes
|
|
4
3
|
# = DependencyResolver
|
|
5
4
|
#
|
|
@@ -44,7 +43,7 @@ module Workflow
|
|
|
44
43
|
end
|
|
45
44
|
end
|
|
46
45
|
rescue => exception
|
|
47
|
-
|
|
46
|
+
RailsWorkflow::Error.create_from(
|
|
48
47
|
exception, {
|
|
49
48
|
parent: self,
|
|
50
49
|
target: self,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
module User
|
|
4
3
|
module Assignment
|
|
5
4
|
extend ActiveSupport::Concern
|
|
6
5
|
|
|
7
6
|
included do
|
|
8
|
-
has_many :operations, class:
|
|
7
|
+
has_many :operations, class: RailsWorkflow::Operation, as: :assignment
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def self.role_text role
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module RailsWorkflow
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
before_filter only: [:index, :show, :edit] do
|
|
4
|
+
RailsWorkflow::OperationTemplate.inheritance_column = nil
|
|
5
|
+
RailsWorkflow::Operation.inheritance_column = nil
|
|
6
|
+
RailsWorkflow::ProcessTemplate.inheritance_column = nil
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module
|
|
1
|
+
module RailsWorkflow
|
|
2
2
|
class ErrorsController < ActionController::Base
|
|
3
3
|
|
|
4
4
|
def retry
|
|
5
|
-
process =
|
|
5
|
+
process = RailsWorkflow::Process.find(permitted_params[:process_id])
|
|
6
6
|
|
|
7
7
|
if permitted_params[:operation_id].present?
|
|
8
8
|
operation = Operation.find(permitted_params[:operation_id])
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
3
|
-
module Workflow
|
|
1
|
+
require 'rails_workflow/application_controller'
|
|
2
|
+
module RailsWorkflow
|
|
4
3
|
class OperationTemplatesController < ::InheritedResources::Base
|
|
5
|
-
layout '
|
|
4
|
+
layout 'rails_workflow/application'
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
defaults collection_name: 'operations', resource_class: OperationTemplate
|
|
@@ -23,7 +22,7 @@ module Workflow
|
|
|
23
22
|
end
|
|
24
23
|
|
|
25
24
|
def update
|
|
26
|
-
@operation_template =
|
|
25
|
+
@operation_template = RailsWorkflow::OperationTemplate.find(params[:id])
|
|
27
26
|
update! { process_template_operation_templates_url }
|
|
28
27
|
end
|
|
29
28
|
|
|
@@ -60,7 +59,7 @@ module Workflow
|
|
|
60
59
|
dependencies = parms[:operation_template][:dependencies].values.map(&:to_h).each do |dep|
|
|
61
60
|
dep['id'] = dep['id'].to_i
|
|
62
61
|
dep['statuses'] = (dep['statuses'] ||
|
|
63
|
-
|
|
62
|
+
RailsWorkflow::OperationTemplate.all_statuses
|
|
64
63
|
).map(&:to_i)
|
|
65
64
|
end
|
|
66
65
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require_dependency "
|
|
1
|
+
require_dependency "rails_workflow/application_controller"
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module RailsWorkflow
|
|
4
4
|
class OperationsController < ::InheritedResources::Base
|
|
5
|
-
layout '
|
|
5
|
+
layout 'rails_workflow/application'
|
|
6
6
|
|
|
7
7
|
before_filter do
|
|
8
8
|
if parent.present?
|
|
@@ -24,12 +24,12 @@ module Workflow
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def update
|
|
27
|
-
@operation =
|
|
27
|
+
@operation = RailsWorkflow::Operation.find(params[:id])
|
|
28
28
|
update! { process_operation_url }
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def pickup
|
|
32
|
-
@operation =
|
|
32
|
+
@operation = RailsWorkflow::Operation.find(params[:id])
|
|
33
33
|
|
|
34
34
|
if @operation.assign(current_user)
|
|
35
35
|
set_current_operation
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
3
|
-
module Workflow
|
|
1
|
+
require 'rails_workflow/application_controller'
|
|
2
|
+
module RailsWorkflow
|
|
4
3
|
class ProcessTemplatesController < ::InheritedResources::Base
|
|
5
4
|
before_filter do
|
|
6
5
|
@config_section_active = true
|
|
7
6
|
end
|
|
8
7
|
|
|
9
|
-
layout '
|
|
8
|
+
layout 'rails_workflow/application'
|
|
10
9
|
|
|
11
10
|
def create
|
|
12
11
|
# create!{ process_template_url(resource) }
|
|
@@ -28,7 +27,7 @@ module Workflow
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
def collection
|
|
31
|
-
::
|
|
30
|
+
::RailsWorkflow::ProcessTemplateDecorator.decorate_collection(super)
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def resource
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
require '
|
|
2
|
-
|
|
3
|
-
module Workflow
|
|
1
|
+
require 'rails_workflow/application_controller'
|
|
2
|
+
module RailsWorkflow
|
|
4
3
|
class ProcessesController < ::InheritedResources::Base
|
|
5
|
-
layout '
|
|
4
|
+
layout 'rails_workflow/application'
|
|
6
5
|
|
|
7
6
|
before_filter do
|
|
8
7
|
@processes_section_active = true
|
|
@@ -12,7 +11,7 @@ module Workflow
|
|
|
12
11
|
#any process should be build by process manager
|
|
13
12
|
#using some process template.
|
|
14
13
|
|
|
15
|
-
@process =
|
|
14
|
+
@process = RailsWorkflow::ProcessManager.start_process params[:process][:template_id], {}
|
|
16
15
|
|
|
17
16
|
create! { process_url(resource) }
|
|
18
17
|
end
|
|
@@ -27,13 +26,13 @@ module Workflow
|
|
|
27
26
|
|
|
28
27
|
def index
|
|
29
28
|
|
|
30
|
-
@errors =
|
|
31
|
-
@open_user_operations =
|
|
32
|
-
|
|
29
|
+
@errors = RailsWorkflow::Error.unresolved.order(id: :asc).includes(:parent).limit(10)
|
|
30
|
+
@open_user_operations = RailsWorkflow::OperationDecorator.decorate_collection(
|
|
31
|
+
RailsWorkflow::Operation.incompleted.unassigned.includes(:template).limit(20)
|
|
33
32
|
)
|
|
34
33
|
@statistic = {
|
|
35
|
-
all:
|
|
36
|
-
statuses:
|
|
34
|
+
all: RailsWorkflow::Process.count,
|
|
35
|
+
statuses: RailsWorkflow::Process.count_by_statuses
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
index!
|
|
@@ -50,7 +49,7 @@ module Workflow
|
|
|
50
49
|
collection_scope = end_of_association_chain
|
|
51
50
|
|
|
52
51
|
if params[:filter]
|
|
53
|
-
status = ::
|
|
52
|
+
status = ::RailsWorkflow::Process.get_status_code(params[:filter]['status'])
|
|
54
53
|
collection_scope = collection_scope.by_status(status)
|
|
55
54
|
end
|
|
56
55
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
module
|
|
1
|
+
|
|
2
|
+
module RailsWorkflow
|
|
3
3
|
class OperationDecorator < OperationHelperDecorator
|
|
4
4
|
delegate_all
|
|
5
5
|
|
|
@@ -17,7 +17,7 @@ module Workflow
|
|
|
17
17
|
|
|
18
18
|
def child_process
|
|
19
19
|
if object.child_process
|
|
20
|
-
::
|
|
20
|
+
::RailsWorkflow::ProcessDecorator.decorate(object.child_process)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module RailsWorkflow
|
|
2
2
|
class ProcessDecorator < Decorator
|
|
3
3
|
delegate_all
|
|
4
4
|
|
|
@@ -15,8 +15,6 @@ module Workflow
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def parents
|
|
18
|
-
#todo collect all parrents -> parents of parent etc
|
|
19
|
-
|
|
20
18
|
if object.parent_operation.present?
|
|
21
19
|
[self.class.decorate(object.parent_operation.process)]
|
|
22
20
|
else
|
|
@@ -25,7 +23,6 @@ module Workflow
|
|
|
25
23
|
end
|
|
26
24
|
|
|
27
25
|
def children
|
|
28
|
-
#todo and children hierarchy
|
|
29
26
|
children = object.operations.with_child_process.map(&:child_process)
|
|
30
27
|
if children.present?
|
|
31
28
|
self.class.decorate_collection(children)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
class ProcessTemplateDecorator < Decorator
|
|
4
3
|
delegate_all
|
|
5
4
|
|
|
@@ -8,15 +7,15 @@ module Workflow
|
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
def default_class
|
|
11
|
-
|
|
10
|
+
RailsWorkflow.config.process_class
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def default_manager
|
|
15
|
-
|
|
14
|
+
RailsWorkflow.config.manager_class
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
def default_type
|
|
19
|
-
|
|
18
|
+
RailsWorkflow.config.process_template_type
|
|
20
19
|
end
|
|
21
20
|
end
|
|
22
21
|
end
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
class ProcessManager
|
|
4
3
|
class << self
|
|
5
4
|
def build_process template_id, context
|
|
6
|
-
template =
|
|
5
|
+
template = RailsWorkflow::ProcessTemplate.find template_id
|
|
7
6
|
template.build_process! context
|
|
8
7
|
end
|
|
9
8
|
|
|
@@ -26,7 +25,7 @@ module Workflow
|
|
|
26
25
|
def start_process
|
|
27
26
|
process.start
|
|
28
27
|
rescue => exception
|
|
29
|
-
|
|
28
|
+
RailsWorkflow::Error.create_from exception, parent: process
|
|
30
29
|
end
|
|
31
30
|
|
|
32
31
|
def operation_exception
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
module
|
|
1
|
+
module RailsWorkflow
|
|
2
2
|
class Error < ActiveRecord::Base
|
|
3
3
|
belongs_to :parent, polymorphic: true
|
|
4
|
-
has_one :context, class_name: "
|
|
4
|
+
has_one :context, class_name: "RailsWorkflow::Context", as: :parent
|
|
5
5
|
scope :unresolved, -> { where("resolved is null or resolved = false")}
|
|
6
6
|
|
|
7
7
|
def retry
|
|
@@ -13,25 +13,25 @@ module Workflow
|
|
|
13
13
|
|
|
14
14
|
target.send(method, *args)
|
|
15
15
|
|
|
16
|
-
operation = parent if parent.is_a?
|
|
16
|
+
operation = parent if parent.is_a? RailsWorkflow::Operation
|
|
17
17
|
|
|
18
18
|
process = if operation
|
|
19
19
|
operation.process
|
|
20
|
-
elsif target.is_a?
|
|
20
|
+
elsif target.is_a? RailsWorkflow::Process
|
|
21
21
|
target
|
|
22
|
-
elsif parent.is_a?
|
|
22
|
+
elsif parent.is_a? RailsWorkflow::Process
|
|
23
23
|
parent
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
if operation.present?
|
|
27
27
|
operation.reload
|
|
28
|
-
if operation.status ==
|
|
29
|
-
operation.update_attribute(:status,
|
|
28
|
+
if operation.status == RailsWorkflow::Operation::ERROR
|
|
29
|
+
operation.update_attribute(:status, RailsWorkflow::Operation::NOT_STARTED)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
if process.present? && can_restart_process(process)
|
|
34
|
-
process.update_attribute(:status,
|
|
34
|
+
process.update_attribute(:status, RailsWorkflow::Process::IN_PROGRESS)
|
|
35
35
|
process.start
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -46,13 +46,13 @@ module Workflow
|
|
|
46
46
|
|
|
47
47
|
parent = context[:parent]
|
|
48
48
|
|
|
49
|
-
if parent.is_a?
|
|
50
|
-
correct_parent = parent.becomes(
|
|
51
|
-
elsif parent.is_a?
|
|
52
|
-
correct_parent = parent.becomes(
|
|
49
|
+
if parent.is_a? RailsWorkflow::Operation
|
|
50
|
+
correct_parent = parent.becomes(RailsWorkflow::Operation)
|
|
51
|
+
elsif parent.is_a? RailsWorkflow::Process
|
|
52
|
+
correct_parent = parent.becomes(RailsWorkflow::Process)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
error =
|
|
55
|
+
error = RailsWorkflow::Error.create(
|
|
56
56
|
parent_id: parent.id,
|
|
57
57
|
parent_type: (correct_parent || parent).class.to_s,
|
|
58
58
|
message: exception.message.first(250),
|
|
@@ -64,7 +64,7 @@ module Workflow
|
|
|
64
64
|
# Workflow.config.sidekiq_enabled ?
|
|
65
65
|
# Workflow::ErrorWorker.perform_async(parent.id, parent.class.to_s) :
|
|
66
66
|
# Workflow::ErrorWorker.new.perform(parent.id, parent.class.to_s)
|
|
67
|
-
|
|
67
|
+
RailsWorkflow::ErrorWorker.new.perform(parent.id, parent.class.to_s)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
end
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
module Workflow
|
|
1
|
+
module RailsWorkflow
|
|
3
2
|
class Operation < ActiveRecord::Base
|
|
4
3
|
include OperationStatus
|
|
5
4
|
|
|
@@ -7,11 +6,11 @@ module Workflow
|
|
|
7
6
|
include Operations::Dependencies
|
|
8
7
|
include Operations::Assignments
|
|
9
8
|
|
|
10
|
-
belongs_to :process, class_name: "
|
|
11
|
-
belongs_to :template, class_name: "
|
|
12
|
-
belongs_to :child_process, class_name: "
|
|
13
|
-
has_one :context, class_name: "
|
|
14
|
-
has_many :workflow_errors, class_name: "
|
|
9
|
+
belongs_to :process, class_name: "RailsWorkflow::Process"
|
|
10
|
+
belongs_to :template, class_name: "RailsWorkflow::OperationTemplate"
|
|
11
|
+
belongs_to :child_process, class_name: "RailsWorkflow::Process"
|
|
12
|
+
has_one :context, class_name: "RailsWorkflow::Context", as: :parent
|
|
13
|
+
has_many :workflow_errors, class_name: "RailsWorkflow::Error", as: :parent
|
|
15
14
|
|
|
16
15
|
delegate :data, to: :context
|
|
17
16
|
delegate :role, to: :template
|