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,153 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "value_type"
|
|
4
|
+
|
|
5
|
+
module Operaton
|
|
6
|
+
module Bpm
|
|
7
|
+
module Engine
|
|
8
|
+
module Variable
|
|
9
|
+
# Mirrors org.operaton.bpm.engine.variable.value.TypedValue
|
|
10
|
+
class TypedValue
|
|
11
|
+
attr_reader :value, :type
|
|
12
|
+
|
|
13
|
+
def initialize(value, type, is_transient = false)
|
|
14
|
+
@value = value
|
|
15
|
+
@type = type
|
|
16
|
+
@is_transient = is_transient
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def transient?
|
|
20
|
+
@is_transient
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attr_writer :is_transient
|
|
24
|
+
|
|
25
|
+
def to_s
|
|
26
|
+
"Value '#{value}' of type '#{type}', isTransient=#{transient?}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Mirrors org.operaton.bpm.engine.variable.value.PrimitiveValue
|
|
31
|
+
class PrimitiveTypeValue < TypedValue
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class BooleanValue < PrimitiveTypeValue
|
|
35
|
+
def initialize(value, is_transient = false)
|
|
36
|
+
super(value, ValueType::BOOLEAN, is_transient)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class StringValue < PrimitiveTypeValue
|
|
41
|
+
def initialize(value, is_transient = false)
|
|
42
|
+
super(value, ValueType::STRING, is_transient)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
class DateValue < PrimitiveTypeValue
|
|
47
|
+
def initialize(value, is_transient = false)
|
|
48
|
+
super(value, ValueType::DATE, is_transient)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
class BytesValue < PrimitiveTypeValue
|
|
53
|
+
def initialize(value, is_transient = false)
|
|
54
|
+
super(value, ValueType::BYTES, is_transient)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class IntegerValue < PrimitiveTypeValue
|
|
59
|
+
def initialize(value, is_transient = false)
|
|
60
|
+
super(value, ValueType::INTEGER, is_transient)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
class LongValue < PrimitiveTypeValue
|
|
65
|
+
def initialize(value, is_transient = false)
|
|
66
|
+
super(value, ValueType::LONG, is_transient)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class ShortValue < PrimitiveTypeValue
|
|
71
|
+
def initialize(value, is_transient = false)
|
|
72
|
+
super(value, ValueType::SHORT, is_transient)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
class DoubleValue < PrimitiveTypeValue
|
|
77
|
+
def initialize(value, is_transient = false)
|
|
78
|
+
super(value, ValueType::DOUBLE, is_transient)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Mirrors org.operaton.bpm.engine.variable.impl.value.UntypedValueImpl
|
|
83
|
+
class UntypedValue < TypedValue
|
|
84
|
+
def initialize(value, is_transient = false)
|
|
85
|
+
super(value, nil, is_transient)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Mirrors org.operaton.bpm.engine.variable.impl.value.NullValueImpl
|
|
90
|
+
class NullValue < TypedValue
|
|
91
|
+
def initialize(is_transient = false)
|
|
92
|
+
super(nil, ValueType::NULL, is_transient)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
INSTANCE = new
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Mirrors org.operaton.bpm.engine.variable.value.ObjectValue /
|
|
99
|
+
# SerializableValue semantics.
|
|
100
|
+
class ObjectValue < TypedValue
|
|
101
|
+
attr_accessor :object_type_name, :serialization_data_format, :serialized_value
|
|
102
|
+
|
|
103
|
+
def initialize(value, serialized_value = nil, serialization_data_format = nil,
|
|
104
|
+
object_type_name = nil, deserialized = true, is_transient = false)
|
|
105
|
+
super(value, ValueType::OBJECT, is_transient)
|
|
106
|
+
@serialized_value = serialized_value
|
|
107
|
+
@serialization_data_format = serialization_data_format
|
|
108
|
+
@object_type_name = object_type_name
|
|
109
|
+
@deserialized = deserialized
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def deserialized?
|
|
113
|
+
@deserialized
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def value_serialized
|
|
117
|
+
@serialized_value
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def value
|
|
121
|
+
unless deserialized?
|
|
122
|
+
raise Client::ValueMapperException,
|
|
123
|
+
"Object is not deserialized: call value_serialized instead"
|
|
124
|
+
end
|
|
125
|
+
@value
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def set_value(value) # rubocop:disable Naming/AccessorMethodName
|
|
129
|
+
@value = value
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Mirrors org.operaton.bpm.engine.variable.value.FileValue (FileValueImpl)
|
|
134
|
+
class FileValue < TypedValue
|
|
135
|
+
attr_accessor :filename, :mime_type, :encoding
|
|
136
|
+
|
|
137
|
+
def initialize(filename, byte_array = nil, is_transient = false)
|
|
138
|
+
super(byte_array, ValueType::FILE, is_transient)
|
|
139
|
+
@filename = filename
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def byte_array
|
|
143
|
+
@value
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def set_value(bytes) # rubocop:disable Naming/AccessorMethodName
|
|
147
|
+
@value = bytes
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Operaton
|
|
4
|
+
module Bpm
|
|
5
|
+
module Engine
|
|
6
|
+
module Variable
|
|
7
|
+
# Mirrors org.operaton.bpm.engine.variable.type.ValueType and its
|
|
8
|
+
# implementations, reduced to what the external task client needs.
|
|
9
|
+
class ValueType
|
|
10
|
+
attr_reader :name
|
|
11
|
+
|
|
12
|
+
def initialize(name)
|
|
13
|
+
@name = name
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def primitive_value_type?
|
|
17
|
+
false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def abstract?
|
|
21
|
+
false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Mirrors ValueType#getValueInfo(TypedValue)
|
|
25
|
+
def value_info(typed_value)
|
|
26
|
+
info = {}
|
|
27
|
+
info[VALUE_INFO_TRANSIENT] = true if typed_value.transient?
|
|
28
|
+
info
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_s
|
|
32
|
+
name
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
VALUE_INFO_TRANSIENT = "transient"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class PrimitiveValueType < ValueType
|
|
39
|
+
def initialize(name, &assignable)
|
|
40
|
+
super(name)
|
|
41
|
+
@assignable = assignable
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def primitive_value_type?
|
|
45
|
+
true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Mirrors PrimitiveValueType#getJavaType assignability checks.
|
|
49
|
+
def assignable?(value)
|
|
50
|
+
@assignable ? @assignable.call(value) : false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class NumberValueType < PrimitiveValueType
|
|
55
|
+
def abstract?
|
|
56
|
+
true
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class ObjectValueType < ValueType
|
|
61
|
+
VALUE_INFO_OBJECT_TYPE_NAME = "objectTypeName"
|
|
62
|
+
VALUE_INFO_SERIALIZATION_DATA_FORMAT = "serializationDataFormat"
|
|
63
|
+
|
|
64
|
+
def initialize
|
|
65
|
+
super("object")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def value_info(typed_value)
|
|
69
|
+
info = {}
|
|
70
|
+
if typed_value.object_type_name
|
|
71
|
+
info[VALUE_INFO_OBJECT_TYPE_NAME] = typed_value.object_type_name
|
|
72
|
+
end
|
|
73
|
+
if typed_value.serialization_data_format
|
|
74
|
+
info[VALUE_INFO_SERIALIZATION_DATA_FORMAT] = typed_value.serialization_data_format
|
|
75
|
+
end
|
|
76
|
+
info[VALUE_INFO_TRANSIENT] = true if typed_value.transient?
|
|
77
|
+
info
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class FileValueType < ValueType
|
|
82
|
+
VALUE_INFO_FILE_NAME = "filename"
|
|
83
|
+
VALUE_INFO_FILE_MIME_TYPE = "mimetype"
|
|
84
|
+
VALUE_INFO_FILE_ENCODING = "encoding"
|
|
85
|
+
|
|
86
|
+
def initialize
|
|
87
|
+
super("file")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def value_info(typed_value)
|
|
91
|
+
info = {}
|
|
92
|
+
info[VALUE_INFO_FILE_NAME] = typed_value.filename
|
|
93
|
+
info[VALUE_INFO_FILE_MIME_TYPE] = typed_value.mime_type if typed_value.mime_type
|
|
94
|
+
info[VALUE_INFO_FILE_ENCODING] = typed_value.encoding if typed_value.encoding
|
|
95
|
+
info[VALUE_INFO_TRANSIENT] = true if typed_value.transient?
|
|
96
|
+
info
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class ValueType
|
|
101
|
+
INTEGER_MIN = -2**31
|
|
102
|
+
INTEGER_MAX = 2**31 - 1
|
|
103
|
+
LONG_MIN = -2**63
|
|
104
|
+
LONG_MAX = 2**63 - 1
|
|
105
|
+
SHORT_MIN = -2**15
|
|
106
|
+
SHORT_MAX = 2**15 - 1
|
|
107
|
+
|
|
108
|
+
NULL = PrimitiveValueType.new("null") { |v| v.nil? }
|
|
109
|
+
BOOLEAN = PrimitiveValueType.new("boolean") { |v| v == true || v == false }
|
|
110
|
+
STRING = PrimitiveValueType.new("string") { |v| v.is_a?(String) }
|
|
111
|
+
DATE = PrimitiveValueType.new("date") do |v|
|
|
112
|
+
v.is_a?(Time) || (defined?(DateTime) && v.is_a?(DateTime)) || (defined?(::Date) && v.is_a?(::Date))
|
|
113
|
+
end
|
|
114
|
+
BYTES = PrimitiveValueType.new("bytes") { |v| v.is_a?(String) }
|
|
115
|
+
INTEGER = PrimitiveValueType.new("integer") { |v| v.is_a?(Integer) && v.between?(INTEGER_MIN, INTEGER_MAX) }
|
|
116
|
+
LONG = PrimitiveValueType.new("long") { |v| v.is_a?(Integer) && v.between?(LONG_MIN, LONG_MAX) }
|
|
117
|
+
SHORT = PrimitiveValueType.new("short") { |v| v.is_a?(Integer) && v.between?(SHORT_MIN, SHORT_MAX) }
|
|
118
|
+
DOUBLE = PrimitiveValueType.new("double") { |v| v.is_a?(Float) }
|
|
119
|
+
NUMBER = NumberValueType.new("number") { |v| v.is_a?(Numeric) }
|
|
120
|
+
OBJECT = ObjectValueType.new
|
|
121
|
+
FILE = FileValueType.new
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "typed_value"
|
|
4
|
+
|
|
5
|
+
module Operaton
|
|
6
|
+
module Bpm
|
|
7
|
+
module Engine
|
|
8
|
+
module Variable
|
|
9
|
+
# Mirrors org.operaton.bpm.engine.variable.VariableMap: a map of
|
|
10
|
+
# variable names to typed values, with untyped access convenience.
|
|
11
|
+
class VariableMap
|
|
12
|
+
include Enumerable
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@map = {}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Mirrors VariableMap#putValue
|
|
19
|
+
def put_value(name, value)
|
|
20
|
+
put_value_typed(name, Variables.untyped_value(value))
|
|
21
|
+
end
|
|
22
|
+
alias []= put_value
|
|
23
|
+
|
|
24
|
+
# Mirrors VariableMap#putValueTyped
|
|
25
|
+
def put_value_typed(name, typed_value)
|
|
26
|
+
@map[name] = typed_value
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Mirrors VariableMap#getValue (raw value access)
|
|
31
|
+
def get_value(name)
|
|
32
|
+
typed = @map[name]
|
|
33
|
+
typed&.value
|
|
34
|
+
end
|
|
35
|
+
alias [] get_value
|
|
36
|
+
|
|
37
|
+
# Mirrors VariableMap#getValueTyped
|
|
38
|
+
def get_value_typed(name)
|
|
39
|
+
@map[name]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def keys
|
|
43
|
+
@map.keys
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def key?(name)
|
|
47
|
+
@map.key?(name)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def size
|
|
51
|
+
@map.size
|
|
52
|
+
end
|
|
53
|
+
alias length size
|
|
54
|
+
|
|
55
|
+
def empty?
|
|
56
|
+
@map.empty?
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def each
|
|
60
|
+
return enum_for(:each) unless block_given?
|
|
61
|
+
|
|
62
|
+
@map.each_key { |name| yield name, get_value(name) }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def to_h
|
|
66
|
+
@map.keys.to_h { |name| [name, get_value(name)] }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "typed_value"
|
|
4
|
+
require_relative "variable_map"
|
|
5
|
+
|
|
6
|
+
module Operaton
|
|
7
|
+
module Bpm
|
|
8
|
+
module Engine
|
|
9
|
+
module Variable
|
|
10
|
+
# Factory methods mirroring org.operaton.bpm.engine.variable.Variables.
|
|
11
|
+
# Defined as a mixin so that Operaton::Bpm::Client::Variable::ClientValues
|
|
12
|
+
# can "extend" Variables like the Java class does.
|
|
13
|
+
module VariablesFactory
|
|
14
|
+
def create_variables
|
|
15
|
+
VariableMap.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def untyped_value(value, is_transient = false)
|
|
19
|
+
return value if value.is_a?(TypedValue)
|
|
20
|
+
|
|
21
|
+
UntypedValue.new(value, is_transient)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def untyped_null_value(is_transient = false)
|
|
25
|
+
UntypedValue.new(nil, is_transient)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def boolean_value(value, is_transient = false)
|
|
29
|
+
BooleanValue.new(value, is_transient)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def string_value(value, is_transient = false)
|
|
33
|
+
StringValue.new(value, is_transient)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def date_value(value, is_transient = false)
|
|
37
|
+
DateValue.new(value, is_transient)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def byte_array_value(value, is_transient = false)
|
|
41
|
+
BytesValue.new(value, is_transient)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def integer_value(value, is_transient = false)
|
|
45
|
+
IntegerValue.new(value, is_transient)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def long_value(value, is_transient = false)
|
|
49
|
+
LongValue.new(value, is_transient)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def short_value(value, is_transient = false)
|
|
53
|
+
ShortValue.new(value, is_transient)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def double_value(value, is_transient = false)
|
|
57
|
+
DoubleValue.new(value, is_transient)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Mirrors Variables.objectValue(value) which returns an ObjectValueBuilder
|
|
61
|
+
def object_value(value, is_transient = false)
|
|
62
|
+
ObjectValueBuilder.new(value, is_transient)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Mirrors Variables.serializedObjectValue(...)
|
|
66
|
+
def serialized_object_value(serialized_value = nil)
|
|
67
|
+
SerializedObjectValueBuilder.new(serialized_value)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Mirrors Variables.fileValue(filename) which returns a FileValueBuilder
|
|
71
|
+
def file_value(filename)
|
|
72
|
+
FileValueBuilder.new(filename)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
module Variables
|
|
77
|
+
extend VariablesFactory
|
|
78
|
+
|
|
79
|
+
# Mirrors Variables.SerializationDataFormats
|
|
80
|
+
module SerializationDataFormats
|
|
81
|
+
JAVA = "application/x-java-serialized-object"
|
|
82
|
+
JSON = "application/json"
|
|
83
|
+
XML = "application/xml"
|
|
84
|
+
|
|
85
|
+
def self.json
|
|
86
|
+
JSON
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Mirrors org.operaton.bpm.engine.variable.value.builder.ObjectValueBuilder
|
|
92
|
+
class ObjectValueBuilder
|
|
93
|
+
def initialize(value, is_transient = false)
|
|
94
|
+
@value = value
|
|
95
|
+
@is_transient = is_transient
|
|
96
|
+
@serialization_data_format = nil
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def serialization_data_format(format)
|
|
100
|
+
@serialization_data_format = format
|
|
101
|
+
self
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def set_transient(is_transient) # rubocop:disable Naming/AccessorMethodName
|
|
105
|
+
@is_transient = is_transient
|
|
106
|
+
self
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def create
|
|
110
|
+
ObjectValue.new(@value, nil, @serialization_data_format, nil, true, @is_transient)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Mirrors org.operaton.bpm.engine.variable.value.builder.SerializedObjectValueBuilder
|
|
115
|
+
class SerializedObjectValueBuilder
|
|
116
|
+
def initialize(serialized_value = nil)
|
|
117
|
+
@serialized_value = serialized_value
|
|
118
|
+
@serialization_data_format = nil
|
|
119
|
+
@object_type_name = nil
|
|
120
|
+
@is_transient = false
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def serialized_value(value)
|
|
124
|
+
@serialized_value = value
|
|
125
|
+
self
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def serialization_data_format(format)
|
|
129
|
+
@serialization_data_format = format
|
|
130
|
+
self
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def object_type_name(name)
|
|
134
|
+
@object_type_name = name
|
|
135
|
+
self
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def set_transient(is_transient) # rubocop:disable Naming/AccessorMethodName
|
|
139
|
+
@is_transient = is_transient
|
|
140
|
+
self
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def create
|
|
144
|
+
ObjectValue.new(nil, @serialized_value, @serialization_data_format,
|
|
145
|
+
@object_type_name, false, @is_transient)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Mirrors org.operaton.bpm.engine.variable.value.builder.FileValueBuilder
|
|
150
|
+
class FileValueBuilder
|
|
151
|
+
def initialize(filename)
|
|
152
|
+
@filename = filename
|
|
153
|
+
@bytes = nil
|
|
154
|
+
@mime_type = nil
|
|
155
|
+
@encoding = nil
|
|
156
|
+
@is_transient = false
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Accepts a byte string, an IO, or a file path.
|
|
160
|
+
def file(file)
|
|
161
|
+
@bytes =
|
|
162
|
+
if file.respond_to?(:read)
|
|
163
|
+
file.read
|
|
164
|
+
elsif file.is_a?(String) && !file.include?("\0") && ::File.file?(file)
|
|
165
|
+
::File.binread(file)
|
|
166
|
+
else
|
|
167
|
+
file
|
|
168
|
+
end
|
|
169
|
+
self
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def mime_type(mime_type)
|
|
173
|
+
@mime_type = mime_type
|
|
174
|
+
self
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def encoding(encoding)
|
|
178
|
+
@encoding = encoding
|
|
179
|
+
self
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def set_transient(is_transient) # rubocop:disable Naming/AccessorMethodName
|
|
183
|
+
@is_transient = is_transient
|
|
184
|
+
self
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def create
|
|
188
|
+
value = FileValue.new(@filename, @bytes, @is_transient)
|
|
189
|
+
value.mime_type = @mime_type
|
|
190
|
+
value.encoding = @encoding
|
|
191
|
+
value
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|