diff --git a/components/tasklist-backend/src/main/api/openapi.yml b/components/tasklist-backend/src/main/api/openapi.yml index bb64f442..f3d9d417 100755 --- a/components/tasklist-backend/src/main/api/openapi.yml +++ b/components/tasklist-backend/src/main/api/openapi.yml @@ -221,6 +221,65 @@ paths: '404': description: Task not found. + '/tasks/payload/attribute/names': + parameters: + - $ref: '#/components/parameters/CurrentUserIdParam' + - $ref: '#/components/parameters/FiltersParam' + get: + tags: + - Task + summary: Lists all available attribute names for task payload. + operationId: getTasksAttributeNames + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + title: List of attribute names. + type: array + items: + $ref: '#/components/schemas/TaskAttributeName' + headers: + X-ElementCount: + description: Number of elements in total. + schema: + type: integer + '401': + description: Not authenticated. + '403': + description: Not authorized. + + '/tasks/payload/attribute/{attributeName}/values': + parameters: + - $ref: '#/components/parameters/CurrentUserIdParam' + - $ref: '#/components/parameters/AttributeNameParam' + - $ref: '#/components/parameters/FiltersParam' + get: + tags: + - Task + summary: Lists all available attribute values for given attribute name. + operationId: getTasksAttributeValues + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + title: List of attribute values. + type: array + items: + $ref: '#/components/schemas/TaskAttributeValue' + headers: + X-ElementCount: + description: Number of elements in total. + schema: + type: integer + '401': + description: Not authenticated. + '403': + description: Not authorized. + '/business-data-entries': parameters: - $ref: '#/components/parameters/CurrentUserIdParam' @@ -313,6 +372,14 @@ components: schema: type: string + AttributeNameParam: + name: attributeName + in: path + description: Paylpad Attribute Name. + required: true + schema: + type: string + schemas: TaskWithDataEntries: type: object @@ -554,4 +621,21 @@ components: type: string description: username of currently logged-in user. + TaskAttributeName: + type: object + description: Represents a user task. + properties: + name: + type: string + required: + - name + + TaskAttributeValue: + type: object + description: Represents a user task. + properties: + value: + type: object + required: + - value diff --git a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskResource.kt b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskResource.kt index ba4157e6..2e7bd924 100644 --- a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskResource.kt +++ b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskResource.kt @@ -4,6 +4,8 @@ import io.holunda.camunda.taskpool.api.task.* import io.holunda.polyflow.example.tasklist.adapter.rest.ElementNotFoundException import io.holunda.polyflow.example.tasklist.adapter.rest.api.TaskApiDelegate import io.holunda.polyflow.example.tasklist.adapter.rest.mapper.TaskWithDataEntriesMapper +import io.holunda.polyflow.example.tasklist.adapter.rest.model.TaskAttributeNameDto +import io.holunda.polyflow.example.tasklist.adapter.rest.model.TaskAttributeValueDto import io.holunda.polyflow.example.tasklist.adapter.rest.model.TaskWithDataEntriesDto import io.holunda.polyflow.view.Task import io.holunda.polyflow.view.auth.User @@ -147,6 +149,33 @@ class TaskResource( return ResponseEntity.noContent().build() } + override fun getTasksAttributeNames( + xCurrentUserID: String, + filters: List? + ): ResponseEntity> { + val user = userService.getUser(xCurrentUserID) + val result = taskServiceGateway.getTaskAttributeNames(user,filters ?: listOf()) + + return ResponseEntity + .ok() + .headers(HttpHeaders().apply { this[HEADER_ELEMENT_COUNT] = result.totalElementCount.toString() }) + .body(mapper.mapTaskAttributeNameDto(result.elements)) + } + + override fun getTasksAttributeValues( + xCurrentUserID: String, + attributeName: String, + filters: List? + ): ResponseEntity> { + val user = userService.getUser(xCurrentUserID) + val result = taskServiceGateway.getTaskAttributeValues(attributeName, user,filters ?: listOf()) + + return ResponseEntity + .ok() + .headers(HttpHeaders().apply { this[HEADER_ELEMENT_COUNT] = result.totalElementCount.toString() }) + .body(mapper.mapTaskAttributeValueDto(result.elements)) + } + private fun getAuthorizedTask(taskId: String, user: User): Task = taskServiceGateway .getTask(taskId) .apply { diff --git a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskServiceGateway.kt b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskServiceGateway.kt index 755aaae3..1ff27966 100644 --- a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskServiceGateway.kt +++ b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/impl/TaskServiceGateway.kt @@ -5,9 +5,7 @@ import io.holunda.polyflow.example.tasklist.adapter.rest.ElementNotFoundExceptio import io.holunda.polyflow.view.Task import io.holunda.polyflow.view.TaskQueryClient import io.holunda.polyflow.view.auth.User -import io.holunda.polyflow.view.query.task.TaskForIdQuery -import io.holunda.polyflow.view.query.task.TasksWithDataEntriesForUserQuery -import io.holunda.polyflow.view.query.task.TasksWithDataEntriesQueryResult +import io.holunda.polyflow.view.query.task.* import mu.KLogging import org.axonframework.commandhandling.gateway.CommandGateway import org.axonframework.queryhandling.QueryGateway @@ -56,4 +54,30 @@ class TaskServiceGateway( filters = filters ) ).join() ?: throw ElementNotFoundException() + + fun getTaskAttributeNames( + user: User, + filters: List + ): TaskAttributeNamesQueryResult = taskQueryClient + .query( + TaskAttributeNamesQuery( + user = user, + assignedToMeOnly = false, + filters = filters + ) + ).join() ?: throw ElementNotFoundException() + + fun getTaskAttributeValues( + attributeName: String, + user: User, + filters: List + ): TaskAttributeValuesQueryResult = taskQueryClient + .query( + TaskAttributeValuesQuery( + attributeName = attributeName, + user = user, + assignedToMeOnly = false, + filters = filters + ) + ).join() ?: throw ElementNotFoundException() } diff --git a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/mapper/TaskWithDataEntriesMapper.kt b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/mapper/TaskWithDataEntriesMapper.kt index b5e79e83..dfe21783 100755 --- a/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/mapper/TaskWithDataEntriesMapper.kt +++ b/components/tasklist-backend/src/main/kotlin/io/holunda/polyflow/example/tasklist/adapter/rest/mapper/TaskWithDataEntriesMapper.kt @@ -1,9 +1,6 @@ package io.holunda.polyflow.example.tasklist.adapter.rest.mapper -import io.holunda.polyflow.example.tasklist.adapter.rest.model.DataEntryDto -import io.holunda.polyflow.example.tasklist.adapter.rest.model.ProtocolEntryDto -import io.holunda.polyflow.example.tasklist.adapter.rest.model.TaskDto -import io.holunda.polyflow.example.tasklist.adapter.rest.model.TaskWithDataEntriesDto +import io.holunda.polyflow.example.tasklist.adapter.rest.model.* import io.holunda.polyflow.view.* import org.mapstruct.* import org.springframework.beans.factory.annotation.Autowired @@ -60,6 +57,11 @@ abstract class TaskWithDataEntriesMapper { ) abstract fun dto(taskWithDataEntries: TaskWithDataEntries): TaskWithDataEntriesDto + fun mapTaskAttributeNameDto(names: List): List = names.map { TaskAttributeNameDto(it) } + + fun mapTaskAttributeValueDto(values: List): List = values.map { TaskAttributeValueDto(it) } + + fun toOffsetDateTime(@Valid time: Instant?): OffsetDateTime? = if (time == null) null else OffsetDateTime.ofInstant(time, ZoneOffset.UTC) diff --git a/pom.xml b/pom.xml index a081c688..44e5e189 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 3.2.6 - 4.2.0 + 4.2.1-SNAPSHOT 7.21.0 7.21.0-ee