Search in sources :

Example 1 with CommentResponse

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();
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) BaseTaskService(org.wso2.carbon.bpmn.rest.service.base.BaseTaskService)

Example 2 with CommentResponse

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();
}
Also used : CommentResponse(org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) CommentResponseCollection(org.wso2.carbon.bpmn.rest.model.runtime.CommentResponseCollection)

Example 3 with CommentResponse

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();
}
Also used : Comment(org.activiti.engine.task.Comment) CommentResponse(org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 4 with CommentResponse

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();
}
Also used : Comment(org.activiti.engine.task.Comment) CommentResponse(org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 5 with CommentResponse

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();
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) BaseTaskService(org.wso2.carbon.bpmn.rest.service.base.BaseTaskService)

Aggregations

RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)5 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)3 CommentResponse (org.wso2.carbon.bpmn.rest.model.runtime.CommentResponse)3 Comment (org.activiti.engine.task.Comment)2 BaseTaskService (org.wso2.carbon.bpmn.rest.service.base.BaseTaskService)2 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)1 CommentResponseCollection (org.wso2.carbon.bpmn.rest.model.runtime.CommentResponseCollection)1