Search in sources :

Example 1 with NodeNotFoundException

use of io.automatiko.engine.api.workflow.NodeNotFoundException in project automatiko-engine by automatiko-io.

the class NodeNotFoundExceptionMapper method toResponse.

@Override
public Response toResponse(NodeNotFoundException ex) {
    NodeNotFoundException exception = (NodeNotFoundException) ex;
    Map<String, String> response = new HashMap<>();
    response.put(MESSAGE, exception.getMessage());
    response.put(PROCESS_INSTANCE_ID, exception.getProcessInstanceId());
    response.put(NODE_ID, exception.getNodeId());
    return notFound(response);
}
Also used : NodeNotFoundException(io.automatiko.engine.api.workflow.NodeNotFoundException) HashMap(java.util.HashMap)

Example 2 with NodeNotFoundException

use of io.automatiko.engine.api.workflow.NodeNotFoundException in project automatiko-engine by automatiko-io.

the class AbstractProcessInstance method triggerNode.

@Override
public void triggerNode(String nodeId) {
    lock();
    WorkflowProcessInstanceImpl wfpi = ((WorkflowProcessInstanceImpl) processInstance());
    ExecutableProcess rfp = ((ExecutableProcess) wfpi.getProcess());
    Node node = rfp.getNodesRecursively().stream().filter(ni -> nodeId.equals(ni.getMetaData().get("UniqueId"))).findFirst().orElseThrow(() -> new NodeNotFoundException(this.id, nodeId));
    Node parentNode = rfp.getParentNode(node.getId());
    NodeInstanceContainer nodeInstanceContainerNode = parentNode == null ? wfpi : ((NodeInstanceContainer) wfpi.getNodeInstance(parentNode));
    if (nodeInstanceContainerNode.getNodeInstances().isEmpty() && nodeInstanceContainerNode instanceof CompositeContextNodeInstance) {
        ((CompositeContextNodeInstance) nodeInstanceContainerNode).internalTriggerOnlyParent(null, nodeId);
    }
    nodeInstanceContainerNode.getNodeInstance(node).trigger(null, io.automatiko.engine.workflow.process.core.Node.CONNECTION_DEFAULT_TYPE);
}
Also used : NodeNotFoundException(io.automatiko.engine.api.workflow.NodeNotFoundException) NodeInstanceContainer(io.automatiko.engine.workflow.process.instance.NodeInstanceContainer) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) SubProcessNode(io.automatiko.engine.workflow.process.core.node.SubProcessNode) Node(io.automatiko.engine.api.definition.process.Node) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Aggregations

NodeNotFoundException (io.automatiko.engine.api.workflow.NodeNotFoundException)2 Node (io.automatiko.engine.api.definition.process.Node)1 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)1 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)1 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)1 NodeInstanceContainer (io.automatiko.engine.workflow.process.instance.NodeInstanceContainer)1 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)1 CompositeContextNodeInstance (io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance)1 HashMap (java.util.HashMap)1