Search in sources :

Example 31 with InternalProcessRuntime

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

the class SubProcessNodeInstance method cancel.

@Override
public void cancel() {
    super.cancel();
    if (getSubProcessNode() == null || !getSubProcessNode().isIndependent()) {
        ProcessInstance processInstance = null;
        InternalProcessRuntime kruntime = ((ProcessInstance) getProcessInstance()).getProcessRuntime();
        processInstance = (ProcessInstance) kruntime.getProcessInstance(processInstanceId);
        if (processInstance != null) {
            processInstance.setState(ProcessInstance.STATE_ABORTED);
        }
    }
}
Also used : ProcessInstance(io.automatiko.engine.workflow.base.instance.ProcessInstance) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Example 32 with InternalProcessRuntime

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

the class TimerNodeInstance method triggerCompleted.

public void triggerCompleted(boolean remove) {
    if (remove) {
        removeEventListeners();
        InternalProcessRuntime processRuntime = ((InternalProcessRuntime) getProcessInstance().getProcessRuntime());
        processRuntime.getUnitOfWorkManager().currentUnitOfWork().intercept(WorkUnit.create(timerId, e -> {
            processRuntime.getJobsService().cancelJob(timerId);
        }));
    }
    internalChangeState(NodeInstanceState.Occur);
    triggerCompleted(io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE, remove);
}
Also used : Logger(org.slf4j.Logger) Date(java.util.Date) NodeInstance(io.automatiko.engine.api.runtime.process.NodeInstance) NodeInstanceState(io.automatiko.engine.api.runtime.process.NodeInstanceState) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) LoggerFactory(org.slf4j.LoggerFactory) ExpirationTime(io.automatiko.engine.api.jobs.ExpirationTime) Set(java.util.Set) HashMap(java.util.HashMap) WorkUnit(io.automatiko.engine.api.uow.WorkUnit) TimerInstance(io.automatiko.engine.services.time.TimerInstance) JobsService(io.automatiko.engine.api.jobs.JobsService) BaseEventDescription(io.automatiko.engine.api.workflow.BaseEventDescription) Map(java.util.Map) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) EventListener(io.automatiko.engine.api.runtime.process.EventListener) EventDescription(io.automatiko.engine.api.workflow.EventDescription) ProcessInstanceJobDescription(io.automatiko.engine.api.jobs.ProcessInstanceJobDescription) WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance) Collections(java.util.Collections) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Example 33 with InternalProcessRuntime

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

the class EventNodeInstance method handleSLAViolation.

protected void handleSLAViolation() {
    if (slaCompliance == ProcessInstance.SLA_PENDING) {
        InternalProcessRuntime processRuntime = getProcessInstance().getProcessRuntime();
        processRuntime.getProcessEventSupport().fireBeforeSLAViolated(getProcessInstance(), this, getProcessInstance().getProcessRuntime());
        logger.debug("SLA violated on node instance {}", getId());
        this.slaCompliance = ProcessInstance.SLA_VIOLATED;
        this.slaTimerId = null;
        processRuntime.getProcessEventSupport().fireAfterSLAViolated(getProcessInstance(), this, getProcessInstance().getProcessRuntime());
    }
}
Also used : InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Example 34 with InternalProcessRuntime

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

the class NodeInstanceImpl method triggerNodeInstance.

protected void triggerNodeInstance(io.automatiko.engine.workflow.process.instance.NodeInstance nodeInstance, String type, boolean fireEvents) {
    if (nodeInstance == null) {
        return;
    }
    leaveTime = new Date();
    boolean hidden = false;
    if (getNode().getMetaData().get(HIDDEN) != null) {
        hidden = true;
    }
    InternalProcessRuntime runtime = getProcessInstance().getProcessRuntime();
    if (!hidden && fireEvents) {
        runtime.getProcessEventSupport().fireBeforeNodeLeft(this, runtime);
    }
    // trigger next node
    nodeInstance.trigger(this, type);
    Collection<Connection> outgoing = getNode().getOutgoingConnections(type);
    for (Connection conn : outgoing) {
        if (conn.getTo().getId() == nodeInstance.getNodeId()) {
            this.metaData.put(OUTGOING_CONNECTION, conn.getMetaData().get(UNIQUE_ID));
            break;
        }
    }
    if (!hidden && fireEvents) {
        runtime.getProcessEventSupport().fireAfterNodeLeft(this, runtime);
    }
}
Also used : Connection(io.automatiko.engine.api.definition.process.Connection) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) Date(java.util.Date)

Example 35 with InternalProcessRuntime

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

the class WorkflowProcessInstanceImpl method handleSLAViolation.

private void handleSLAViolation() {
    if (slaCompliance == SLA_PENDING) {
        InternalProcessRuntime processRuntime = getProcessRuntime();
        processRuntime.getProcessEventSupport().fireBeforeSLAViolated(this, processRuntime);
        logger.debug("SLA violated on process instance {}", getId());
        this.slaCompliance = SLA_VIOLATED;
        this.slaTimerId = null;
        processRuntime.getProcessEventSupport().fireAfterSLAViolated(this, processRuntime);
    }
}
Also used : InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)

Aggregations

InternalProcessRuntime (io.automatiko.engine.workflow.base.instance.InternalProcessRuntime)39 Test (org.junit.jupiter.api.Test)18 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)17 ArrayList (java.util.ArrayList)17 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)16 HashMap (java.util.HashMap)12 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)11 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)10 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)10 List (java.util.List)10 Map (java.util.Map)10 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)9 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)8 ProcessRuntimeImpl (io.automatiko.engine.workflow.base.instance.ProcessRuntimeImpl)7 Date (java.util.Date)7 Process (io.automatiko.engine.api.definition.process.Process)6 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)6 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)6 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)6 WorkflowProcessInstance (io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance)6