use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet in project kie-wb-common by kiegroup.
the class SimulationSets method of.
public static SimulationSet of(ElementParameters eleType) {
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return new SimulationSet();
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
SimulationSet simulationSet = Match.of(ParameterValue.class, SimulationSet.class).when(NormalDistributionType.class, ndt -> {
SimulationSet sset = new SimulationSet();
sset.getMean().setValue(ndt.getMean());
sset.getStandardDeviation().setValue(ndt.getStandardDeviation());
sset.getDistributionType().setValue("normal");
return sset;
}).when(UniformDistributionType.class, udt -> {
SimulationSet sset = new SimulationSet();
sset.getMin().setValue(udt.getMin());
sset.getMax().setValue(udt.getMax());
sset.getDistributionType().setValue("uniform");
return sset;
}).when(PoissonDistributionType.class, pdt -> {
SimulationSet sset = new SimulationSet();
sset.getMean().setValue(pdt.getMean());
sset.getDistributionType().setValue("poisson");
return sset;
}).apply(paramValue).asSuccess().value();
CostParameters costParams = eleType.getCostParameters();
if (costParams != null) {
simulationSet.getUnitCost().setValue(extractDouble(costParams.getUnitCost()));
}
ResourceParameters resourceParams = eleType.getResourceParameters();
if (resourceParams != null) {
Double quantity = extractDouble(resourceParams.getQuantity());
simulationSet.getQuantity().setValue(quantity);
Double availability = extractDouble(resourceParams.getAvailability());
simulationSet.getWorkingHours().setValue(availability);
}
return simulationSet;
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet in project kie-wb-common by kiegroup.
the class Simulations method simulationSet.
public static SimulationSet simulationSet(ElementParameters eleType) {
SimulationSet simulationSet = new SimulationSet();
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return simulationSet;
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
VoidMatch.of(ParameterValue.class).when(NormalDistributionType.class, ndt -> {
simulationSet.getMean().setValue(ndt.getMean());
simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation());
simulationSet.getDistributionType().setValue("normal");
}).when(UniformDistributionType.class, udt -> {
simulationSet.getMin().setValue(udt.getMin());
simulationSet.getMax().setValue(udt.getMax());
simulationSet.getDistributionType().setValue("uniform");
}).when(PoissonDistributionType.class, pdt -> {
simulationSet.getMean().setValue(pdt.getMean());
simulationSet.getDistributionType().setValue("poisson");
}).apply(paramValue).asSuccess().value();
CostParameters costParams = eleType.getCostParameters();
if (costParams != null) {
simulationSet.getUnitCost().setValue(extractDouble(costParams.getUnitCost()));
}
// controlParams(eleType, simulationSet);
ResourceParameters resourceParams = eleType.getResourceParameters();
if (resourceParams != null) {
Double quantity = extractDouble(resourceParams.getQuantity());
simulationSet.getQuantity().setValue(quantity);
Double availability = extractDouble(resourceParams.getAvailability());
simulationSet.getWorkingHours().setValue(availability);
}
return simulationSet;
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet in project kie-wb-common by kiegroup.
the class Simulations method simulationAttributeSet.
public static SimulationAttributeSet simulationAttributeSet(ElementParameters eleType) {
SimulationAttributeSet simulationSet = new SimulationAttributeSet();
TimeParameters timeParams = eleType.getTimeParameters();
if (timeParams == null) {
return simulationSet;
}
Parameter processingTime = timeParams.getProcessingTime();
ParameterValue paramValue = processingTime.getParameterValue().get(0);
return Match.of(ParameterValue.class, SimulationAttributeSet.class).when(NormalDistributionType.class, ndt -> {
simulationSet.getMean().setValue(ndt.getMean());
simulationSet.getStandardDeviation().setValue(ndt.getStandardDeviation());
simulationSet.getDistributionType().setValue("normal");
return simulationSet;
}).when(UniformDistributionType.class, udt -> {
simulationSet.getMin().setValue(udt.getMin());
simulationSet.getMax().setValue(udt.getMax());
simulationSet.getDistributionType().setValue("uniform");
return simulationSet;
}).when(PoissonDistributionType.class, pdt -> {
simulationSet.getMean().setValue(pdt.getMean());
simulationSet.getDistributionType().setValue("poisson");
return simulationSet;
}).apply(paramValue).asSuccess().value();
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallSimulationProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallSimulationProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SIMULATIONPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("SimulationProperties", diagram.getMetadata().getTitle());
SimulationSet simulationSet = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof UserTask) {
UserTask userTask = (UserTask) oDefinition;
simulationSet = userTask.getSimulationSet();
break;
}
}
}
assertEquals(Double.valueOf(111), simulationSet.getQuantity().getValue());
assertEquals("poisson", simulationSet.getDistributionType().getValue());
assertEquals(Double.valueOf(123), simulationSet.getUnitCost().getValue());
assertEquals(Double.valueOf(999), simulationSet.getWorkingHours().getValue());
assertEquals(Double.valueOf(321), simulationSet.getMean().getValue());
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallSimulationProperties.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallSimulationProperties() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SIMULATIONPROPERTIES);
assertDiagram(diagram, 4);
assertEquals("SimulationProperties", diagram.getMetadata().getTitle());
SimulationSet simulationSet = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof UserTask) {
UserTask userTask = (UserTask) oDefinition;
simulationSet = userTask.getSimulationSet();
break;
}
}
}
assertEquals(Double.valueOf(111), simulationSet.getQuantity().getValue());
assertEquals("poisson", simulationSet.getDistributionType().getValue());
assertEquals(Double.valueOf(123), simulationSet.getUnitCost().getValue());
assertEquals(Double.valueOf(999), simulationSet.getWorkingHours().getValue());
assertEquals(Double.valueOf(321), simulationSet.getMean().getValue());
}
Aggregations