-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L30
|
||
} | ||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L33
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L35
|
||
} 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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L38-L39
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L43
|
||
} 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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L45-L48
|
||
) | ||
} | ||
} 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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L52-L53
|
||
} | ||
} | ||
} | ||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L57-L58
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/AbstractListOfMapsReadWriteAdapter.kt#L62
|
||
} | ||
} |
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L14-L15
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L19
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L22-L23
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L26-L28
|
||
) | ||
) | ||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L34
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L38
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L42
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L46
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L50
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L54
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L58
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadAdapterLockedExternalTask.kt#L62
|
||
} | ||
} |
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L27-L30
|
||
) | ||
) | ||
) | ||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L37-L38
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L41-L44
|
||
) | ||
) | ||
) | ||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L51-L52
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L55-L56
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterCaseService.kt#L59-L60
|
||
} |
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L26
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L30-L31
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L34-L35
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L39-L40
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L43-L44
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterRuntimeService.kt#L47-L48
|
||
} |
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L26
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L30-L31
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L34
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L38-L39
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L42-L43
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterTaskService.kt#L46-L47
|
||
} |
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L25
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L29-L30
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L33
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L37
|
||
} | ||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L41-L42
|
||
|
||
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 Codecov / codecov/patchextension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/listofmaps/ListOfMapsReadWriteAdapterVariableMap.kt#L45
|
||
} | ||
} |