diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 970235b4..0fc861f2 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -10,9 +10,7 @@ on: jobs: build: - runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v3 @@ -33,12 +31,15 @@ jobs: - name: Run integration tests and generate coverage reports run: ./mvnw -Pitest verify failsafe:verify -ntp + coverage: + needs: [ build ] + runs-on: ubuntu-latest + steps: - name: Upload coverage to Codecov if: github.event_name == 'push' && github.actor != 'dependabot[bot]' uses: codecov/codecov-action@v3 with: token: ${{secrets.CODECOV_TOKEN}} - - name: Upload test coverage to Codacy if: github.event_name == 'push' && github.actor != 'dependabot[bot]' run: bash <(curl -Ls https://coverage.codacy.com/get.sh) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2e6eae24..05defbde 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -6,9 +6,7 @@ on: - master jobs: build: - runs-on: ubuntu-latest - steps: - name: Checkout code uses: actions/checkout@v3 @@ -23,13 +21,6 @@ jobs: server-username: OSS_CENTRAL_USERNAME # env variable for Maven Central server-password: OSS_CENTRAL_PASSWORD # env variable for Maven Central - # Get GPG private key into GPG - - name: Import GPG Owner Trust - run: echo ${{ secrets.GPG_OWNERTRUST }} | base64 --decode | gpg --import-ownertrust - - - name: Import GPG key - run: echo ${{ secrets.GPG_SECRET_KEYS }} | base64 --decode | gpg --import --no-tty --batch --yes - - name: Prepare mvnw run: chmod +x ./mvnw @@ -39,12 +30,27 @@ jobs: - name: Run integration tests and generate coverage reports run: ./mvnw -Pitest verify failsafe:verify + deploy: + needs: [ build ] + runs-on: ubuntu-latest + steps: + # Get GPG private key into GPG + - name: Import GPG Owner Trust + run: echo ${{ secrets.GPG_OWNERTRUST }} | base64 --decode | gpg --import-ownertrust + + - name: Import GPG key + run: echo ${{ secrets.GPG_SECRET_KEYS }} | base64 --decode | gpg --import --no-tty --batch --yes + - name: Deploy a new version to central run: ./mvnw clean deploy -B -DskipTests -DskipExamples -Prelease -Dgpg.keyname="${{secrets.GPG_KEYNAME}}" -Dgpg.passphrase="${{secrets.GPG_PASSPHRASE}}" env: OSS_CENTRAL_USERNAME: "${{ secrets.SONATYPE_USERNAME }}" OSS_CENTRAL_PASSWORD: "${{ secrets.SONATYPE_PASSWORD }}" + coverage: + needs: [ build ] + runs-on: ubuntu-latest + steps: - name: Upload test coverage to Codacy if: github.event_name == 'push' && github.actor != 'dependabot[bot]' run: bash <(curl -Ls https://coverage.codacy.com/get.sh) diff --git a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt index 3bcae1fb..a4cc6efa 100644 --- a/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt +++ b/example/example-kotlin/src/main/kotlin/process/OrderApproval.kt @@ -67,7 +67,7 @@ class OrderApproval { fun calculateOrderPositions() = JavaDelegate { execution -> val orderPosition = ORDER_POSITION.from(execution).get() - ORDER_TOTAL.on(execution).update { total -> total.plus(orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount))) } + ORDER_TOTAL.on(execution).update { total -> total?.plus(orderPosition.netCost.times(BigDecimal.valueOf(orderPosition.amount))) } } /** diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt index 0a3d6848..c9905ec9 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/VariableFactoryFluentApi.kt @@ -44,7 +44,7 @@ fun VariableMap.remove(factory: VariableFactory) = this.apply { * @param valueProcessor update function. * @param isTransient flag for transient access, false by default. */ -fun VariableMap.update(factory: VariableFactory, valueProcessor: (T) -> T, isTransient: Boolean = false) = this.apply { +fun VariableMap.update(factory: VariableFactory, valueProcessor: (T?) -> T?, isTransient: Boolean = false) = this.apply { factory.on(this).update(valueProcessor, isTransient) } @@ -90,7 +90,7 @@ fun VariableScope.remove(factory: VariableFactory) = this.apply { * @param valueProcessor update function. * @param isTransient flag for transient access, false by default. */ -fun VariableScope.update(factory: VariableFactory, valueProcessor: (T) -> T, isTransient: Boolean = false) = this.apply { +fun VariableScope.update(factory: VariableFactory, valueProcessor: (T?) -> T?, isTransient: Boolean = false) = this.apply { factory.on(this).update(valueProcessor, isTransient) } @@ -118,7 +118,7 @@ fun VariableScope.removeLocal(factory: VariableFactory) = this.apply { * @param valueProcessor update function. * @param isTransient flag for transient access, false by default. */ -fun VariableScope.updateLocal(factory: VariableFactory, valueProcessor: (T) -> T, isTransient: Boolean = false) = this.apply { +fun VariableScope.updateLocal(factory: VariableFactory, valueProcessor: (T?) -> T?, isTransient: Boolean = false) = this.apply { factory.on(this).updateLocal(valueProcessor, isTransient) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt index 3b9b1019..78577531 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/AbstractReadWriteAdapter.kt @@ -9,11 +9,11 @@ import java.util.function.Function * @param variableName variable name, */ abstract class AbstractReadWriteAdapter(protected val variableName: String) : ReadAdapter, WriteAdapter { - override fun set(value: T) { + override fun set(value: T?) { set(value, false) } - override fun setLocal(value: T) { + override fun setLocal(value: T?) { setLocal(value, false) } @@ -25,7 +25,7 @@ abstract class AbstractReadWriteAdapter(protected val variableName: String) : return getLocalOptional().orElseThrow { VariableNotFoundException("Couldn't find required local variable '$variableName'") } } - override fun update(valueProcessor: Function, isTransient: Boolean) { + override fun update(valueProcessor: Function, isTransient: Boolean) { val oldValue = get() val newValue = valueProcessor.apply(oldValue) if (oldValue != newValue) { @@ -34,7 +34,7 @@ abstract class AbstractReadWriteAdapter(protected val variableName: String) : } } - override fun updateLocal(valueProcessor: Function, isTransient: Boolean) { + override fun updateLocal(valueProcessor: Function, isTransient: Boolean) { val oldValue = getLocal() val newValue = valueProcessor.apply(oldValue) if (oldValue != newValue) { @@ -43,11 +43,11 @@ abstract class AbstractReadWriteAdapter(protected val variableName: String) : } } - override fun update(valueProcessor: Function) { + override fun update(valueProcessor: Function) { update(valueProcessor, false) } - override fun updateLocal(valueProcessor: Function) { + override fun updateLocal(valueProcessor: Function) { updateLocal(valueProcessor, false) } } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt index 0260f9a9..8e0fe5d8 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/WriteAdapter.kt @@ -14,7 +14,7 @@ interface WriteAdapter { * * @param value value to write. */ - fun set(value: T) + fun set(value: T?) /** * Writes a value as a transient variable. @@ -22,14 +22,14 @@ interface WriteAdapter { * @param value value to write. * @param isTransient allows to specify if the variable is transient. */ - operator fun set(value: T, isTransient: Boolean) + operator fun set(value: T?, isTransient: Boolean) /** * Writes a local variable. * * @param value value to write. */ - fun setLocal(value: T) + fun setLocal(value: T?) /** * Writes a local variable. @@ -37,7 +37,7 @@ interface WriteAdapter { * @param value value to write. * @param isTransient allows to specify if the variable is transient. */ - fun setLocal(value: T, isTransient: Boolean) + fun setLocal(value: T?, isTransient: Boolean) /** * Removes a variable from the scope. @@ -55,7 +55,7 @@ interface WriteAdapter { * * @param valueProcessor function updating the value based on the old value. */ - fun update(valueProcessor: Function) + fun update(valueProcessor: Function) /** * Updates a local variable using provided value processor. @@ -63,7 +63,7 @@ interface WriteAdapter { * * @param valueProcessor function updating the value based on the old value. */ - fun updateLocal(valueProcessor: Function) + fun updateLocal(valueProcessor: Function) /** * Updates a variable using provided value processor. @@ -72,7 +72,7 @@ interface WriteAdapter { * @param valueProcessor function updating the value based on the old value. * @param isTransient transient flag. */ - fun update(valueProcessor: Function, isTransient: Boolean) + fun update(valueProcessor: Function, isTransient: Boolean) /** * Updates a local variable using provided value processor. @@ -81,7 +81,7 @@ interface WriteAdapter { * @param valueProcessor function updating the value based on the old value. * @param isTransient transient flag. */ - fun updateLocal(valueProcessor: Function, isTransient: Boolean) + fun updateLocal(valueProcessor: Function, isTransient: Boolean) /** * Constructs typed value. diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt index ebdea13f..27ac306b 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadAdapterLockedExternalTask.kt @@ -26,11 +26,11 @@ class ReadAdapterLockedExternalTask( ) } - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a variable on an external task") } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on an external task") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt index d3dc6c18..b3ac1c9d 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterCaseService.kt @@ -23,7 +23,7 @@ class ReadWriteAdapterCaseService( return Optional.ofNullable(getOrNull(caseService.getVariable(caseExecutionId, variableName))) } - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) } @@ -31,7 +31,7 @@ class ReadWriteAdapterCaseService( return Optional.ofNullable(getOrNull(caseService.getVariableLocal(caseExecutionId, variableName))) } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt index 5f17a126..bb525b6d 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterRuntimeService.kt @@ -22,7 +22,7 @@ class ReadWriteAdapterRuntimeService( return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))) } - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) } @@ -30,7 +30,7 @@ class ReadWriteAdapterRuntimeService( return Optional.ofNullable(getOrNull(runtimeService.getVariableLocal(executionId, variableName))) } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt index 3956a5d3..cf81336a 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterTaskService.kt @@ -22,7 +22,7 @@ class ReadWriteAdapterTaskService( return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) } - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) } @@ -30,7 +30,7 @@ class ReadWriteAdapterTaskService( return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt index 1de360b5..8320cfe4 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableMap.kt @@ -18,7 +18,7 @@ class ReadWriteAdapterVariableMap(private val variableMap: VariableMap, return Optional.ofNullable(getOrNull(variableMap[variableName])) } - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) } @@ -26,7 +26,7 @@ class ReadWriteAdapterVariableMap(private val variableMap: VariableMap, throw UnsupportedOperationException("Can't get a local variable on a variable map") } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on a variable map") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt index 41ad85f7..ab1ed6a8 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/basic/ReadWriteAdapterVariableScope.kt @@ -16,7 +16,7 @@ class ReadWriteAdapterVariableScope( variableName: String, clazz: Class ) : AbstractBasicReadWriteAdapter(variableName, clazz) { - override fun set(value: T, isTransient: Boolean) { + override fun set(value: T?, isTransient: Boolean) { variableScope.setVariable(variableName, getTypedValue(value, isTransient)) } @@ -24,7 +24,7 @@ class ReadWriteAdapterVariableScope( return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) } - override fun setLocal(value: T, isTransient: Boolean) { + override fun setLocal(value: T?, isTransient: Boolean) { variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt index 8bf961d7..4bf0c4a0 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadAdapterLockedExternalTask.kt @@ -27,11 +27,11 @@ class ListReadAdapterLockedExternalTask( ) } - override fun set(value: List, isTransient: Boolean) { + override fun set(value: List?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a variable on an external task") } - override fun setLocal(value: List, isTransient: Boolean) { + override fun setLocal(value: List?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on an external task") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt index ae25bd67..5a5b7e74 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterCaseService.kt @@ -29,8 +29,8 @@ class ListReadWriteAdapterCaseService( ) } - override fun set(value: List, isTransient: Boolean) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: List?, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -43,8 +43,8 @@ class ListReadWriteAdapterCaseService( ) } - override fun setLocal(value: List, isTransient: Boolean) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: List?, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt index 40ff1d66..f228268e 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterRuntimeService.kt @@ -29,8 +29,8 @@ class ListReadWriteAdapterRuntimeService( ) } - override fun set(value: List, isTransient: Boolean) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: List?, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -43,8 +43,8 @@ class ListReadWriteAdapterRuntimeService( ) } - override fun setLocal(value: List, isTransient: Boolean) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: List?, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt index dc010e49..0833373a 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterTaskService.kt @@ -23,16 +23,16 @@ class ListReadWriteAdapterTaskService( return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) } - override fun set(value: List, isTransient: Boolean) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + override fun set(value: List?, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) } - override fun setLocal(value: List, isTransient: Boolean) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: List?, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt index 4f78d152..c831dd23 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableMap.kt @@ -22,15 +22,15 @@ class ListReadWriteAdapterVariableMap( return Optional.ofNullable(getOrNull(variableMap[variableName])) } - override fun set(value: List, isTransient: Boolean) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + override fun set(value: List?, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun getLocalOptional(): Optional> { throw UnsupportedOperationException("Can't get a local variable on a variable map") } - override fun setLocal(value: List, isTransient: Boolean) { + override fun setLocal(value: List?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on a variable map") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt index ef6e5a25..a7549352 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/list/ListReadWriteAdapterVariableScope.kt @@ -21,16 +21,16 @@ class ListReadWriteAdapterVariableScope( return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) } - override fun set(value: List, isTransient: Boolean) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + override fun set(value: List?, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) } - override fun setLocal(value: List, isTransient: Boolean) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: List?, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value ?: listOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt index b98f4807..a258c467 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadAdapterLockedExternalTask.kt @@ -55,11 +55,11 @@ class MapReadAdapterLockedExternalTask( throw UnsupportedOperationException("Can't remove a local variable on an external task") } - override fun set(value: Map, isTransient: Boolean) { + override fun set(value: Map?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a variable on an external task") } - override fun setLocal(value: Map, isTransient: Boolean) { + override fun setLocal(value: Map?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on an external task") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt index 03835702..21cbb747 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterCaseService.kt @@ -31,8 +31,8 @@ class MapReadWriteAdapterCaseService( ) } - override fun set(value: Map, isTransient: Boolean) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Map?, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -45,8 +45,8 @@ class MapReadWriteAdapterCaseService( ) } - override fun setLocal(value: Map, isTransient: Boolean) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Map?, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt index 4864a0f5..2cab7059 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterRuntimeService.kt @@ -31,8 +31,8 @@ class MapReadWriteAdapterRuntimeService( ) } - override fun set(value: Map, isTransient: Boolean) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Map?, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -45,8 +45,8 @@ class MapReadWriteAdapterRuntimeService( ) } - override fun setLocal(value: Map, isTransient: Boolean) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Map?, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt index 748ae68b..56d01366 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterTaskService.kt @@ -25,16 +25,16 @@ class MapReadWriteAdapterTaskService( return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) } - override fun set(value: Map, isTransient: Boolean) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Map?, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) } - override fun setLocal(value: Map, isTransient: Boolean) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Map?, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt index 1fdb56cd..a596950f 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableMap.kt @@ -23,15 +23,15 @@ class MapReadWriteAdapterVariableMap( return Optional.ofNullable(getOrNull(variableMap[variableName])) } - override fun set(value: Map, isTransient: Boolean) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + override fun set(value: Map?, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun getLocalOptional(): Optional> { throw UnsupportedOperationException("Can't get a local variable on a variable map") } - override fun setLocal(value: Map, isTransient: Boolean) { + override fun setLocal(value: Map?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on a variable map") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt index 0644e255..e2496526 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/map/MapReadWriteAdapterVariableScope.kt @@ -23,16 +23,16 @@ class MapReadWriteAdapterVariableScope( return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) } - override fun set(value: Map, isTransient: Boolean) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + override fun set(value: Map?, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) } - override fun setLocal(value: Map, isTransient: Boolean) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Map?, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value ?: mapOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt index 423fa0a5..527e16f5 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadAdapterLockedExternalTask.kt @@ -27,11 +27,11 @@ class SetReadAdapterLockedExternalTask( ) } - override fun set(value: Set, isTransient: Boolean) { + override fun set(value: Set?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a variable on an external task") } - override fun setLocal(value: Set, isTransient: Boolean) { + override fun setLocal(value: Set?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on an external task") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt index 58f90690..59705adc 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterCaseService.kt @@ -28,8 +28,8 @@ class SetReadWriteAdapterCaseService( ) } - override fun set(value: Set, isTransient: Boolean) { - caseService.setVariable(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Set?, isTransient: Boolean) { + caseService.setVariable(caseExecutionId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -42,8 +42,8 @@ class SetReadWriteAdapterCaseService( ) } - override fun setLocal(value: Set, isTransient: Boolean) { - caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Set?, isTransient: Boolean) { + caseService.setVariableLocal(caseExecutionId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt index d19933b8..d046f74f 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterRuntimeService.kt @@ -22,8 +22,8 @@ class SetReadWriteAdapterRuntimeService( return Optional.ofNullable(getOrNull(runtimeService.getVariable(executionId, variableName))) } - override fun set(value: Set, isTransient: Boolean) { - runtimeService.setVariable(executionId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Set?, isTransient: Boolean) { + runtimeService.setVariable(executionId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun getLocalOptional(): Optional> { @@ -36,8 +36,8 @@ class SetReadWriteAdapterRuntimeService( ) } - override fun setLocal(value: Set, isTransient: Boolean) { - runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Set?, isTransient: Boolean) { + runtimeService.setVariableLocal(executionId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt index 35ef79dd..981c686b 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterTaskService.kt @@ -22,16 +22,16 @@ class SetReadWriteAdapterTaskService( return Optional.ofNullable(getOrNull(taskService.getVariable(taskId, variableName))) } - override fun set(value: Set, isTransient: Boolean) { - taskService.setVariable(taskId, variableName, getTypedValue(value, isTransient)) + override fun set(value: Set?, isTransient: Boolean) { + taskService.setVariable(taskId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(taskService.getVariableLocal(taskId, variableName))) } - override fun setLocal(value: Set, isTransient: Boolean) { - taskService.setVariableLocal(taskId, variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Set?, isTransient: Boolean) { + taskService.setVariableLocal(taskId, variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt index 01f533b8..596b7df9 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableMap.kt @@ -20,15 +20,15 @@ class SetReadWriteAdapterVariableMap( return Optional.ofNullable(getOrNull(variableMap[variableName])) } - override fun set(value: Set, isTransient: Boolean) { - variableMap.putValueTyped(variableName, getTypedValue(value, isTransient)) + override fun set(value: Set?, isTransient: Boolean) { + variableMap.putValueTyped(variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun getLocalOptional(): Optional> { throw UnsupportedOperationException("Can't get a local variable on a variable map") } - override fun setLocal(value: Set, isTransient: Boolean) { + override fun setLocal(value: Set?, isTransient: Boolean) { throw UnsupportedOperationException("Can't set a local variable on a variable map") } diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt index 6887940c..a4440331 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/adapter/set/SetReadWriteAdapterVariableScope.kt @@ -20,16 +20,16 @@ class SetReadWriteAdapterVariableScope( return Optional.ofNullable(getOrNull(variableScope.getVariable(variableName))) } - override fun set(value: Set, isTransient: Boolean) { - variableScope.setVariable(variableName, getTypedValue(value, isTransient)) + override fun set(value: Set?, isTransient: Boolean) { + variableScope.setVariable(variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun getLocalOptional(): Optional> { return Optional.ofNullable(getOrNull(variableScope.getVariableLocal(variableName))) } - override fun setLocal(value: Set, isTransient: Boolean) { - variableScope.setVariableLocal(variableName, getTypedValue(value, isTransient)) + override fun setLocal(value: Set?, isTransient: Boolean) { + variableScope.setVariableLocal(variableName, getTypedValue(value ?: setOf(), isTransient)) } override fun remove() { diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt index 93a16b30..2af53af9 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/CaseServiceVariableWriter.kt @@ -20,34 +20,34 @@ class CaseServiceVariableWriter(private val caseService: CaseService, private va return caseService.getVariablesLocalTyped(caseExecutionId) } - override fun set(variableFactory: VariableFactory, value: T): CaseServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?): CaseServiceVariableWriter { return this.set(variableFactory, value, false) } - override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): CaseServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): CaseServiceVariableWriter { variableFactory.on(caseService, caseExecutionId)[value] = isTransient return this } - override fun setLocal(variableFactory: VariableFactory, value: T): CaseServiceVariableWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?): CaseServiceVariableWriter { return this.setLocal(variableFactory, value, false) } - override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): CaseServiceVariableWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?, isTransient: Boolean): CaseServiceVariableWriter { variableFactory.on(caseService, caseExecutionId).setLocal(value, isTransient) return this } override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function + valueProcessor: Function ): CaseServiceVariableWriter { return updateLocal(variableFactory, valueProcessor, false) } override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): CaseServiceVariableWriter { variableFactory.on(caseService, caseExecutionId).updateLocal(valueProcessor, isTransient) @@ -64,14 +64,14 @@ class CaseServiceVariableWriter(private val caseService: CaseService, private va return this } - override fun update(variableFactory: VariableFactory, valueProcessor: Function): CaseServiceVariableWriter { + override fun update(variableFactory: VariableFactory, valueProcessor: Function): CaseServiceVariableWriter { variableFactory.on(caseService, caseExecutionId).update(valueProcessor) return this } override fun update( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): CaseServiceVariableWriter { variableFactory.on(caseService, caseExecutionId).updateLocal(valueProcessor, isTransient) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt index dc856de5..baf94eb7 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/GlobalVariableWriter.kt @@ -19,7 +19,7 @@ interface GlobalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.set] */ - operator fun set(variableFactory: VariableFactory, value: T): S + operator fun set(variableFactory: VariableFactory, value: T?): S /** * Sets the (transient) value for the provided variable and returns the builder (fluently). @@ -31,7 +31,7 @@ interface GlobalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.set] */ - operator fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): S + operator fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): S /** * Sets the global value for the provided variable and returns the builder (fluently). @@ -42,7 +42,7 @@ interface GlobalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun update(variableFactory: VariableFactory, valueProcessor: Function): S + fun update(variableFactory: VariableFactory, valueProcessor: Function): S /** * Updates the global (transient) value for the provided variable and returns the builder (fluently). @@ -54,7 +54,7 @@ interface GlobalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun update(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S + fun update(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S /** * Removes the value for the provided variable and returns the builder (fluently). diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt index 1b8ed27b..ad35fce5 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/LocalVariableWriter.kt @@ -19,7 +19,7 @@ interface LocalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun setLocal(variableFactory: VariableFactory, value: T): S + fun setLocal(variableFactory: VariableFactory, value: T?): S /** * Sets the local (transient) value for the provided variable and returns the builder (fluently). @@ -31,7 +31,7 @@ interface LocalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): S + fun setLocal(variableFactory: VariableFactory, value: T?, isTransient: Boolean): S /** * Sets the local value for the provided variable and returns the builder (fluently). @@ -42,7 +42,7 @@ interface LocalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): S + fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): S /** * Updates the local (transient) value for the provided variable and returns the builder (fluently). @@ -54,7 +54,7 @@ interface LocalVariableWriter> { * @return current writer instance * @see [io.holunda.camunda.bpm.data.adapter.WriteAdapter.setLocal] */ - fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S + fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function, isTransient: Boolean): S /** * Removes the local value for the provided variable and returns the builder (fluently). diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt index 7a9a8273..3d67f476 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/RuntimeServiceVariableWriter.kt @@ -19,22 +19,22 @@ class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, p return runtimeService.getVariablesLocalTyped(executionId) } - override fun set(variableFactory: VariableFactory, value: T): RuntimeServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?): RuntimeServiceVariableWriter { return this.set(variableFactory, value, false) } - override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): RuntimeServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId)[value] = isTransient return this } - override fun setLocal(variableFactory: VariableFactory, value: T): RuntimeServiceVariableWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?): RuntimeServiceVariableWriter { return this.setLocal(variableFactory, value, false) } override fun setLocal( variableFactory: VariableFactory, - value: T, + value: T?, isTransient: Boolean ): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId).setLocal(value, isTransient) @@ -51,14 +51,14 @@ class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, p return this } - override fun update(variableFactory: VariableFactory, valueProcessor: Function): RuntimeServiceVariableWriter { + override fun update(variableFactory: VariableFactory, valueProcessor: Function): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId).update(valueProcessor) return this } override fun update( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId).update(valueProcessor, isTransient) @@ -67,7 +67,7 @@ class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, p override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function + valueProcessor: Function ): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId).updateLocal(valueProcessor) return this @@ -75,7 +75,7 @@ class RuntimeServiceVariableWriter(private val runtimeService: RuntimeService, p override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): RuntimeServiceVariableWriter { variableFactory.on(runtimeService, executionId).updateLocal(valueProcessor, isTransient) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt index db814221..570da72b 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/TaskServiceVariableWriter.kt @@ -19,20 +19,20 @@ class TaskServiceVariableWriter(private val taskService: TaskService, private va return taskService.getVariablesLocalTyped(taskId) } - override fun set(variableFactory: VariableFactory, value: T): TaskServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?): TaskServiceVariableWriter { return this.set(variableFactory, value, false) } - override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): TaskServiceVariableWriter { + override fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): TaskServiceVariableWriter { variableFactory.on(taskService, taskId)[value] = isTransient return this } - override fun setLocal(variableFactory: VariableFactory, value: T): TaskServiceVariableWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?): TaskServiceVariableWriter { return this.setLocal(variableFactory, value, false) } - override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): TaskServiceVariableWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?, isTransient: Boolean): TaskServiceVariableWriter { variableFactory.on(taskService, taskId).setLocal(value, isTransient) return this } @@ -47,14 +47,14 @@ class TaskServiceVariableWriter(private val taskService: TaskService, private va return this } - override fun update(variableFactory: VariableFactory, valueProcessor: Function): TaskServiceVariableWriter { + override fun update(variableFactory: VariableFactory, valueProcessor: Function): TaskServiceVariableWriter { variableFactory.on(taskService, taskId).update(valueProcessor) return this } override fun update( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): TaskServiceVariableWriter { variableFactory.on(taskService, taskId).update(valueProcessor, isTransient) @@ -63,7 +63,7 @@ class TaskServiceVariableWriter(private val taskService: TaskService, private va override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function + valueProcessor: Function ): TaskServiceVariableWriter { variableFactory.on(taskService, taskId).updateLocal(valueProcessor) return this @@ -71,7 +71,7 @@ class TaskServiceVariableWriter(private val taskService: TaskService, private va override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): TaskServiceVariableWriter { variableFactory.on(taskService, taskId).updateLocal(valueProcessor, isTransient) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt index 8bcda408..6dc8c066 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableMapWriter.kt @@ -9,11 +9,11 @@ import java.util.function.Function * @param variables variables to work on. */ class VariableMapWriter(private val variables: VariableMap) : GlobalVariableWriter { - override fun set(variableFactory: VariableFactory, value: T): VariableMapWriter { + override fun set(variableFactory: VariableFactory, value: T?): VariableMapWriter { return this.set(variableFactory, value, false) } - override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableMapWriter { + override fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): VariableMapWriter { variableFactory.on(variables)[value] = isTransient return this } @@ -23,14 +23,14 @@ class VariableMapWriter(private val variables: VariableMap) : GlobalVariableWrit return this } - override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableMapWriter { + override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableMapWriter { variableFactory.on(variables).update(valueProcessor) return this } override fun update( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): VariableMapWriter { variableFactory.on(variables).update(valueProcessor, isTransient) diff --git a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt index c89b625c..9eb18c2d 100644 --- a/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt +++ b/extension/core/src/main/kotlin/io/holunda/camunda/bpm/data/writer/VariableScopeWriter.kt @@ -10,46 +10,46 @@ import java.util.function.Function * @param scope variables to work on. */ class VariableScopeWriter(private val scope: VariableScope) : VariableWriter { - override fun set(variableFactory: VariableFactory, value: T): VariableScopeWriter { + override fun set(variableFactory: VariableFactory, value: T?): VariableScopeWriter { return this.set(variableFactory, value, false) } - override fun set(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableScopeWriter { + override fun set(variableFactory: VariableFactory, value: T?, isTransient: Boolean): VariableScopeWriter { variableFactory.on(scope)[value] = isTransient return this } - override fun setLocal(variableFactory: VariableFactory, value: T): VariableScopeWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?): VariableScopeWriter { return this.setLocal(variableFactory, value, false) } - override fun setLocal(variableFactory: VariableFactory, value: T, isTransient: Boolean): VariableScopeWriter { + override fun setLocal(variableFactory: VariableFactory, value: T?, isTransient: Boolean): VariableScopeWriter { variableFactory.on(scope).setLocal(value, isTransient) return this } - override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { + override fun update(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { variableFactory.on(scope).update(valueProcessor) return this } override fun update( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): VariableScopeWriter { variableFactory.on(scope).update(valueProcessor, isTransient) return this } - override fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { + override fun updateLocal(variableFactory: VariableFactory, valueProcessor: Function): VariableScopeWriter { variableFactory.on(scope).updateLocal(valueProcessor) return this } override fun updateLocal( variableFactory: VariableFactory, - valueProcessor: Function, + valueProcessor: Function, isTransient: Boolean ): VariableScopeWriter { variableFactory.on(scope).updateLocal(valueProcessor, isTransient) diff --git a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt index 7525c90e..7ab5bcf2 100644 --- a/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt +++ b/extension/core/src/test/kotlin/io/holunda/camunda/bpm/data/FluentApiTest.kt @@ -44,7 +44,7 @@ class FluentApiTest { fake.set(MY_VAR, "new val") assertThat(fake[MY_VAR]).isEqualTo("new val") - fake.update(MY_VAR, { v -> v.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) + fake.update(MY_VAR, { v -> v?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) assertThat(fake[MY_VAR]).isEqualTo("New val") fake.remove(MY_VAR) @@ -68,13 +68,13 @@ class FluentApiTest { fake.set(MY_VAR, "new val") assertThat(fake[MY_VAR]).isEqualTo("new val") - fake.update(MY_VAR, { v -> v.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) + fake.update(MY_VAR, { v -> v?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) assertThat(fake[MY_VAR]).isEqualTo("New val") fake.setLocal(MY_VAR, "another new local val") assertThat(fake.getLocal(MY_VAR)).isEqualTo("another new local val") - fake.updateLocal(MY_VAR, { v -> v.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) + fake.updateLocal(MY_VAR, { v -> v?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) assertThat(fake[MY_VAR]).isEqualTo("Another new local val") fake.removeLocal(MY_VAR) @@ -83,7 +83,7 @@ class FluentApiTest { localVars.set(MY_VAR, "new val") assertThat(localVars[MY_VAR]).isEqualTo("new val") - localVars.update(MY_VAR, { v -> v.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) + localVars.update(MY_VAR, { v -> v?.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } }, false) assertThat(localVars[MY_VAR]).isEqualTo("New val") localVars.remove(MY_VAR)