Search in sources :

Example 1 with SignalNodeInstanceAction

use of org.jbpm.process.instance.impl.SignalNodeInstanceAction in project jbpm by kiegroup.

the class ProcessHandler method linkBoundaryTimerEvent.

private static 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();
    timer.setName(concatName(compositeNode.getName(), node.getName()));
    if (timeDuration != null) {
        timer.setDelay(timeDuration);
        timer.setTimeType(Timer.TIME_DURATION);
        DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeDuration + "-" + node.getId()));
        compositeNode.addTimer(timer, action);
    } 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);
        DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "-" + node.getId()));
        compositeNode.addTimer(timer, action);
    } else if (timeDate != null) {
        timer.setDate(timeDate);
        timer.setTimeType(Timer.TIME_DATE);
        DroolsConsequenceAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new SignalNodeInstanceAction("Timer-" + attachedTo + "-" + timeDate + "-" + node.getId()));
        compositeNode.addTimer(timer, action);
    }
    if (cancelActivity) {
        List<DroolsAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_BOUNDARY);
        if (actions == null) {
            actions = new ArrayList<DroolsAction>();
        }
        DroolsConsequenceAction cancelAction = new DroolsConsequenceAction("java", null);
        cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
        actions.add(cancelAction);
        ((EventNode) node).setActions(EndNode.EVENT_NODE_BOUNDARY, actions);
    }
}
Also used : StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) DroolsAction(org.jbpm.workflow.core.DroolsAction) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) CancelNodeInstanceAction(org.jbpm.process.instance.impl.CancelNodeInstanceAction) Timer(org.jbpm.process.core.timer.Timer) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) SignalNodeInstanceAction(org.jbpm.process.instance.impl.SignalNodeInstanceAction)

Aggregations

Timer (org.jbpm.process.core.timer.Timer)1 CancelNodeInstanceAction (org.jbpm.process.instance.impl.CancelNodeInstanceAction)1 SignalNodeInstanceAction (org.jbpm.process.instance.impl.SignalNodeInstanceAction)1 DroolsAction (org.jbpm.workflow.core.DroolsAction)1 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)1 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)1 EventNode (org.jbpm.workflow.core.node.EventNode)1 StateBasedNode (org.jbpm.workflow.core.node.StateBasedNode)1