private NodeInstance findNodeByUniqueId(Collection<NodeInstance> nodeInstances, String uniqueId) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); if (uniqueId.equals(nodeUniqueId)) { return nInstance; } if (nInstance instanceof CompositeNodeInstance) { NodeInstance nodeInstance = findNodeByUniqueId(((CompositeNodeInstance) nInstance).getNodeInstances(), uniqueId); if (nodeInstance != null) { return nodeInstance; } } } } return null; }
private static 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(); } // clean up iteration levels for removed (old) nodes Map<String, Integer> iterLevels = ((WorkflowProcessInstanceImpl) nodeInstance.getProcessInstance()).getIterationLevels(); String uniqueId = (String) ((NodeImpl) nodeInstance.getNode()).getMetaData("UniqueId"); iterLevels.remove(uniqueId); // and now set to new node id ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
private boolean isAttachedToNodeActive(Collection<NodeInstance> nodeInstances, String attachedTo, String type, Object event) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); boolean isActivating = ((WorkflowProcessInstanceImpl)nInstance.getProcessInstance()).getActivatingNodeIds().contains(nodeUniqueId); if (attachedTo.equals(nodeUniqueId) && !isActivating) { // in case this is timer event make sure it corresponds to the proper node instance if (type.startsWith("Timer-")) { if (Long.valueOf(nInstance.getId()).equals(event)) { return true; } } else { return true; } } if (nInstance instanceof CompositeNodeInstance) { boolean hasActive = isAttachedToNodeActive(((CompositeNodeInstance) nInstance).getNodeInstances(), attachedTo, type, event); if (hasActive) { return true; } } } } return false; }
private static 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(); } // clean up iteration levels for removed (old) nodes Map<String, Integer> iterLevels = ((WorkflowProcessInstanceImpl) nodeInstance.getProcessInstance()).getIterationLevels(); String uniqueId = (String) ((NodeImpl) nodeInstance.getNode()).getMetaData("UniqueId"); iterLevels.remove(uniqueId); // and now set to new node id ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { logger.debug("before node"); Map<String, Object> metaData = event.getNodeInstance().getNode().getMetaData(); for (Map.Entry<String, Object> entry: metaData.entrySet()) { logger.debug(entry.getKey() + " " + entry.getValue()); } String customTag = (String) metaData.get("customTag"); if (customTag != null) { list1.add(customTag); } String customTag2 = (String) metaData.get("customTag2"); if (customTag2 != null) { list2.add(customTag2); } } public void afterVariableChanged(ProcessVariableChangedEvent event) {
continue; Node node = nodeInstance.getNode(); Set<Long> vistedNodes = new HashSet<Long>(); checkNodes(vistedNodes,node, node, lookFor);
if (nodeInstance.getNode() == null) { continue;
public Node getNode() { return new NodeAdapter(delegate.getNode()); }
private NodeInstance findNodeByUniqueId(Collection<NodeInstance> nodeInstances, String uniqueId) { if (nodeInstances != null && !nodeInstances.isEmpty()) { for (NodeInstance nInstance : nodeInstances) { String nodeUniqueId = (String) nInstance.getNode().getMetaData().get("UniqueId"); if (uniqueId.equals(nodeUniqueId)) { return nInstance; } if (nInstance instanceof CompositeNodeInstance) { NodeInstance nodeInstance = findNodeByUniqueId(((CompositeNodeInstance) nInstance).getNodeInstances(), uniqueId); if (nodeInstance != null) { return nodeInstance; } } } } return null; }
public void beforeNodeTriggered(ProcessNodeTriggeredEvent event) { logger.debug("before node"); Map<String, Object> metaData = event.getNodeInstance().getNode().getMetaData(); for (Map.Entry<String, Object> entry: metaData.entrySet()) { logger.debug(entry.getKey() + " " + entry.getValue()); } String customTag = (String) metaData.get("customTag"); if (customTag != null) { list1.add(customTag); } String customTag2 = (String) metaData.get("customTag2"); if (customTag2 != null) { list2.add(customTag2); } } public void afterVariableChanged(ProcessVariableChangedEvent event) {
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance gateway = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = gateway.getNode().getMetaData(); ProcessInstance pi = gateway.getProcessInstance(); Node node = gateway.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); // todo long duration = 0; long endTime = startTime + duration; context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); SimulationDataProvider provider = context.getDataProvider(); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new GatewaySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, endTime, bpmn2NodeId, node.getName(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance gateway = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = gateway.getNode().getMetaData(); ProcessInstance pi = gateway.getProcessInstance(); Node node = gateway.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); // todo long duration = 0; long endTime = startTime + duration; context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); SimulationDataProvider provider = context.getDataProvider(); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new GatewaySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, endTime, bpmn2NodeId, node.getName(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance eventNodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = eventNodeInstance.getNode().getMetaData(); ProcessInstance pi = eventNodeInstance.getProcessInstance(); Node node = eventNodeInstance.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance eventNodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = eventNodeInstance.getNode().getMetaData(); ProcessInstance pi = eventNodeInstance.getProcessInstance(); Node node = eventNodeInstance.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance stateNode = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = stateNode.getNode().getMetaData(); ProcessInstance pi = stateNode.getProcessInstance(); Node node = stateNode.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance stateNode = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); Map<String, Object> metadata = stateNode.getNode().getMetaData(); ProcessInstance pi = stateNode.getProcessInstance(); Node node = stateNode.getNode(); String bpmn2NodeId = (String) metadata.get("UniqueId"); SimulationDataProvider provider = context.getDataProvider(); TimeGenerator timeGenerator=TimeGeneratorFactory.newTimeGenerator(provider.getSimulationDataForNode(node)); long duration = timeGenerator.generateTime(); context.getClock().advanceTime(duration, TimeUnit.MILLISECONDS); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); String type = (String) provider.getProcessDataForNode(node).get("node.type"); return new ActivitySimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), node.getName(), bpmn2NodeId, duration, startTime, context.getClock().getCurrentTime(), type); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; ProcessInstance pi = nodeInstance.getProcessInstance(); context.setStartTime(context.getClock().getCurrentTime()); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new StartSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), context.getStartTime(), context.getClock().getCurrentTime(), bpmn2NodeId, node.getName()); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; ProcessInstance pi = nodeInstance.getProcessInstance(); context.setStartTime(context.getClock().getCurrentTime()); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new StartSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), context.getStartTime(), context.getClock().getCurrentTime(), bpmn2NodeId, node.getName()); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); ProcessInstance pi = nodeInstance.getProcessInstance(); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); String processName = pi.getProcessName(); String processVer = pi.getProcess().getVersion(); if (processVer == null) { processVer = ""; } // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new EndSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, context.getClock().getCurrentTime(), context.getStartTime(), bpmn2NodeId, node.getName(), processName, processVer); }
public SimulationEvent simulate(Object activity, SimulationContext context) { NodeInstance nodeInstance = (NodeInstance) activity; long startTime = context.getClock().getCurrentTime(); ProcessInstance pi = nodeInstance.getProcessInstance(); Node node = nodeInstance.getNode(); String bpmn2NodeId = (String) node.getMetaData().get("UniqueId"); String processName = pi.getProcessName(); String processVer = pi.getProcess().getVersion(); if (processVer == null) { processVer = ""; } // set end time for processinstance end time context.setMaxEndTime(context.getClock().getCurrentTime()); return new EndSimulationEvent(pi.getProcessId(), context.getProcessInstanceId(), startTime, context.getClock().getCurrentTime(), context.getStartTime(), bpmn2NodeId, node.getName(), processName, processVer); }