use of org.kie.server.api.model.instance.TaskCommentList in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method getTaskCommentsByTaskId.
@Override
public List<TaskComment> getTaskCommentsByTaskId(String containerId, Long taskId) {
TaskCommentList commentList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
commentList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_COMMENTS_GET_URI, valuesMap), TaskCommentList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getCommentsByTaskId", marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
commentList = deserialize(response.getResult(), TaskCommentList.class);
}
if (commentList.getTasks() != null) {
return Arrays.asList(commentList.getTasks());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.TaskCommentList in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceBase method getCommentsByTaskId.
public String getCommentsByTaskId(String containerId, Number taskId, String marshallingType) {
containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue()));
List<Comment> comments = userTaskService.getCommentsByTaskId(containerId, taskId.longValue());
TaskComment[] taskComments = new TaskComment[comments.size()];
int counter = 0;
for (Comment comment : comments) {
TaskComment taskComment = TaskComment.builder().id(comment.getId()).text(comment.getText()).addedBy(comment.getAddedBy().getId()).addedAt(comment.getAddedAt()).build();
taskComments[counter] = taskComment;
counter++;
}
TaskCommentList result = new TaskCommentList(taskComments);
logger.debug("About to marshal task '{}' comments {}", taskId, result);
String response = marshallerHelper.marshal(containerId, marshallingType, result);
return response;
}
Aggregations