Package org.drools.workflow.core.node

Examples of org.drools.workflow.core.node.StartNode


    }

    private void initProcessEventListeners() {
        for ( Process process : ruleBase.getProcesses() ) {
            if ( process instanceof RuleFlowProcess ) {
                StartNode startNode = ((RuleFlowProcess) process).getStart();
                List<Trigger> triggers = startNode.getTriggers();
                if ( triggers != null ) {
                    for ( Trigger trigger : triggers ) {
                        if ( trigger instanceof EventTrigger ) {
                            final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
                            String type = null;
View Full Code Here


            public void addNode(org.drools.definition.process.Node node) {
                ((Node) node).setId(++id);
                super.addNode(node);
            }
        };
        process.addNode(new StartNode());
        process.addNode(new EndNode());
        process.addNode(new ActionNode());
        process.addNode(new Split());
        process.addNode(new Join());
        process.addNode(new MilestoneNode());
View Full Code Here

        exceptionHandler.setFaultVariable("faultVariable2");
        action = new DroolsConsequenceAction("dialect2", "consequence2");
        exceptionHandler.setAction(action);
        process.getExceptionScope().setExceptionHandler("myFault2", exceptionHandler);
       
        StartNode startNode = new StartNode();
        startNode.setName("start");
        startNode.setMetaData("x", 1);
        startNode.setMetaData("y", 2);
        startNode.setMetaData("width", 3);
        startNode.setMetaData("height", 4);
        ConstraintTrigger constraintTrigger = new ConstraintTrigger();
        constraintTrigger.setConstraint("constraint");
        Map<String, String> inMapping = new HashMap<String, String>();
        inMapping.put("key", "value");
        inMapping.put("key2", "value2");
        constraintTrigger.setInMappings(inMapping);
        startNode.addTrigger(constraintTrigger);
        EventTrigger eventTrigger = new EventTrigger();
        EventTypeFilter eventTypeFilter = new EventTypeFilter();
        eventTypeFilter.setType("eventType");
        eventTrigger.addEventFilter(eventTypeFilter);
        inMapping = new HashMap<String, String>();
        inMapping.put("key", "value");
        inMapping.put("key2", "value2");
        eventTrigger.setInMappings(inMapping);
        startNode.addTrigger(eventTrigger);
        process.addNode(startNode);
       
        ActionNode actionNode = new ActionNode();
        actionNode.setName("action");
        actionNode.setMetaData("x", 1);
View Full Code Here

                String messageType = (String) node.getMetaData().get("MessageType");
                xmlDump.append(
                    "  <itemDefinition id=\"" + XmlDumper.replaceIllegalChars(messageRef) + "Type\" structureRef=\"" + XmlDumper.replaceIllegalChars(messageType) + "\"/>" + EOL +
                    "  <message id=\"" + XmlDumper.replaceIllegalChars(messageRef) + "\" structureRef=\"" + XmlDumper.replaceIllegalChars(messageRef) + "Type\" />" + EOL + EOL);
            } else if (node instanceof StartNode) {
                StartNode startNode = (StartNode) node;
                if (startNode.getTriggers() != null && !startNode.getTriggers().isEmpty()) {
                    Trigger trigger = startNode.getTriggers().get(0);
                    if (trigger instanceof EventTrigger) {
                        String eventType = ((EventTypeFilter) ((EventTrigger) trigger).getEventFilters().get(0)).getType();
                        if (eventType.startsWith("Message-")) {
                            eventType = eventType.substring(8);
                            String messageType = (String) node.getMetaData().get("MessageType");
View Full Code Here

import org.xml.sax.SAXException;

public class StartEventHandler extends AbstractNodeHandler {
   
    protected Node createNode(Attributes attrs) {
        return new StartNode();
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    protected 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);
        StartNode startNode = (StartNode) node;
        org.w3c.dom.Node xmlNode = element.getFirstChild();
        while (xmlNode != null) {
            String nodeName = xmlNode.getNodeName();
            if ("dataOutputAssociation".equals(nodeName)) {
                readDataOutputAssociation(xmlNode, startNode);
            } else if ("conditionalEventDefinition".equals(nodeName)) {
                String constraint = null;
                org.w3c.dom.Node subNode = xmlNode.getFirstChild();
                while (subNode != null) {
                    String subnodeName = subNode.getNodeName();
                    if ("condition".equals(subnodeName)) {
                        constraint = xmlNode.getTextContent();
                        break;
                    }
                    subNode = subNode.getNextSibling();
                }
                ConstraintTrigger trigger = new ConstraintTrigger();
                trigger.setConstraint(constraint);
                startNode.addTrigger(trigger);
                break;
            } else if ("signalEventDefinition".equals(nodeName)) {
                String type = ((Element) xmlNode).getAttribute("signalRef");
                if (type != null && type.trim().length() > 0) {
                    EventTrigger trigger = new EventTrigger();
                    EventTypeFilter eventFilter = new EventTypeFilter();
                    eventFilter.setType(type);
                    trigger.addEventFilter(eventFilter);
                    String mapping = (String) startNode.getMetaData("TriggerMapping");
                    if (mapping != null) {
                        trigger.addInMapping(mapping, "event");
                    }
                    startNode.addTrigger(trigger);
                }
            } else if ("messageEventDefinition".equals(nodeName)) {
                String messageRef = ((Element) xmlNode).getAttribute("messageRef");
                Map<String, Message> messages = (Map<String, Message>)
                    ((ProcessBuildData) parser.getData()).getMetaData("Messages");
                if (messages == null) {
                    throw new IllegalArgumentException("No messages found");
                }
                Message message = messages.get(messageRef);
                if (message == null) {
                    throw new IllegalArgumentException("Could not find message " + messageRef);
                }
                startNode.setMetaData("MessageType", message.getType());
                EventTrigger trigger = new EventTrigger();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType("Message-" + messageRef);
                trigger.addEventFilter(eventFilter);
                String mapping = (String) startNode.getMetaData("TriggerMapping");
                if (mapping != null) {
                    trigger.addInMapping(mapping, "event");
                }
                startNode.addTrigger(trigger);
            } else if ("timerEventDefinition".equals(nodeName)) {
              org.w3c.dom.Node subNode = xmlNode.getFirstChild();
                while (subNode instanceof Element) {
                    String subNodeName = subNode.getNodeName();
                    if ("timeCycle".equals(subNodeName)) {
                        String period = subNode.getTextContent();
                        if (period != null && period.trim().length() > 0) {
                          ConstraintTrigger trigger = new ConstraintTrigger();
                          trigger.setConstraint("");
                          trigger.setHeader("timer (int:" + period + " " + period + ")");
                          startNode.addTrigger(trigger);
                          break;
                        }
                    }
                    subNode = subNode.getNextSibling();
               }
View Full Code Here

        String to = subNode.getTextContent();
        startNode.setMetaData("TriggerMapping", to);
    }

    public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    StartNode startNode = (StartNode) node;
    writeNode("startEvent", startNode, xmlDump, includeMeta);
    List<Trigger> triggers = startNode.getTriggers();
    if (triggers != null) {
        xmlDump.append(">" + EOL);
        if (triggers.size() > 1) {
            throw new IllegalArgumentException("Multiple start triggers not supported");
        }
        Trigger trigger = triggers.get(0);
        if (trigger instanceof ConstraintTrigger) {
          ConstraintTrigger constraintTrigger = (ConstraintTrigger) trigger;
          if (constraintTrigger.getHeader() == null) {
              xmlDump.append("      <conditionalEventDefinition>" + EOL);
                  xmlDump.append("        <condition xs:type=\"tFormalExpression\" language=\"" + XmlBPMNProcessDumper.RULE_LANGUAGE + "\">" + constraintTrigger.getConstraint() + "</condition>" + EOL);
                  xmlDump.append("      </conditionalEventDefinition>" + EOL);
          } else {
            String header = constraintTrigger.getHeader();
            int lenght = (header.length() - 13)/2;
            String period = header.substring(11, 11 + lenght);
              xmlDump.append("      <timerEventDefinition>" + EOL);
                  xmlDump.append("        <timeCycle xs:type=\"tFormalExpression\">" + period + "</timeCycle>" + EOL);
                  xmlDump.append("      </timerEventDefinition>" + EOL);
          }
        } else if (trigger instanceof EventTrigger) {
            EventTrigger eventTrigger = (EventTrigger) trigger;
            if (!trigger.getInMappings().isEmpty()) {
                String mapping = eventTrigger.getInMappings().keySet().iterator().next();
                xmlDump.append(
                      "      <dataOutput id=\"_" + startNode.getId() + "_Output\" />" + EOL +
                        "      <dataOutputAssociation>" + EOL +
                        "        <sourceRef>_" + startNode.getId() + "_Output</sourceRef>" + EOL +
                        "        <targetRef>" + mapping + "</targetRef>" + EOL +
                        "      </dataOutputAssociation>" + EOL +
                        "      <outputSet>" + EOL +
                        "        <dataOutputRefs>_" + startNode.getId() + "_Output</dataOutputRefs>" + EOL +
                        "      </outputSet>" + EOL);
            }
            String type = ((EventTypeFilter) eventTrigger.getEventFilters().get(0)).getType();
            if (type.startsWith("Message-")) {
                    type = type.substring(8);
View Full Code Here

        } else {
          // try to search for start nodes
          boolean found = false;
          for (Node node: getCompositeNode().getNodes()) {
            if (node instanceof StartNode) {
              StartNode startNode = (StartNode) node;
              if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) {
                      NodeInstance nodeInstance = getNodeInstance(startNode.getTo().getTo());
                      ((org.drools.workflow.instance.NodeInstance) nodeInstance)
                        .trigger(null, NodeImpl.CONNECTION_DEFAULT_TYPE);
                      found = true;
              }
            }
View Full Code Here

    public StartNodeFactory(RuleFlowNodeContainerFactory nodeContainerFactory, NodeContainer nodeContainer, long id) {
        super(nodeContainerFactory, nodeContainer, id);
    }

    protected Node createNode() {
        return new StartNode();
    }
View Full Code Here

    }

    private void initProcessEventListeners() {
        for ( Process process : ruleBase.getProcesses() ) {
            if ( process instanceof RuleFlowProcess ) {
                StartNode startNode = ((RuleFlowProcess) process).getStart();
                List<Trigger> triggers = startNode.getTriggers();
                if ( triggers != null ) {
                    for ( Trigger trigger : triggers ) {
                        if ( trigger instanceof EventTrigger ) {
                            final List<EventFilter> filters = ((EventTrigger) trigger).getEventFilters();
                            String type = null;
View Full Code Here

TOP

Related Classes of org.drools.workflow.core.node.StartNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.