Search in sources :

Example 6 with Node

use of org.jbpm.workflow.core.Node in project jbpm by kiegroup.

the class AbstractNodeHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    handleNode(node, element, uri, localName, parser);
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.jbpm.workflow.core.Node) NodeContainer(org.jbpm.workflow.core.NodeContainer)

Example 7 with Node

use of org.jbpm.workflow.core.Node in project jbpm by kiegroup.

the class AbstractNodeHandler method getErrorIdForErrorCode.

protected String getErrorIdForErrorCode(String errorCode, Node node) {
    org.kie.api.definition.process.NodeContainer parent = node.getNodeContainer();
    while (!(parent instanceof RuleFlowProcess) && parent instanceof Node) {
        parent = ((Node) parent).getNodeContainer();
    }
    if (!(parent instanceof RuleFlowProcess)) {
        throw new RuntimeException("This should never happen: !(parent instanceof RuleFlowProcess): parent is " + parent.getClass().getSimpleName());
    }
    List<Error> errors = ((Definitions) ((RuleFlowProcess) parent).getMetaData("Definitions")).getErrors();
    Error error = null;
    for (Error listError : errors) {
        if (errorCode.equals(listError.getErrorCode())) {
            error = listError;
            break;
        } else if (errorCode.equals(listError.getId())) {
            error = listError;
            break;
        }
    }
    if (error == null) {
        throw new IllegalArgumentException("Could not find error with errorCode " + errorCode);
    }
    return error.getId();
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.jbpm.workflow.core.Node) Definitions(org.jbpm.bpmn2.core.Definitions) Error(org.jbpm.bpmn2.core.Error)

Example 8 with Node

use of org.jbpm.workflow.core.Node in project jbpm by kiegroup.

the class ForEachNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    ForEachNode forEachNode = (ForEachNode) node;
    writeNode("subProcess", forEachNode, xmlDump, metaDataType);
    xmlDump.append(" >" + EOL);
    writeExtensionElements(node, xmlDump);
    // ioSpecification and dataInputAssociation
    xmlDump.append("      <ioSpecification>" + EOL);
    String parameterName = forEachNode.getVariableName();
    if (parameterName != null) {
        xmlDump.append("        <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input\" name=\"MultiInstanceInput\" />" + EOL);
    }
    xmlDump.append("        <inputSet/>" + EOL + "        <outputSet/>" + EOL + "      </ioSpecification>" + EOL);
    String collectionExpression = forEachNode.getCollectionExpression();
    if (collectionExpression != null) {
        xmlDump.append("      <dataInputAssociation>" + EOL + "        <sourceRef>" + XmlDumper.replaceIllegalChars(collectionExpression) + "</sourceRef>" + EOL + "        <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</targetRef>" + EOL + "      </dataInputAssociation>" + EOL);
    }
    // multiInstanceLoopCharacteristics
    xmlDump.append("      <multiInstanceLoopCharacteristics>" + EOL + "        <loopDataInputRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</loopDataInputRef>" + EOL);
    if (parameterName != null) {
        xmlDump.append("        <inputDataItem id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(parameterName) + "\" itemSubjectRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_multiInstanceItemType\"/>" + EOL);
    }
    xmlDump.append("      </multiInstanceLoopCharacteristics>" + EOL);
    // nodes
    List<Node> subNodes = getSubNodes(forEachNode);
    XmlBPMNProcessDumper.INSTANCE.visitNodes(subNodes, xmlDump, metaDataType);
    // connections
    visitConnectionsAndAssociations(forEachNode, xmlDump, metaDataType);
    endNode("subProcess", xmlDump);
}
Also used : Node(org.jbpm.workflow.core.Node) ForEachNode(org.jbpm.workflow.core.node.ForEachNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) ForEachNode(org.jbpm.workflow.core.node.ForEachNode)

Example 9 with Node

use of org.jbpm.workflow.core.Node in project jbpm by kiegroup.

the class CompensationTest method testCompensationEventSubProcessSpecific.

@Test
public void testCompensationEventSubProcessSpecific() throws Exception {
    String processId = "org.jbpm.process.compensation.event.subprocess";
    String[] workItemNames = { "kwik", "kwek", "kwak" };
    List<String> eventList = new ArrayList<String>();
    RuleFlowProcess process = createCompensationEventSubProcessProcess(processId, workItemNames, eventList);
    Node toCompensateNode = findNode(process, "sub0");
    String compensationEvent = (String) toCompensateNode.getMetaData().get("UniqueId");
    // run process
    ksession = createKieSession(process);
    runCompensationEventSubProcessSpecificTest(ksession, process, processId, workItemNames, eventList, compensationEvent);
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Node(org.jbpm.workflow.core.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 10 with Node

use of org.jbpm.workflow.core.Node in project jbpm by kiegroup.

the class CompensationTest method testNestedCompensationBoundaryEventSpecific.

@Test
public void testNestedCompensationBoundaryEventSpecific() throws Exception {
    String processId = "org.jbpm.process.compensation.boundary.nested";
    String[] workItemNames = { "Don-Quixote", "Sancho", "Ricote" };
    List<String> eventList = new ArrayList<String>();
    RuleFlowProcess process = createNestedCompensationBoundaryEventProcess(processId, workItemNames, eventList);
    // run process
    ksession = createKieSession(process);
    Node compensatedNode = findNode(process, "work-comp-1");
    String compensationEvent = (String) compensatedNode.getMetaData().get("UniqueId");
    runCompensationBoundaryEventSpecificTest(ksession, process, processId, workItemNames, eventList, compensationEvent);
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) CompositeContextNode(org.jbpm.workflow.core.node.CompositeContextNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) Node(org.jbpm.workflow.core.Node) ArrayList(java.util.ArrayList) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Aggregations

Node (org.jbpm.workflow.core.Node)30 ActionNode (org.jbpm.workflow.core.node.ActionNode)16 EndNode (org.jbpm.workflow.core.node.EndNode)16 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)14 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)13 StartNode (org.jbpm.workflow.core.node.StartNode)13 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)13 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)12 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)11 ArrayList (java.util.ArrayList)10 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)10 Test (org.junit.Test)10 NodeContainer (org.jbpm.workflow.core.NodeContainer)9 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)9 Element (org.w3c.dom.Element)9 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)8 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)8 EventNode (org.jbpm.workflow.core.node.EventNode)7 Variable (org.jbpm.process.core.context.variable.Variable)4 Map (java.util.Map)3