Search in sources :

Example 6 with NodeImpl

use of org.jbpm.workflow.core.impl.NodeImpl in project jbpm by kiegroup.

the class CompositeNode method addOutgoingConnection.

public void addOutgoingConnection(String type, Connection connection) {
    if (connection.getTo().getNodeContainer() == this) {
        linkIncomingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, connection.getTo().getId(), connection.getToType());
    } else {
        super.addOutgoingConnection(type, connection);
        CompositeNode.NodeAndType outNode = internalGetLinkedOutgoingNode(type);
        if (outNode != null) {
            CompositeNodeEnd end = new CompositeNodeEnd(this, connection.getTo(), type);
            internalAddNode(end);
            NodeImpl node = (NodeImpl) outNode.getNode();
            if (node != null) {
                new ConnectionImpl(outNode.getNode(), outNode.getType(), end, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
            }
        }
    }
}
Also used : NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl)

Example 7 with NodeImpl

use of org.jbpm.workflow.core.impl.NodeImpl in project jbpm by kiegroup.

the class CompositeNode method addIncomingConnection.

public void addIncomingConnection(String type, Connection connection) {
    if (connection.getFrom().getNodeContainer() == this) {
        linkOutgoingConnections(connection.getFrom().getId(), connection.getFromType(), org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
    } else {
        super.addIncomingConnection(type, connection);
        CompositeNode.NodeAndType inNode = internalGetLinkedIncomingNode(type);
        if (inNode != null) {
            CompositeNodeStart start = new CompositeNodeStart(this, connection.getFrom(), type);
            internalAddNode(start);
            NodeImpl node = (NodeImpl) inNode.getNode();
            if (node != null) {
                new ConnectionImpl(start, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, inNode.getNode(), inNode.getType());
            }
        }
    }
}
Also used : NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl)

Example 8 with NodeImpl

use of org.jbpm.workflow.core.impl.NodeImpl in project jbpm by kiegroup.

the class MigrateProcessInstanceCommand method updateNodeInstances.

private void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map<String, Long> nodeMapping) {
    for (NodeInstance nodeInstance : nodeInstanceContainer.getNodeInstances()) {
        String oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getUniqueId();
        Long newNodeId = nodeMapping.get(oldNodeId);
        if (newNodeId == null) {
            newNodeId = nodeInstance.getNodeId();
        }
        ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId);
        if (nodeInstance instanceof NodeInstanceContainer) {
            updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping);
        }
    }
}
Also used : NodeInstanceImpl(org.jbpm.workflow.instance.impl.NodeInstanceImpl) NodeInstanceContainer(org.jbpm.workflow.instance.NodeInstanceContainer) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) NodeInstance(org.kie.api.runtime.process.NodeInstance)

Example 9 with NodeImpl

use of org.jbpm.workflow.core.impl.NodeImpl in project jbpm by kiegroup.

the class CompensationScopeInstance method handleException.

public void handleException(ExceptionHandler handler, String compensationActivityRef, Object dunno) {
    WorkflowProcessInstanceImpl processInstance = (WorkflowProcessInstanceImpl) getProcessInstance();
    NodeInstanceContainer nodeInstanceContainer = (NodeInstanceContainer) getContextInstanceContainer();
    if (handler instanceof CompensationHandler) {
        CompensationHandler compensationHandler = (CompensationHandler) handler;
        try {
            Node handlerNode = compensationHandler.getnode();
            if (handlerNode instanceof BoundaryEventNode) {
                NodeInstance compensationHandlerNodeInstance = nodeInstanceContainer.getNodeInstance(handlerNode);
                compensationInstances.add(compensationHandlerNodeInstance);
                // The BoundaryEventNodeInstance.signalEvent() contains the necessary logic
                // to check whether or not compensation may proceed (? : (not-active + completed))
                EventNodeInstance eventNodeInstance = (EventNodeInstance) compensationHandlerNodeInstance;
                eventNodeInstance.signalEvent("Compensation", compensationActivityRef);
            } else if (handlerNode instanceof EventSubProcessNode) {
                // Check that subprocess parent has completed.
                List<String> completedIds = processInstance.getCompletedNodeIds();
                if (completedIds.contains(((NodeImpl) handlerNode.getNodeContainer()).getMetaData("UniqueId"))) {
                    NodeInstance subProcessNodeInstance = ((NodeInstanceContainer) nodeInstanceContainer).getNodeInstance((Node) handlerNode.getNodeContainer());
                    compensationInstances.add(subProcessNodeInstance);
                    NodeInstance compensationHandlerNodeInstance = ((NodeInstanceContainer) subProcessNodeInstance).getNodeInstance(handlerNode);
                    compensationInstances.add(compensationHandlerNodeInstance);
                    EventSubProcessNodeInstance eventNodeInstance = (EventSubProcessNodeInstance) compensationHandlerNodeInstance;
                    eventNodeInstance.signalEvent("Compensation", compensationActivityRef);
                }
            }
            assert handlerNode instanceof BoundaryEventNode || handlerNode instanceof EventSubProcessNode : "Unexpected compensation handler node type : " + handlerNode.getClass().getSimpleName();
        } catch (Exception e) {
            throwWorkflowRuntimeException(nodeInstanceContainer, processInstance, "Unable to execute compensation.", e);
        }
    } else {
        Exception e = new IllegalArgumentException("Unsupported compensation handler: " + handler);
        throwWorkflowRuntimeException(nodeInstanceContainer, processInstance, e.getMessage(), e);
    }
}
Also used : NodeInstanceContainer(org.jbpm.workflow.instance.NodeInstanceContainer) NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) Node(org.kie.api.definition.process.Node) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) CompensationHandler(org.jbpm.process.core.context.exception.CompensationHandler) BoundaryEventNode(org.jbpm.workflow.core.node.BoundaryEventNode) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) List(java.util.List) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) NodeInstance(org.jbpm.workflow.instance.NodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance)

Example 10 with NodeImpl

use of org.jbpm.workflow.core.impl.NodeImpl in project jbpm by kiegroup.

the class DocumentationHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    Element element = parser.endElementBuilder();
    Object parent = parser.getParent();
    if (parent instanceof NodeImpl) {
        String text = ((Text) element.getChildNodes().item(0)).getWholeText();
        if (text != null) {
            text = text.trim();
            if ("".equals(text)) {
                text = null;
            }
        }
        ((NodeImpl) parent).getMetaData().put("Documentation", text);
    }
    return parser.getCurrent();
}
Also used : NodeImpl(org.jbpm.workflow.core.impl.NodeImpl) Element(org.w3c.dom.Element) Text(org.w3c.dom.Text)

Aggregations

NodeImpl (org.jbpm.workflow.core.impl.NodeImpl)16 Node (org.kie.api.definition.process.Node)8 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)6 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)6 HumanTaskNode (org.jbpm.workflow.core.node.HumanTaskNode)6 ExtendedNodeImpl (org.jbpm.workflow.core.impl.ExtendedNodeImpl)5 ActionNode (org.jbpm.workflow.core.node.ActionNode)5 BoundaryEventNode (org.jbpm.workflow.core.node.BoundaryEventNode)5 EndNode (org.jbpm.workflow.core.node.EndNode)5 StartNode (org.jbpm.workflow.core.node.StartNode)5 CompositeContextNode (org.jbpm.workflow.core.node.CompositeContextNode)4 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)4 EventNode (org.jbpm.workflow.core.node.EventNode)4 FaultNode (org.jbpm.workflow.core.node.FaultNode)4 RuleSetNode (org.jbpm.workflow.core.node.RuleSetNode)4 StateBasedNode (org.jbpm.workflow.core.node.StateBasedNode)4 List (java.util.List)3 EventFilter (org.jbpm.process.core.event.EventFilter)3 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)3 StateNode (org.jbpm.workflow.core.node.StateNode)3