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;
}
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;
}
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;
}
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;
}
Aggregations