Package org.activiti.engine.task

Examples of org.activiti.engine.task.Comment


    try {
      pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(null, pi.getId(), "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
          RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT_COLLECTION, pi.getId())), HttpStatus.SC_OK);
     
      assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     
      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("processInstanceUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), comment.getId())));
      assertEquals(pi.getProcessInstanceId(), commentNode.get("processInstanceId").asText());
      assertTrue(commentNode.get("taskUrl").isNull());
      assertTrue(commentNode.get("taskId").isNull());
     
      // Test with unexisting task
View Full Code Here


    try {
      pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");

      // Add a comment as "kermit"
      identityService.setAuthenticatedUserId("kermit");
      Comment comment = taskService.addComment(null, pi.getId(), "This is a comment...");
      identityService.setAuthenticatedUserId(null);
     
      CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(
          RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), comment.getId())), 200);
     
      assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
     
      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("processInstanceUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, pi.getId(), comment.getId())));
      assertEquals(pi.getProcessInstanceId(), responseNode.get("processInstanceId").asText());
      assertTrue(responseNode.get("taskUrl").isNull());
      assertTrue(responseNode.get("taskId").isNull());
     
      // Test with unexisting process-instance
View Full Code Here

    try {
      pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");

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

      String taskId = task.getId();

      identityService.setAuthenticatedUserId("johndoe");
      // Fetch the task again and update
      taskService.addComment(taskId, null, "look at this \n       isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd");
      Comment comment = taskService.getTaskComments(taskId).get(0);
      assertEquals("johndoe", comment.getUserId());
      assertEquals(taskId, comment.getTaskId());
      assertNull(comment.getProcessInstanceId());
      assertEquals("look at this isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg ...", ((Event)comment).getMessage());
      assertEquals("look at this \n       isn't this great? slkdjf sldkfjs ldkfjs ldkfjs ldkfj sldkfj sldkfj sldkjg laksfg sdfgsd;flgkj ksajdhf skjdfh ksjdhf skjdhf kalskjgh lskh dfialurhg kajsh dfuieqpgkja rzvkfnjviuqerhogiuvysbegkjz lkhf ais liasduh flaisduh ajiasudh vaisudhv nsfd", comment.getFullMessage());
      assertNotNull(comment.getTime());

      // Finally, delete task
      taskService.deleteTask(taskId, true);
    }
  }
View Full Code Here

     
      identityService.setAuthenticatedUserId("johndoe");
      String customType1 = "Type1";
      String customType2 = "Type2";
     
      Comment comment = taskService.addComment(taskId, null, "This is a regular comment");
      Comment customComment1 = taskService.addComment(taskId, null, customType1, "This is a custom comment of type Type1");
      Comment customComment2 = taskService.addComment(taskId, null, customType1, "This is another Type1 comment");
      Comment customComment3 = taskService.addComment(taskId, null, customType2, "This is another custom comment. Type2 this time!");
     
      assertEquals(CommentEntity.TYPE_COMMENT, comment.getType());
      assertEquals(customType1, customComment1.getType());
      assertEquals(customType2, customComment3.getType());
     
      assertNotNull(taskService.getComment(comment.getId()));
      assertNotNull(taskService.getComment(customComment1.getId()));
     
      List<Comment> regularComments = taskService.getTaskComments(taskId);
View Full Code Here

    String processInstanceId = null;
    if (comment.isSaveProcessInstanceId()) {
      Task taskEntity = taskService.createTaskQuery().taskId(task.getId()).singleResult();
      processInstanceId = taskEntity.getProcessInstanceId();
    }
    Comment createdComment = taskService.addComment(task.getId(), processInstanceId, comment.getMessage());
    response.setStatus(HttpStatus.CREATED.value());
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/runtime/tasks/"));
   
View Full Code Here

   
    if (comment.getMessage() == null) {
      throw new ActivitiIllegalArgumentException("Comment text is required.");
    }
   
    Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage());
    response.setStatus(HttpStatus.CREATED.value());
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/history/historic-process-instances/"));
    return restResponseFactory.createRestComment(createdComment, serverRootUrl);
View Full Code Here

     
      Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
      assertNotNull(task);
     
      // Create link-comment
      Comment comment = taskService.addComment(task.getId(), task.getProcessInstanceId(), "comment");
      assertEquals(2, listener.getEventsReceived().size());
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      Comment commentFromEvent = (Comment) event.getEntity();
      assertEquals(comment.getId(), commentFromEvent.getId());
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
      listener.clearEventsReceived();
     
      // Finally, delete comment
      taskService.deleteComment(comment.getId());
      assertEquals(1, listener.getEventsReceived().size());
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(processInstance.getId(), event.getProcessInstanceId());
      assertEquals(processInstance.getId(), event.getExecutionId());
      assertEquals(processInstance.getProcessDefinitionId(), event.getProcessDefinitionId());
      commentFromEvent = (Comment) event.getEntity();
      assertEquals(comment.getId(), commentFromEvent.getId());
    }
  }
View Full Code Here

        task = taskService.newTask();
        taskService.saveTask(task);
        assertNotNull(task);
       
        // Create link-comment
        Comment comment = taskService.addComment(task.getId(), null, "comment");
        assertEquals(2, listener.getEventsReceived().size());
        ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
        assertNull(event.getProcessInstanceId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        Comment commentFromEvent = (Comment) event.getEntity();
        assertEquals(comment.getId(), commentFromEvent.getId());
       
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
        assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
        listener.clearEventsReceived();
       
        // Finally, delete comment
        taskService.deleteComment(comment.getId());
        assertEquals(1, listener.getEventsReceived().size());
        event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
        assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
        assertNull(event.getProcessInstanceId());
        assertNull(event.getExecutionId());
        assertNull(event.getProcessDefinitionId());
        commentFromEvent = (Comment) event.getEntity();
        assertEquals(comment.getId(), commentFromEvent.getId());
       
      } finally {
        if(task != null && task.getId() != null) {
          taskService.deleteTask(task.getId());
          historyService.deleteHistoricTaskInstance(task.getId());
View Full Code Here

  public CommentResponse getComment(@PathVariable("processInstanceId") String processInstanceId,
      @PathVariable("commentId") String commentId, HttpServletRequest request) {
    
    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);
    }
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/history/historic-process-instances/"));
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.