Search in sources :

Example 1 with EventSubProcessNodeInstance

use of org.jbpm.workflow.instance.node.EventSubProcessNodeInstance in project jbpm by kiegroup.

the class WorkflowProcessInstanceImpl method start.

public void start(String trigger) {
    synchronized (this) {
        registerExternalEventNodeListeners();
        // activate timer event sub processes
        Node[] nodes = getNodeContainer().getNodes();
        for (Node node : nodes) {
            if (node instanceof EventSubProcessNode) {
                Map<Timer, DroolsAction> timers = ((EventSubProcessNode) node).getTimers();
                if (timers != null && !timers.isEmpty()) {
                    EventSubProcessNodeInstance eventSubprocess = (EventSubProcessNodeInstance) getNodeInstance(node);
                    eventSubprocess.trigger(null, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
                }
            }
        }
        super.start(trigger);
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) Timer(org.jbpm.process.core.timer.Timer) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) 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) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance)

Example 2 with EventSubProcessNodeInstance

use of org.jbpm.workflow.instance.node.EventSubProcessNodeInstance in project jbpm by kiegroup.

the class AbstractProtobufProcessInstanceMarshaller method readNodeInstance.

public NodeInstance readNodeInstance(MarshallerReaderContext context, NodeInstanceContainer nodeInstanceContainer, WorkflowProcessInstance processInstance) throws IOException {
    JBPMMessages.ProcessInstance.NodeInstance _node = (JBPMMessages.ProcessInstance.NodeInstance) context.parameterObject;
    NodeInstanceImpl nodeInstance = readNodeInstanceContent(_node, context, processInstance);
    nodeInstance.setNodeId(_node.getNodeId());
    nodeInstance.setId(_node.getId());
    nodeInstance.setNodeInstanceContainer(nodeInstanceContainer);
    nodeInstance.setProcessInstance((org.jbpm.workflow.instance.WorkflowProcessInstance) processInstance);
    nodeInstance.setLevel(_node.getLevel() == 0 ? 1 : _node.getLevel());
    nodeInstance.internalSetSlaCompliance(_node.getSlaCompliance());
    if (_node.getSlaDueDate() > 0) {
        nodeInstance.internalSetSlaDueDate(new Date(_node.getSlaDueDate()));
    }
    nodeInstance.internalSetSlaTimerId(_node.getSlaTimerId());
    switch(_node.getContent().getType()) {
        case COMPOSITE_CONTEXT_NODE:
        case DYNAMIC_NODE:
            if (_node.getContent().getComposite().getVariableCount() > 0) {
                Context variableScope = ((org.jbpm.process.core.Process) ((org.jbpm.process.instance.ProcessInstance) processInstance).getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
                VariableScopeInstance variableScopeInstance = (VariableScopeInstance) ((CompositeContextNodeInstance) nodeInstance).getContextInstance(variableScope);
                for (JBPMMessages.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 (JBPMMessages.IterationLevel _level : _node.getContent().getComposite().getIterationLevelsList()) {
                    ((CompositeContextNodeInstance) nodeInstance).getIterationLevels().put(_level.getId(), _level.getLevel());
                }
            }
            for (JBPMMessages.ProcessInstance.NodeInstance _instance : _node.getContent().getComposite().getNodeInstanceList()) {
                context.parameterObject = _instance;
                readNodeInstance(context, (CompositeContextNodeInstance) nodeInstance, processInstance);
            }
            for (JBPMMessages.ProcessInstance.ExclusiveGroupInstance _excl : _node.getContent().getComposite().getExclusiveGroupList()) {
                ExclusiveGroupInstance exclusiveGroupInstance = new ExclusiveGroupInstance();
                ((CompositeContextNodeInstance) nodeInstance).addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, exclusiveGroupInstance);
                for (Long nodeInstanceId : _excl.getGroupNodeInstanceIdList()) {
                    NodeInstance groupNodeInstance = ((org.jbpm.workflow.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 (JBPMMessages.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 (JBPMMessages.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 (JBPMMessages.IterationLevel _level : _node.getContent().getForEach().getIterationLevelsList()) {
                        ((ForEachNodeInstance) nodeInstance).getIterationLevels().put(_level.getId(), _level.getLevel());
                    }
                }
            }
            break;
        case EVENT_SUBPROCESS_NODE:
            for (JBPMMessages.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 (JBPMMessages.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 : NodeInstanceImpl(org.jbpm.workflow.instance.impl.NodeInstanceImpl) MarshallerWriteContext(org.drools.core.marshalling.impl.MarshallerWriteContext) MarshallerReaderContext(org.drools.core.marshalling.impl.MarshallerReaderContext) Context(org.jbpm.process.core.Context) SwimlaneContext(org.jbpm.process.core.context.swimlane.SwimlaneContext) ExclusiveGroupInstance(org.jbpm.process.instance.context.exclusive.ExclusiveGroupInstance) CompositeContextNodeInstance(org.jbpm.workflow.instance.node.CompositeContextNodeInstance) NodeInstanceContainer(org.kie.api.runtime.process.NodeInstanceContainer) Process(org.kie.api.definition.process.Process) Date(java.util.Date) VariableScopeInstance(org.jbpm.process.instance.context.variable.VariableScopeInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) RuleSetNodeInstance(org.jbpm.workflow.instance.node.RuleSetNodeInstance) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) StateNodeInstance(org.jbpm.workflow.instance.node.StateNodeInstance) TimerNodeInstance(org.jbpm.workflow.instance.node.TimerNodeInstance) CompositeContextNodeInstance(org.jbpm.workflow.instance.node.CompositeContextNodeInstance) DynamicNodeInstance(org.jbpm.workflow.instance.node.DynamicNodeInstance) AsyncEventNodeInstance(org.jbpm.workflow.instance.node.AsyncEventNodeInstance) SubProcessNodeInstance(org.jbpm.workflow.instance.node.SubProcessNodeInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) HumanTaskNodeInstance(org.jbpm.workflow.instance.node.HumanTaskNodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) ForEachNodeInstance(org.jbpm.workflow.instance.node.ForEachNodeInstance) MilestoneNodeInstance(org.jbpm.workflow.instance.node.MilestoneNodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance)

Example 3 with EventSubProcessNodeInstance

use of org.jbpm.workflow.instance.node.EventSubProcessNodeInstance 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 4 with EventSubProcessNodeInstance

use of org.jbpm.workflow.instance.node.EventSubProcessNodeInstance in project jbpm by kiegroup.

the class WorkflowProcessInstanceImpl method signalEvent.

@SuppressWarnings("unchecked")
public void signalEvent(String type, Object event) {
    logger.debug("Signal {} received with data {} in process instance {}", type, event, getId());
    synchronized (this) {
        if (getState() != ProcessInstance.STATE_ACTIVE) {
            return;
        }
        if ("timerTriggered".equals(type)) {
            TimerInstance timer = (TimerInstance) event;
            if (timer.getId() == slaTimerId) {
                handleSLAViolation();
                // no need to pass the event along as it was purely for SLA tracking
                return;
            }
        }
        if ("slaViolation".equals(type)) {
            handleSLAViolation();
            // no need to pass the event along as it was purely for SLA tracking
            return;
        }
        List<NodeInstance> currentView = new ArrayList<NodeInstance>(this.nodeInstances);
        try {
            this.activatingNodeIds = new ArrayList<String>();
            List<EventListener> listeners = eventListeners.get(type);
            if (listeners != null) {
                for (EventListener listener : listeners) {
                    listener.signalEvent(type, event);
                }
            }
            listeners = externalEventListeners.get(type);
            if (listeners != null) {
                for (EventListener listener : listeners) {
                    listener.signalEvent(type, event);
                }
            }
            for (Node node : getWorkflowProcess().getNodes()) {
                if (node instanceof EventNodeInterface) {
                    if (((EventNodeInterface) node).acceptsEvent(type, event, (e) -> resolveVariable(e))) {
                        if (node instanceof EventNode && ((EventNode) node).getFrom() == null) {
                            EventNodeInstance eventNodeInstance = (EventNodeInstance) getNodeInstance(node);
                            eventNodeInstance.signalEvent(type, event);
                        } else {
                            if (node instanceof EventSubProcessNode && ((resolveVariables(((EventSubProcessNode) node).getEvents()).contains(type)))) {
                                EventSubProcessNodeInstance eventNodeInstance = (EventSubProcessNodeInstance) getNodeInstance(node);
                                eventNodeInstance.signalEvent(type, event);
                            }
                            if (node instanceof DynamicNode && type.equals(((DynamicNode) node).getActivationEventName())) {
                                DynamicNodeInstance dynamicNodeInstance = (DynamicNodeInstance) getNodeInstance(node);
                                dynamicNodeInstance.signalEvent(type, event);
                            } else {
                                List<NodeInstance> nodeInstances = getNodeInstances(node.getId(), currentView);
                                if (nodeInstances != null && !nodeInstances.isEmpty()) {
                                    for (NodeInstance nodeInstance : nodeInstances) {
                                        ((EventNodeInstanceInterface) nodeInstance).signalEvent(type, event);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (((org.jbpm.workflow.core.WorkflowProcess) getWorkflowProcess()).isDynamic()) {
                for (Node node : getWorkflowProcess().getNodes()) {
                    if (type.equals(node.getName()) && node.getIncomingConnections().isEmpty()) {
                        NodeInstance nodeInstance = getNodeInstance(node);
                        if (event != null) {
                            Map<String, Object> dynamicParams = new HashMap<>();
                            if (event instanceof Map) {
                                dynamicParams.putAll((Map<String, Object>) event);
                            } else {
                                dynamicParams.put("Data", event);
                            }
                            ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).setDynamicParameters(dynamicParams);
                        }
                        ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, NodeImpl.CONNECTION_DEFAULT_TYPE);
                    }
                }
            }
        } finally {
            if (this.activatingNodeIds != null) {
                this.activatingNodeIds.clear();
                this.activatingNodeIds = null;
            }
        }
    }
}
Also used : DynamicNodeInstance(org.jbpm.workflow.instance.node.DynamicNodeInstance) TimerInstance(org.jbpm.process.instance.timer.TimerInstance) HashMap(java.util.HashMap) EventNodeInterface(org.jbpm.workflow.core.node.EventNodeInterface) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode) StateBasedNode(org.jbpm.workflow.core.node.StateBasedNode) EventSubProcessNode(org.jbpm.workflow.core.node.EventSubProcessNode) 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) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) AsyncEventNode(org.jbpm.workflow.core.node.AsyncEventNode) EventNode(org.jbpm.workflow.core.node.EventNode) EventNodeInstanceInterface(org.jbpm.workflow.instance.node.EventNodeInstanceInterface) DynamicNode(org.jbpm.workflow.core.node.DynamicNode) EventListener(org.kie.api.runtime.process.EventListener) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) DynamicNodeInstance(org.jbpm.workflow.instance.node.DynamicNodeInstance) EndNodeInstance(org.jbpm.workflow.instance.node.EndNodeInstance) NodeInstance(org.jbpm.workflow.instance.NodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) CompositeNodeInstance(org.jbpm.workflow.instance.node.CompositeNodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance) WorkflowProcess(org.kie.api.definition.process.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with EventSubProcessNodeInstance

use of org.jbpm.workflow.instance.node.EventSubProcessNodeInstance in project jbpm by kiegroup.

the class AbstractProtobufProcessInstanceMarshaller method readNodeInstanceContent.

protected NodeInstanceImpl readNodeInstanceContent(JBPMMessages.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();
            ((RuleSetNodeInstance) nodeInstance).setRuleFlowGroup(_content.getRuleSet().getRuleFlowGroup());
            if (_content.getRuleSet().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getRuleSet().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((RuleSetNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            if (_content.getRuleSet().getMapEntryCount() > 0) {
                Map<String, FactHandle> factInfo = new HashMap<String, FactHandle>();
                for (TextMapEntry entry : _content.getRuleSet().getMapEntryList()) {
                    factInfo.put(entry.getName(), DefaultFactHandle.createFromExternalFormat(entry.getValue()));
                }
                ((RuleSetNodeInstance) nodeInstance).setFactHandles(factInfo);
            }
            break;
        case HUMAN_TASK_NODE:
            nodeInstance = new HumanTaskNodeInstance();
            ((HumanTaskNodeInstance) nodeInstance).internalSetWorkItemId(_content.getHumanTask().getWorkItemId());
            if (_content.getHumanTask().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getHumanTask().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((HumanTaskNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case WORK_ITEM_NODE:
            nodeInstance = new WorkItemNodeInstance();
            ((WorkItemNodeInstance) nodeInstance).internalSetWorkItemId(_content.getWorkItem().getWorkItemId());
            if (_content.getWorkItem().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getWorkItem().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((WorkItemNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case SUBPROCESS_NODE:
            nodeInstance = new SubProcessNodeInstance();
            ((SubProcessNodeInstance) nodeInstance).internalSetProcessInstanceId(_content.getSubProcess().getProcessInstanceId());
            if (_content.getSubProcess().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getSubProcess().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((SubProcessNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case MILESTONE_NODE:
            nodeInstance = new MilestoneNodeInstance();
            if (_content.getMilestone().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _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 ASYNC_EVENT_NODE:
            nodeInstance = new AsyncEventNodeInstance();
            ((AsyncEventNodeInstance) nodeInstance).setEventType(_content.getAsyncEvent().getEventType());
            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 (JBPMMessages.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();
            break;
        case COMPOSITE_CONTEXT_NODE:
            nodeInstance = new CompositeContextNodeInstance();
            if (_content.getComposite().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getComposite().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case DYNAMIC_NODE:
            nodeInstance = new DynamicNodeInstance();
            if (_content.getComposite().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _timerId : _content.getComposite().getTimerInstanceIdList()) {
                    timerInstances.add(_timerId);
                }
                ((CompositeContextNodeInstance) nodeInstance).internalSetTimerInstances(timerInstances);
            }
            break;
        case STATE_NODE:
            nodeInstance = new StateNodeInstance();
            if (_content.getState().getTimerInstanceIdCount() > 0) {
                List<Long> timerInstances = new ArrayList<Long>();
                for (Long _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<Long> timerInstances = new ArrayList<Long>();
                for (Long _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 : AsyncEventNodeInstance(org.jbpm.workflow.instance.node.AsyncEventNodeInstance) JoinInstance(org.jbpm.workflow.instance.node.JoinInstance) DynamicNodeInstance(org.jbpm.workflow.instance.node.DynamicNodeInstance) FactHandle(org.kie.api.runtime.rule.FactHandle) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HumanTaskNodeInstance(org.jbpm.workflow.instance.node.HumanTaskNodeInstance) NodeInstanceContent(org.jbpm.marshalling.impl.JBPMMessages.ProcessInstance.NodeInstanceContent) RuleSetNodeInstance(org.jbpm.workflow.instance.node.RuleSetNodeInstance) NodeInstanceImpl(org.jbpm.workflow.instance.impl.NodeInstanceImpl) MilestoneNodeInstance(org.jbpm.workflow.instance.node.MilestoneNodeInstance) StateNodeInstance(org.jbpm.workflow.instance.node.StateNodeInstance) CompositeContextNodeInstance(org.jbpm.workflow.instance.node.CompositeContextNodeInstance) TextMapEntry(org.jbpm.marshalling.impl.JBPMMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.TextMapEntry) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) EventSubProcessNodeInstance(org.jbpm.workflow.instance.node.EventSubProcessNodeInstance) SubProcessNodeInstance(org.jbpm.workflow.instance.node.SubProcessNodeInstance) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkflowProcessInstance(org.kie.api.runtime.process.WorkflowProcessInstance) ForEachNodeInstance(org.jbpm.workflow.instance.node.ForEachNodeInstance) TimerNodeInstance(org.jbpm.workflow.instance.node.TimerNodeInstance) AsyncEventNodeInstance(org.jbpm.workflow.instance.node.AsyncEventNodeInstance) EventNodeInstance(org.jbpm.workflow.instance.node.EventNodeInstance)

Aggregations

EventSubProcessNodeInstance (org.jbpm.workflow.instance.node.EventSubProcessNodeInstance)6 EventNodeInstance (org.jbpm.workflow.instance.node.EventNodeInstance)5 DynamicNodeInstance (org.jbpm.workflow.instance.node.DynamicNodeInstance)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 EventSubProcessNode (org.jbpm.workflow.core.node.EventSubProcessNode)3 AsyncEventNodeInstance (org.jbpm.workflow.instance.node.AsyncEventNodeInstance)3 CompositeContextNodeInstance (org.jbpm.workflow.instance.node.CompositeContextNodeInstance)3 ForEachNodeInstance (org.jbpm.workflow.instance.node.ForEachNodeInstance)3 HumanTaskNodeInstance (org.jbpm.workflow.instance.node.HumanTaskNodeInstance)3 MilestoneNodeInstance (org.jbpm.workflow.instance.node.MilestoneNodeInstance)3 RuleSetNodeInstance (org.jbpm.workflow.instance.node.RuleSetNodeInstance)3 StateNodeInstance (org.jbpm.workflow.instance.node.StateNodeInstance)3 SubProcessNodeInstance (org.jbpm.workflow.instance.node.SubProcessNodeInstance)3 TimerNodeInstance (org.jbpm.workflow.instance.node.TimerNodeInstance)3 WorkItemNodeInstance (org.jbpm.workflow.instance.node.WorkItemNodeInstance)3 List (java.util.List)2 Map (java.util.Map)2 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)2 NodeInstanceContent (org.jbpm.marshalling.impl.JBPMMessages.ProcessInstance.NodeInstanceContent)2