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,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Impl
|
|
7
|
+
# Mirrors org.operaton.bpm.client.impl.RequestDto
|
|
8
|
+
class RequestDto
|
|
9
|
+
attr_reader :worker_id
|
|
10
|
+
|
|
11
|
+
def initialize(worker_id)
|
|
12
|
+
@worker_id = worker_id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Subclasses add their fields; nil values are omitted from the JSON
|
|
16
|
+
# payload (Jackson NON_NULL semantics where the Java DTO uses them).
|
|
17
|
+
def as_json
|
|
18
|
+
{ "workerId" => worker_id }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
require "openssl"
|
|
6
|
+
require "timeout"
|
|
7
|
+
|
|
8
|
+
require_relative "external_task_client_logger"
|
|
9
|
+
require_relative "engine_client_logger"
|
|
10
|
+
require_relative "engine_client_exception"
|
|
11
|
+
require_relative "engine_rest_exception_dto"
|
|
12
|
+
require_relative "object_mapper"
|
|
13
|
+
|
|
14
|
+
module Operaton
|
|
15
|
+
module Bpm
|
|
16
|
+
module Client
|
|
17
|
+
module Impl
|
|
18
|
+
# Mirrors org.operaton.bpm.client.impl.RequestExecutor, built on
|
|
19
|
+
# Net::HTTP instead of Apache HttpClient.
|
|
20
|
+
class RequestExecutor
|
|
21
|
+
HEADER_CONTENT_TYPE_JSON = ["Content-Type", "application/json"].freeze
|
|
22
|
+
HEADER_USER_AGENT = ["User-Agent", "Operaton External Task Client"].freeze
|
|
23
|
+
|
|
24
|
+
# Sentinels standing in for the Java response-class parameters
|
|
25
|
+
VOID = :void
|
|
26
|
+
BYTES = :bytes
|
|
27
|
+
|
|
28
|
+
def initialize(object_mapper, interceptor_handler: nil, http_customizer: nil, read_timeout: 60)
|
|
29
|
+
@object_mapper = object_mapper
|
|
30
|
+
@interceptor_handler = interceptor_handler
|
|
31
|
+
@http_customizer = http_customizer
|
|
32
|
+
@read_timeout = read_timeout
|
|
33
|
+
@logger = ExternalTaskClientLogger.engine_client_logger
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# response_type: VOID, BYTES, or a class/array responding to .from_json.
|
|
37
|
+
# Passing [SomeDto] deserializes a JSON array into a list of DTOs.
|
|
38
|
+
def post_request(resource_url, request_dto, response_type)
|
|
39
|
+
body = serialize_request(request_dto)
|
|
40
|
+
uri = URI(resource_url)
|
|
41
|
+
|
|
42
|
+
request = Net::HTTP::Post.new(uri)
|
|
43
|
+
request[HEADER_USER_AGENT[0]] = HEADER_USER_AGENT[1]
|
|
44
|
+
request[HEADER_CONTENT_TYPE_JSON[0]] = HEADER_CONTENT_TYPE_JSON[1]
|
|
45
|
+
request.body = body
|
|
46
|
+
|
|
47
|
+
execute_request(uri, request, response_type)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def get_request(resource_url)
|
|
51
|
+
uri = URI(resource_url)
|
|
52
|
+
|
|
53
|
+
request = Net::HTTP::Get.new(uri)
|
|
54
|
+
request[HEADER_USER_AGENT[0]] = HEADER_USER_AGENT[1]
|
|
55
|
+
request[HEADER_CONTENT_TYPE_JSON[0]] = HEADER_CONTENT_TYPE_JSON[1]
|
|
56
|
+
|
|
57
|
+
execute_request(uri, request, BYTES)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
protected
|
|
61
|
+
|
|
62
|
+
def execute_request(uri, request, response_type)
|
|
63
|
+
@interceptor_handler&.process(request)
|
|
64
|
+
|
|
65
|
+
response = perform_http_request(uri, request)
|
|
66
|
+
handle_response(request, response, response_type)
|
|
67
|
+
rescue RestException => e
|
|
68
|
+
raise @logger.exception_while_receiving_response(describe(request), e)
|
|
69
|
+
rescue IOError, SystemCallError, SocketError, Timeout::Error,
|
|
70
|
+
OpenSSL::SSL::SSLError, Net::OpenTimeout, Net::ReadTimeout => e
|
|
71
|
+
raise @logger.exception_while_establishing_connection(describe(request), e)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def perform_http_request(uri, request)
|
|
75
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
76
|
+
http.use_ssl = uri.scheme == "https"
|
|
77
|
+
http.read_timeout = @read_timeout
|
|
78
|
+
@http_customizer&.call(http)
|
|
79
|
+
http.start { |conn| conn.request(request) }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def handle_response(request, response, response_type)
|
|
83
|
+
status = response.code.to_i
|
|
84
|
+
|
|
85
|
+
if status >= 300
|
|
86
|
+
engine_exception = deserialize_error(response).to_rest_exception
|
|
87
|
+
engine_exception.http_status_code = status
|
|
88
|
+
raise engine_exception
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
return nil if response_type == VOID
|
|
92
|
+
return response.body if response_type == BYTES
|
|
93
|
+
return nil if response.body.nil? || response.body.empty?
|
|
94
|
+
|
|
95
|
+
deserialize_response(response.body, response_type)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def deserialize_error(response)
|
|
99
|
+
EngineRestExceptionDto.from_json(@object_mapper.read_value(response.body.to_s))
|
|
100
|
+
rescue StandardError
|
|
101
|
+
dto = EngineRestExceptionDto.new
|
|
102
|
+
dto.message = response.body.to_s
|
|
103
|
+
dto
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def deserialize_response(body, response_type)
|
|
107
|
+
parsed =
|
|
108
|
+
begin
|
|
109
|
+
@object_mapper.read_value(body)
|
|
110
|
+
rescue JSON::ParserError => e
|
|
111
|
+
raise @logger.exception_while_parsing_json_object(response_type, e)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
begin
|
|
115
|
+
if response_type.is_a?(Array)
|
|
116
|
+
item_type = response_type.first
|
|
117
|
+
parsed.map { |item| item_type.from_json(item, @object_mapper) }
|
|
118
|
+
elsif response_type.respond_to?(:from_json)
|
|
119
|
+
response_type.from_json(parsed, @object_mapper)
|
|
120
|
+
else
|
|
121
|
+
parsed
|
|
122
|
+
end
|
|
123
|
+
rescue StandardError => e
|
|
124
|
+
raise @logger.exception_while_mapping_json_object(response_type, e)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def serialize_request(request_dto)
|
|
129
|
+
return nil if request_dto.nil?
|
|
130
|
+
|
|
131
|
+
@object_mapper.write_value_as_string(request_dto.as_json)
|
|
132
|
+
rescue StandardError => e
|
|
133
|
+
raise @logger.exception_while_serializing_json_object(request_dto, e)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def describe(request)
|
|
137
|
+
"#{request.method} #{request.uri}"
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "base64"
|
|
4
|
+
require_relative "../client_request_interceptor"
|
|
5
|
+
require_relative "../../impl/external_task_client_logger"
|
|
6
|
+
|
|
7
|
+
module Operaton
|
|
8
|
+
module Bpm
|
|
9
|
+
module Client
|
|
10
|
+
module Interceptor
|
|
11
|
+
module Auth
|
|
12
|
+
# Mirrors org.operaton.bpm.client.interceptor.auth.BasicAuthProvider
|
|
13
|
+
class BasicAuthProvider
|
|
14
|
+
include ClientRequestInterceptor
|
|
15
|
+
|
|
16
|
+
AUTHORIZATION = "Authorization"
|
|
17
|
+
|
|
18
|
+
def initialize(username, password)
|
|
19
|
+
if username.nil? || password.nil?
|
|
20
|
+
raise Client::Impl::ExternalTaskClientLogger.client_logger.basic_auth_credentials_null_exception
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
@username = username
|
|
24
|
+
@password = password
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def intercept(request_context)
|
|
28
|
+
auth_token = "#{@username}:#{@password}"
|
|
29
|
+
request_context.add_header(AUTHORIZATION, "Basic #{encode_to_base64(auth_token)}")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
def encode_to_base64(decoded_string)
|
|
35
|
+
Base64.strict_encode64(decoded_string)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Interceptor
|
|
7
|
+
# Mirrors org.operaton.bpm.client.interceptor.ClientRequestContext
|
|
8
|
+
module ClientRequestContext
|
|
9
|
+
def add_header(name, value)
|
|
10
|
+
raise NotImplementedError, "#{self.class} must implement #add_header"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Interceptor
|
|
7
|
+
# Mirrors org.operaton.bpm.client.interceptor.ClientRequestInterceptor
|
|
8
|
+
# (a functional interface in Java). Any object responding to
|
|
9
|
+
# #intercept(request_context) — including a Proc via #to_proc — works.
|
|
10
|
+
module ClientRequestInterceptor
|
|
11
|
+
def intercept(request_context)
|
|
12
|
+
raise NotImplementedError, "#{self.class} must implement #intercept"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../client_request_context"
|
|
4
|
+
|
|
5
|
+
module Operaton
|
|
6
|
+
module Bpm
|
|
7
|
+
module Client
|
|
8
|
+
module Interceptor
|
|
9
|
+
module Impl
|
|
10
|
+
# Mirrors org.operaton.bpm.client.interceptor.impl.ClientRequestContextImpl
|
|
11
|
+
class ClientRequestContextImpl
|
|
12
|
+
include ClientRequestContext
|
|
13
|
+
|
|
14
|
+
attr_reader :headers
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
@headers = {}
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add_header(name, value)
|
|
21
|
+
@headers[name] = value
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "client_request_context_impl"
|
|
4
|
+
require_relative "../../impl/external_task_client_logger"
|
|
5
|
+
|
|
6
|
+
module Operaton
|
|
7
|
+
module Bpm
|
|
8
|
+
module Client
|
|
9
|
+
module Interceptor
|
|
10
|
+
module Impl
|
|
11
|
+
# Mirrors org.operaton.bpm.client.interceptor.impl.RequestInterceptorHandler.
|
|
12
|
+
# Applied to every outgoing HTTP request by the RequestExecutor.
|
|
13
|
+
class RequestInterceptorHandler
|
|
14
|
+
attr_reader :interceptors
|
|
15
|
+
|
|
16
|
+
def initialize(interceptors)
|
|
17
|
+
@interceptors = interceptors
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# http_request is a Net::HTTPRequest; interceptor headers are added to it.
|
|
21
|
+
def process(http_request)
|
|
22
|
+
intercepted_request = ClientRequestContextImpl.new
|
|
23
|
+
|
|
24
|
+
interceptors.each do |request_interceptor|
|
|
25
|
+
if request_interceptor.respond_to?(:intercept)
|
|
26
|
+
request_interceptor.intercept(intercepted_request)
|
|
27
|
+
else
|
|
28
|
+
request_interceptor.call(intercepted_request)
|
|
29
|
+
end
|
|
30
|
+
rescue StandardError => e
|
|
31
|
+
Client::Impl::ExternalTaskClientLogger.engine_client_logger.request_interceptor_exception(e)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
intercepted_request.headers.each do |name, value|
|
|
35
|
+
http_request[name] = value
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Spi
|
|
7
|
+
# Mirrors org.operaton.bpm.client.spi.DataFormat
|
|
8
|
+
module DataFormat
|
|
9
|
+
def name
|
|
10
|
+
raise NotImplementedError
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def can_map(value)
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def write_value(value)
|
|
18
|
+
raise NotImplementedError
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def read_value(value, type_identifier_or_class)
|
|
22
|
+
raise NotImplementedError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def canonical_type_name(value)
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Spi
|
|
7
|
+
# Mirrors org.operaton.bpm.client.spi.DataFormatConfigurator. Where
|
|
8
|
+
# Java uses java.util.ServiceLoader, configurators register themselves here.
|
|
9
|
+
module DataFormatConfigurator
|
|
10
|
+
class << self
|
|
11
|
+
def register(configurator)
|
|
12
|
+
configurators << configurator
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def configurators
|
|
16
|
+
@configurators ||= []
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def data_format_class
|
|
21
|
+
raise NotImplementedError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def configure(data_format)
|
|
25
|
+
raise NotImplementedError
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Client
|
|
6
|
+
module Spi
|
|
7
|
+
# Mirrors org.operaton.bpm.client.spi.DataFormatProvider. Where Java
|
|
8
|
+
# uses java.util.ServiceLoader, providers register themselves here.
|
|
9
|
+
module DataFormatProvider
|
|
10
|
+
class << self
|
|
11
|
+
def register(provider)
|
|
12
|
+
providers << provider
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def providers
|
|
16
|
+
@providers ||= []
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def data_format_name
|
|
21
|
+
raise NotImplementedError
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create_instance
|
|
25
|
+
raise NotImplementedError
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
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.ExternalTask. Documents the
|
|
8
|
+
# contract implemented by Task::Impl::ExternalTaskImpl.
|
|
9
|
+
module ExternalTask
|
|
10
|
+
INTERFACE_METHODS = %i[
|
|
11
|
+
activity_id activity_instance_id error_message error_details
|
|
12
|
+
execution_id id lock_expiration_time create_time
|
|
13
|
+
process_definition_id process_definition_key process_definition_version_tag
|
|
14
|
+
process_instance_id retries worker_id topic_name tenant_id priority
|
|
15
|
+
variable variable_typed all_variables all_variables_typed
|
|
16
|
+
business_key extension_property extension_properties
|
|
17
|
+
].freeze
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
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.ExternalTaskHandler, a
|
|
8
|
+
# functional interface. Handlers may be any object responding to
|
|
9
|
+
# #execute(external_task, external_task_service) or any callable
|
|
10
|
+
# (Proc/lambda) taking the same two arguments.
|
|
11
|
+
module ExternalTaskHandler
|
|
12
|
+
def execute(external_task, external_task_service)
|
|
13
|
+
raise NotImplementedError, "#{self.class} must implement #execute"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Invokes a handler regardless of which convention it follows.
|
|
17
|
+
def self.invoke(handler, external_task, external_task_service)
|
|
18
|
+
if handler.respond_to?(:execute)
|
|
19
|
+
handler.execute(external_task, external_task_service)
|
|
20
|
+
else
|
|
21
|
+
handler.call(external_task, external_task_service)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
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.ExternalTaskService. The Java
|
|
8
|
+
# overloads accepting either an ExternalTask or an id are collapsed
|
|
9
|
+
# into single Ruby methods that accept either.
|
|
10
|
+
module ExternalTaskService
|
|
11
|
+
INTERFACE_METHODS = %i[
|
|
12
|
+
lock unlock complete set_variables handle_failure handle_bpmn_error extend_lock
|
|
13
|
+
].freeze
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
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.BpmnErrorRequestDto
|
|
12
|
+
class BpmnErrorRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :error_code, :error_message, :variables
|
|
14
|
+
|
|
15
|
+
def initialize(worker_id, error_code, error_message = nil, variables = nil)
|
|
16
|
+
super(worker_id)
|
|
17
|
+
@error_code = error_code
|
|
18
|
+
@error_message = error_message
|
|
19
|
+
@variables = variables
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def as_json
|
|
23
|
+
super.merge(
|
|
24
|
+
"errorCode" => error_code,
|
|
25
|
+
"errorMessage" => error_message,
|
|
26
|
+
"variables" => variables&.transform_values(&:as_json)
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
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.CompleteRequestDto
|
|
12
|
+
class CompleteRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :variables, :local_variables
|
|
14
|
+
|
|
15
|
+
def initialize(worker_id, variables, local_variables)
|
|
16
|
+
super(worker_id)
|
|
17
|
+
@variables = variables
|
|
18
|
+
@local_variables = local_variables
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def as_json
|
|
22
|
+
super.merge(
|
|
23
|
+
"variables" => variables&.transform_values(&:as_json),
|
|
24
|
+
"localVariables" => local_variables&.transform_values(&:as_json)
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -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.ExtendLockRequestDto
|
|
12
|
+
class ExtendLockRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :new_duration
|
|
14
|
+
|
|
15
|
+
def initialize(worker_id, new_duration)
|
|
16
|
+
super(worker_id)
|
|
17
|
+
@new_duration = new_duration
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def as_json
|
|
21
|
+
super.merge("newDuration" => new_duration)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
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.FailureRequestDto
|
|
12
|
+
class FailureRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :error_message, :error_details, :retries, :retry_timeout,
|
|
14
|
+
:variables, :local_variables
|
|
15
|
+
|
|
16
|
+
def initialize(worker_id, error_message, error_details, retries, retry_timeout,
|
|
17
|
+
variables = nil, local_variables = nil)
|
|
18
|
+
super(worker_id)
|
|
19
|
+
@error_message = error_message
|
|
20
|
+
@error_details = error_details
|
|
21
|
+
@retries = retries
|
|
22
|
+
@retry_timeout = retry_timeout
|
|
23
|
+
@variables = variables
|
|
24
|
+
@local_variables = local_variables
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def as_json
|
|
28
|
+
super.merge(
|
|
29
|
+
"errorMessage" => error_message,
|
|
30
|
+
"errorDetails" => error_details,
|
|
31
|
+
"retries" => retries,
|
|
32
|
+
"retryTimeout" => retry_timeout,
|
|
33
|
+
"variables" => variables&.transform_values(&:as_json),
|
|
34
|
+
"localVariables" => local_variables&.transform_values(&:as_json)
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -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.LockRequestDto
|
|
12
|
+
class LockRequestDto < Client::Impl::RequestDto
|
|
13
|
+
attr_reader :lock_duration
|
|
14
|
+
|
|
15
|
+
def initialize(worker_id, lock_duration)
|
|
16
|
+
super(worker_id)
|
|
17
|
+
@lock_duration = lock_duration
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def as_json
|
|
21
|
+
super.merge("lockDuration" => lock_duration)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|