use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class CleanFilesEventListener method afterProcessCompleted.
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
ProcessInstance pi = event.getProcessInstance();
store.remove(pi.getProcess().getId(), pi.getProcess().getVersion(), pi.getId());
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class CleanFilesEventListener method afterProcessCompleted.
@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
ProcessInstance pi = event.getProcessInstance();
for (Entry<String, Object> variable : pi.getVariables().entrySet()) {
if (variable.getValue() instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) variable.getValue();
store.remove(pi.getProcess().getId(), pi.getProcess().getVersion(), pi.getId(), variable.getKey(), file.name());
} else if (variable.getValue() instanceof Collection) {
for (Object potentialFile : (Collection<?>) variable.getValue()) {
if (potentialFile instanceof ByteArrayFile) {
ByteArrayFile file = (ByteArrayFile) potentialFile;
store.remove(pi.getProcess().getId(), pi.getProcess().getVersion(), pi.getId(), variable.getKey(), file.name());
}
}
}
}
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class NodeInnerClassesTest method testNodeReading.
@Test
public void testNodeReading() {
ExecutableProcess process = new ExecutableProcess();
process.setId("org.company.core.process.event");
process.setName("Event Process");
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("event");
ObjectDataType personDataType = new ObjectDataType(Person.class);
variable.setType(personDataType);
variables.add(variable);
process.getVariableScope().setVariables(variables);
process.setDynamic(true);
CompositeNode compositeNode = new CompositeNode();
compositeNode.setName("CompositeNode");
compositeNode.setId(2);
ForEachNode forEachNode = new ForEachNode();
ForEachNode.ForEachSplitNode split = new ForEachNode.ForEachSplitNode();
split.setName("ForEachSplit");
split.setMetaData("hidden", true);
split.setMetaData("UniqueId", forEachNode.getMetaData("Uniqueid") + ":foreach:split");
forEachNode.internalAddNode(split);
forEachNode.linkIncomingConnections(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, new CompositeNode.NodeAndType(split, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE));
process.addNode(forEachNode);
InternalProcessRuntime ksession = createProcessRuntime(process);
TestProcessEventListener procEventListener = new TestProcessEventListener();
ksession.addEventListener(procEventListener);
ProcessInstance processInstance = ksession.startProcess("org.company.core.process.event");
assertNotNull(processInstance);
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance 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.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class ProtobufProcessMarshaller method readProcessInstances.
public List<ProcessInstance> readProcessInstances(MarshallerReaderContext context) throws IOException {
AutomatikoMessages.ProcessData _pdata = (AutomatikoMessages.ProcessData) context.parameterObject;
List<ProcessInstance> processInstanceList = new ArrayList<ProcessInstance>();
for (AutomatikoMessages.ProcessInstance _instance : _pdata.getExtension(AutomatikoMessages.processInstance)) {
context.parameterObject = _instance;
ProcessInstance processInstance = ProcessMarshallerRegistry.INSTANCE.getMarshaller(_instance.getProcessType()).readProcessInstance(context);
((WorkflowProcessInstanceImpl) processInstance).reconnect();
processInstanceList.add(processInstance);
}
return processInstanceList;
}
Aggregations