Search in sources :

Example 16 with HistoricProcessInstance

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

the class BoundaryErrorEventTest method testDeeplyNestedErrorThrownOnlyAutomaticSteps.

@Deployment
public void testDeeplyNestedErrorThrownOnlyAutomaticSteps() {
    // input == 1 -> error2 is thrown -> caught on subprocess2 -> end event in subprocess -> proc inst end 1
    String procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId();
    assertProcessEnded(procId);
    HistoricProcessInstance hip;
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
        assertEquals("processEnd1", hip.getEndActivityId());
    }
    // input == 2 -> error2 is thrown -> caught on subprocess1 -> proc inst end 2
    procId = runtimeService.startProcessInstanceByKey("deeplyNestedErrorThrown", CollectionUtil.singletonMap("input", 1)).getId();
    assertProcessEnded(procId);
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        hip = historyService.createHistoricProcessInstanceQuery().processInstanceId(procId).singleResult();
        assertEquals("processEnd1", hip.getEndActivityId());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 17 with HistoricProcessInstance

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

the class TerminateEndEventTest method assertHistoricProcessInstanceDetails.

protected void assertHistoricProcessInstanceDetails(ProcessInstance pi) {
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(pi.getId()).singleResult();
        assertHistoricProcessInstance(historicProcessInstance);
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 18 with HistoricProcessInstance

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

the class AdminCompletedInstancesPanel method initInstancesTable.

protected void initInstancesTable() {
    instancesTable = new Table();
    instancesTable.setWidth(100, UNITS_PERCENTAGE);
    instancesTable.setHeight(250, UNITS_PIXELS);
    instancesTable.setEditable(false);
    instancesTable.setImmediate(true);
    instancesTable.setSelectable(true);
    instancesTable.setSortDisabled(false);
    instancesTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("business key", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_BUSINESSKEY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start user id", String.class, null, i18nManager.getMessage(Messages.ADMIN_STARTED_BY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start activity id", String.class, null, i18nManager.getMessage(Messages.ADMIN_START_ACTIVITY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start time", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_STARTED), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("end time", String.class, null, i18nManager.getMessage(Messages.TASK_COMPLETE_TIME), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("duration", String.class, null, i18nManager.getMessage(Messages.TASK_DURATION), null, Table.ALIGN_LEFT);
    instancesTable.addListener(new Property.ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            // the value of the property is the itemId of the table entry
            Item item = instancesTable.getItem(event.getProperty().getValue());
            if (item != null) {
                String instanceId = (String) item.getItemProperty("id").getValue();
                HistoricProcessInstance processInstance = null;
                for (HistoricProcessInstance instance : selectedManagementDefinition.runningInstances) {
                    if (instance.getId().equals(instanceId)) {
                        processInstance = instance;
                        break;
                    }
                }
                if (processInstance != null)
                    addProcessImage(selectedManagementDefinition.processDefinition, processInstance);
                addTasks(processInstance);
                addVariables(processInstance);
            }
        }
    });
    instancesLayout.addComponent(instancesTable);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoricFormProperty(org.activiti.engine.history.HistoricFormProperty) Property(com.vaadin.data.Property)

Example 19 with HistoricProcessInstance

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

the class AdminRunningInstancesPanel method initDefinitionsTable.

protected void initDefinitionsTable() {
    if (instanceList == null || instanceList.isEmpty()) {
        noMembersTable = new Label(i18nManager.getMessage(Messages.ADMIN_RUNNING_NONE_FOUND));
        definitionsLayout.addComponent(noMembersTable);
    } else {
        runningDefinitions = new HashMap<String, ManagementProcessDefinition>();
        for (HistoricProcessInstance instance : instanceList) {
            String processDefinitionId = instance.getProcessDefinitionId();
            ManagementProcessDefinition managementDefinition = null;
            if (runningDefinitions.containsKey(processDefinitionId)) {
                managementDefinition = runningDefinitions.get(processDefinitionId);
            } else {
                ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processDefinitionId).singleResult();
                if (definition == null) {
                    // this process has a missing definition - skip
                    continue;
                }
                managementDefinition = new ManagementProcessDefinition();
                managementDefinition.processDefinition = definition;
                managementDefinition.runningInstances = new ArrayList<HistoricProcessInstance>();
                runningDefinitions.put(definition.getId(), managementDefinition);
            }
            managementDefinition.runningInstances.add(instance);
        }
        definitionsTable = new Table();
        definitionsTable.setWidth(100, UNITS_PERCENTAGE);
        definitionsTable.setHeight(250, UNITS_PIXELS);
        definitionsTable.setEditable(false);
        definitionsTable.setImmediate(true);
        definitionsTable.setSelectable(true);
        definitionsTable.setSortDisabled(false);
        definitionsTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
        definitionsTable.addContainerProperty("name", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_NAME), null, Table.ALIGN_LEFT);
        definitionsTable.addContainerProperty("nr of instances", String.class, null, i18nManager.getMessage(Messages.ADMIN_NR_INSTANCES), null, Table.ALIGN_LEFT);
        for (ManagementProcessDefinition managementDefinition : runningDefinitions.values()) {
            definitionsTable.addItem(new String[] { managementDefinition.processDefinition.getId(), managementDefinition.processDefinition.getName(), String.valueOf(managementDefinition.runningInstances.size()) }, managementDefinition.processDefinition.getId());
        }
        definitionsTable.addListener(new Property.ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                // the value of the property is the itemId of the table entry
                Item item = definitionsTable.getItem(event.getProperty().getValue());
                if (item != null) {
                    String definitionId = (String) item.getItemProperty("id").getValue();
                    selectedManagementDefinition = runningDefinitions.get(definitionId);
                    refreshInstancesTable();
                }
            }
        });
        definitionsLayout.addComponent(definitionsTable);
    }
}
Also used : Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Label(com.vaadin.ui.Label) PrettyTimeLabel(org.activiti.explorer.ui.custom.PrettyTimeLabel) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Property(com.vaadin.data.Property)

Example 20 with HistoricProcessInstance

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

the class AdminRunningInstancesPanel method initInstancesTable.

protected void initInstancesTable() {
    instancesTable = new Table();
    instancesTable.setWidth(100, UNITS_PERCENTAGE);
    instancesTable.setHeight(250, UNITS_PIXELS);
    instancesTable.setEditable(false);
    instancesTable.setImmediate(true);
    instancesTable.setSelectable(true);
    instancesTable.setSortDisabled(false);
    instancesTable.addContainerProperty("id", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_ID), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("business key", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_BUSINESSKEY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start user id", String.class, null, i18nManager.getMessage(Messages.ADMIN_STARTED_BY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start activity id", String.class, null, i18nManager.getMessage(Messages.ADMIN_START_ACTIVITY), null, Table.ALIGN_LEFT);
    instancesTable.addContainerProperty("start time", String.class, null, i18nManager.getMessage(Messages.PROCESS_INSTANCE_STARTED), null, Table.ALIGN_LEFT);
    instancesTable.addListener(new Property.ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            // the value of the property is the itemId of the table entry
            Item item = instancesTable.getItem(event.getProperty().getValue());
            if (item != null) {
                String instanceId = (String) item.getItemProperty("id").getValue();
                HistoricProcessInstance processInstance = null;
                for (HistoricProcessInstance instance : selectedManagementDefinition.runningInstances) {
                    if (instance.getId().equals(instanceId)) {
                        processInstance = instance;
                        break;
                    }
                }
                if (processInstance != null)
                    addProcessImage(selectedManagementDefinition.processDefinition, processInstance);
                addTasks(processInstance);
                addVariables(processInstance);
            }
        }
    });
    instancesLayout.addComponent(instancesTable);
}
Also used : Item(com.vaadin.data.Item) ValueChangeEvent(com.vaadin.data.Property.ValueChangeEvent) Table(com.vaadin.ui.Table) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) Property(com.vaadin.data.Property)

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