Search in sources :

Example 16 with ProcessInstance

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());
}
Also used : ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance)

Example 17 with ProcessInstance

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());
                }
            }
        }
    }
}
Also used : Collection(java.util.Collection) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) ByteArrayFile(io.automatiko.engine.workflow.file.ByteArrayFile)

Example 18 with ProcessInstance

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);
}
Also used : Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) ArrayList(java.util.ArrayList) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) TestProcessEventListener(io.automatiko.engine.workflow.process.test.TestProcessEventListener) Test(org.junit.jupiter.api.Test) AbstractBaseTest(io.automatiko.engine.workflow.test.util.AbstractBaseTest)

Example 19 with 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;
    }
}
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 20 with 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;
}
Also used : ArrayList(java.util.ArrayList) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance)

Aggregations

ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)56 ArrayList (java.util.ArrayList)25 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)19 List (java.util.List)18 WorkItem (io.automatiko.engine.api.runtime.process.WorkItem)17 ProcessCompletedEvent (io.automatiko.engine.api.event.process.ProcessCompletedEvent)16 ProcessEventListener (io.automatiko.engine.api.event.process.ProcessEventListener)16 ProcessNodeLeftEvent (io.automatiko.engine.api.event.process.ProcessNodeLeftEvent)16 ProcessNodeTriggeredEvent (io.automatiko.engine.api.event.process.ProcessNodeTriggeredEvent)16 ProcessStartedEvent (io.automatiko.engine.api.event.process.ProcessStartedEvent)16 ProcessVariableChangedEvent (io.automatiko.engine.api.event.process.ProcessVariableChangedEvent)16 ProcessRuntime (io.automatiko.engine.api.runtime.process.ProcessRuntime)16 DelayedExecution (io.automatiko.engine.api.event.process.DelayedExecution)15 ProcessNodeInstanceFailedEvent (io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent)15 ProcessSignaledEvent (io.automatiko.engine.api.event.process.ProcessSignaledEvent)15 ProcessWorkItemTransitionEvent (io.automatiko.engine.api.event.process.ProcessWorkItemTransitionEvent)15 SLAViolatedEvent (io.automatiko.engine.api.event.process.SLAViolatedEvent)15 UnitOfWorkManager (io.automatiko.engine.api.uow.UnitOfWorkManager)15 WorkUnit (io.automatiko.engine.api.uow.WorkUnit)15 Transition (io.automatiko.engine.api.workflow.workitem.Transition)15