Search in sources :

Example 1 with CompositeContextNodeInstance

use of io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance in project automatiko-engine by automatiko-io.

the class AbstractProtobufProcessInstanceMarshaller method readNodeInstanceContent.

protected NodeInstanceImpl readNodeInstanceContent(AutomatikoMessages.ProcessInstance.NodeInstance _node, MarshallerReaderContext context, WorkflowProcessInstance processInstance) throws IOException {
    NodeInstanceImpl nodeInstance = null;
    NodeInstanceContent _content = _node.getContent();
    switch(_content.getType()) {
        case RULE_SET_NODE:
            nodeInstance = new RuleSetNodeInstance();
            if (_content.getRuleSet().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getRuleSet().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((RuleSetNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case HUMAN_TASK_NODE:
            nodeInstance = new HumanTaskNodeInstance();
            ((HumanTaskNodeInstance) nodeInstance).internalSetWorkItemId(_content.getHumanTask().getWorkItemId());
            ((HumanTaskNodeInstance) nodeInstance).internalSetWorkItem((WorkItemImpl) readHumanTaskWorkItem(processInstance, context, _content.getHumanTask().getWorkitem()));
            if (_content.getHumanTask().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getHumanTask().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((HumanTaskNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            ((WorkItemNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getHumanTask().getErrorHandlingProcessInstanceId());
            break;
        case WORK_ITEM_NODE:
            nodeInstance = new WorkItemNodeInstance();
            ((WorkItemNodeInstance) nodeInstance).internalSetWorkItemId(_content.getWorkItem().getWorkItemId());
            ((WorkItemNodeInstance) nodeInstance).internalSetWorkItem((WorkItemImpl) readWorkItem(processInstance, context, _content.getWorkItem().getWorkitem()));
            if (_content.getWorkItem().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getWorkItem().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((WorkItemNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            ((WorkItemNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getWorkItem().getErrorHandlingProcessInstanceId());
            break;
        case SUBPROCESS_NODE:
            nodeInstance = new SubProcessNodeInstance();
            ((SubProcessNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getSubProcess().getProcessInstanceId());
            if (_content.getSubProcess().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getSubProcess().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((SubProcessNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case SUB_PROCESS_NODE:
            nodeInstance = new LambdaSubProcessNodeInstance();
            ((LambdaSubProcessNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getSubProcess().getProcessInstanceId());
            ((LambdaSubProcessNodeInstance) nodeInstance).internalSetProcessInstanceName(_content.getSubProcess().getProcessInstanceName());
            if (_content.getSubProcess().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getSubProcess().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((LambdaSubProcessNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case MILESTONE_NODE:
            nodeInstance = new MilestoneNodeInstance();
            if (_content.getMilestone().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getMilestone().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((MilestoneNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case TIMER_NODE:
            nodeInstance = new TimerNodeInstance();
            ((TimerNodeInstance) nodeInstance).internalSetTimerId(_content.getTimer().getTimerId());
            break;
        case EVENT_NODE:
            nodeInstance = new EventNodeInstance();
            break;
        case JOIN_NODE:
            nodeInstance = new JoinInstance();
            if (_content.getJoin().getTriggerCount() > 0) {
                Map<Long, Integer> triggers = new HashMap<Long, Integer>();
                for (AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.JoinTrigger _join : _content.getJoin().getTriggerList()) {
                    triggers.put(_join.getNodeId(), _join.getCounter());
                }
                ((JoinInstance) nodeInstance).internalSetTriggers(triggers);
            }
            break;
        case FOR_EACH_NODE:
            nodeInstance = new ForEachNodeInstance();
            ((ForEachNodeInstance) nodeInstance).setInternalSequentialCounter(_content.getForEach().getSequentialCounter());
            break;
        case COMPOSITE_CONTEXT_NODE:
            nodeInstance = new CompositeContextNodeInstance();
            if (_content.getComposite().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case DYNAMIC_NODE:
            nodeInstance = new DynamicNodeInstance();
            if (_content.getComposite().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case STATE_NODE:
            nodeInstance = new StateNodeInstance();
            if (_content.getState().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getState().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case EVENT_SUBPROCESS_NODE:
            nodeInstance = new EventSubProcessNodeInstance();
            if (_content.getComposite().getTimerInstanceIdCount() > 0) {
                List<String> timerInstances = new ArrayList<>();
                for (String _timerId : _content.getComposite().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        default:
            throw new IllegalArgumentException("Unknown node type: " + _content.getType());
    }
    return nodeInstance;
}
Also used : JoinInstance(io.automatiko.engine.workflow.process.instance.node.JoinInstance) DynamicNodeInstance(io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HumanTaskNodeInstance(io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance) NodeInstanceContent(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.ProcessInstance.NodeInstanceContent) RuleSetNodeInstance(io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance) NodeInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.NodeInstanceImpl) MilestoneNodeInstance(io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance) StateNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateNodeInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) WorkItemNodeInstance(io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) SubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.api.runtime.process.WorkflowProcessInstance) ForEachNodeInstance(io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance) TimerNodeInstance(io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)

Example 2 with CompositeContextNodeInstance

use of io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance in project automatiko-engine by automatiko-io.

the class AbstractProtobufProcessInstanceMarshaller method writeNodeInstanceContent.

protected AutomatikoMessages.ProcessInstance.NodeInstanceContent writeNodeInstanceContent(AutomatikoMessages.ProcessInstance.NodeInstance.Builder _node, NodeInstance nodeInstance, MarshallerWriteContext context) throws IOException {
    AutomatikoMessages.ProcessInstance.NodeInstanceContent.Builder _content = null;
    if (nodeInstance instanceof RuleSetNodeInstance) {
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.RULE_SET_NODE);
        List<String> timerInstances = ((RuleSetNodeInstance) nodeInstance).getTimerInstances();
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.Builder _ruleSet = AutomatikoMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.newBuilder();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _ruleSet.addTimerInstanceId(id);
            }
        }
        _content.setRuleSet(_ruleSet.build());
    } else if (nodeInstance instanceof HumanTaskNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.HumanTaskNode.Builder _task = AutomatikoMessages.ProcessInstance.NodeInstanceContent.HumanTaskNode.newBuilder().setWorkItemId(((HumanTaskNodeInstance) nodeInstance).getWorkItemId()).setWorkitem(writeHumanTaskWorkItem(context, (HumanTaskWorkItem) ((HumanTaskNodeInstance) nodeInstance).getWorkItem()));
        List<String> timerInstances = ((HumanTaskNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _task.addTimerInstanceId(id);
            }
        }
        if (((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId() != null) {
            _task.setErrorHandlingProcessInstanceId(((HumanTaskNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId());
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.HUMAN_TASK_NODE).setHumanTask(_task.build());
    } else if (nodeInstance instanceof WorkItemNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.WorkItemNode.Builder _wi = AutomatikoMessages.ProcessInstance.NodeInstanceContent.WorkItemNode.newBuilder().setWorkItemId(((WorkItemNodeInstance) nodeInstance).getWorkItemId()).setWorkitem(writeWorkItem(context, ((WorkItemNodeInstance) nodeInstance).getWorkItem()));
        List<String> timerInstances = ((WorkItemNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _wi.addTimerInstanceId(id);
            }
        }
        if (((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId() != null) {
            _wi.setErrorHandlingProcessInstanceId(((WorkItemNodeInstance) nodeInstance).getExceptionHandlingProcessInstanceId());
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.WORK_ITEM_NODE).setWorkItem(_wi.build());
    } else if (nodeInstance instanceof LambdaSubProcessNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.Builder _sp = AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.newBuilder().setProcessInstanceId(((LambdaSubProcessNodeInstance) nodeInstance).getProcessInstanceId()).setProcessInstanceName(((LambdaSubProcessNodeInstance) nodeInstance).getProcessInstanceName());
        List<String> timerInstances = ((LambdaSubProcessNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _sp.addTimerInstanceId(id);
            }
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.SUB_PROCESS_NODE).setSubProcess(_sp.build());
    } else if (nodeInstance instanceof SubProcessNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.Builder _sp = AutomatikoMessages.ProcessInstance.NodeInstanceContent.SubProcessNode.newBuilder().setProcessInstanceId(((SubProcessNodeInstance) nodeInstance).getProcessInstanceId());
        List<String> timerInstances = ((SubProcessNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _sp.addTimerInstanceId(id);
            }
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.SUBPROCESS_NODE).setSubProcess(_sp.build());
    } else if (nodeInstance instanceof MilestoneNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.MilestoneNode.Builder _ms = AutomatikoMessages.ProcessInstance.NodeInstanceContent.MilestoneNode.newBuilder();
        List<String> timerInstances = ((MilestoneNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _ms.addTimerInstanceId(id);
            }
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.MILESTONE_NODE).setMilestone(_ms.build());
    } else if (nodeInstance instanceof EventNodeInstance) {
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.EVENT_NODE);
    } else if (nodeInstance instanceof TimerNodeInstance) {
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.TIMER_NODE).setTimer(AutomatikoMessages.ProcessInstance.NodeInstanceContent.TimerNode.newBuilder().setTimerId(((TimerNodeInstance) nodeInstance).getTimerId()).build());
    } else if (nodeInstance instanceof JoinInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.Builder _join = AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.newBuilder();
        Map<Long, Integer> triggers = ((JoinInstance) nodeInstance).getTriggers();
        List<Long> keys = new ArrayList<Long>(triggers.keySet());
        Collections.sort(keys, new Comparator<Long>() {

            public int compare(Long o1, Long o2) {
                return o1.compareTo(o2);
            }
        });
        for (Long key : keys) {
            _join.addTrigger(AutomatikoMessages.ProcessInstance.NodeInstanceContent.JoinNode.JoinTrigger.newBuilder().setNodeId(key).setCounter(triggers.get(key)).build());
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.JOIN_NODE).setJoin(_join.build());
    } else if (nodeInstance instanceof StateNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.StateNode.Builder _state = AutomatikoMessages.ProcessInstance.NodeInstanceContent.StateNode.newBuilder();
        List<String> timerInstances = ((StateNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _state.addTimerInstanceId(id);
            }
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.STATE_NODE).setState(_state.build());
    } else if (nodeInstance instanceof ForEachNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.ForEachNode.Builder _foreach = AutomatikoMessages.ProcessInstance.NodeInstanceContent.ForEachNode.newBuilder();
        ForEachNodeInstance forEachNodeInstance = (ForEachNodeInstance) nodeInstance;
        List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(forEachNodeInstance.getNodeInstances());
        Collections.sort(nodeInstances, new Comparator<NodeInstance>() {

            public int compare(NodeInstance o1, NodeInstance o2) {
                return (int) (o1.getId().compareTo(o2.getId()));
            }
        });
        for (NodeInstance subNodeInstance : nodeInstances) {
            if (subNodeInstance instanceof CompositeContextNodeInstance) {
                _foreach.addNodeInstance(writeNodeInstance(context, subNodeInstance));
            }
        }
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) forEachNodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
        if (variableScopeInstance != null) {
            List<Map.Entry<String, Object>> variables = new ArrayList<Map.Entry<String, Object>>(variableScopeInstance.getVariables().entrySet());
            Collections.sort(variables, new Comparator<Map.Entry<String, Object>>() {

                public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
                    return o1.getKey().compareTo(o2.getKey());
                }
            });
            for (Map.Entry<String, Object> variable : variables) {
                _foreach.addVariable(ProtobufProcessMarshaller.marshallVariable(context, variable.getKey(), variable.getValue(), false));
            }
        }
        List<Map.Entry<String, Integer>> iterationlevels = new ArrayList<Map.Entry<String, Integer>>(forEachNodeInstance.getIterationLevels().entrySet());
        Collections.sort(iterationlevels, new Comparator<Map.Entry<String, Integer>>() {

            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o1.getKey().compareTo(o2.getKey());
            }
        });
        for (Map.Entry<String, Integer> level : iterationlevels) {
            if (level.getKey() != null && level.getValue() != null) {
                _foreach.addIterationLevels(AutomatikoMessages.IterationLevel.newBuilder().setId(level.getKey()).setLevel(level.getValue()));
            }
        }
        _foreach.setSequentialCounter(forEachNodeInstance.getSequentialCounter());
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(NodeInstanceType.FOR_EACH_NODE).setForEach(_foreach.build());
    } else if (nodeInstance instanceof CompositeContextNodeInstance) {
        AutomatikoMessages.ProcessInstance.NodeInstanceContent.CompositeContextNode.Builder _composite = AutomatikoMessages.ProcessInstance.NodeInstanceContent.CompositeContextNode.newBuilder();
        AutomatikoMessages.ProcessInstance.NodeInstanceType _type = null;
        if (nodeInstance instanceof DynamicNodeInstance) {
            _type = AutomatikoMessages.ProcessInstance.NodeInstanceType.DYNAMIC_NODE;
        } else if (nodeInstance instanceof EventSubProcessNodeInstance) {
            _type = AutomatikoMessages.ProcessInstance.NodeInstanceType.EVENT_SUBPROCESS_NODE;
        } else {
            _type = AutomatikoMessages.ProcessInstance.NodeInstanceType.COMPOSITE_CONTEXT_NODE;
        }
        CompositeContextNodeInstance compositeNodeInstance = (CompositeContextNodeInstance) nodeInstance;
        List<String> timerInstances = ((CompositeContextNodeInstance) nodeInstance).getTimerInstances();
        if (timerInstances != null) {
            for (String id : timerInstances) {
                _composite.addTimerInstanceId(id);
            }
        }
        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) compositeNodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
        if (variableScopeInstance != null) {
            List<Map.Entry<String, Object>> variables = new ArrayList<Map.Entry<String, Object>>(variableScopeInstance.getVariables().entrySet());
            Collections.sort(variables, new Comparator<Map.Entry<String, Object>>() {

                public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
                    return o1.getKey().compareTo(o2.getKey());
                }
            });
            for (Map.Entry<String, Object> variable : variables) {
                _composite.addVariable(ProtobufProcessMarshaller.marshallVariable(context, variable.getKey(), variable.getValue(), true));
            }
        }
        List<Map.Entry<String, Integer>> iterationlevels = new ArrayList<Map.Entry<String, Integer>>(compositeNodeInstance.getIterationLevels().entrySet());
        Collections.sort(iterationlevels, new Comparator<Map.Entry<String, Integer>>() {

            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o1.getKey().compareTo(o2.getKey());
            }
        });
        for (Map.Entry<String, Integer> level : iterationlevels) {
            if (level.getKey() != null && level.getValue() != null) {
                _composite.addIterationLevels(AutomatikoMessages.IterationLevel.newBuilder().setId(level.getKey()).setLevel(level.getValue()));
            }
        }
        List<NodeInstance> nodeInstances = new ArrayList<NodeInstance>(compositeNodeInstance.getNodeInstances());
        Collections.sort(nodeInstances, new Comparator<NodeInstance>() {

            public int compare(NodeInstance o1, NodeInstance o2) {
                return (int) (o1.getId().compareTo(o2.getId()));
            }
        });
        for (NodeInstance subNodeInstance : nodeInstances) {
            _composite.addNodeInstance(writeNodeInstance(context, subNodeInstance));
        }
        List<ContextInstance> exclusiveGroupInstances = compositeNodeInstance.getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
        if (exclusiveGroupInstances != null) {
            for (ContextInstance contextInstance : exclusiveGroupInstances) {
                AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.Builder _excl = AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance.newBuilder();
                ExclusiveGroupInstance exclusiveGroupInstance = (ExclusiveGroupInstance) contextInstance;
                Collection<NodeInstance> groupNodeInstances = exclusiveGroupInstance.getNodeInstances();
                for (NodeInstance groupNodeInstance : groupNodeInstances) {
                    _excl.addGroupNodeInstanceId(groupNodeInstance.getId());
                }
                _composite.addExclusiveGroup(_excl.build());
            }
        }
        _content = AutomatikoMessages.ProcessInstance.NodeInstanceContent.newBuilder().setType(_type).setComposite(_composite.build());
    } else {
        throw new IllegalArgumentException("Unknown node instance type: " + nodeInstance);
    }
    return _content.build();
}
Also used : JoinInstance(io.automatiko.engine.workflow.process.instance.node.JoinInstance) DynamicNodeInstance(io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) ArrayList(java.util.ArrayList) NodeInstanceType(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.ProcessInstance.NodeInstanceType) Comparator(java.util.Comparator) HumanTaskNodeInstance(io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance) List(java.util.List) ArrayList(java.util.ArrayList) NodeInstanceContent(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.ProcessInstance.NodeInstanceContent) RuleSetNodeInstance(io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance) StateNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateNodeInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) WorkItemNodeInstance(io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) SwimlaneContextInstance(io.automatiko.engine.workflow.base.instance.context.swimlane.SwimlaneContextInstance) ContextInstance(io.automatiko.engine.workflow.base.instance.ContextInstance) Collection(java.util.Collection) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.api.runtime.process.WorkflowProcessInstance) TimerNodeInstance(io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) StateNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateNodeInstance) ForEachNodeInstance(io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) TimerNodeInstance(io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance) MilestoneNodeInstance(io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance) HumanTaskNodeInstance(io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance) SubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance) WorkItemNodeInstance(io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance) DynamicNodeInstance(io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) NodeInstance(io.automatiko.engine.api.runtime.process.NodeInstance) RuleSetNodeInstance(io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance) Map(java.util.Map) HashMap(java.util.HashMap) Entry(java.util.Map.Entry) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) ExclusiveGroupInstance(io.automatiko.engine.workflow.base.instance.context.exclusive.ExclusiveGroupInstance) MilestoneNodeInstance(io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) SubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) ForEachNodeInstance(io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)

Example 3 with CompositeContextNodeInstance

use of io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance in project automatiko-engine by automatiko-io.

the class AbstractProtobufProcessInstanceMarshaller method readNodeInstance.

public NodeInstance readNodeInstance(MarshallerReaderContext context, NodeInstanceContainer nodeInstanceContainer, WorkflowProcessInstance processInstance) throws IOException {
    AutomatikoMessages.ProcessInstance.NodeInstance _node = (AutomatikoMessages.ProcessInstance.NodeInstance) context.parameterObject;
    NodeInstanceImpl nodeInstance = readNodeInstanceContent(_node, context, processInstance);
    nodeInstance.setNodeId(_node.getNodeId());
    nodeInstance.setId(_node.getId());
    nodeInstance.setNodeInstanceContainer(nodeInstanceContainer);
    nodeInstance.setProcessInstance((io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance) processInstance);
    nodeInstance.setLevel(_node.getLevel() == 0 ? 1 : _node.getLevel());
    nodeInstance.internalSetTriggerTime(new Date(_node.getTriggerDate()));
    nodeInstance.internalSetSlaCompliance(_node.getSlaCompliance());
    if (_node.getSlaDueDate() > 0) {
        nodeInstance.internalSetSlaDueDate(new Date(_node.getSlaDueDate()));
    }
    nodeInstance.internalSetSlaTimerId(_node.getSlaTimerId());
    nodeInstance.internalSetRetryJobId(_node.getRetryJobId());
    nodeInstance.internalSetRetryAttempts(_node.getRetryAttempts());
    switch(_node.getContent().getType()) {
        case COMPOSITE_CONTEXT_NODE:
        case DYNAMIC_NODE:
            if (_node.getContent().getComposite().getVariableCount() > 0) {
                Context variableScope = ((io.automatiko.engine.workflow.base.core.Process) ((io.automatiko.engine.workflow.base.instance.ProcessInstance) processInstance).getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) nodeInstance).getContextInstance(variableScope);
                for (AutomatikoMessages.Variable _variable : _node.getContent().getComposite().getVariableList()) {
                    try {
                        Object _value = ProtobufProcessMarshaller.unmarshallVariableValue(context, _variable);
                        variableScopeInstance.internalSetVariable(_variable.getName(), _value);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException("Could not reload variable " + _variable.getName());
                    }
                }
            }
            if (_node.getContent().getComposite().getIterationLevelsCount() > 0) {
                for (AutomatikoMessages.IterationLevel _level : _node.getContent().getComposite().getIterationLevelsList()) {
                    ((CompositeContextNodeInstance) nodeInstance).getIterationLevels().put(_level.getId(), _level.getLevel());
                }
            }
            for (AutomatikoMessages.ProcessInstance.NodeInstance _instance : _node.getContent().getComposite().getNodeInstanceList()) {
                context.parameterObject = _instance;
                readNodeInstance(context, (CompositeContextNodeInstance) nodeInstance, processInstance);
            }
            for (AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance _excl : _node.getContent().getComposite().getExclusiveGroupList()) {
                ExclusiveGroupInstance exclusiveGroupInstance = new ExclusiveGroupInstance();
                ((CompositeContextNodeInstance) nodeInstance).addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, exclusiveGroupInstance);
                for (String nodeInstanceId : _excl.getGroupNodeInstanceIdList()) {
                    NodeInstance groupNodeInstance = ((io.automatiko.engine.workflow.process.instance.NodeInstanceContainer) processInstance).getNodeInstance(nodeInstanceId, true);
                    if (groupNodeInstance == null) {
                        throw new IllegalArgumentException("Could not find node instance when deserializing exclusive group instance: " + nodeInstanceId);
                    }
                    exclusiveGroupInstance.addNodeInstance(groupNodeInstance);
                }
            }
            break;
        case FOR_EACH_NODE:
            for (AutomatikoMessages.ProcessInstance.NodeInstance _instance : _node.getContent().getForEach().getNodeInstanceList()) {
                context.parameterObject = _instance;
                readNodeInstance(context, (ForEachNodeInstance) nodeInstance, processInstance);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((ForEachNodeInstance) nodeInstance).getContextInstance(VariableScope.VARIABLE_SCOPE);
                for (AutomatikoMessages.Variable _variable : _node.getContent().getForEach().getVariableList()) {
                    try {
                        Object _value = ProtobufProcessMarshaller.unmarshallVariableValue(context, _variable);
                        variableScopeInstance.internalSetVariable(_variable.getName(), _value);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException("Could not reload variable " + _variable.getName());
                    }
                }
                if (_node.getContent().getForEach().getIterationLevelsCount() > 0) {
                    for (AutomatikoMessages.IterationLevel _level : _node.getContent().getForEach().getIterationLevelsList()) {
                        ((ForEachNodeInstance) nodeInstance).getIterationLevels().put(_level.getId(), _level.getLevel());
                    }
                }
            }
            break;
        case EVENT_SUBPROCESS_NODE:
            for (AutomatikoMessages.ProcessInstance.NodeInstance _instance : _node.getContent().getComposite().getNodeInstanceList()) {
                context.parameterObject = _instance;
                readNodeInstance(context, (EventSubProcessNodeInstance) nodeInstance, processInstance);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((EventSubProcessNodeInstance) nodeInstance).getContextInstance(VariableScope.VARIABLE_SCOPE);
                for (AutomatikoMessages.Variable _variable : _node.getContent().getComposite().getVariableList()) {
                    try {
                        Object _value = ProtobufProcessMarshaller.unmarshallVariableValue(context, _variable);
                        variableScopeInstance.internalSetVariable(_variable.getName(), _value);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException("Could not reload variable " + _variable.getName());
                    }
                }
            }
            break;
        default:
    }
    return nodeInstance;
}
Also used : NodeInstanceContainer(io.automatiko.engine.api.runtime.process.NodeInstanceContainer) Process(io.automatiko.engine.api.definition.process.Process) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) NodeInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.NodeInstanceImpl) Context(io.automatiko.engine.workflow.base.core.Context) SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) ExclusiveGroupInstance(io.automatiko.engine.workflow.base.instance.context.exclusive.ExclusiveGroupInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) Date(java.util.Date) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.api.runtime.process.WorkflowProcessInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) StateNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateNodeInstance) ForEachNodeInstance(io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) TimerNodeInstance(io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance) MilestoneNodeInstance(io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance) HumanTaskNodeInstance(io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance) SubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance) WorkItemNodeInstance(io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance) DynamicNodeInstance(io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) NodeInstance(io.automatiko.engine.api.runtime.process.NodeInstance) RuleSetNodeInstance(io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)

Example 4 with CompositeContextNodeInstance

use of io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance in project automatiko-engine by automatiko-io.

the class SubProcessNode method internalSubProcess.

public void internalSubProcess(Collection<io.automatiko.engine.api.workflow.Process> availableProcesses) {
    io.automatiko.engine.api.workflow.Process process = (io.automatiko.engine.api.workflow.Process<Map<String, Object>>) availableProcesses.stream().filter(p -> p.id().equals(processId)).findFirst().orElse(null);
    if (process == null) {
        return;
    }
    this.subProcessFactory = new SubProcessFactory<Object>() {

        @SuppressWarnings({ "unchecked", "rawtypes" })
        @Override
        public Map<String, Object> bind(ProcessContext ctx) {
            Map<String, Object> parameters = new HashMap<String, Object>();
            for (Iterator<DataAssociation> iterator = getInAssociations().iterator(); iterator.hasNext(); ) {
                DataAssociation mapping = iterator.next();
                Object parameterValue = null;
                if (mapping.getTransformation() != null) {
                    Transformation transformation = mapping.getTransformation();
                    DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
                    if (transformer != null) {
                        parameterValue = transformer.transform(transformation.getCompiledExpression(), getSourceParameters(ctx, mapping));
                    }
                } else if (mapping.getAssignments() == null || mapping.getAssignments().isEmpty()) {
                    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((NodeInstance) ctx.getNodeInstance()).resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getSources().get(0));
                    if (variableScopeInstance != null) {
                        parameterValue = variableScopeInstance.getVariable(mapping.getSources().get(0));
                    } else {
                        try {
                            ExpressionEvaluator evaluator = (ExpressionEvaluator) ((WorkflowProcess) ctx.getProcessInstance().getProcess()).getDefaultContext(ExpressionEvaluator.EXPRESSION_EVALUATOR);
                            parameterValue = evaluator.evaluate(mapping.getSources().get(0), new NodeInstanceResolverFactory((NodeInstance) ctx.getNodeInstance()));
                        } catch (Throwable t) {
                            parameterValue = VariableUtil.resolveVariable(mapping.getSources().get(0), ctx.getNodeInstance());
                            if (parameterValue != null) {
                                parameters.put(mapping.getTarget(), parameterValue);
                            }
                        }
                    }
                } else {
                    mapping.getAssignments().stream().forEach(a -> handleAssignment(ctx, parameters, a));
                }
                if (parameterValue != null) {
                    parameters.put(mapping.getTarget(), parameterValue);
                }
            }
            return parameters;
        }

        @Override
        public ProcessInstance createInstance(Object model) {
            Model data = (Model) process.createModel();
            data.fromMap((Map<String, Object>) model);
            return process.createInstance(data);
        }

        @Override
        public void unbind(ProcessContext ctx, Object model) {
            Map<String, Object> result = ((Model) model).toMap();
            for (Iterator<DataAssociation> iterator = getOutAssociations().iterator(); iterator.hasNext(); ) {
                DataAssociation mapping = iterator.next();
                if (mapping.getTransformation() != null) {
                    Transformation transformation = mapping.getTransformation();
                    DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
                    if (transformer != null) {
                        Map<String, Object> dataSet = new HashMap<String, Object>();
                        if (ctx.getNodeInstance().getNodeInstanceContainer() instanceof CompositeContextNodeInstance) {
                            VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) ctx.getNodeInstance().getNodeInstanceContainer()).getContextInstance(VariableScope.VARIABLE_SCOPE);
                            if (variableScopeInstance != null) {
                                dataSet.putAll(variableScopeInstance.getVariables());
                            }
                        }
                        dataSet.putAll(result);
                        Object parameterValue = transformer.transform(transformation.getCompiledExpression(), dataSet);
                        VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((NodeInstance) ctx.getNodeInstance()).resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget());
                        if (variableScopeInstance != null && parameterValue != null) {
                            variableScopeInstance.setVariable(ctx.getNodeInstance(), mapping.getTarget(), parameterValue);
                        }
                    }
                } else {
                    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((NodeInstance) ctx.getNodeInstance()).resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget());
                    if (variableScopeInstance != null) {
                        Object value = result.get(mapping.getSources().get(0));
                        if (value == null) {
                            try {
                                value = MVEL.eval(mapping.getSources().get(0), result);
                            } catch (Throwable t) {
                            // do nothing
                            }
                        }
                        variableScopeInstance.setVariable(ctx.getNodeInstance(), mapping.getTarget(), value);
                    } else {
                        String output = mapping.getSources().get(0);
                        String target = mapping.getTarget();
                        Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(target);
                        if (matcher.find()) {
                            String paramName = matcher.group(1);
                            String expression = paramName + " = " + output;
                            Serializable compiled = MVEL.compileExpression(expression);
                            MVEL.executeExpression(compiled, result);
                        }
                    }
                }
            }
        }

        @SuppressWarnings("unchecked")
        @Override
        public void abortInstance(String instanceId) {
            process.instances().findById(instanceId).ifPresent(pi -> {
                try {
                    ((ProcessInstance<?>) pi).abort();
                } catch (IllegalArgumentException e) {
                // ignore it as this might be thrown in case of canceling already aborted instance
                }
            });
        }

        private void handleAssignment(ProcessContext ctx, Map<String, Object> output, Assignment assignment) {
            AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action");
            try {
                WorkItemImpl workItem = new WorkItemImpl();
                action.execute(workItem, ctx);
                output.putAll(workItem.getParameters());
            } catch (WorkItemExecutionError e) {
                throw e;
            } catch (Exception e) {
                throw new RuntimeException("unable to execute Assignment", e);
            }
        }
    };
}
Also used : VariableUtil(io.automatiko.engine.workflow.base.instance.impl.util.VariableUtil) Context(io.automatiko.engine.workflow.base.core.Context) HashMap(java.util.HashMap) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) ArrayList(java.util.ArrayList) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) ProcessContext(io.automatiko.engine.api.runtime.process.ProcessContext) ExpressionEvaluator(io.automatiko.engine.api.expression.ExpressionEvaluator) Matcher(java.util.regex.Matcher) AbstractContext(io.automatiko.engine.workflow.base.core.context.AbstractContext) WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) Map(java.util.Map) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) LinkedList(java.util.LinkedList) Connection(io.automatiko.engine.api.definition.process.Connection) NodeInstance(io.automatiko.engine.workflow.process.instance.NodeInstance) Iterator(java.util.Iterator) Model(io.automatiko.engine.api.Model) NodeInstanceResolverFactory(io.automatiko.engine.workflow.process.instance.impl.NodeInstanceResolverFactory) Collection(java.util.Collection) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) WorkItemExecutionError(io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError) Serializable(java.io.Serializable) DataTransformerRegistry(io.automatiko.engine.workflow.base.core.impl.DataTransformerRegistry) List(java.util.List) PatternConstants(io.automatiko.engine.workflow.util.PatternConstants) ContextContainerImpl(io.automatiko.engine.workflow.base.core.impl.ContextContainerImpl) Mappable(io.automatiko.engine.workflow.base.core.context.variable.Mappable) AssignmentAction(io.automatiko.engine.workflow.base.instance.impl.AssignmentAction) Collections(java.util.Collections) MVEL(org.mvel2.MVEL) Serializable(java.io.Serializable) Matcher(java.util.regex.Matcher) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) ExpressionEvaluator(io.automatiko.engine.api.expression.ExpressionEvaluator) ProcessContext(io.automatiko.engine.api.runtime.process.ProcessContext) DataTransformer(io.automatiko.engine.api.runtime.process.DataTransformer) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) Iterator(java.util.Iterator) WorkItemExecutionError(io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) AssignmentAction(io.automatiko.engine.workflow.base.instance.impl.AssignmentAction) NodeInstanceResolverFactory(io.automatiko.engine.workflow.process.instance.impl.NodeInstanceResolverFactory) Model(io.automatiko.engine.api.Model) WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) ProcessInstance(io.automatiko.engine.api.workflow.ProcessInstance) HashMap(java.util.HashMap) Map(java.util.Map) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) NodeInstance(io.automatiko.engine.workflow.process.instance.NodeInstance)

Example 5 with CompositeContextNodeInstance

use of io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance 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

CompositeContextNodeInstance (io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance)6 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)3 WorkflowProcessInstance (io.automatiko.engine.api.runtime.process.WorkflowProcessInstance)3 VariableScopeInstance (io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance)3 DynamicNodeInstance (io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance)3 EventNodeInstance (io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)3 EventSubProcessNodeInstance (io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance)3 ForEachNodeInstance (io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance)3 HumanTaskNodeInstance (io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance)3 LambdaSubProcessNodeInstance (io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance)3 MilestoneNodeInstance (io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance)3 RuleSetNodeInstance (io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance)3 StateNodeInstance (io.automatiko.engine.workflow.process.instance.node.StateNodeInstance)3 SubProcessNodeInstance (io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance)3 TimerNodeInstance (io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance)3 WorkItemNodeInstance (io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)2 Context (io.automatiko.engine.workflow.base.core.Context)2