diff --git a/src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/services/CFTTaskMapper.java b/src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/services/CFTTaskMapper.java index 4e485440c9..2fdb04c6ea 100644 --- a/src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/services/CFTTaskMapper.java +++ b/src/main/java/uk/gov/hmcts/reform/wataskmanagementapi/services/CFTTaskMapper.java @@ -185,8 +185,8 @@ public TaskResource mapToApiFirstTaskResource(CreateTaskRequestTask request) { taskTitle != null ? taskTitle : taskName, request.getDescription(), new ArrayList(), - majorPriority != null ? majorPriority : 5000, - minorPriority != null ? minorPriority : 500, + majorPriority, + minorPriority, null, //Need to get from taskPayload assignee false, //autoAssigned executionTypeResource, @@ -915,6 +915,7 @@ public TaskResource mapToTaskResourceForReconfigure(TaskResource taskResource, T taskResource.setPriorityDate(task.getPriorityDate()); taskResource.setMajorPriority(task.getMajorPriority()); taskResource.setMinorPriority(task.getMinorPriority()); + String taskId = task.getId().toString(); Set taskRoleResources = mapPermissions(task.getPermissions(), taskId); taskResource.setTaskRoleResources(taskRoleResources); @@ -926,15 +927,23 @@ public TaskResource mapToTaskResourceForReconfigure(TaskResource taskResource, T taskResource.setRoleCategory(task.getRoleCategory()); taskResource.setNextHearingDate(task.getNextHearingDate()); taskResource.setNextHearingId(task.getNextHearingId()); - Map additionalProperties = Collections.emptyMap(); + Map additionalProperties = new ConcurrentHashMap<>(); + + // Start with existing values if present + if (taskResource.getAdditionalProperties() != null + && !taskResource.getAdditionalProperties().isEmpty()) { + additionalProperties.putAll(taskResource.getAdditionalProperties()); + } + + // Merge / update with new values from task if (task.getAdditionalProperties() != null) { - additionalProperties = task.getAdditionalProperties().entrySet() - .stream() - .collect(Collectors.toMap( - Map.Entry::getKey, - e -> String.valueOf(e.getValue()) - )); + task.getAdditionalProperties().forEach( + (key, value) -> additionalProperties.put(key, String.valueOf(value)) // put() handles both add & update + ); } + + + // Set back to resource taskResource.setAdditionalProperties(additionalProperties); return taskResource; } diff --git a/src/main/resources/api-specs/openapi.yaml b/src/main/resources/api-specs/openapi.yaml index 391d908ec1..f2eb56f646 100644 --- a/src/main/resources/api-specs/openapi.yaml +++ b/src/main/resources/api-specs/openapi.yaml @@ -352,9 +352,11 @@ components: major_priority: type: integer description: Major priority level. + default: 5000 minor_priority: type: integer description: Minor priority level. + default: 500 location_name: type: string description: Location display name. @@ -514,6 +516,10 @@ components: - case_name - region - location + - role_category + - title + - major_priority + - minor_priority description: Task attributes that can be updated during reconfiguration. properties: id: