Java Code Examples for org.flowable.engine.runtime.ProcessInstance#isEnded()

The following examples show how to use org.flowable.engine.runtime.ProcessInstance#isEnded() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestResponseFactory.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public ProcessInstanceResponse createProcessInstanceResponse(ProcessInstance processInstance, boolean returnVariables,
        Map<String, Object> runtimeVariableMap, List<HistoricVariableInstance> historicVariableList) {

    RestUrlBuilder urlBuilder = createUrlBuilder();
    ProcessInstanceResponse result = internalCreateProcessInstanceResponse(processInstance, urlBuilder);

    if (returnVariables) {

        if (processInstance.isEnded()) {
            if (historicVariableList != null) {
                for (HistoricVariableInstance historicVariable : historicVariableList) {
                    result.addVariable(createRestVariable(historicVariable.getVariableName(), historicVariable.getValue(), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false,
                            urlBuilder));
                }
            }

        } else {
            if (runtimeVariableMap != null) {
                for (String name : runtimeVariableMap.keySet()) {
                    result.addVariable(createRestVariable(name, runtimeVariableMap.get(name), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
                }
            }
        }
    }
    return result;
}
 
Example 2
Source File: RestResponseFactory.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected ProcessInstanceResponse internalCreateProcessInstanceResponse(ProcessInstance processInstance, RestUrlBuilder urlBuilder) {
    ProcessInstanceResponse result = new ProcessInstanceResponse();
    result.setActivityId(processInstance.getActivityId());
    result.setStartUserId(processInstance.getStartUserId());
    result.setStartTime(processInstance.getStartTime());
    result.setBusinessKey(processInstance.getBusinessKey());
    result.setId(processInstance.getId());
    result.setName(processInstance.getName());
    result.setProcessDefinitionId(processInstance.getProcessDefinitionId());
    result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId()));
    result.setEnded(processInstance.isEnded());
    result.setSuspended(processInstance.isSuspended());
    result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId()));
    result.setCallbackId(processInstance.getCallbackId());
    result.setCallbackType(processInstance.getCallbackType());
    result.setReferenceId(processInstance.getReferenceId());
    result.setReferenceType(processInstance.getReferenceType());
    result.setTenantId(processInstance.getTenantId());

    if (processInstance.isEnded()) {
        result.setCompleted(true);
    } else {
        result.setCompleted(false);
    }
    return result;
}
 
Example 3
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deprecated
public ProcessInstance startProcessByName(String string) {

    if (Context.getCommandContext() != null) {
        throw new FlowableCdiException("Cannot use startProcessByName in an active command.");
    }

    ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
    if (definition == null) {
        throw new FlowableObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
    }
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), getAndClearCachedVariables());
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 4
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Deprecated
public ProcessInstance startProcessByName(String string, Map<String, Object> variables) {

    if (Context.getCommandContext() != null) {
        throw new FlowableCdiException("Cannot use startProcessByName in an active command.");
    }

    ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
    if (definition == null) {
        throw new FlowableObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
    }
    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(variables);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables);
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 5
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId) {
    validateValidUsage();

    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, getAndClearCachedVariables());
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 6
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId, String businessKey) {
    validateValidUsage();

    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, businessKey, getAndClearCachedVariables());
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 7
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId, Map<String, Object> variables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(variables);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, cachedVariables);
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 8
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessById(String processDefinitionId, String businessKey, Map<String, Object> variables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(variables);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(processDefinitionId, businessKey, cachedVariables);
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 9
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key) {
    validateValidUsage();

    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, getAndClearCachedVariables());
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 10
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key, String businessKey) {
    validateValidUsage();

    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, businessKey, getAndClearCachedVariables());
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 11
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key, Map<String, Object> variables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(variables);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, cachedVariables);
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 12
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByKey(String key, String businessKey, Map<String, Object> variables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(variables);
    ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceByKey(key, businessKey, cachedVariables);
    if (!instance.isEnded()) {
        setExecution(instance);
    }
    return instance;
}
 
Example 13
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByMessage(String messageName) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByMessage(messageName, cachedVariables);
    if (!processInstance.isEnded()) {
        setExecution(processInstance);
    }
    return processInstance;
}
 
Example 14
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByMessage(String messageName, Map<String, Object> processVariables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(processVariables);
    ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByMessage(messageName, cachedVariables);
    if (!processInstance.isEnded()) {
        setExecution(processInstance);
    }
    return processInstance;
}
 
Example 15
Source File: BusinessProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public ProcessInstance startProcessByMessage(String messageName, String businessKey, Map<String, Object> processVariables) {
    validateValidUsage();

    Map<String, Object> cachedVariables = getAndClearCachedVariables();
    cachedVariables.putAll(processVariables);
    ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByMessage(messageName, businessKey, cachedVariables);
    if (!processInstance.isEnded()) {
        setExecution(processInstance);
    }
    return processInstance;
}