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;
}
}
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;
}
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;
}
Aggregations