Java Code Examples for org.kie.api.runtime.process.ProcessInstance#getState()

The following examples show how to use org.kie.api.runtime.process.ProcessInstance#getState() . 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: SuspendProcessInstanceCommand.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public Object execute(Context context ) {
    KieSession ksession = ((RegistryContext) context).lookup( KieSession.class );
    if (processInstanceId == null) {
        return null;
    }
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
    if ( processInstance == null ) {
        throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId );
    }
    if ( processInstance.getState() != ProcessInstance.STATE_ACTIVE ) {
    	throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState());
    }
    ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_SUSPENDED );
    return null;
}
 
Example 2
Source File: ResumeProcessInstanceCommand.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
public Object execute(Context context ) {
    KieSession ksession = ((RegistryContext) context).lookup( KieSession.class );
    if (processInstanceId == null) {
        return null;
    }
    ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
    if ( processInstance == null ) {
        throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId );
    }
    if ( processInstance.getState() != ProcessInstance.STATE_SUSPENDED ) {
    	throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState());
    }
    ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ACTIVE );
    return null;
}
 
Example 3
Source File: KieClientConnector.java    From pnc with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isProcessInstanceCompleted(Long processInstanceId) {
    ProcessInstance processInstance = session.getProcessInstance(processInstanceId);
    log.debug("fetched: {}", processInstance);
    if (processInstance == null) {
        return true;
    }
    int state = processInstance.getState();
    return state == STATE_COMPLETED || state == STATE_ABORTED;
}
 
Example 4
Source File: JbpmBpmn2TestCase.java    From kogito-runtimes with Apache License 2.0 2 votes vote down vote up
protected boolean assertProcessInstanceState(int state, ProcessInstance processInstance) {
    
    return processInstance.getState() == state;         
}