Skip to content

Commit

Permalink
#115 map more fields to TaskInformation for C7Enbedded
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelVonB committed Dec 13, 2024
1 parent d870410 commit 0726115
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<IdentityLink>, processDefinitionKey: String? = null) =

Check warning on line 12 in engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt

View check run for this annotation

Codecov / codecov/patch

engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt#L12

Added line #L12 was not covered by tests
TaskInformation(
taskId = this.id,
meta = mapOf(
Expand All @@ -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)
Expand All @@ -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

Check warning on line 49 in engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt

View check run for this annotation

Codecov / codecov/patch

engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt#L48-L49

Added lines #L48 - L49 were not covered by tests
"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(",")

Check warning on line 54 in engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt

View check run for this annotation

Codecov / codecov/patch

engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt#L52-L54

Added lines #L52 - L54 were not covered by tests
)
)

Expand All @@ -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

Check warning on line 69 in engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt

View check run for this annotation

Codecov / codecov/patch

engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt#L68-L69

Added lines #L68 - L69 were not covered by tests
"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(",")

Check warning on line 73 in engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt

View check run for this annotation

Codecov / codecov/patch

engine-adapter/camunda-platform-7-embedded-core/src/main/kotlin/dev/bpmcrafters/processengineapi/adapter/c7/embedded/task/delivery/TaskInformationExtensions.kt#L72-L73

Added lines #L72 - L73 were not covered by tests
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 0726115

Please sign in to comment.