Search in sources :

Example 1 with NodeInstanceFactory

use of org.jbpm.workflow.instance.impl.NodeInstanceFactory in project jbpm by kiegroup.

the class CompositeNodeInstance method getNodeInstance.

public NodeInstance getNodeInstance(final Node node) {
    // TODO do this cleaner for start / end of composite?
    if (node instanceof CompositeNode.CompositeNodeStart) {
        CompositeNodeStartInstance nodeInstance = new CompositeNodeStartInstance();
        nodeInstance.setNodeId(node.getId());
        nodeInstance.setNodeInstanceContainer(this);
        nodeInstance.setProcessInstance(getProcessInstance());
        return nodeInstance;
    } else if (node instanceof CompositeNode.CompositeNodeEnd) {
        CompositeNodeEndInstance nodeInstance = new CompositeNodeEndInstance();
        nodeInstance.setNodeId(node.getId());
        nodeInstance.setNodeInstanceContainer(this);
        nodeInstance.setProcessInstance(getProcessInstance());
        return nodeInstance;
    }
    Node actualNode = node;
    // async continuation handling
    if (node instanceof AsyncEventNode) {
        actualNode = ((AsyncEventNode) node).getActualNode();
    } else if (useAsync(node)) {
        actualNode = new AsyncEventNode(node);
    }
    NodeInstanceFactory conf = NodeInstanceFactoryRegistry.getInstance(getProcessInstance().getKnowledgeRuntime().getEnvironment()).getProcessNodeInstanceFactory(actualNode);
    if (conf == null) {
        throw new IllegalArgumentException("Illegal node type: " + node.getClass());
    }
    NodeInstanceImpl nodeInstance = (NodeInstanceImpl) conf.getNodeInstance(actualNode, getProcessInstance(), this);
    if (nodeInstance == null) {
        throw new IllegalArgumentException("Illegal node type: " + node.getClass());
    }
    return nodeInstance;
}
Also used : NodeInstanceImpl(org.jbpm.workflow.instance.impl.NodeInstanceImpl) NodeInstanceFactory(org.jbpm.workflow.instance.impl.NodeInstanceFactory) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) StartNode(org.jbpm.workflow.core.node.StartNode) CompositeNode(org.jbpm.workflow.core.node.CompositeNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode) ActionNode(org.jbpm.workflow.core.node.ActionNode) EndNode(org.jbpm.workflow.core.node.EndNode) EventNode(org.jbpm.workflow.core.node.EventNode) Node(org.kie.api.definition.process.Node) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode)

Aggregations

ActionNode (org.jbpm.workflow.core.node.ActionNode)1 AsyncEventNode (org.jbpm.workflow.core.node.AsyncEventNode)1 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)1 EndNode (org.jbpm.workflow.core.node.EndNode)1 EventNode (org.jbpm.workflow.core.node.EventNode)1 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)1 StartNode (org.jbpm.workflow.core.node.StartNode)1 StateBasedNode (org.jbpm.workflow.core.node.StateBasedNode)1 NodeInstanceFactory (org.jbpm.workflow.instance.impl.NodeInstanceFactory)1 NodeInstanceImpl (org.jbpm.workflow.instance.impl.NodeInstanceImpl)1 Node (org.kie.api.definition.process.Node)1