Search in sources :

Example 1 with ProcessInstanceManager

use of io.automatiko.engine.workflow.base.instance.ProcessInstanceManager in project automatiko-engine by automatiko-io.

the class ProcessInstanceResolverStrategy method unmarshal.

public Object unmarshal(String dataType, Context context, ObjectInputStream is, byte[] object, ClassLoader classloader) throws IOException, ClassNotFoundException {
    String processInstanceId = new String(object);
    ProcessInstanceManager pim = retrieveProcessInstanceManager(is);
    // load it as read only to avoid any updates to the data base
    ProcessInstance processInstance = pim.getProcessInstance(processInstanceId, true);
    if (processInstance == null) {
        ExecutableProcessInstance result = new ExecutableProcessInstance();
        result.setId(processInstanceId);
        result.internalSetState(ProcessInstance.STATE_COMPLETED);
        return result;
    } else {
        connectProcessInstanceToRuntimeAndProcess(processInstance, is);
        return processInstance;
    }
}
Also used : ProcessInstanceManager(io.automatiko.engine.workflow.base.instance.ProcessInstanceManager) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance)

Example 2 with ProcessInstanceManager

use of io.automatiko.engine.workflow.base.instance.ProcessInstanceManager in project automatiko-engine by automatiko-io.

the class ProcessInstanceResolverStrategy method retrieveKnowledgeRuntime.

/**
 * Retrieve the {@link ProcessInstanceManager} object from the ObjectOutput- or
 * ObjectInputStream. The stream object will secretly also either be a
 * {@link MarshallerReaderContext} or a {@link MarshallerWriteContext}.
 * </p>
 * The knowledge runtime object is useful in order to reconnect the process
 * instance to the process and the knowledge runtime object.
 *
 * @param streamContext The marshaller stream/context.
 * @return A {@link InternalKnowledgeRuntime} object.
 */
public static InternalProcessRuntime retrieveKnowledgeRuntime(Object streamContext) {
    InternalProcessRuntime kruntime = null;
    if (streamContext instanceof MarshallerWriteContext) {
        MarshallerWriteContext context = (MarshallerWriteContext) streamContext;
        kruntime = context.getProcessRuntime();
    } else if (streamContext instanceof MarshallerReaderContext) {
        MarshallerReaderContext context = (MarshallerReaderContext) streamContext;
        kruntime = context.getProcessRuntime();
    } else {
        throw new UnsupportedOperationException("Unable to retrieve " + ProcessInstanceManager.class.getSimpleName() + " from " + streamContext.getClass().getName());
    }
    return kruntime;
}
Also used : ProcessInstanceManager(io.automatiko.engine.workflow.base.instance.ProcessInstanceManager) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Example 3 with ProcessInstanceManager

use of io.automatiko.engine.workflow.base.instance.ProcessInstanceManager in project automatiko-engine by automatiko-io.

the class ProcessInstanceResolverStrategy method retrieveProcessInstanceManager.

/**
 * Retrieve the {@link ProcessInstanceManager} object from the ObjectOutput- or
 * ObjectInputStream. The stream object will secretly also either be a
 * {@link MarshallerReaderContext} or a {@link MarshallerWriteContext}.
 *
 * @param streamContext The marshaller stream/context.
 * @return A {@link ProcessInstanceManager} object.
 */
public static ProcessInstanceManager retrieveProcessInstanceManager(Object streamContext) {
    ProcessInstanceManager pim = null;
    if (streamContext instanceof MarshallerWriteContext) {
        MarshallerWriteContext context = (MarshallerWriteContext) streamContext;
        pim = ((ProcessRuntimeImpl) context.getProcessRuntime()).getProcessInstanceManager();
    } else if (streamContext instanceof MarshallerReaderContext) {
        MarshallerReaderContext context = (MarshallerReaderContext) streamContext;
        pim = ((ProcessRuntimeImpl) context.getProcessRuntime()).getProcessInstanceManager();
    } else {
        throw new UnsupportedOperationException("Unable to retrieve " + ProcessInstanceManager.class.getSimpleName() + " from " + streamContext.getClass().getName());
    }
    return pim;
}
Also used : ProcessInstanceManager(io.automatiko.engine.workflow.base.instance.ProcessInstanceManager) ProcessRuntimeImpl(io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl)

Aggregations

ProcessInstanceManager (io.automatiko.engine.workflow.base.instance.ProcessInstanceManager)3 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)1 InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)1 ProcessRuntimeImpl (io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl)1 ExecutableProcessInstance (io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance)1