Package org.activiti.engine.task

Examples of org.activiti.engine.task.Comment


  public void deleteComment(@PathVariable("processInstanceId") String processInstanceId,
      @PathVariable("commentId") String commentId, HttpServletRequest request, HttpServletResponse response) {
   
    HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
   
    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);
    }
   
    taskService.deleteComment(commentId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
View Full Code Here


      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT_COLLECTION, task.getId()));
      CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
      assertTrue(responseNode.isArray());
      assertEquals(1, responseNode.size());
     
      ObjectNode commentNode = (ObjectNode) responseNode.get(0);
      assertEquals("kermit", commentNode.get("author").textValue());
      assertEquals("This is a comment...", commentNode.get("message").textValue());
      assertEquals(comment.getId(), commentNode.get("id").textValue());
      assertTrue(commentNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId())));
      assertEquals(task.getId(), commentNode.get("taskId").asText());
      assertTrue(commentNode.get("processInstanceUrl").isNull());
      assertTrue(commentNode.get("processInstanceId").isNull());
     
      // Test with unexisting task
View Full Code Here

      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId()));
      CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
     
      assertEquals("kermit", responseNode.get("author").textValue());
      assertEquals("This is a comment...", responseNode.get("message").textValue());
      assertEquals(comment.getId(), responseNode.get("id").textValue());
      assertTrue(responseNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId())));
      assertEquals(task.getId(), responseNode.get("taskId").asText());
      assertTrue(responseNode.get("processInstanceUrl").isNull());
      assertTrue(responseNode.get("processInstanceId").isNull());
     
      // Test with unexisting task
View Full Code Here

      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId()));
      closeResponse(executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT));
     
      // Test with unexisting task
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, "unexistingtask", "123"));
View Full Code Here

      Task task = taskService.newTask();
      taskService.saveTask(task);

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(task.getId(), null, "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      taskService.complete(task.getId());
     
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId()));
      CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertNotNull(responseNode);
     
      assertEquals("kermit", responseNode.get("author").textValue());
      assertEquals("This is a comment...", responseNode.get("message").textValue());
      assertEquals(comment.getId(), responseNode.get("id").textValue());
      assertTrue(responseNode.get("taskUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_COMMENT, task.getId(), comment.getId())));
      assertEquals(task.getId(), responseNode.get("taskId").asText());
      assertTrue(responseNode.get("processInstanceUrl").isNull());
      assertTrue(responseNode.get("processInstanceId").isNull());
     
    } finally {
View Full Code Here

  public CommentResponse getComment(@PathVariable("taskId") String taskId,
      @PathVariable("commentId") String commentId, HttpServletRequest request) {
   
    HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
   
    Comment comment = taskService.getComment(commentId);
    if (comment == null || !task.getId().equals(comment.getTaskId())) {
      throw new ActivitiObjectNotFoundException("Task '" + task.getId() +"' doesn't have a comment with id '" + commentId + "'.", Comment.class);
    }
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/tasks/"));
View Full Code Here

      @PathVariable("commentId") String commentId, HttpServletResponse response) {
   
    // Check if task exists
    Task task = getTaskFromRequest(taskId);
   
    Comment comment = taskService.getComment(commentId);
    if (comment == null || comment.getTaskId() == null || !comment.getTaskId().equals(task.getId())) {
      throw new ActivitiObjectNotFoundException("Task '" + task.getId() +"' doesn't have a comment with id '" + commentId + "'.", Comment.class);
    }
   
    taskService.deleteComment(commentId);
    response.setStatus(HttpStatus.NO_CONTENT.value());
View Full Code Here

  public Void execute(CommandContext commandContext) {
    CommentEntityManager commentManager = commandContext.getCommentEntityManager();
   
    if(commentId != null) {
      // Delete for an individual comment
      Comment comment = commentManager.findComment(commentId);
      if(comment == null) {
        throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
      }
      commentManager.delete((CommentEntity) comment);
     
View Full Code Here

 
  public void delete(PersistentObject persistentObject) {
    checkHistoryEnabled();
    super.delete(persistentObject);
   
    Comment comment = (Comment) persistentObject;
    if(getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      // Forced to fetch the process-instance to associate the right process definition
      String processDefinitionId = null;
      String processInstanceId = comment.getProcessInstanceId();
      if(comment.getProcessInstanceId() != null) {
        ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId());
        if(process != null) {
          processDefinitionId = process.getProcessDefinitionId();
        }
      }
      getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
View Full Code Here

  public void insert(PersistentObject persistentObject) {
    checkHistoryEnabled();
    super.insert(persistentObject);
   
    Comment comment = (Comment) persistentObject;
    if(getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      // Forced to fetch the process-instance to associate the right process definition
      String processDefinitionId = null;
      String processInstanceId = comment.getProcessInstanceId();
      if(comment.getProcessInstanceId() != null) {
        ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId());
        if(process != null) {
          processDefinitionId = process.getProcessDefinitionId();
        }
      }
      getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
View Full Code Here

TOP

Related Classes of org.activiti.engine.task.Comment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.