Search in sources :

Example 11 with HistoricTaskInstance

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);
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) Embedded(com.vaadin.ui.Embedded) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 12 with HistoricTaskInstance

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);
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Button(com.vaadin.ui.Button) ClickEvent(com.vaadin.ui.Button.ClickEvent) ClickListener(com.vaadin.ui.Button.ClickListener)

Example 13 with HistoricTaskInstance

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());
        }
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) StringEntity(org.apache.http.entity.StringEntity) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Deployment(org.activiti.engine.test.Deployment)

Example 14 with HistoricTaskInstance

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());
            }
        }
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) AssertionFailedError(junit.framework.AssertionFailedError) HistoricActivityInstance(org.activiti.engine.history.HistoricActivityInstance)

Example 15 with HistoricTaskInstance

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);
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)64 Task (org.activiti.engine.task.Task)27 Deployment (org.activiti.engine.test.Deployment)26 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)16 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)6 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Label (com.vaadin.ui.Label)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Attachment (org.activiti.engine.task.Attachment)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3