Search in sources :

Example 26 with EventNode

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

the class ProcessHandler method linkBoundaryTimerEvent.

protected void linkBoundaryTimerEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
    StateBasedNode compositeNode = (StateBasedNode) attachedNode;
    String timeDuration = (String) node.getMetaData().get("TimeDuration");
    String timeCycle = (String) node.getMetaData().get("TimeCycle");
    String timeDate = (String) node.getMetaData().get("TimeDate");
    Timer timer = new Timer();
    if (timeDuration != null) {
        timer.setDelay(timeDuration);
        timer.setTimeType(Timer.TIME_DURATION);
        ConsequenceAction consequenceAction = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
        compositeNode.addTimer(timer, consequenceAction);
    } else if (timeCycle != null) {
        int index = timeCycle.indexOf("###");
        if (index != -1) {
            String period = timeCycle.substring(index + 3);
            timeCycle = timeCycle.substring(0, index);
            timer.setPeriod(period);
        }
        timer.setDelay(timeCycle);
        timer.setTimeType(Timer.TIME_CYCLE);
        String finalTimeCycle = timeCycle;
        ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + finalTimeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
        compositeNode.addTimer(timer, action);
    } else if (timeDate != null) {
        timer.setDate(timeDate);
        timer.setTimeType(Timer.TIME_DATE);
        ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId(), kcontext -> kcontext.getNodeInstance().getId(), SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
        compositeNode.addTimer(timer, action);
    }
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<ProcessAction>();
        }
        ConsequenceAction action = createJavaAction(new CancelNodeInstanceAction(attachedTo));
        actions.add(action);
        ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
    }
}
Also used : Handler(io.automatiko.engine.workflow.compiler.xml.Handler) CompensationHandler(io.automatiko.engine.workflow.base.core.context.exception.CompensationHandler) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) Constraint(io.automatiko.engine.workflow.process.core.Constraint) ExecutableProcessValidator(io.automatiko.engine.workflow.process.executable.core.validation.ExecutableProcessValidator) LoggerFactory(org.slf4j.LoggerFactory) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) FunctionTagDefinition(io.automatiko.engine.workflow.base.core.FunctionTagDefinition) Error(io.automatiko.engine.workflow.bpmn2.core.Error) Action(io.automatiko.engine.workflow.base.instance.impl.Action) NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) Matcher(java.util.regex.Matcher) ConstraintImpl(io.automatiko.engine.workflow.process.core.impl.ConstraintImpl) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) DataStore(io.automatiko.engine.workflow.bpmn2.core.DataStore) CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) Map(java.util.Map) TagDefinition(io.automatiko.engine.workflow.base.core.TagDefinition) Swimlane(io.automatiko.engine.workflow.base.core.context.swimlane.Swimlane) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) FaultNode(io.automatiko.engine.workflow.process.core.node.FaultNode) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) List(java.util.List) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) ProcessInstanceCompensationAction(io.automatiko.engine.workflow.base.instance.impl.actions.ProcessInstanceCompensationAction) PatternConstants(io.automatiko.engine.workflow.util.PatternConstants) ExtensibleXmlParser(io.automatiko.engine.workflow.compiler.xml.ExtensibleXmlParser) SAXException(org.xml.sax.SAXException) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) BaseAbstractHandler(io.automatiko.engine.workflow.compiler.xml.BaseAbstractHandler) StaticTagDefinition(io.automatiko.engine.workflow.base.core.StaticTagDefinition) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface) Lane(io.automatiko.engine.workflow.bpmn2.core.Lane) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) IntermediateLink(io.automatiko.engine.workflow.bpmn2.core.IntermediateLink) Resource(io.automatiko.engine.workflow.bpmn2.core.Resource) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) Split(io.automatiko.engine.workflow.process.core.node.Split) HashMap(java.util.HashMap) ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) DataAssociation(io.automatiko.engine.workflow.process.core.node.DataAssociation) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) Escalation(io.automatiko.engine.workflow.bpmn2.core.Escalation) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) Attributes(org.xml.sax.Attributes) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) Association(io.automatiko.engine.workflow.bpmn2.core.Association) Logger(org.slf4j.Logger) Signal(io.automatiko.engine.workflow.bpmn2.core.Signal) ConnectionImpl(io.automatiko.engine.workflow.process.core.impl.ConnectionImpl) Connection(io.automatiko.engine.workflow.process.core.Connection) ExtendedNodeImpl(io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) SequenceFlow(io.automatiko.engine.workflow.bpmn2.core.SequenceFlow) ConnectionRef(io.automatiko.engine.workflow.process.core.impl.ConnectionRef) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) Process(io.automatiko.engine.workflow.base.core.Process) CompensationScope(io.automatiko.engine.workflow.base.core.context.exception.CompensationScope) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) MVEL(org.mvel2.MVEL) Message(io.automatiko.engine.workflow.bpmn2.core.Message) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Timer(io.automatiko.engine.workflow.base.core.timer.Timer)

Example 27 with EventNode

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

the class ProcessHandler method linkBoundaryErrorEvent.

protected void linkBoundaryErrorEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    ContextContainer compositeNode = (ContextContainer) attachedNode;
    ExceptionScope exceptionScope = (ExceptionScope) compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope == null) {
        exceptionScope = new ExceptionScope();
        compositeNode.addContext(exceptionScope);
        compositeNode.setDefaultContext(exceptionScope);
    }
    String errorCode = (String) node.getMetaData().get("ErrorEvent");
    boolean hasErrorCode = (Boolean) node.getMetaData().get("HasErrorEvent");
    String errorStructureRef = (String) node.getMetaData().get("ErrorStructureRef");
    ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
    String variable = ((EventNode) node).getVariableName();
    ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Error-" + attachedTo + "-" + errorCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
    exceptionHandler.setAction(action);
    exceptionHandler.setFaultVariable(variable);
    if (hasErrorCode) {
        for (String error : errorCode.split(",")) {
            exceptionScope.setExceptionHandler(error, exceptionHandler);
        }
    } else {
        exceptionScope.setExceptionHandler(null, exceptionHandler);
    }
    exceptionHandler.setRetryAfter((Integer) node.getMetaData().get("ErrorRetry"));
    exceptionHandler.setRetryLimit((Integer) node.getMetaData().get("ErrorRetryLimit"));
    exceptionHandler.setRetryIncrement((Integer) node.getMetaData().get("ErrorRetryIncrement"));
    if (node.getMetaData().get("ErrorRetryIncrementMultiplier") != null) {
        exceptionHandler.setRetryIncrementMultiplier(((Number) node.getMetaData().get("ErrorRetryIncrementMultiplier")).floatValue());
    }
    if (errorStructureRef != null) {
        exceptionScope.setExceptionHandler(errorStructureRef, exceptionHandler);
    }
    List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
    if (actions == null) {
        actions = new ArrayList<ProcessAction>();
    }
    ConsequenceAction cancelAction = new ConsequenceAction("java", null);
    cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
    actions.add(cancelAction);
    ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode)

Example 28 with EventNode

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

the class ProcessHandler method linkBoundaryConditionEvent.

protected void linkBoundaryConditionEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    String processId = ((ExecutableProcess) nodeContainer).getId();
    String eventType = "RuleFlowStateEvent-" + processId + "-" + ((EventNode) node).getUniqueId() + "-" + attachedTo;
    ((EventTypeFilter) ((EventNode) node).getEventFilters().get(0)).setType(eventType);
    boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
    if (cancelActivity) {
        List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
        if (actions == null) {
            actions = new ArrayList<ProcessAction>();
        }
        ConsequenceAction action = createJavaAction(new CancelNodeInstanceAction(attachedTo));
        actions.add(action);
        ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
    }
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Example 29 with EventNode

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

the class IntermediateCatchEventHandler method readDataOutputAssociation.

protected void readDataOutputAssociation(org.w3c.dom.Node xmlNode, EventNode eventNode) {
    // sourceRef
    org.w3c.dom.Node subNode = xmlNode.getFirstChild();
    String from = subNode.getTextContent();
    String to = null;
    Transformation transformation = null;
    // targetRef
    subNode = subNode.getNextSibling();
    if (subNode != null && "targetRef".equals(subNode.getNodeName())) {
        to = subNode.getTextContent();
        eventNode.setVariableName(to);
        subNode = subNode.getNextSibling();
    }
    if (subNode != null && "transformation".equals(subNode.getNodeName())) {
        String lang = subNode.getAttributes().getNamedItem("language").getNodeValue();
        String expression = subNode.getTextContent();
        DataTransformer transformer = transformerRegistry.find(lang);
        if (transformer == null) {
            throw new IllegalArgumentException("No transformer registered for language " + lang);
        }
        transformation = new Transformation(lang, expression, dataOutputs.get(from));
        eventNode.setMetaData("Transformation", transformation);
        eventNode.setEventTransformer(new EventTransformerImpl(transformation));
    } else if (subNode != null && "assignment".equals(subNode.getNodeName())) {
        // assignments
        while (subNode != null) {
            org.w3c.dom.Node ssubNode = subNode.getFirstChild();
            to = ssubNode.getNextSibling().getTextContent();
            subNode = subNode.getNextSibling();
            eventNode.setVariableName(to);
        }
    }
}
Also used : Transformation(io.automatiko.engine.workflow.process.core.node.Transformation) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) TimerNode(io.automatiko.engine.workflow.process.core.node.TimerNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) CatchLinkNode(io.automatiko.engine.workflow.process.core.node.CatchLinkNode) Node(io.automatiko.engine.workflow.process.core.Node) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Example 30 with EventNode

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

the class IntermediateCatchEventHandler method handleSignalNode.

protected void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    EventNode eventNode = (EventNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataOutput".equals(nodeName)) {
            String id = ((Element) xmlNode).getAttribute("id");
            String outputName = ((Element) xmlNode).getAttribute("name");
            dataOutputs.put(id, outputName);
            populateDataOutputs(xmlNode, outputName, parser);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, eventNode);
        } else if ("signalEventDefinition".equals(nodeName)) {
            String type = ((Element) xmlNode).getAttribute("signalRef");
            if (type != null && type.trim().length() > 0) {
                Signal signal = findSignalByName(parser, type);
                if (signal != null) {
                    eventNode.setMetaData("MessageType", retrieveDataType(signal.getStructureRef(), null, parser));
                }
                type = checkSignalAndConvertToRealSignalNam(parser, type);
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType(type);
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Signal(io.automatiko.engine.workflow.bpmn2.core.Signal) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter)

Aggregations

EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)37 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)19 EventTypeFilter (io.automatiko.engine.workflow.base.core.event.EventTypeFilter)18 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)18 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)18 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)18 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)17 Node (io.automatiko.engine.api.definition.process.Node)16 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)13 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 FaultNode (io.automatiko.engine.workflow.process.core.node.FaultNode)13 StateNode (io.automatiko.engine.workflow.process.core.node.StateNode)13 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)13 ArrayList (java.util.ArrayList)13 EventFilter (io.automatiko.engine.workflow.base.core.event.EventFilter)11 StateBasedNode (io.automatiko.engine.workflow.process.core.node.StateBasedNode)11 CancelNodeInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction)10 HumanTaskNode (io.automatiko.engine.workflow.process.core.node.HumanTaskNode)10 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)10