Skip to content

Commit

Permalink
feat(#358): support List<Map<*,*>> variable factory
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiikkkkaa committed Jan 19, 2024
1 parent d71245e commit 17654b5
Show file tree
Hide file tree
Showing 11 changed files with 640 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ object CamundaBpmData {
return ListVariableFactory(variableName, clazz)
}

/**
* Creates a variable factory for list of custom type.
*
* @param variableName name of the variable.
* @param keyClazz class of specifying the key type.
* @param valueClazz class of specifying the value type.
* @param <K> factory key type.
* @param <V> factory value type.
* @return variable factory for given type.
</T> */
@JvmStatic
fun <K, V> listOfMapsVariable(variableName: String, keyClazz: Class<K>, valueClazz: Class<V>): VariableFactory<List<Map<K, V>>> {
return ListOfMapsVariableFactory(variableName, keyClazz, valueClazz)
}

/**
* Creates a variable factory for set of custom type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ abstract class AbstractListReadWriteAdapter<T>(variableName: String, protected v
@Suppress("UNCHECKED_CAST")
valueAsList as List<T>
} else {
throw WrongVariableTypeException("Error reading " + variableName + ": Wrong list type detected, expected " + memberClazz.name + ", but was not found in " + valueAsList)
throw WrongVariableTypeException(
"Error reading $variableName: Wrong list type detected, expected ${memberClazz.name}, but was not found in $valueAsList"
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import io.holunda.camunda.bpm.data.adapter.AbstractReadWriteAdapter
import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue
import io.holunda.camunda.bpm.data.adapter.WrongVariableTypeException
import org.camunda.bpm.engine.variable.value.TypedValue

/**
* Base class for all list of maps read-write adapter.
*
* @param [K] key type.
* @param [V] value type.
* @param variableName name of variable.
* @param keyClazz key class.
* @param valueClazz value class.
*/
abstract class AbstractListOfMapsReadWriteAdapter<K, V>(
variableName: String,
protected val keyClazz: Class<K>,
protected val valueClazz: Class<V>
) : AbstractReadWriteAdapter<List<Map<K, V>>>(variableName) {
/**
* Read the value of null.
*
* @param value raw value.
* @return list or null.
*/
protected fun getOrNull(value: Any?): List<Map<K, V>>? {
if (value == null) {
return null

Check warning on line 30 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L30

Added line #L30 was not covered by tests
}
if (MutableList::class.java.isAssignableFrom(value.javaClass)) {
val valueAsList = value as List<*>

Check warning on line 33 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L33

Added line #L33 was not covered by tests
return if (valueAsList.isEmpty()) {
emptyList()

Check warning on line 35 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L35

Added line #L35 was not covered by tests
} else {
if (MutableMap::class.java.isAssignableFrom(value.javaClass)) {
val valueAsMap = valueAsList.iterator().next() as Map<*, *>
val (key, value1) = valueAsMap.entries.iterator().next()

Check warning on line 39 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L38-L39

Added lines #L38 - L39 were not covered by tests
if (keyClazz.isAssignableFrom(key!!.javaClass) &&
valueClazz.isAssignableFrom(value1!!.javaClass)) {
@Suppress("UNCHECKED_CAST")
valueAsList as List<Map<K, V>>

Check warning on line 43 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L43

Added line #L43 was not covered by tests
} else {
throw WrongVariableTypeException(
"Error reading " + variableName + ": Wrong map type detected, expected Map<"
+ keyClazz.name + "," + valueClazz.name
+ ", but was not found in " + valueAsMap

Check warning on line 48 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L45-L48

Added lines #L45 - L48 were not covered by tests
)
}
} else {
throw WrongVariableTypeException(
"Error reading $variableName: Wrong list type detected, expected mutable list, but was not found in $valueAsList")

Check warning on line 53 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L52-L53

Added lines #L52 - L53 were not covered by tests
}
}
}
throw WrongVariableTypeException(
"Error reading $variableName: Couldn't read value of type List of Maps from $value")

Check warning on line 58 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L57-L58

Added lines #L57 - L58 were not covered by tests
}

override fun getTypedValue(value: Any?, isTransient: Boolean): TypedValue {
return getTypedValue(MutableList::class.java, value, isTransient)

Check warning on line 62 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L62

Added line #L62 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import org.camunda.bpm.engine.externaltask.LockedExternalTask
import org.camunda.bpm.engine.variable.Variables
import java.util.*
import kotlin.collections.Map

/**
* Read adapter for external task.
*
* @param [K] key type.
* @param [V] value type.
*/
class ListOfMapsReadAdapterLockedExternalTask<K, V>(
private val lockedExternalTask: LockedExternalTask,

Check warning on line 15 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L14-L15

Added lines #L14 - L15 were not covered by tests
variableName: String,
keyClazz: Class<K>,
valueClazz: Class<V>
) : AbstractListOfMapsReadWriteAdapter<K, V>(variableName, keyClazz, valueClazz) {

Check warning on line 19 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L19

Added line #L19 was not covered by tests

private val value: Any?
get() = Optional.ofNullable(lockedExternalTask.variables)
.orElse(Variables.createVariables())[variableName]

Check warning on line 23 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L22-L23

Added lines #L22 - L23 were not covered by tests

override fun getOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(
getOrNull(
value

Check warning on line 28 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L26-L28

Added lines #L26 - L28 were not covered by tests
)
)
}

override fun set(value: List<Map<K, V>>, isTransient: Boolean) {
throw UnsupportedOperationException("Can't set a variable on an external task")

Check warning on line 34 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L34

Added line #L34 was not covered by tests
}

override fun setLocal(value: List<Map<K, V>>, isTransient: Boolean) {
throw UnsupportedOperationException("Can't set a local variable on an external task")

Check warning on line 38 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L38

Added line #L38 was not covered by tests
}

override fun getLocal(): List<Map<K, V>> {
throw UnsupportedOperationException("Can't get a local variable on an external task")

Check warning on line 42 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L42

Added line #L42 was not covered by tests
}

override fun getLocalOptional(): Optional<List<Map<K, V>>> {
throw UnsupportedOperationException("Can't get a local variable on an external task")

Check warning on line 46 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L46

Added line #L46 was not covered by tests
}

override fun getLocalOrDefault(defaultValue: List<Map<K, V>>): List<Map<K, V>> {
throw UnsupportedOperationException("Can't get a local variable on an external task")

Check warning on line 50 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L50

Added line #L50 was not covered by tests
}

override fun getLocalOrNull(): List<Map<K, V>> {
throw UnsupportedOperationException("Can't get a local variable on an external task")

Check warning on line 54 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L54

Added line #L54 was not covered by tests
}

override fun remove() {
throw UnsupportedOperationException("Can't remove a variable on an external task")

Check warning on line 58 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L58

Added line #L58 was not covered by tests
}

override fun removeLocal() {
throw UnsupportedOperationException("Can't remove a local variable on an external task")

Check warning on line 62 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L62

Added line #L62 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue
import org.camunda.bpm.engine.CaseService
import java.util.*

/**
* Read write adapter for case service access.
*
* @param [K] key type.
* @param [V] value type.
* @param caseService case service to use.
* @param caseExecutionId id of the execution to read from and write to.
* @param variableName name of the variable.
* @param keyClazz key class.
* @param valueClazz value class.
*/
class ListOfMapsReadWriteAdapterCaseService<K, V>(
private val caseService: CaseService,
private val caseExecutionId: String,
variableName: String,
keyClazz: Class<K>,
valueClazz: Class<V>
) : AbstractListOfMapsReadWriteAdapter<K, V>(variableName, keyClazz, valueClazz) {

override fun getOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(
getOrNull(
caseService.getVariable(
caseExecutionId, variableName

Check warning on line 30 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L27-L30

Added lines #L27 - L30 were not covered by tests
)
)
)
}

override fun set(value: List<Map<K, V>>, isTransient: Boolean) {
caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 38 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L37-L38

Added lines #L37 - L38 were not covered by tests

override fun getLocalOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(
getOrNull(
caseService.getVariableLocal(
caseExecutionId, variableName

Check warning on line 44 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L41-L44

Added lines #L41 - L44 were not covered by tests
)
)
)
}

override fun setLocal(value: List<Map<K, V>>, isTransient: Boolean) {
caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 52 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L51-L52

Added lines #L51 - L52 were not covered by tests

override fun remove() {
caseService.removeVariable(caseExecutionId, variableName)
}

Check warning on line 56 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L55-L56

Added lines #L55 - L56 were not covered by tests

override fun removeLocal() {
caseService.removeVariableLocal(caseExecutionId, variableName)
}

Check warning on line 60 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L59-L60

Added lines #L59 - L60 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import java.util.*
import org.camunda.bpm.engine.RuntimeService

/**
* Read write adapter for runtime service access.
*
* @param [K] key type.
* @param [V] value type.
* @param runtimeService runtime service to use.
* @param executionId id of the execution to read from and write to.
* @param variableName name of the variable.
* @param keyClazz key class.
* @param valueClazz value class.
*/
class ListOfMapsReadWriteAdapterRuntimeService<K, V>(
private val runtimeService: RuntimeService,
private val executionId: String,
variableName: String,
keyClazz: Class<K>,
valueClazz: Class<V>
) : AbstractListOfMapsReadWriteAdapter<K, V>(variableName, keyClazz, valueClazz) {

override fun getOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName)))

Check warning on line 26 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L26

Added line #L26 was not covered by tests
}

override fun set(value: List<Map<K, V>>, isTransient: Boolean) {
runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 31 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L30-L31

Added lines #L30 - L31 were not covered by tests

override fun getLocalOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(
getOrNull(runtimeService.getVariableLocal(executionId, variableName)))

Check warning on line 35 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L34-L35

Added lines #L34 - L35 were not covered by tests
}

override fun setLocal(value: List<Map<K, V>>, isTransient: Boolean) {
runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 40 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L39-L40

Added lines #L39 - L40 were not covered by tests

override fun remove() {
runtimeService.removeVariable(executionId, variableName)
}

Check warning on line 44 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L43-L44

Added lines #L43 - L44 were not covered by tests

override fun removeLocal() {
runtimeService.removeVariableLocal(executionId, variableName)
}

Check warning on line 48 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L47-L48

Added lines #L47 - L48 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import org.camunda.bpm.engine.TaskService
import java.util.*

/**
* Read write adapter for task service access.
*
* @param [K] key type.
* @param [V] value type.
* @param taskService task service to use.
* @param taskId id of the task to read from and write to.
* @param variableName name of the variable.
* @param keyClazz key class.
* @param valueClazz value class.
*/
class ListOfMapsReadWriteAdapterTaskService<K, V>(
private val taskService: TaskService,
private val taskId: String,
variableName: String,
keyClazz: Class<K>,
valueClazz: Class<V>
) : AbstractListOfMapsReadWriteAdapter<K, V>(variableName, keyClazz, valueClazz) {

override fun getOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName)))

Check warning on line 26 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L26

Added line #L26 was not covered by tests
}

override fun set(value: List<Map<K, V>>, isTransient: Boolean) {
taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 31 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L30-L31

Added lines #L30 - L31 were not covered by tests

override fun getLocalOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName)))

Check warning on line 34 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L34

Added line #L34 was not covered by tests
}

override fun setLocal(value: List<Map<K, V>>, isTransient: Boolean) {
taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient))
}

Check warning on line 39 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L38-L39

Added lines #L38 - L39 were not covered by tests

override fun remove() {
taskService.removeVariable(taskId, variableName)
}

Check warning on line 43 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L42-L43

Added lines #L42 - L43 were not covered by tests

override fun removeLocal() {
taskService.removeVariableLocal(taskId, variableName)
}

Check warning on line 47 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L46-L47

Added lines #L46 - L47 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.holunda.camunda.bpm.data.adapter.listofmaps

import io.holunda.camunda.bpm.data.adapter.ValueWrapperUtil.getTypedValue
import org.camunda.bpm.engine.variable.VariableMap
import java.util.*

/**
* Read-write adapter for variable map.
*
* @param [K] key type.
* @param [V] value type.
* @param variableMap variable map to access.
* @param variableName variable to access.
* @param keyClazz key class.
* @param valueClazz value class.
</T> */
class ListOfMapsReadWriteAdapterVariableMap<K, V>(
private val variableMap: VariableMap,
variableName: String,
keyClazz: Class<K>,
valueClazz: Class<V>
) : AbstractListOfMapsReadWriteAdapter<K, V>(variableName, keyClazz, valueClazz) {

override fun getOptional(): Optional<List<Map<K, V>>> {
return Optional.ofNullable(getOrNull(variableMap[variableName]))

Check warning on line 25 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L25

Added line #L25 was not covered by tests
}

override fun set(value: List<Map<K, V>>, isTransient: Boolean) {
variableMap.putValueTyped(variableName, getTypedValue(value, isTransient))
}

Check warning on line 30 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L29-L30

Added lines #L29 - L30 were not covered by tests

override fun getLocalOptional(): Optional<List<Map<K, V>>> {
throw UnsupportedOperationException("Can't get a local variable on a variable map")

Check warning on line 33 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L33

Added line #L33 was not covered by tests
}

override fun setLocal(value: List<Map<K, V>>, isTransient: Boolean) {
throw UnsupportedOperationException("Can't set a local variable on a variable map")

Check warning on line 37 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L37

Added line #L37 was not covered by tests
}

override fun remove() {
variableMap.remove(variableName)
}

Check warning on line 42 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L41-L42

Added lines #L41 - L42 were not covered by tests

override fun removeLocal() {
throw UnsupportedOperationException("Can't set a local variable on a variable map")

Check warning on line 45 in extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt

View check run for this annotation

Codecov / codecov/patch

extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L45

Added line #L45 was not covered by tests
}
}
Loading

0 comments on commit 17654b5

Please sign in to comment.