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);
}
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());
}
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;
}
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);
}
}
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());
}
}
Aggregations