From 9c0bb7c7eec7cbbe119d020ba6ba2db98a08a0a4 Mon Sep 17 00:00:00 2001 From: Jan Rohwer Date: Tue, 16 Apr 2024 12:35:10 +0200 Subject: [PATCH] feat: #521 support camunda version 7.21 --- .../AbstractExternalTaskServiceAdapter.kt | 10 ++++++ .../adapter/AbstractRuntimeServiceAdapter.kt | 15 +++++++++ .../rest/adapter/ExternalTaskAdapter.kt | 7 ++++ .../rest/adapter/LockedExternalTaskAdapter.kt | 7 ++++ .../rest/impl/RemoteRuntimeService.kt | 33 ++++++++++++++----- .../DelegatingMessageCorrelationBuilder.kt | 15 +++++++++ .../impl/query/DelegatingExternalTaskQuery.kt | 5 +++ .../query/DelegatingProcessDefinitionQuery.kt | 7 ++++ pom.xml | 4 +-- 9 files changed, 92 insertions(+), 11 deletions(-) diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractExternalTaskServiceAdapter.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractExternalTaskServiceAdapter.kt index c5f0975c..89a9541a 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractExternalTaskServiceAdapter.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractExternalTaskServiceAdapter.kt @@ -4,10 +4,12 @@ import org.camunda.bpm.engine.ExternalTaskService import org.camunda.bpm.engine.batch.Batch import org.camunda.bpm.engine.externaltask.ExternalTaskQuery import org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder +import org.camunda.bpm.engine.externaltask.FetchAndLockBuilder import org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesSelectBuilder import org.camunda.community.rest.impl.RemoteExternalTaskService import org.camunda.community.rest.impl.RemoteRuntimeService import org.camunda.community.rest.impl.implementedBy +import java.util.* /** * Adapter for implementing external task service. @@ -120,4 +122,12 @@ abstract class AbstractExternalTaskServiceAdapter : ExternalTaskService { override fun lock(externalTaskId: String, workerId: String, lockDuration: Long) { implementedBy(RemoteExternalTaskService::class) } + + /** + * @since 7.21 + */ + override fun fetchAndLock(): FetchAndLockBuilder { + TODO("Not yet implemented") + } + } diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractRuntimeServiceAdapter.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractRuntimeServiceAdapter.kt index 6343c8ff..3a32acb6 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractRuntimeServiceAdapter.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/AbstractRuntimeServiceAdapter.kt @@ -33,6 +33,7 @@ import org.camunda.bpm.engine.variable.VariableMap import org.camunda.bpm.engine.variable.value.TypedValue import org.camunda.community.rest.impl.RemoteRuntimeService import org.camunda.community.rest.impl.implementedBy +import java.util.* /** * Adapter for implementing runtime service. @@ -489,4 +490,18 @@ abstract class AbstractRuntimeServiceAdapter : RuntimeService { TODO("Not yet implemented") } + /** + * @since 7.21 + */ + override fun deleteProcessInstances(processInstanceIds: MutableList, deleteReason: String?, skipCustomListeners: Boolean, + externallyTerminated: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean) { + implementedBy(RemoteRuntimeService::class) + } + + override fun deleteProcessInstancesAsync(processInstanceIds: MutableList?, processInstanceQuery: ProcessInstanceQuery?, + historicProcessInstanceQuery: HistoricProcessInstanceQuery?, deleteReason: String?, + skipCustomListeners: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean): Batch { + implementedBy(RemoteRuntimeService::class) + } + } diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/ExternalTaskAdapter.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/ExternalTaskAdapter.kt index 7e77ed51..337cef5e 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/ExternalTaskAdapter.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/ExternalTaskAdapter.kt @@ -48,6 +48,13 @@ class ExternalTaskAdapter( throw UnsupportedOperationException("Extension properties not supported via REST") } + /** + * @since 7.21 + */ + override fun getCreateTime(): Date { + throw UnsupportedOperationException("Create time not supported via REST") + } + } /** diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/LockedExternalTaskAdapter.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/LockedExternalTaskAdapter.kt index 135af01b..c014c661 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/LockedExternalTaskAdapter.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/adapter/LockedExternalTaskAdapter.kt @@ -51,6 +51,13 @@ class LockedExternalTaskAdapter( override fun getExtensionProperties(): Map? = lockedExternalTaskBean.extensionProperties + /** + * @since 7.21 + */ + override fun getCreateTime(): Date { + throw UnsupportedOperationException("Create time not supported via REST") + } + } /** diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/RemoteRuntimeService.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/RemoteRuntimeService.kt index 5389d8bc..e42c5999 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/RemoteRuntimeService.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/RemoteRuntimeService.kt @@ -530,15 +530,8 @@ class RemoteRuntimeService( }.correlateStartMessage() override fun deleteProcessInstancesAsync(processInstanceIds: MutableList?, processInstanceQuery: ProcessInstanceQuery?, historicProcessInstanceQuery: HistoricProcessInstanceQuery?, deleteReason: String?, skipCustomListeners: Boolean, skipSubprocesses: Boolean): Batch = - BatchAdapter(BatchBean.fromDto(processInstanceApiClient.deleteProcessInstancesAsyncOperation( - DeleteProcessInstancesDto() - .processInstanceIds(processInstanceIds) - .processInstanceQuery(processInstanceQuery?.toDto()) - .historicProcessInstanceQuery(historicProcessInstanceQuery?.toDto()) - .deleteReason(deleteReason) - .skipSubprocesses(skipSubprocesses) - .skipCustomListeners(skipCustomListeners) - ).body!!)) + deleteProcessInstancesAsync(processInstanceIds = processInstanceIds, processInstanceQuery = processInstanceQuery, historicProcessInstanceQuery = null, + deleteReason = deleteReason, skipCustomListeners = skipCustomListeners, skipSubprocesses = skipSubprocesses, skipIoMappings = false) override fun deleteProcessInstancesAsync(processInstanceIds: MutableList?, processInstanceQuery: ProcessInstanceQuery?, deleteReason: String?) = deleteProcessInstancesAsync(processInstanceIds = processInstanceIds, processInstanceQuery = processInstanceQuery, historicProcessInstanceQuery = null, @@ -611,6 +604,28 @@ class RemoteRuntimeService( override fun createExecutionQuery() = DelegatingExecutionQuery(executionApiClient) + override fun deleteProcessInstances(processInstanceIds: MutableList, deleteReason: String?, skipCustomListeners: Boolean, + externallyTerminated: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean) { + processInstanceIds.forEach { + deleteProcessInstance(processInstanceId = it, deleteReason = deleteReason, skipCustomListeners = skipCustomListeners, + skipSubprocesses = skipSubprocesses, externallyTerminated = externallyTerminated, skipIoMappings = skipIoMappings) + } + } + + override fun deleteProcessInstancesAsync(processInstanceIds: MutableList?, processInstanceQuery: ProcessInstanceQuery?, + historicProcessInstanceQuery: HistoricProcessInstanceQuery?, deleteReason: String?, + skipCustomListeners: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean): Batch = + BatchAdapter(BatchBean.fromDto(processInstanceApiClient.deleteProcessInstancesAsyncOperation( + DeleteProcessInstancesDto() + .processInstanceIds(processInstanceIds) + .processInstanceQuery(processInstanceQuery?.toDto()) + .historicProcessInstanceQuery(historicProcessInstanceQuery?.toDto()) + .deleteReason(deleteReason) + .skipSubprocesses(skipSubprocesses) + .skipCustomListeners(skipCustomListeners) + .skipIoMappings(skipIoMappings) + ).body!!)) + private fun ProcessInstanceQuery.toDto() = if (this is DelegatingProcessInstanceQuery) this.fillQueryDto() else throw IllegalArgumentException() private fun HistoricProcessInstanceQuery.toDto() = if (this is DelegatingHistoricProcessInstanceQuery) this.fillQueryDto() else throw IllegalArgumentException() diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/builder/DelegatingMessageCorrelationBuilder.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/builder/DelegatingMessageCorrelationBuilder.kt index 0dd04c76..585ef54b 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/builder/DelegatingMessageCorrelationBuilder.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/builder/DelegatingMessageCorrelationBuilder.kt @@ -50,6 +50,7 @@ class DelegatingMessageCorrelationBuilder( this.localCorrelationKeys = mutableMapOf() this.processVariables = mutableMapOf() this.processVariablesLocal = mutableMapOf() + this.processVariablesToTriggeredScope = mutableMapOf() } @@ -213,4 +214,18 @@ class DelegatingMessageCorrelationBuilder( override fun correlate() { messageApiClient.deliverMessage(correlationMessageDto) } + + /** + * @since 7.21 + */ + override fun setVariablesToTriggeredScope(variables: MutableMap): MessageCorrelationBuilder { + correlationMessageDto.processVariablesToTriggeredScope.putAll(valueMapper.mapValues(variables)) + return this + } + + override fun setVariableToTriggeredScope(variableName: String, variableValue: Any): MessageCorrelationBuilder { + correlationMessageDto.processVariablesToTriggeredScope[variableName] = valueMapper.mapValue(variableValue) + return this + } + } diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingExternalTaskQuery.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingExternalTaskQuery.kt index 4a5d74fb..a2c00f08 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingExternalTaskQuery.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingExternalTaskQuery.kt @@ -86,6 +86,11 @@ class DelegatingExternalTaskQuery( override fun orderByPriority() = this.apply { orderBy("taskPriority") } override fun orderByProcessDefinitionId() = this.apply { orderBy("processDefinitionId") } + /** + * @since 7.21 + */ + override fun orderByCreateTime(): ExternalTaskQuery = this.apply { orderBy("createTime") } + override fun listPage(firstResult: Int, maxResults: Int): List = externalTaskApiClient.queryExternalTasks(firstResult, maxResults, fillQueryDto()).body!!.map { ExternalTaskAdapter(ExternalTaskBean.fromDto(it)) diff --git a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessDefinitionQuery.kt b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessDefinitionQuery.kt index 1ac4fee0..2421f6fd 100644 --- a/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessDefinitionQuery.kt +++ b/extension/core/src/main/kotlin/org/camunda/community/rest/impl/query/DelegatingProcessDefinitionQuery.kt @@ -95,11 +95,17 @@ class DelegatingProcessDefinitionQuery( override fun processDefinitionKey(processDefinitionKey: String?) = this.apply { this.key = requireNotNull(processDefinitionKey) } + @Deprecated("Deprecated in Java") override fun processDefinitionKeysIn(vararg processDefinitionKeysIn: String): ProcessDefinitionQueryImpl { this.keys = processDefinitionKeysIn return ProcessDefinitionQueryImpl() } + /** + * @since 7.21 + */ + override fun processDefinitionKeyIn(vararg processDefinitionKeys: String): ProcessDefinitionQuery = this.apply { this.keys = processDefinitionKeys } + override fun processDefinitionKeyLike(processDefinitionKeyLike: String?) = this.apply { this.keyLike = requireNotNull(processDefinitionKeyLike) } override fun processDefinitionVersion(processDefinitionVersion: Int?) = this.apply { this.version = requireNotNull(processDefinitionVersion) } @@ -136,6 +142,7 @@ class DelegatingProcessDefinitionQuery( this.versionTag = null } + @Deprecated("Deprecated in Java") override fun messageEventSubscription(name: String?) = this.apply { this.messageEventSubscriptionName(name) } override fun messageEventSubscriptionName(name: String?) = this.apply { diff --git a/pom.xml b/pom.xml index a9d84f47..845d0c18 100644 --- a/pom.xml +++ b/pom.xml @@ -31,10 +31,10 @@ ${java.version} ${java.version} - 7.20 + 7.21 ${camunda.version.base}.0 ${camunda.version.base}.0-ee - 7.20.0 + 7.21.0 1.23.0 3.2.4