use of org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse in project carbon-business-process by wso2.
the class WorkflowTaskService method createComment.
@POST
@Path("/{taskId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createComment(@PathParam("taskId") String taskId, CommentRequest comment) {
Task task = getTaskFromRequest(taskId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
String processInstanceId = null;
TaskService taskService = BPMNOSGIService.getTaskService();
if (comment.isSaveProcessInstanceId()) {
Task taskEntity = taskService.createTaskQuery().taskId(task.getId()).singleResult();
processInstanceId = taskEntity.getProcessInstanceId();
}
Comment createdComment = taskService.addComment(task.getId(), processInstanceId, comment.getMessage());
CommentResponse commentResponse = new RestResponseFactory().createRestComment(createdComment, uriInfo.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(commentResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method getComments.
@GET
@Path("/{processInstanceId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComments(@PathParam("processInstanceId") String processInstanceId) {
TaskService taskService = BPMNOSGIService.getTaskService();
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
List<CommentResponse> commentResponseList = new RestResponseFactory().createRestCommentList(taskService.getProcessInstanceComments(instance.getId()), uriInfo.getBaseUri().toString());
CommentResponseCollection commentResponseCollection = new CommentResponseCollection();
commentResponseCollection.setCommentResponseList(commentResponseList);
return Response.ok().entity(commentResponseCollection).build();
}
use of org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method getComment.
@GET
@Path("/{processInstanceId}/comments/{commentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComment(@PathParam("processInstanceId") String processInstanceId, @PathParam("commentId") String commentId) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) {
throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
CommentResponse commentResponse = new RestResponseFactory().createRestComment(comment, uriInfo.getBaseUri().toString());
return Response.ok().entity(commentResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method createComment.
@POST
@Path("/{processInstanceId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createComment(@PathParam("processInstanceId") String processInstanceId, CommentResponse comment) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
TaskService taskService = BPMNOSGIService.getTaskService();
Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage());
CommentResponse commentResponse = new RestResponseFactory().createRestComment(createdComment, uriInfo.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(commentResponse).build();
}
use of org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse in project carbon-business-process by wso2.
the class WorkflowTaskService method getComments.
@GET
@Path("/{taskId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComments(@PathParam("taskId") String taskId) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
List<CommentResponse> commentResponseList = new RestResponseFactory().createRestCommentList(taskService.getTaskComments(task.getId()), uriInfo.getBaseUri().toString());
CommentResponseCollection commentResponseCollection = new CommentResponseCollection();
commentResponseCollection.setCommentResponseList(commentResponseList);
return Response.ok().entity(commentResponseCollection).build();
}
Aggregations