Search in sources :

Example 1 with ParallelGateway

use of org.eclipse.bpmn2.ParallelGateway in project runawfe-free-server by processtech.

the class ParallelGatewayDefinitionUpdateValidator method getParallelGatewaysForCheck.

/**
 * Partial implementation
 *
 * @return parallel gateways nearby to active nodes only
 */
private Set<ParallelGateway> getParallelGatewaysForCheck(DeploymentUpdateData deploymentUpdateData) {
    Set<ParallelGateway> parallelGateways = new HashSet<>();
    Set<Node> seenNodes = new HashSet<>();
    for (ru.runa.wfe.execution.Process process : deploymentUpdateData.getProcesses()) {
        for (Token token : tokenDao.findByProcessAndExecutionStatusIsNotEnded(process)) {
            String nodeId = token.getNodeId();
            Node node = deploymentUpdateData.getOldDefinition().getNodeNotNull(nodeId);
            fetchNearestParallelGateways(parallelGateways, seenNodes, node);
        }
    }
    return parallelGateways;
}
Also used : ParallelGateway(ru.runa.wfe.lang.bpmn2.ParallelGateway) Node(ru.runa.wfe.lang.Node) Token(ru.runa.wfe.execution.Token) HashSet(java.util.HashSet)

Example 2 with ParallelGateway

use of org.eclipse.bpmn2.ParallelGateway in project droolsjbpm-integration by kiegroup.

the class BPMN2SimulationDataProvider method getSimulationDataForNode.

public Map<String, Object> getSimulationDataForNode(String nodeId) {
    boolean reverse = false;
    if (nodeId.startsWith("$reverseprops$")) {
        reverse = true;
        nodeId = nodeId.replaceFirst("\\$reverseprops\\$", "");
    }
    Map<String, Object> properties = new HashMap<String, Object>();
    // default value for probability is 50
    double defaultValue = 50.0;
    if (reverse) {
        defaultValue = 100 - defaultValue;
    }
    properties.put("probability", defaultValue);
    Scenario scenario = getDefaultScenario(def);
    if (scenario != null) {
        String baseTimeUnitValue = "";
        String baseCurrencyUnitValue = "";
        if (scenario.getScenarioParameters() != null) {
            baseCurrencyUnitValue = scenario.getScenarioParameters().getBaseCurrencyUnit();
            baseTimeUnitValue = scenario.getScenarioParameters().getBaseTimeUnit().getName();
        }
        if (scenario.getElementParameters() != null) {
            for (ElementParameters eleType : scenario.getElementParameters()) {
                if (eleType.getElementRef().equals(nodeId)) {
                    if (eleType.getControlParameters() != null && eleType.getControlParameters().getProbability() != null) {
                        FlowElement element = null;
                        for (RootElement root : def.getRootElements()) {
                            if (root instanceof Process) {
                                element = findElementInContainer((FlowElementsContainer) root, nodeId);
                                if (element != null && element instanceof SequenceFlow) {
                                    element = ((SequenceFlow) element).getSourceRef();
                                }
                                break;
                            }
                        }
                        if (element != null && element instanceof ParallelGateway) {
                            // probability should be ignored for parallel gateways so use default value
                            properties.put("probability", 100.0);
                        } else {
                            FloatingParameterType valType = (FloatingParameterType) eleType.getControlParameters().getProbability().getParameterValue().get(0);
                            double value = valType.getValue();
                            if (reverse) {
                                value = 100 - value;
                            }
                            properties.put("probability", value);
                        }
                    }
                    if (eleType.getTimeParameters() != null) {
                        if (eleType.getTimeParameters().getProcessingTime() != null) {
                            Parameter processingTime = eleType.getTimeParameters().getProcessingTime();
                            ParameterValue paramValue = processingTime.getParameterValue().get(0);
                            if (paramValue instanceof NormalDistributionType) {
                                NormalDistributionType ndt = (NormalDistributionType) paramValue;
                                properties.put("mean", ndt.getMean());
                                properties.put("standarddeviation", ndt.getStandardDeviation());
                                properties.put("distributiontype", "normal");
                            } else if (paramValue instanceof UniformDistributionType) {
                                UniformDistributionType udt = (UniformDistributionType) paramValue;
                                properties.put("max", udt.getMax());
                                properties.put("min", udt.getMin());
                                properties.put("distributiontype", "uniform");
                            // random distribution not supported in bpsim 1.0
                            // } else if(paramValue instanceof RandomDistributionType) {
                            // RandomDistributionType rdt = (RandomDistributionType) paramValue;
                            // properties.put("max", rdt.getMax());
                            // properties.put("min", rdt.getMin());
                            // properties.put("distributiontype", "random");
                            } else if (paramValue instanceof PoissonDistributionType) {
                                PoissonDistributionType pdt = (PoissonDistributionType) paramValue;
                                properties.put("mean", pdt.getMean());
                                properties.put("distributiontype", "poisson");
                            }
                            properties.put("timeunit", baseTimeUnitValue);
                            if (eleType.getTimeParameters().getWaitTime() != null) {
                                FloatingParameterType waittimeType = (FloatingParameterType) eleType.getTimeParameters().getWaitTime().getParameterValue().get(0);
                                properties.put("waittime", waittimeType.getValue());
                            }
                        }
                    }
                    if (eleType.getCostParameters() != null) {
                        CostParameters costParams = eleType.getCostParameters();
                        if (costParams.getUnitCost() != null) {
                            FloatingParameterType unitCostVal = (FloatingParameterType) costParams.getUnitCost().getParameterValue().get(0);
                            properties.put("unitcost", unitCostVal.getValue());
                        }
                        properties.put("currency", baseCurrencyUnitValue);
                    }
                    if (eleType.getResourceParameters() != null) {
                        ResourceParameters resourceParams = eleType.getResourceParameters();
                        if (resourceParams.getQuantity() != null) {
                            FloatingParameterType quantityVal = (FloatingParameterType) resourceParams.getQuantity().getParameterValue().get(0);
                            properties.put("quantity", quantityVal.getValue());
                        }
                        if (resourceParams.getAvailability() != null) {
                            FloatingParameterType workingHoursVal = (FloatingParameterType) resourceParams.getAvailability().getParameterValue().get(0);
                            properties.put("workinghours", workingHoursVal.getValue());
                        }
                    }
                }
            }
        }
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) Process(org.eclipse.bpmn2.Process) RootElement(org.eclipse.bpmn2.RootElement) FlowElement(org.eclipse.bpmn2.FlowElement) ParallelGateway(org.eclipse.bpmn2.ParallelGateway)

Example 3 with ParallelGateway

use of org.eclipse.bpmn2.ParallelGateway in project droolsjbpm-integration by kiegroup.

the class BPMN2SimulationDataProvider method getProcessDataForNode.

public Map<String, Object> getProcessDataForNode(Node node) {
    Map<String, Object> nodeProperties = new HashMap<String, Object>();
    FlowElement flowElement = null;
    List<RootElement> rootElements = def.getRootElements();
    for (RootElement root : rootElements) {
        if (root instanceof Process) {
            flowElement = findElementInContainer((FlowElementsContainer) root, (String) node.getMetaData().get("UniqueId"));
            break;
        }
    }
    if (flowElement != null) {
        if (flowElement instanceof ScriptTask) {
            nodeProperties.put("node.type", "ScriptTask");
        } else if (flowElement instanceof BusinessRuleTask) {
            nodeProperties.put("node.type", "BusinessRuleTask");
        } else if (flowElement instanceof UserTask) {
            nodeProperties.put("node.type", "UserTask");
        } else if (flowElement instanceof SendTask) {
            nodeProperties.put("node.type", "SendTask");
        } else if (flowElement instanceof ServiceTask) {
            nodeProperties.put("node.type", "ServiceTask");
        } else if (flowElement instanceof ReceiveTask) {
            nodeProperties.put("node.type", "ReceiveTask");
        } else if (flowElement instanceof ManualTask) {
            nodeProperties.put("node.type", "ManualTask");
        } else if (flowElement instanceof InclusiveGateway) {
            nodeProperties.put("node.type", "InclusiveGateway");
        } else if (flowElement instanceof ExclusiveGateway) {
            nodeProperties.put("node.type", "ExclusiveGateway");
        } else if (flowElement instanceof ParallelGateway) {
            nodeProperties.put("node.type", "ParallelGateway");
        } else if (flowElement instanceof BoundaryEvent) {
            BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "BoundaryEvent:" + eventDef);
        } else if (flowElement instanceof IntermediateCatchEvent) {
            IntermediateCatchEvent boundaryEvent = (IntermediateCatchEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "IntermediateCatchEvent:" + eventDef);
        } else if (flowElement instanceof IntermediateThrowEvent) {
            IntermediateThrowEvent boundaryEvent = (IntermediateThrowEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "IntermediateThrowEvent:" + eventDef);
        } else if (flowElement instanceof StartEvent) {
            StartEvent boundaryEvent = (StartEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "StartEvent:" + eventDef);
        } else if (flowElement instanceof EndEvent) {
            EndEvent boundaryEvent = (EndEvent) flowElement;
            List<EventDefinition> defs = boundaryEvent.getEventDefinitions();
            String eventDef = "";
            if (defs != null && !defs.isEmpty()) {
                eventDef = getEventDefinitionAsString(defs.get(0));
            }
            nodeProperties.put("node.type", "EndEvent:" + eventDef);
        }
    } else {
        nodeProperties.put("node.type", "unknown");
    }
    return nodeProperties;
}
Also used : ServiceTask(org.eclipse.bpmn2.ServiceTask) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) HashMap(java.util.HashMap) BusinessRuleTask(org.eclipse.bpmn2.BusinessRuleTask) Process(org.eclipse.bpmn2.Process) EventDefinition(org.eclipse.bpmn2.EventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) LinkEventDefinition(org.eclipse.bpmn2.LinkEventDefinition) CancelEventDefinition(org.eclipse.bpmn2.CancelEventDefinition) ManualTask(org.eclipse.bpmn2.ManualTask) InclusiveGateway(org.eclipse.bpmn2.InclusiveGateway) StartEvent(org.eclipse.bpmn2.StartEvent) EndEvent(org.eclipse.bpmn2.EndEvent) List(java.util.List) ReceiveTask(org.eclipse.bpmn2.ReceiveTask) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) UserTask(org.eclipse.bpmn2.UserTask) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) IntermediateThrowEvent(org.eclipse.bpmn2.IntermediateThrowEvent) ExclusiveGateway(org.eclipse.bpmn2.ExclusiveGateway) RootElement(org.eclipse.bpmn2.RootElement) ScriptTask(org.eclipse.bpmn2.ScriptTask) FlowElement(org.eclipse.bpmn2.FlowElement) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) SendTask(org.eclipse.bpmn2.SendTask)

Example 4 with ParallelGateway

use of org.eclipse.bpmn2.ParallelGateway in project droolsjbpm-integration by kiegroup.

the class MainElementHandler method handle.

public boolean handle(FlowElement element, PathContextManager manager) {
    PathContext context = manager.getContextFromStack();
    if (!(element instanceof SubProcess)) {
        manager.addToPath(element, context);
    }
    List<SequenceFlow> outgoing = getOutgoing(element);
    if (outgoing != null && !outgoing.isEmpty()) {
        boolean handled = false;
        if (element instanceof Gateway) {
            Gateway gateway = ((Gateway) element);
            if (gateway.getGatewayDirection() == GatewayDirection.DIVERGING) {
                handled = HandlerRegistry.getHandler(element).handle(element, manager);
            } else {
                if (gateway instanceof ParallelGateway) {
                    handled = HandlerRegistry.getHandler(element).handle(element, manager);
                } else {
                    handled = HandlerRegistry.getHandler().handle(element, manager);
                }
            }
        } else if (element instanceof Activity) {
            handled = HandlerRegistry.getHandler(element).handle(element, manager);
        } else if (element instanceof IntermediateThrowEvent) {
            handled = HandlerRegistry.getHandler(element).handle(element, manager);
        } else {
            handled = HandlerRegistry.getHandler().handle(element, manager);
        }
        if (!handled && BPMN2Utils.isAdHoc(element)) {
            manager.clearCurrentContext();
        }
    } else {
        ElementHandler handelr = HandlerRegistry.getHandler(element);
        if (handelr != null) {
            boolean handled = handelr.handle(element, manager);
            if (!handled) {
                manager.finalizePath();
            }
        } else {
            manager.finalizePath();
        }
    }
    return true;
}
Also used : SubProcess(org.eclipse.bpmn2.SubProcess) PathContext(org.jbpm.simulation.PathContext) SequenceFlow(org.eclipse.bpmn2.SequenceFlow) Gateway(org.eclipse.bpmn2.Gateway) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) ParallelGateway(org.eclipse.bpmn2.ParallelGateway) Activity(org.eclipse.bpmn2.Activity) IntermediateThrowEvent(org.eclipse.bpmn2.IntermediateThrowEvent)

Aggregations

ParallelGateway (org.eclipse.bpmn2.ParallelGateway)3 HashMap (java.util.HashMap)2 FlowElement (org.eclipse.bpmn2.FlowElement)2 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)2 IntermediateThrowEvent (org.eclipse.bpmn2.IntermediateThrowEvent)2 Process (org.eclipse.bpmn2.Process)2 RootElement (org.eclipse.bpmn2.RootElement)2 SequenceFlow (org.eclipse.bpmn2.SequenceFlow)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Activity (org.eclipse.bpmn2.Activity)1 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)1 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)1 CancelEventDefinition (org.eclipse.bpmn2.CancelEventDefinition)1 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)1 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)1 EndEvent (org.eclipse.bpmn2.EndEvent)1 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)1 EventDefinition (org.eclipse.bpmn2.EventDefinition)1 ExclusiveGateway (org.eclipse.bpmn2.ExclusiveGateway)1