Package org.activiti.engine.runtime

Examples of org.activiti.engine.runtime.ProcessInstance


        List<String> processIds = (List<String>) execution.getVariable(variableWithProcessIds);

        List<String> forceEnded = Lists.newArrayList(Iterables.filter(processIds, new Predicate<String>() {
            @Override
            public boolean apply(String processInstanceId) {
                ProcessInstance instance = runtimeService.createProcessInstanceQuery()
                    .processInstanceId(processInstanceId).singleResult();
                if (instance != null && !instance.isEnded()) {
                    runtimeService.deleteProcessInstance(processInstanceId, "Pending process needs to be killed");
                    return true;
                }
                return false;
            }
View Full Code Here


        LOG.info(String.format("Process instance %s ended as expected in less than %d milliseconds",
            processInstanceId, timeoutInMilliseconds));
    }

    private boolean isProcessNotEnded(final String processInstanceId) throws InterruptedException {
        ProcessInstance localInstance = getProcessInstanceById(processInstanceId);
        return localInstance != null && !localInstance.isEnded();
    }
View Full Code Here

        ProcessEngine pe = this.getProcessEngine();
        RepositoryService repo = pe.getRepositoryService();
        RuntimeService rt = pe.getRuntimeService();
        HistoryService hs = pe.getHistoryService();

        ProcessInstance pi = rt.createProcessInstanceQuery().processInstanceId(pid).singleResult();
        HistoricProcessInstance hpi = hs.createHistoricProcessInstanceQuery().processInstanceId(pid)
            .singleResult();
        if (pi == null && hpi == null) {
            // both null means. no process with that id.
            out().printf("No process details found with process id %s \n", pid);
            return;
        }

        String pdId = null;
        if (pi != null) {
            pdId = pi.getProcessDefinitionId();
        } else if (hpi != null) {
            pdId = hpi.getProcessDefinitionId();
        }

        ProcessDefinition pd = repo.createProcessDefinitionQuery().processDefinitionId(pdId).singleResult();
View Full Code Here

            return null;
        }

        RuntimeService rt = pe.getRuntimeService();
        if (definitionID != null) {
            ProcessInstance pi = rt.startProcessInstanceById(definitionID);
            out().printf("Process instance %s Started\n", pi.getProcessInstanceId());
        }

        return null;
    }
View Full Code Here

        arguments.put(ProcessVariables.SPOT_BID, pool.getProvider().getOption(ProviderOptions.SPOT_BID));

        /* Authenticate as kermit to make the process visible in the Explorer UI */
        processEngine.getIdentityService().setAuthenticatedUserId(CoreConstants.ACTIVITI_EXPLORER_DEFAULT_USER);

        ProcessInstance instance = processEngine.getRuntimeService()
            .startProcessInstanceByKey(MANAGEMENT_PROCESS_KEY, businessKey, arguments);

        return instance.getProcessInstanceId();
    }
View Full Code Here

        return instance.getProcessInstanceId();
    }

    @Override
    public List<Machine> getMachines(String businessKey) {
        ProcessInstance instance = processEngine.getRuntimeService().createProcessInstanceQuery()
            .processInstanceBusinessKey(businessKey).singleResult();
        if (instance == null) {
            throw new NoSuchElementException("No active pool found with key: " + businessKey);
        }

        @SuppressWarnings("unchecked") List<Machine> machines = (List<Machine>) processEngine.getRuntimeService()
            .getVariable(instance.getId(), CoreProcessVariables.MACHINES);

        return Optional.fromNullable(machines).or(Collections.<Machine>emptyList());
    }
View Full Code Here

        return Optional.fromNullable(machines).or(Collections.<Machine>emptyList());
    }

    @Override
    public String getStatus(String businessKey) {
        ProcessInstance instance = processEngine.getRuntimeService().createProcessInstanceQuery()
            .processInstanceBusinessKey(businessKey).singleResult();
        if (instance == null) {
            throw new NoSuchElementException("No active pool found with key: " + businessKey);
        }

        String status = (String) processEngine.getRuntimeService().getVariable(instance.getId(),
            CoreProcessVariables.STATUS);

        return Optional.fromNullable(status).or(PoolStatus.UNDEFINED);
    }
View Full Code Here

        /* Authenticate as kermit to make the process visible in the Explorer UI */
        processEngine.getIdentityService().setAuthenticatedUserId(CoreConstants.ACTIVITI_EXPLORER_DEFAULT_USER);

        RuntimeService runtimeService = processEngine.getRuntimeService();
        ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS_KEY, businessKey, arguments);

        return instance.getProcessInstanceId();
    }
View Full Code Here

        Map<String, Object> variables = new TreeMap<String, Object>();
        variables.put("myfoo", new Foo());
        variables.put("mybar", new Bar());
        variables.put("my.array", new Object[]{new Foo(), new Bar()});

        ProcessInstance processInstance = this.startProcess(processKey, variables);

        InfoActivitiCommand command = new InfoActivitiCommand();
        command.setProcessEngine(this.getProcessEngine());
        command.setInstanceID(processInstance.getId());
        command.setOut(getOut());
        command.setErr(getErr());

        command.doExecute();
View Full Code Here

        command.setBusinessKey(TEST_BUSINESS_KEY);
        command.execute(session);
    }

    public ProcessEngine mockProcessEngine(String processInstanceId, String businessKey, String providerId) {
        ProcessInstance instance = mock(ProcessInstance.class);
        when(instance.getId()).thenReturn(processInstanceId);

        ProcessInstanceQuery query = mock(ProcessInstanceQuery.class);
        when(query.singleResult()).thenReturn(instance);
        when(query.processInstanceBusinessKey(eq(businessKey))).thenReturn(query);
View Full Code Here

TOP

Related Classes of org.activiti.engine.runtime.ProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.