Search in sources :

Example 36 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceCommentCollectionResource method createComment.

@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments", method = RequestMethod.POST, produces = "application/json")
public CommentResponse createComment(@PathVariable String processInstanceId, @RequestBody CommentResponse comment, HttpServletRequest request, HttpServletResponse response) {
    HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
    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());
    return restResponseFactory.createRestComment(createdComment);
}
Also used : Comment(org.activiti.engine.task.Comment) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 37 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceCommentResource method deleteComment.

@RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}", method = RequestMethod.DELETE)
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());
}
Also used : Comment(org.activiti.engine.task.Comment) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 38 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class RestResponseFactory method createHistoricProcessInstanceResponseList.

public List<HistoricProcessInstanceResponse> createHistoricProcessInstanceResponseList(List<HistoricProcessInstance> processInstances) {
    RestUrlBuilder urlBuilder = createUrlBuilder();
    List<HistoricProcessInstanceResponse> responseList = new ArrayList<HistoricProcessInstanceResponse>();
    for (HistoricProcessInstance instance : processInstances) {
        responseList.add(createHistoricProcessInstanceResponse(instance, urlBuilder));
    }
    return responseList;
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) HistoricProcessInstanceResponse(org.activiti.rest.service.api.history.HistoricProcessInstanceResponse)

Example 39 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceAndVariablesQueryTest method testQueryByprocessDefinition.

public void testQueryByprocessDefinition() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        // DeploymentId
        String deploymentId = repositoryService.createDeploymentQuery().list().get(0).getId();
        HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("anothertest", 123).deploymentId(deploymentId).singleResult();
        Map<String, Object> variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        assertEquals(deploymentId, processInstance.getDeploymentId());
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("anothertest", "invalid").deploymentId(deploymentId).singleResult();
        assertNull(processInstance);
        // ProcessDefinitionName
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("anothertest", 123).processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        assertEquals(PROCESS_DEFINITION_NAME_2, processInstance.getProcessDefinitionName());
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("test", "test").processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult();
        assertNull(processInstance);
        // ProcessDefinitionCategory
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("anothertest", 123).processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("test", "test").processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult();
        assertNull(processInstance);
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 40 with HistoricProcessInstance

use of org.activiti.engine.history.HistoricProcessInstance in project Activiti by Activiti.

the class HistoricProcessInstanceAndVariablesQueryTest method testQuery.

public void testQuery() {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().variableValueEquals("anothertest", 123).singleResult();
        Map<String, Object> variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        List<HistoricProcessInstance> instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().list();
        assertEquals(6, instanceList.size());
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).list();
        assertEquals(4, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        assertEquals(PROCESS_DEFINITION_KEY, instanceList.get(0).getProcessDefinitionKey());
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY_2).singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(1, variableMap.size());
        assertEquals(123, variableMap.get("anothertest"));
        processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().finished().singleResult();
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().listPage(0, 50);
        assertEquals(6, instanceList.size());
        assertEquals(6, historyService.createHistoricProcessInstanceQuery().includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueEquals("test", "test").includeProcessVariables().listPage(0, 50);
        assertEquals(4, instanceList.size());
        assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("test", "test").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueLike("test", "te%").includeProcessVariables().list();
        assertEquals(4, instanceList.size());
        assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueLike("test", "te%").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueLike("test2", "te%2").includeProcessVariables().list();
        assertEquals(4, instanceList.size());
        assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueLike("test2", "te%2").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("test", "te%").includeProcessVariables().list();
        assertEquals(4, instanceList.size());
        assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("test", "te%").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("test", "t3%").includeProcessVariables().list();
        assertEquals(0, instanceList.size());
        assertEquals(0, historyService.createHistoricProcessInstanceQuery().variableValueLikeIgnoreCase("test", "t3%").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().listPage(0, 50);
        assertEquals(6, instanceList.size());
        assertEquals(6, historyService.createHistoricProcessInstanceQuery().includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueEquals("test", "test").includeProcessVariables().listPage(0, 1);
        assertEquals(1, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("test", "test").includeProcessVariables().count());
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).listPage(1, 2);
        assertEquals(2, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).listPage(3, 4);
        assertEquals(1, instanceList.size());
        processInstance = instanceList.get(0);
        variableMap = processInstance.getProcessVariables();
        assertEquals(2, variableMap.size());
        assertEquals("test", variableMap.get("test"));
        assertEquals("test2", variableMap.get("test2"));
        instanceList = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().processDefinitionKey(PROCESS_DEFINITION_KEY).listPage(4, 2);
        assertEquals(0, instanceList.size());
        instanceList = historyService.createHistoricProcessInstanceQuery().variableValueEquals("test", "test").includeProcessVariables().orderByProcessInstanceId().asc().listPage(0, 50);
        assertEquals(4, instanceList.size());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Aggregations

HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)74 Deployment (org.activiti.engine.test.Deployment)34 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)29 Task (org.activiti.engine.task.Task)14 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)9 Item (com.vaadin.data.Item)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)6 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)6 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 Test (org.junit.Test)6 Property (com.vaadin.data.Property)4 ValueChangeEvent (com.vaadin.data.Property.ValueChangeEvent)4 Table (com.vaadin.ui.Table)4 Calendar (java.util.Calendar)4 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3