use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskDetailPanel method populateSubTasks.
protected void populateSubTasks(List<HistoricTaskInstance> subTasks) {
for (final HistoricTaskInstance subTask : subTasks) {
// icon
Embedded icon = new Embedded(null, Images.TASK_22);
icon.setWidth(22, UNITS_PIXELS);
icon.setWidth(22, UNITS_PIXELS);
subTaskGrid.addComponent(icon);
// Link to subtask
Button subTaskLink = new Button(subTask.getName());
subTaskLink.addStyleName(Reindeer.BUTTON_LINK);
subTaskLink.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApp.get().getViewManager().showTaskPage(subTask.getId());
}
});
subTaskGrid.addComponent(subTaskLink);
subTaskGrid.setComponentAlignment(subTaskLink, Alignment.MIDDLE_LEFT);
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class HistoricTaskDetailPanel method initParentTaskLink.
protected void initParentTaskLink() {
if (historicTask.getParentTaskId() != null) {
final HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(historicTask.getParentTaskId()).singleResult();
Button showParentTaskButton = new Button(i18nManager.getMessage(Messages.TASK_SUBTASK_OF_PARENT_TASK, parentTask.getName()));
showParentTaskButton.addStyleName(Reindeer.BUTTON_LINK);
showParentTaskButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
viewManager.showTaskPage(parentTask.getId());
}
});
centralLayout.addComponent(showParentTaskButton);
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskResourceTest method testCompleteTask.
/**
* Test completing a single task.
* POST runtime/tasks/{taskId}
*/
@Deployment
public void testCompleteTask() throws Exception {
try {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
ObjectNode requestNode = objectMapper.createObjectNode();
requestNode.put("action", "complete");
HttpPost httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, task.getId()));
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_OK));
// Task shouldn't exist anymore
task = taskService.createTaskQuery().taskId(taskId).singleResult();
assertNull(task);
// Test completing with variables
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskId = task.getId();
requestNode = objectMapper.createObjectNode();
ArrayNode variablesNode = objectMapper.createArrayNode();
requestNode.put("action", "complete");
requestNode.put("variables", variablesNode);
ObjectNode var1 = objectMapper.createObjectNode();
variablesNode.add(var1);
var1.put("name", "var1");
var1.put("value", "First value");
ObjectNode var2 = objectMapper.createObjectNode();
variablesNode.add(var2);
var2.put("name", "var2");
var2.put("value", "Second value");
httpPost = new HttpPost(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK, taskId));
httpPost.setEntity(new StringEntity(requestNode.toString()));
closeResponse(executeRequest(httpPost, HttpStatus.SC_OK));
task = taskService.createTaskQuery().taskId(taskId).singleResult();
assertNull(task);
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
assertNotNull(historicTaskInstance);
List<HistoricVariableInstance> updates = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list();
assertNotNull(updates);
assertEquals(2, updates.size());
boolean foundFirst = false;
boolean foundSecond = false;
for (HistoricVariableInstance var : updates) {
if (var.getVariableName().equals("var1")) {
assertEquals("First value", var.getValue());
foundFirst = true;
} else if (var.getVariableName().equals("var2")) {
assertEquals("Second value", var.getValue());
foundSecond = true;
}
}
assertTrue(foundFirst);
assertTrue(foundSecond);
}
} finally {
// Clean adhoc-tasks even if test fails
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.deleteTask(task.getId(), true);
}
// Clean historic tasks with no runtime-counterpart
List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().list();
for (HistoricTaskInstance task : historicTasks) {
historyService.deleteHistoricTaskInstance(task.getId());
}
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class SecureScriptingBaseTest method assertProcessEnded.
public void assertProcessEnded(final String processInstanceId) {
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (processInstance != null) {
throw new AssertionFailedError("Expected finished process instance '" + processInstanceId + "' but it was still in the db");
}
// Verify historical data if end times are correctly set
if (processEngine.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
// process instance
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
Assert.assertEquals(processInstanceId, historicProcessInstance.getId());
Assert.assertNotNull("Historic process instance has no start time", historicProcessInstance.getStartTime());
Assert.assertNotNull("Historic process instance has no end time", historicProcessInstance.getEndTime());
// tasks
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).list();
if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) {
Assert.assertEquals(processInstanceId, historicTaskInstance.getProcessInstanceId());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no start time", historicTaskInstance.getStartTime());
Assert.assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no end time", historicTaskInstance.getEndTime());
}
}
// activities
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
if (historicActivityInstances != null && historicActivityInstances.size() > 0) {
for (HistoricActivityInstance historicActivityInstance : historicActivityInstances) {
Assert.assertEquals(processInstanceId, historicActivityInstance.getProcessInstanceId());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no start time", historicActivityInstance.getStartTime());
Assert.assertNotNull("Historic activity instance " + historicActivityInstance.getActivityId() + " has no end time", historicActivityInstance.getEndTime());
}
}
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class ScriptTaskListenerTest method testScriptTaskListener.
@Deployment(resources = { "org/activiti/examples/bpmn/tasklistener/ScriptTaskListenerTest.bpmn20.xml" })
public void testScriptTaskListener() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("scriptTaskListenerProcess");
Task task = taskService.createTaskQuery().singleResult();
assertEquals("Name does not match", "All your base are belong to us", task.getName());
taskService.complete(task.getId());
if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals("kermit", historicTask.getOwner());
task = taskService.createTaskQuery().singleResult();
assertEquals("Task name not set with 'bar' variable", "BAR", task.getName());
}
Object bar = runtimeService.getVariable(processInstance.getId(), "bar");
assertNull("Expected 'bar' variable to be local to script", bar);
Object foo = runtimeService.getVariable(processInstance.getId(), "foo");
assertEquals("Could not find the 'foo' variable in variable scope", "FOO", foo);
}
Aggregations