Skip to content

Commit

Permalink
Merge pull request #524 from camunda-community-hub/feat/#521_support_…
Browse files Browse the repository at this point in the history
…camunda_7_21

feat: #521 support camunda version 7.21
  • Loading branch information
rohwerj authored Apr 19, 2024
2 parents ff167a4 + 9c0bb7c commit 20b161d
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -489,4 +490,18 @@ abstract class AbstractRuntimeServiceAdapter : RuntimeService {
TODO("Not yet implemented")
}

/**
* @since 7.21
*/
override fun deleteProcessInstances(processInstanceIds: MutableList<String>, deleteReason: String?, skipCustomListeners: Boolean,
externallyTerminated: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean) {
implementedBy(RemoteRuntimeService::class)
}

override fun deleteProcessInstancesAsync(processInstanceIds: MutableList<String>?, processInstanceQuery: ProcessInstanceQuery?,
historicProcessInstanceQuery: HistoricProcessInstanceQuery?, deleteReason: String?,
skipCustomListeners: Boolean, skipSubprocesses: Boolean, skipIoMappings: Boolean): Batch {
implementedBy(RemoteRuntimeService::class)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class LockedExternalTaskAdapter(

override fun getExtensionProperties(): Map<String, String>? = lockedExternalTaskBean.extensionProperties

/**
* @since 7.21
*/
override fun getCreateTime(): Date {
throw UnsupportedOperationException("Create time not supported via REST")
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,8 @@ class RemoteRuntimeService(
}.correlateStartMessage()

override fun deleteProcessInstancesAsync(processInstanceIds: MutableList<String>?, 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<String>?, processInstanceQuery: ProcessInstanceQuery?, deleteReason: String?) =
deleteProcessInstancesAsync(processInstanceIds = processInstanceIds, processInstanceQuery = processInstanceQuery, historicProcessInstanceQuery = null,
Expand Down Expand Up @@ -611,6 +604,28 @@ class RemoteRuntimeService(

override fun createExecutionQuery() = DelegatingExecutionQuery(executionApiClient)

override fun deleteProcessInstances(processInstanceIds: MutableList<String>, 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<String>?, 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DelegatingMessageCorrelationBuilder(
this.localCorrelationKeys = mutableMapOf()
this.processVariables = mutableMapOf()
this.processVariablesLocal = mutableMapOf()
this.processVariablesToTriggeredScope = mutableMapOf()
}


Expand Down Expand Up @@ -213,4 +214,18 @@ class DelegatingMessageCorrelationBuilder(
override fun correlate() {
messageApiClient.deliverMessage(correlationMessageDto)
}

/**
* @since 7.21
*/
override fun setVariablesToTriggeredScope(variables: MutableMap<String, Any>): 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
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExternalTask> =
externalTaskApiClient.queryExternalTasks(firstResult, maxResults, fillQueryDto()).body!!.map {
ExternalTaskAdapter(ExternalTaskBean.fromDto(it))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<version.java>${java.version}</version.java>

<camunda.version.base>7.20</camunda.version.base>
<camunda.version.base>7.21</camunda.version.base>
<camunda.version.ce>${camunda.version.base}.0</camunda.version.ce>
<camunda.version.ee>${camunda.version.base}.0-ee</camunda.version.ee>
<camunda-bpm-api.version>7.20.0</camunda-bpm-api.version>
<camunda-bpm-api.version>7.21.0</camunda-bpm-api.version>
<spin.version>1.23.0</spin.version>

<spring-boot.version>3.2.5</spring-boot.version>
Expand Down

0 comments on commit 20b161d

Please sign in to comment.