operaton-bpm-client 0.1.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 +7 -0
- data/README.md +134 -0
- data/lib/operaton/bpm/client/backoff/backoff_strategy.rb +20 -0
- data/lib/operaton/bpm/client/backoff/error_aware_backoff_strategy.rb +22 -0
- data/lib/operaton/bpm/client/backoff/exponential_backoff_strategy.rb +38 -0
- data/lib/operaton/bpm/client/backoff/exponential_error_backoff_strategy.rb +38 -0
- data/lib/operaton/bpm/client/exceptions.rb +74 -0
- data/lib/operaton/bpm/client/external_task_client.rb +20 -0
- data/lib/operaton/bpm/client/external_task_client_builder.rb +18 -0
- data/lib/operaton/bpm/client/impl/engine_client.rb +132 -0
- data/lib/operaton/bpm/client/impl/engine_client_exception.rb +25 -0
- data/lib/operaton/bpm/client/impl/engine_client_logger.rb +54 -0
- data/lib/operaton/bpm/client/impl/engine_rest_exception_dto.rb +28 -0
- data/lib/operaton/bpm/client/impl/external_task_client_builder_impl.rb +349 -0
- data/lib/operaton/bpm/client/impl/external_task_client_impl.rb +41 -0
- data/lib/operaton/bpm/client/impl/external_task_client_logger.rb +236 -0
- data/lib/operaton/bpm/client/impl/object_mapper.rb +44 -0
- data/lib/operaton/bpm/client/impl/permanent_url_resolver.rb +22 -0
- data/lib/operaton/bpm/client/impl/request_dto.rb +24 -0
- data/lib/operaton/bpm/client/impl/request_executor.rb +143 -0
- data/lib/operaton/bpm/client/interceptor/auth/basic_auth_provider.rb +42 -0
- data/lib/operaton/bpm/client/interceptor/client_request_context.rb +16 -0
- data/lib/operaton/bpm/client/interceptor/client_request_interceptor.rb +18 -0
- data/lib/operaton/bpm/client/interceptor/impl/client_request_context_impl.rb +28 -0
- data/lib/operaton/bpm/client/interceptor/impl/request_interceptor_handler.rb +43 -0
- data/lib/operaton/bpm/client/spi/data_format.rb +32 -0
- data/lib/operaton/bpm/client/spi/data_format_configurator.rb +31 -0
- data/lib/operaton/bpm/client/spi/data_format_provider.rb +31 -0
- data/lib/operaton/bpm/client/task/external_task.rb +22 -0
- data/lib/operaton/bpm/client/task/external_task_handler.rb +28 -0
- data/lib/operaton/bpm/client/task/external_task_service.rb +18 -0
- data/lib/operaton/bpm/client/task/impl/dto/bpmn_error_request_dto.rb +35 -0
- data/lib/operaton/bpm/client/task/impl/dto/complete_request_dto.rb +33 -0
- data/lib/operaton/bpm/client/task/impl/dto/extend_lock_request_dto.rb +29 -0
- data/lib/operaton/bpm/client/task/impl/dto/failure_request_dto.rb +43 -0
- data/lib/operaton/bpm/client/task/impl/dto/lock_request_dto.rb +29 -0
- data/lib/operaton/bpm/client/task/impl/dto/set_variables_request_dto.rb +29 -0
- data/lib/operaton/bpm/client/task/impl/external_task_impl.rb +128 -0
- data/lib/operaton/bpm/client/task/impl/external_task_service_impl.rb +90 -0
- data/lib/operaton/bpm/client/task/ordering_config.rb +78 -0
- data/lib/operaton/bpm/client/task/sorting_dto.rb +29 -0
- data/lib/operaton/bpm/client/topic/impl/dto/fetch_and_lock_request_dto.rb +47 -0
- data/lib/operaton/bpm/client/topic/impl/dto/fetch_and_lock_response_dto.rb +32 -0
- data/lib/operaton/bpm/client/topic/impl/dto/topic_request_dto.rb +70 -0
- data/lib/operaton/bpm/client/topic/impl/topic_subscription_builder_impl.rb +164 -0
- data/lib/operaton/bpm/client/topic/impl/topic_subscription_impl.rb +76 -0
- data/lib/operaton/bpm/client/topic/impl/topic_subscription_manager.rb +222 -0
- data/lib/operaton/bpm/client/topic/impl/topic_subscription_manager_logger.rb +52 -0
- data/lib/operaton/bpm/client/topic/topic_subscription.rb +20 -0
- data/lib/operaton/bpm/client/topic/topic_subscription_builder.rb +22 -0
- data/lib/operaton/bpm/client/url_resolver.rb +15 -0
- data/lib/operaton/bpm/client/variable/client_values.rb +33 -0
- data/lib/operaton/bpm/client/variable/impl/abstract_typed_value_mapper.rb +59 -0
- data/lib/operaton/bpm/client/variable/impl/default_value_mappers.rb +71 -0
- data/lib/operaton/bpm/client/variable/impl/format/json/json_data_format.rb +82 -0
- data/lib/operaton/bpm/client/variable/impl/format/json/json_data_format_provider.rb +34 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/boolean_value_mapper.rb +35 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/byte_array_value_mapper.rb +53 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/date_value_mapper.rb +61 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/double_value_mapper.rb +36 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/file_value_mapper.rb +73 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/integer_value_mapper.rb +36 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/json_value_mapper.rb +35 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/long_value_mapper.rb +36 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/null_value_mapper.rb +45 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/number_value_mapper.rb +25 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/object_value_mapper.rb +151 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/primitive_value_mapper.rb +44 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/short_value_mapper.rb +36 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/string_value_mapper.rb +35 -0
- data/lib/operaton/bpm/client/variable/impl/mapper/xml_value_mapper.rb +35 -0
- data/lib/operaton/bpm/client/variable/impl/type/json_type_impl.rb +24 -0
- data/lib/operaton/bpm/client/variable/impl/type/xml_type_impl.rb +24 -0
- data/lib/operaton/bpm/client/variable/impl/typed_value_field.rb +36 -0
- data/lib/operaton/bpm/client/variable/impl/typed_values.rb +100 -0
- data/lib/operaton/bpm/client/variable/impl/value/deferred_file_value_impl.rb +57 -0
- data/lib/operaton/bpm/client/variable/impl/value/json_value_impl.rb +26 -0
- data/lib/operaton/bpm/client/variable/impl/value/xml_value_impl.rb +26 -0
- data/lib/operaton/bpm/client/variable/impl/value_mapper.rb +42 -0
- data/lib/operaton/bpm/client/variable/impl/value_mappers.rb +26 -0
- data/lib/operaton/bpm/client/variable/impl/variable_value.rb +55 -0
- data/lib/operaton/bpm/client/variable/value/deferred_file_value.rb +19 -0
- data/lib/operaton/bpm/client/variable/value/json_value.rb +16 -0
- data/lib/operaton/bpm/client/variable/value/xml_value.rb +16 -0
- data/lib/operaton/bpm/client/version.rb +9 -0
- data/lib/operaton/bpm/client.rb +121 -0
- data/lib/operaton/bpm/engine/variable/typed_value.rb +153 -0
- data/lib/operaton/bpm/engine/variable/value_type.rb +126 -0
- data/lib/operaton/bpm/engine/variable/variable_map.rb +72 -0
- data/lib/operaton/bpm/engine/variable/variables.rb +197 -0
- data/lib/operaton-bpm-client.rb +3 -0
- metadata +188 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../impl/request_dto"
|
|
4
|
+
|
|
5
|
+
module Operaton
|
|
6
|
+
module Bpm
|
|
7
|
+
module Client
|
|
8
|
+
module Task
|
|
9
|
+
module Impl
|
|
10
|
+
module Dto
|
|
11
|
+
# Mirrors org.operaton.bpm.client.task.impl.dto.SetVariablesRequestDto
|
|
12
|
+
class SetVariablesRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :modifications
|
|
14
|
+
|
|
15
|
+
def initialize(worker_id, modifications)
|
|
16
|
+
super(worker_id)
|
|
17
|
+
@modifications = modifications
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def as_json
|
|
21
|
+
super.merge("modifications" => modifications&.transform_values(&:as_json))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../external_task"
|
|
4
|
+
require_relative "../../variable/impl/typed_value_field"
|
|
5
|
+
require_relative "../../../engine/variable/variable_map"
|
|
6
|
+
|
|
7
|
+
module Operaton
|
|
8
|
+
module Bpm
|
|
9
|
+
module Client
|
|
10
|
+
module Task
|
|
11
|
+
module Impl
|
|
12
|
+
# Mirrors org.operaton.bpm.client.task.impl.ExternalTaskImpl
|
|
13
|
+
class ExternalTaskImpl
|
|
14
|
+
include ExternalTask
|
|
15
|
+
|
|
16
|
+
attr_accessor :activity_id, :activity_instance_id, :error_message, :error_details,
|
|
17
|
+
:execution_id, :id, :lock_expiration_time, :create_time,
|
|
18
|
+
:process_definition_id, :process_definition_key,
|
|
19
|
+
:process_definition_version_tag, :process_instance_id, :retries,
|
|
20
|
+
:worker_id, :topic_name, :tenant_id, :priority, :variables,
|
|
21
|
+
:business_key, :received_variable_map
|
|
22
|
+
|
|
23
|
+
def self.from_json(hash, object_mapper)
|
|
24
|
+
task = new
|
|
25
|
+
task.activity_id = hash["activityId"]
|
|
26
|
+
task.activity_instance_id = hash["activityInstanceId"]
|
|
27
|
+
task.error_message = hash["errorMessage"]
|
|
28
|
+
task.error_details = hash["errorDetails"]
|
|
29
|
+
task.execution_id = hash["executionId"]
|
|
30
|
+
task.id = hash["id"]
|
|
31
|
+
task.lock_expiration_time = parse_time(hash["lockExpirationTime"], object_mapper)
|
|
32
|
+
task.create_time = parse_time(hash["createTime"], object_mapper)
|
|
33
|
+
task.process_definition_id = hash["processDefinitionId"]
|
|
34
|
+
task.process_definition_key = hash["processDefinitionKey"]
|
|
35
|
+
task.process_definition_version_tag = hash["processDefinitionVersionTag"]
|
|
36
|
+
task.process_instance_id = hash["processInstanceId"]
|
|
37
|
+
task.retries = hash["retries"]
|
|
38
|
+
task.worker_id = hash["workerId"]
|
|
39
|
+
task.topic_name = hash["topicName"]
|
|
40
|
+
task.tenant_id = hash["tenantId"]
|
|
41
|
+
task.priority = hash["priority"] || 0
|
|
42
|
+
task.business_key = hash["businessKey"]
|
|
43
|
+
task.variables = (hash["variables"] || {}).transform_values do |field|
|
|
44
|
+
Variable::Impl::TypedValueField.from_json(field)
|
|
45
|
+
end
|
|
46
|
+
task.set_extension_properties(hash["extensionProperties"])
|
|
47
|
+
task
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.parse_time(value, object_mapper)
|
|
51
|
+
return nil if value.nil?
|
|
52
|
+
|
|
53
|
+
object_mapper.parse_date(value)
|
|
54
|
+
end
|
|
55
|
+
private_class_method :parse_time
|
|
56
|
+
|
|
57
|
+
def initialize
|
|
58
|
+
@variables = {}
|
|
59
|
+
@received_variable_map = {}
|
|
60
|
+
@extension_properties = nil
|
|
61
|
+
@priority = 0
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Mirrors getAllVariables
|
|
65
|
+
def all_variables
|
|
66
|
+
received_variable_map.keys.to_h { |name| [name, variable(name)] }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Mirrors getVariable
|
|
70
|
+
def variable(variable_name)
|
|
71
|
+
variable_value = received_variable_map[variable_name]
|
|
72
|
+
variable_value&.value
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Mirrors getAllVariablesTyped
|
|
76
|
+
def all_variables_typed(deserialize_object_values = true)
|
|
77
|
+
vars = Engine::Variable::VariableMap.new
|
|
78
|
+
received_variable_map.each_key do |variable_name|
|
|
79
|
+
vars.put_value_typed(variable_name, variable_typed(variable_name, deserialize_object_values))
|
|
80
|
+
end
|
|
81
|
+
vars
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Mirrors getVariableTyped
|
|
85
|
+
def variable_typed(variable_name, deserialize_object_values = true)
|
|
86
|
+
variable_value = received_variable_map[variable_name]
|
|
87
|
+
variable_value&.typed_value(deserialize_object_values)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def extension_properties
|
|
91
|
+
@extension_properties || {}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def set_extension_properties(extension_properties) # rubocop:disable Naming/AccessorMethodName
|
|
95
|
+
@extension_properties = extension_properties
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def extension_property(property_key)
|
|
99
|
+
@extension_properties&.[](property_key)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def to_s
|
|
103
|
+
"ExternalTaskImpl [" \
|
|
104
|
+
"activityId=#{activity_id}, " \
|
|
105
|
+
"activityInstanceId=#{activity_instance_id}, " \
|
|
106
|
+
"businessKey=#{business_key}, " \
|
|
107
|
+
"errorDetails=#{error_details}, " \
|
|
108
|
+
"errorMessage=#{error_message}, " \
|
|
109
|
+
"executionId=#{execution_id}, " \
|
|
110
|
+
"id=#{id}, " \
|
|
111
|
+
"lockExpirationTime=#{lock_expiration_time}, " \
|
|
112
|
+
"createTime=#{create_time}, " \
|
|
113
|
+
"priority=#{priority}, " \
|
|
114
|
+
"processDefinitionId=#{process_definition_id}, " \
|
|
115
|
+
"processDefinitionKey=#{process_definition_key}, " \
|
|
116
|
+
"processDefinitionVersionTag=#{process_definition_version_tag}, " \
|
|
117
|
+
"processInstanceId=#{process_instance_id}, " \
|
|
118
|
+
"retries=#{retries}, " \
|
|
119
|
+
"tenantId=#{tenant_id}, " \
|
|
120
|
+
"topicName=#{topic_name}, " \
|
|
121
|
+
"workerId=#{worker_id}]"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../external_task_service"
|
|
4
|
+
require_relative "../../impl/engine_client_exception"
|
|
5
|
+
require_relative "../../impl/external_task_client_logger"
|
|
6
|
+
|
|
7
|
+
module Operaton
|
|
8
|
+
module Bpm
|
|
9
|
+
module Client
|
|
10
|
+
module Task
|
|
11
|
+
module Impl
|
|
12
|
+
# Mirrors org.operaton.bpm.client.task.impl.ExternalTaskServiceImpl.
|
|
13
|
+
# Methods accept either an ExternalTask or an external task id where
|
|
14
|
+
# the Java interface declares overloads for both.
|
|
15
|
+
class ExternalTaskServiceImpl
|
|
16
|
+
include ExternalTaskService
|
|
17
|
+
|
|
18
|
+
def initialize(engine_client)
|
|
19
|
+
@engine_client = engine_client
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def lock(task_or_id, lock_duration)
|
|
23
|
+
handling_errors("locking task") do
|
|
24
|
+
@engine_client.lock(task_id(task_or_id), lock_duration)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def unlock(external_task)
|
|
29
|
+
handling_errors("unlocking the external task") do
|
|
30
|
+
@engine_client.unlock(task_id(external_task))
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def complete(task_or_id, variables = nil, local_variables = nil)
|
|
35
|
+
handling_errors("completing the external task") do
|
|
36
|
+
@engine_client.complete(task_id(task_or_id), variables, local_variables)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def set_variables(task_or_process_instance_id, variables)
|
|
41
|
+
process_instance_id =
|
|
42
|
+
if task_or_process_instance_id.respond_to?(:process_instance_id)
|
|
43
|
+
task_or_process_instance_id.process_instance_id
|
|
44
|
+
else
|
|
45
|
+
task_or_process_instance_id
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
handling_errors("setting variables for external task") do
|
|
49
|
+
@engine_client.set_variables(process_instance_id, variables)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def handle_failure(task_or_id, error_message, error_details, retries, retry_timeout,
|
|
54
|
+
variables = nil, local_variables = nil)
|
|
55
|
+
handling_errors("notifying a failure") do
|
|
56
|
+
@engine_client.failure(task_id(task_or_id), error_message, error_details,
|
|
57
|
+
retries, retry_timeout, variables, local_variables)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def handle_bpmn_error(task_or_id, error_code, error_message = nil, variables = nil)
|
|
62
|
+
handling_errors("notifying a BPMN error") do
|
|
63
|
+
@engine_client.bpmn_error(task_id(task_or_id), error_code, error_message, variables)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def extend_lock(task_or_id, new_duration)
|
|
68
|
+
handling_errors("extending lock") do
|
|
69
|
+
@engine_client.extend_lock(task_id(task_or_id), new_duration)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
protected
|
|
74
|
+
|
|
75
|
+
def task_id(task_or_id)
|
|
76
|
+
task_or_id.respond_to?(:id) ? task_or_id.id : task_or_id
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def handling_errors(action_name)
|
|
80
|
+
yield
|
|
81
|
+
rescue Client::Impl::EngineClientException => e
|
|
82
|
+
raise Client::Impl::ExternalTaskClientLogger.client_logger
|
|
83
|
+
.handled_engine_client_exception(action_name, e)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../impl/external_task_client_logger"
|
|
4
|
+
require_relative "sorting_dto"
|
|
5
|
+
|
|
6
|
+
module Operaton
|
|
7
|
+
module Bpm
|
|
8
|
+
module Client
|
|
9
|
+
module Task
|
|
10
|
+
# Mirrors org.operaton.bpm.client.task.OrderingConfig
|
|
11
|
+
class OrderingConfig
|
|
12
|
+
module SortingField
|
|
13
|
+
CREATE_TIME = "createTime"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module Direction
|
|
17
|
+
ASC = "asc"
|
|
18
|
+
DESC = "desc"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
attr_reader :ordering_properties
|
|
22
|
+
|
|
23
|
+
def initialize(ordering_properties)
|
|
24
|
+
@ordering_properties = ordering_properties
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.empty
|
|
28
|
+
new([])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def configure_field(field)
|
|
32
|
+
ordering_properties << OrderingProperty.of(field, nil)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def configure_direction_on_last_field(direction)
|
|
36
|
+
last_configured_property = validate_and_get_last_configured_property
|
|
37
|
+
raise logger.double_direction_config_exception unless last_configured_property.direction.nil?
|
|
38
|
+
|
|
39
|
+
last_configured_property.direction = direction
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def validate_ordering_properties
|
|
43
|
+
raise logger.missing_direction_exception if ordering_properties.any? { |p| p.direction.nil? }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_sorting_dtos
|
|
47
|
+
ordering_properties.map { |property| SortingDto.from_ordering_property(property) }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
protected
|
|
51
|
+
|
|
52
|
+
def validate_and_get_last_configured_property
|
|
53
|
+
last_configured_property = ordering_properties.last
|
|
54
|
+
raise logger.unspecified_order_by_method_exception if last_configured_property.nil?
|
|
55
|
+
|
|
56
|
+
last_configured_property
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def logger
|
|
60
|
+
Client::Impl::ExternalTaskClientLogger.client_logger
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Mirrors OrderingConfig.OrderingProperty
|
|
64
|
+
class OrderingProperty
|
|
65
|
+
attr_accessor :field, :direction
|
|
66
|
+
|
|
67
|
+
def self.of(field, direction)
|
|
68
|
+
property = new
|
|
69
|
+
property.field = field
|
|
70
|
+
property.direction = direction
|
|
71
|
+
property
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Task
|
|
7
|
+
# Mirrors org.operaton.bpm.client.task.SortingDto
|
|
8
|
+
class SortingDto
|
|
9
|
+
attr_accessor :sort_by, :sort_order
|
|
10
|
+
|
|
11
|
+
def self.of(sort_by, sort_order)
|
|
12
|
+
dto = new
|
|
13
|
+
dto.sort_by = sort_by
|
|
14
|
+
dto.sort_order = sort_order
|
|
15
|
+
dto
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.from_ordering_property(property)
|
|
19
|
+
of(property.field, property.direction)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def as_json
|
|
23
|
+
{ "sortBy" => sort_by, "sortOrder" => sort_order }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../impl/request_dto"
|
|
4
|
+
require_relative "../../../task/ordering_config"
|
|
5
|
+
|
|
6
|
+
module Operaton
|
|
7
|
+
module Bpm
|
|
8
|
+
module Client
|
|
9
|
+
module Topic
|
|
10
|
+
module Impl
|
|
11
|
+
module Dto
|
|
12
|
+
# Mirrors org.operaton.bpm.client.topic.impl.dto.FetchAndLockRequestDto
|
|
13
|
+
# (annotated @JsonInclude(NON_NULL) in Java — nil fields are omitted).
|
|
14
|
+
class FetchAndLockRequestDto < Client::Impl::RequestDto
|
|
15
|
+
attr_reader :max_tasks, :async_response_timeout, :topics, :sorting
|
|
16
|
+
|
|
17
|
+
def initialize(worker_id, max_tasks, async_response_timeout, topics,
|
|
18
|
+
use_priority = true, ordering_config = Task::OrderingConfig.empty)
|
|
19
|
+
super(worker_id)
|
|
20
|
+
@max_tasks = max_tasks
|
|
21
|
+
@use_priority = use_priority
|
|
22
|
+
@async_response_timeout = async_response_timeout
|
|
23
|
+
@topics = topics
|
|
24
|
+
@sorting = ordering_config.to_sorting_dtos
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def use_priority?
|
|
28
|
+
@use_priority
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def as_json
|
|
32
|
+
json = super.merge(
|
|
33
|
+
"maxTasks" => max_tasks,
|
|
34
|
+
"usePriority" => use_priority?,
|
|
35
|
+
"asyncResponseTimeout" => async_response_timeout,
|
|
36
|
+
"topics" => topics.map(&:as_json),
|
|
37
|
+
"sorting" => sorting.map(&:as_json)
|
|
38
|
+
)
|
|
39
|
+
json.compact
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Topic
|
|
7
|
+
module Impl
|
|
8
|
+
module Dto
|
|
9
|
+
# Mirrors org.operaton.bpm.client.topic.impl.dto.FetchAndLockResponseDto
|
|
10
|
+
class FetchAndLockResponseDto
|
|
11
|
+
attr_reader :external_tasks, :error
|
|
12
|
+
|
|
13
|
+
def initialize(external_tasks_or_error)
|
|
14
|
+
if external_tasks_or_error.is_a?(::Exception)
|
|
15
|
+
@external_tasks = []
|
|
16
|
+
@error = external_tasks_or_error
|
|
17
|
+
else
|
|
18
|
+
@external_tasks = external_tasks_or_error
|
|
19
|
+
@error = nil
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def error?
|
|
24
|
+
!error.nil?
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Topic
|
|
7
|
+
module Impl
|
|
8
|
+
module Dto
|
|
9
|
+
# Mirrors org.operaton.bpm.client.topic.impl.dto.TopicRequestDto
|
|
10
|
+
class TopicRequestDto
|
|
11
|
+
attr_reader :topic_name, :lock_duration, :variables, :business_key
|
|
12
|
+
attr_accessor :local_variables, :process_definition_id, :process_definition_id_in,
|
|
13
|
+
:process_definition_key, :process_definition_key_in,
|
|
14
|
+
:process_definition_version_tag, :process_variables,
|
|
15
|
+
:without_tenant_id, :tenant_id_in, :include_extension_properties
|
|
16
|
+
|
|
17
|
+
def initialize(topic_name, lock_duration, variables, business_key)
|
|
18
|
+
@topic_name = topic_name
|
|
19
|
+
@lock_duration = lock_duration
|
|
20
|
+
@variables = variables
|
|
21
|
+
@business_key = business_key
|
|
22
|
+
@local_variables = false
|
|
23
|
+
@without_tenant_id = false
|
|
24
|
+
@include_extension_properties = false
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.from_topic_subscription(topic_subscription, client_lock_duration)
|
|
28
|
+
lock_duration = topic_subscription.lock_duration || client_lock_duration
|
|
29
|
+
|
|
30
|
+
dto = new(topic_subscription.topic_name, lock_duration,
|
|
31
|
+
topic_subscription.variable_names, topic_subscription.business_key)
|
|
32
|
+
|
|
33
|
+
dto.process_definition_id = topic_subscription.process_definition_id
|
|
34
|
+
dto.process_definition_id_in = topic_subscription.process_definition_id_in
|
|
35
|
+
dto.process_definition_key = topic_subscription.process_definition_key
|
|
36
|
+
dto.process_definition_key_in = topic_subscription.process_definition_key_in
|
|
37
|
+
dto.without_tenant_id = topic_subscription.without_tenant_id?
|
|
38
|
+
dto.tenant_id_in = topic_subscription.tenant_id_in
|
|
39
|
+
dto.process_definition_version_tag = topic_subscription.process_definition_version_tag
|
|
40
|
+
dto.process_variables = topic_subscription.process_variables
|
|
41
|
+
dto.local_variables = topic_subscription.local_variables?
|
|
42
|
+
dto.include_extension_properties = topic_subscription.include_extension_properties?
|
|
43
|
+
dto
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def as_json
|
|
47
|
+
{
|
|
48
|
+
"topicName" => topic_name,
|
|
49
|
+
"lockDuration" => lock_duration,
|
|
50
|
+
"variables" => variables,
|
|
51
|
+
"localVariables" => local_variables,
|
|
52
|
+
"businessKey" => business_key,
|
|
53
|
+
"processDefinitionId" => process_definition_id,
|
|
54
|
+
"processDefinitionIdIn" => process_definition_id_in,
|
|
55
|
+
"processDefinitionKey" => process_definition_key,
|
|
56
|
+
"processDefinitionKeyIn" => process_definition_key_in,
|
|
57
|
+
"processDefinitionVersionTag" => process_definition_version_tag,
|
|
58
|
+
"processVariables" => process_variables,
|
|
59
|
+
"withoutTenantId" => without_tenant_id,
|
|
60
|
+
"tenantIdIn" => tenant_id_in,
|
|
61
|
+
"includeExtensionProperties" => include_extension_properties
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../topic_subscription_builder"
|
|
4
|
+
require_relative "topic_subscription_impl"
|
|
5
|
+
require_relative "../../impl/external_task_client_logger"
|
|
6
|
+
|
|
7
|
+
module Operaton
|
|
8
|
+
module Bpm
|
|
9
|
+
module Client
|
|
10
|
+
module Topic
|
|
11
|
+
module Impl
|
|
12
|
+
# Mirrors org.operaton.bpm.client.topic.impl.TopicSubscriptionBuilderImpl
|
|
13
|
+
class TopicSubscriptionBuilderImpl
|
|
14
|
+
include TopicSubscriptionBuilder
|
|
15
|
+
|
|
16
|
+
def initialize(topic_name, topic_subscription_manager)
|
|
17
|
+
@topic_name = topic_name
|
|
18
|
+
# if not nil, no variables are retrieved by default
|
|
19
|
+
@variable_names = nil
|
|
20
|
+
@lock_duration = nil
|
|
21
|
+
@topic_subscription_manager = topic_subscription_manager
|
|
22
|
+
@local_variables = false
|
|
23
|
+
@business_key = nil
|
|
24
|
+
@process_definition_id = nil
|
|
25
|
+
@process_definition_ids = nil
|
|
26
|
+
@process_definition_key = nil
|
|
27
|
+
@process_definition_keys = nil
|
|
28
|
+
@process_definition_version_tag = nil
|
|
29
|
+
@process_variables = nil
|
|
30
|
+
@without_tenant_id = false
|
|
31
|
+
@tenant_ids = nil
|
|
32
|
+
@external_task_handler = nil
|
|
33
|
+
@include_extension_properties = false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def lock_duration(lock_duration)
|
|
37
|
+
@lock_duration = lock_duration
|
|
38
|
+
self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Accepts a handler object responding to #execute, any callable, or a block.
|
|
42
|
+
def handler(external_task_handler = nil, &block)
|
|
43
|
+
@external_task_handler = external_task_handler || block
|
|
44
|
+
self
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def variables(*variable_names)
|
|
48
|
+
ensure_not_nil(variable_names, "variableNames")
|
|
49
|
+
@variable_names = variable_names.flatten
|
|
50
|
+
self
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def local_variables(local_variables)
|
|
54
|
+
@local_variables = local_variables
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def business_key(business_key)
|
|
59
|
+
@business_key = business_key
|
|
60
|
+
self
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def process_definition_id(process_definition_id)
|
|
64
|
+
@process_definition_id = process_definition_id
|
|
65
|
+
self
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def process_definition_id_in(*process_definition_ids)
|
|
69
|
+
ensure_not_nil(process_definition_ids, "processDefinitionIds")
|
|
70
|
+
@process_definition_ids = process_definition_ids.flatten
|
|
71
|
+
self
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def process_definition_key(process_definition_key)
|
|
75
|
+
@process_definition_key = process_definition_key
|
|
76
|
+
self
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def process_definition_key_in(*process_definition_keys)
|
|
80
|
+
ensure_not_nil(process_definition_keys, "processDefinitionKeys")
|
|
81
|
+
@process_definition_keys = process_definition_keys.flatten
|
|
82
|
+
self
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def process_definition_version_tag(process_definition_version_tag)
|
|
86
|
+
ensure_not_nil(process_definition_version_tag, "processDefinitionVersionTag")
|
|
87
|
+
@process_definition_version_tag = process_definition_version_tag
|
|
88
|
+
self
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def process_variables_equals_in(process_variables)
|
|
92
|
+
ensure_not_nil(process_variables, "processVariables")
|
|
93
|
+
@process_variables ||= {}
|
|
94
|
+
process_variables.each do |name, value|
|
|
95
|
+
ensure_not_nil(name, "processVariableName")
|
|
96
|
+
@process_variables[name] = value
|
|
97
|
+
end
|
|
98
|
+
self
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def process_variable_equals(name, value)
|
|
102
|
+
ensure_not_nil(name, "processVariableName")
|
|
103
|
+
@process_variables ||= {}
|
|
104
|
+
@process_variables[name] = value
|
|
105
|
+
self
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def without_tenant_id
|
|
109
|
+
@without_tenant_id = true
|
|
110
|
+
self
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def tenant_id_in(*tenant_ids)
|
|
114
|
+
ensure_not_nil(tenant_ids, "tenantIds")
|
|
115
|
+
@tenant_ids = tenant_ids.flatten
|
|
116
|
+
self
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def include_extension_properties(include_extension_properties)
|
|
120
|
+
@include_extension_properties = include_extension_properties
|
|
121
|
+
self
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def open
|
|
125
|
+
raise logger.topic_name_null_exception if @topic_name.nil?
|
|
126
|
+
|
|
127
|
+
if !@lock_duration.nil? && @lock_duration <= 0
|
|
128
|
+
raise logger.lock_duration_is_not_greater_than_zero_exception(@lock_duration)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
raise logger.external_task_handler_null_exception if @external_task_handler.nil?
|
|
132
|
+
|
|
133
|
+
subscription = TopicSubscriptionImpl.new(@topic_name, @lock_duration, @external_task_handler,
|
|
134
|
+
@topic_subscription_manager, @variable_names, @business_key)
|
|
135
|
+
subscription.process_definition_id = @process_definition_id if @process_definition_id
|
|
136
|
+
subscription.process_definition_id_in = @process_definition_ids if @process_definition_ids
|
|
137
|
+
subscription.process_definition_key = @process_definition_key if @process_definition_key
|
|
138
|
+
subscription.process_definition_key_in = @process_definition_keys if @process_definition_keys
|
|
139
|
+
subscription.without_tenant_id = @without_tenant_id if @without_tenant_id
|
|
140
|
+
subscription.tenant_id_in = @tenant_ids if @tenant_ids
|
|
141
|
+
subscription.process_definition_version_tag = @process_definition_version_tag if @process_definition_version_tag
|
|
142
|
+
subscription.process_variables = @process_variables if @process_variables
|
|
143
|
+
subscription.local_variables = @local_variables if @local_variables
|
|
144
|
+
subscription.include_extension_properties = @include_extension_properties if @include_extension_properties
|
|
145
|
+
|
|
146
|
+
@topic_subscription_manager.subscribe(subscription)
|
|
147
|
+
subscription
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
protected
|
|
151
|
+
|
|
152
|
+
def ensure_not_nil(parameter, parameter_name)
|
|
153
|
+
raise logger.pass_null_value_parameter(parameter_name) if parameter.nil?
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def logger
|
|
157
|
+
Client::Impl::ExternalTaskClientLogger.client_logger
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|