Search in sources :

Example 26 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.

the class StateBasedNodeInstance method internalTrigger.

@Override
public void internalTrigger(NodeInstance from, String type) {
    super.internalTrigger(from, type);
    // if node instance was cancelled, abort
    if (getNodeInstanceContainer().getNodeInstance(getId()) == null) {
        return;
    }
    addCompletionListeners();
    // activate timers
    Map<Timer, ProcessAction> timers = getEventBasedNode().getTimers();
    if (timers != null) {
        addTimerListener();
        timerInstances = new ArrayList<>(timers.size());
        JobsService jobService = getProcessInstance().getProcessRuntime().getJobsService();
        for (Timer timer : timers.keySet()) {
            ExpirationTime expirationTime = createTimerInstance(timer);
            String jobId = jobService.scheduleProcessInstanceJob(ProcessInstanceJobDescription.of(timer.getId(), expirationTime, getProcessInstanceIdWithParent(), getProcessInstance().getRootProcessInstanceId(), getProcessInstance().getProcessId(), getProcessInstance().getProcess().getVersion(), getProcessInstance().getRootProcessId()));
            timerInstances.add(jobId);
        }
    }
    ((WorkflowProcessInstanceImpl) getProcessInstance()).addActivatingNodeId((String) getNode().getMetaData().get("UniqueId"));
    if (getExtendedNode().hasCondition()) {
        ProcessContext context = new ProcessContext(getProcessInstance().getProcessRuntime());
        context.setProcessInstance(getProcessInstance());
        if (getExtendedNode().getMetaData("ConditionEventType") != null && getExtendedNode().isMet(context)) {
            getProcessInstance().signalEvent((String) getExtendedNode().getMetaData("ConditionEventType"), null);
        } else {
            getProcessInstance().addEventListener("variableChanged", this, false);
        }
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) JobsService(io.automatiko.engine.api.jobs.JobsService) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ExactExpirationTime(io.automatiko.engine.api.jobs.ExactExpirationTime) ExpirationTime(io.automatiko.engine.api.jobs.ExpirationTime) DurationExpirationTime(io.automatiko.engine.api.jobs.DurationExpirationTime) CronExpirationTime(io.automatiko.engine.workflow.base.core.timer.CronExpirationTime) ProcessContext(io.automatiko.engine.workflow.base.core.context.ProcessContext)

Example 27 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.

the class WorkflowProcessInstanceImpl method start.

@Override
public void start(String trigger, Object triggerData) {
    synchronized (this) {
        setStartDate(new Date());
        registerExternalEventNodeListeners();
        // activate timer event sub processes
        Node[] nodes = getNodeContainer().getNodes();
        for (Node node : nodes) {
            if (node instanceof EventSubProcessNode) {
                Map<Timer, ProcessAction> timers = ((EventSubProcessNode) node).getTimers();
                if (timers != null && !timers.isEmpty()) {
                    EventSubProcessNodeInstance eventSubProcess = (EventSubProcessNodeInstance) getNodeInstance(node);
                    eventSubProcess.trigger(null, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
                }
            }
        }
        super.start(trigger, triggerData);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) Node(io.automatiko.engine.api.definition.process.Node) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) Date(java.util.Date) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance)

Example 28 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.

the class TimerHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    Element element = parser.endElementBuilder();
    StateBasedNode parent = (StateBasedNode) parser.getParent();
    String id = element.getAttribute("id");
    emptyAttributeCheck(localName, "id", id, parser);
    String delay = element.getAttribute("delay");
    String period = element.getAttribute("period");
    Timer timer = new Timer();
    timer.setId(new Long(id));
    if (delay != null && delay.length() != 0) {
        timer.setDelay(delay);
    }
    if (period != null && period.length() != 0) {
        timer.setPeriod(period);
    }
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    ProcessAction action = null;
    if (xmlNode instanceof Element) {
        Element actionXml = (Element) xmlNode;
        action = AbstractNodeHandler.extractAction(actionXml);
    }
    parent.addTimer(timer, action);
    return null;
}
Also used : StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) Element(org.w3c.dom.Element)

Example 29 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.

the class AbstractNodeHandler method writeActions.

protected void writeActions(final String type, List<ProcessAction> actions, final StringBuilder xmlDump) {
    if (actions != null && actions.size() > 0) {
        xmlDump.append("      <" + type + ">" + EOL);
        for (ProcessAction action : actions) {
            writeAction(action, xmlDump);
        }
        xmlDump.append("      </" + type + ">" + EOL);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction)

Example 30 with ProcessAction

use of io.automatiko.engine.workflow.process.core.ProcessAction in project automatiko-engine by automatiko-io.

the class ActionNodeHandler method handleNode.

public void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    if (xmlNode instanceof Element) {
        Element actionXml = (Element) xmlNode;
        ProcessAction action = extractAction(actionXml);
        actionNode.setAction(action);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) Element(org.w3c.dom.Element) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode)

Aggregations

ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)47 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)30 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)20 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)18 ArrayList (java.util.ArrayList)18 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)15 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)14 Action (io.automatiko.engine.workflow.base.instance.impl.Action)13 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)13 Timer (io.automatiko.engine.workflow.base.core.timer.Timer)12 ProcessContext (io.automatiko.engine.api.runtime.process.ProcessContext)11 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)11 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)10 ConnectionImpl (io.automatiko.engine.workflow.process.core.impl.ConnectionImpl)9 Node (io.automatiko.engine.api.definition.process.Node)8 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)7 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)7 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)7 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)7