From 0726115c9fd488ecf17669dbc1d790f5fe6637b5 Mon Sep 17 00:00:00 2001 From: Michael von Bargen Date: Thu, 7 Nov 2024 17:27:13 +0100 Subject: [PATCH] #115 map more fields to TaskInformation for C7Enbedded --- .../delivery/TaskInformationExtensions.kt | 26 ++++++++++++++++--- .../pull/EmbeddedPullUserTaskDelivery.kt | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt b/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt index ea26dfeb..6b03b688 100644 --- a/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt +++ b/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt @@ -6,9 +6,10 @@ import org.camunda.bpm.engine.delegate.DelegateTask import org.camunda.bpm.engine.externaltask.LockedExternalTask import org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity +import org.camunda.bpm.engine.task.IdentityLink import org.camunda.bpm.engine.task.Task -fun Task.toTaskInformation(processDefinitionKey: String? = null) = +fun Task.toTaskInformation(candidates: List, processDefinitionKey: String? = null) = TaskInformation( taskId = this.id, meta = mapOf( @@ -18,7 +19,13 @@ fun Task.toTaskInformation(processDefinitionKey: String? = null) = CommonRestrictions.PROCESS_INSTANCE_ID to this.processInstanceId, "taskName" to this.name, "taskDescription" to this.description, - "assignee" to this.assignee + "assignee" to this.assignee, + "creationDate" to this.createTime.toString(), // FIXME -> to zoned iso 8601 + "followUpDate" to (this.followUpDate?.toString() ?: ""), // FIXME -> to zoned iso 8601 + "dueDate" to (this.dueDate?.toString() ?: ""), // FIXME -> to zoned iso 8601 + "formKey" to this.formKey, + "candidateUsers" to candidates.mapNotNull { it.userId }.joinToString(","), + "candidateGroups" to candidates.mapNotNull { it.groupId }.joinToString(",") ).let { if (processDefinitionKey != null) { it + (CommonRestrictions.PROCESS_DEFINITION_KEY to processDefinitionKey) @@ -38,7 +45,13 @@ fun TaskEntity.toTaskInformation() = CommonRestrictions.PROCESS_INSTANCE_ID to this.processInstanceId, "taskName" to this.name, "taskDescription" to this.description, - "assignee" to this.assignee + "assignee" to this.assignee, + "creationDate" to this.createTime.toString(), // FIXME -> to zoned iso 8601 + "followUpDate" to (this.followUpDate?.toString() ?: ""), // FIXME -> to zoned iso 8601 + "dueDate" to (this.dueDate?.toString() ?: ""), // FIXME -> to zoned iso 8601 + "formKey" to this.formKey, + "candidateUsers" to this.candidates.mapNotNull { it.userId }.joinToString(","), + "candidateGroups" to this.candidates.mapNotNull { it.groupId }.joinToString(",") ) ) @@ -52,7 +65,12 @@ fun DelegateTask.toTaskInformation() = CommonRestrictions.PROCESS_INSTANCE_ID to this.processInstanceId, "taskName" to this.name, "taskDescription" to this.description, - "assignee" to this.assignee + "assignee" to this.assignee, + "creationDate" to this.createTime.toString(), // FIXME -> to zoned iso 8601 + "followUpDate" to (this.followUpDate?.toString() ?: ""), // FIXME -> to zoned iso 8601 + "dueDate" to (this.dueDate?.toString() ?: ""), // FIXME -> to zoned iso 8601, + "candidateUsers" to this.candidates.mapNotNull { it.userId }.joinToString(","), + "candidateGroups" to this.candidates.mapNotNull { it.groupId }.joinToString(",") ) ) diff --git a/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/pull/EmbeddedPullUserTaskDelivery.kt b/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/pull/EmbeddedPullUserTaskDelivery.kt index 3556906c..b6a233b9 100644 --- a/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/pull/EmbeddedPullUserTaskDelivery.kt +++ b/engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/pull/EmbeddedPullUserTaskDelivery.kt @@ -38,6 +38,7 @@ class EmbeddedPullUserTaskDelivery( logger.trace { "PROCESS-ENGINE-C7-EMBEDDED-036: pulling user tasks for subscriptions: $subscriptions" } taskService .createTaskQuery() + .initializeFormKeys() .forSubscriptions(subscriptions) .list() .parallelStream() @@ -51,7 +52,7 @@ class EmbeddedPullUserTaskDelivery( try { logger.debug { "PROCESS-ENGINE-C7-EMBEDDED-037: delivering user task ${task.id}." } val processDefinitionKey = cachingProcessDefinitionKeyResolver.getProcessDefinitionKey(task.processDefinitionId) - activeSubscription.action.accept(task.toTaskInformation(processDefinitionKey), variables) + activeSubscription.action.accept(task.toTaskInformation(taskService.getIdentityLinksForTask(task.id), processDefinitionKey), variables) } catch (e: Exception) { logger.error { "PROCESS-ENGINE-C7-EMBEDDED-038: error delivering task ${task.id}: ${e.message}" } subscriptionRepository.deactivateSubscriptionForTask(taskId = task.id)