use of org.drools.scenariosimulation.api.model.ScesimModelDescriptor in project drools-wb by kiegroup.
the class AbstractScesimGridModel method updateHeader.
public void updateHeader(int columnIndex, int headerRowIndex, String headerCellValue) {
final ScenarioHeaderMetaData editedMetadata = (ScenarioHeaderMetaData) getColumns().get(columnIndex).getHeaderMetaData().get(headerRowIndex);
// do not update if old and new value are the same
if (Objects.equals(editedMetadata.getTitle(), headerCellValue)) {
return;
}
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
FactMapping factMappingToEdit = simulationDescriptor.getFactMappingByIndex(columnIndex);
ScenarioHeaderMetaData.MetadataType metadataType = editedMetadata.getMetadataType();
IntStream.range(0, getColumnCount()).forEach(index -> updateFactMapping(simulationDescriptor, factMappingToEdit, index, headerCellValue, metadataType));
if (editedMetadata.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(false));
}
}
use of org.drools.scenariosimulation.api.model.ScesimModelDescriptor in project drools-wb by kiegroup.
the class RULESimulationSettingsCreationStrategy method createSimulation.
@Override
public Simulation createSimulation(Path context, String value) {
Simulation toReturn = new Simulation();
ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor();
simulationDescriptor.addFactMapping(FactIdentifier.INDEX.getName(), FactIdentifier.INDEX, ExpressionIdentifier.INDEX);
simulationDescriptor.addFactMapping(FactIdentifier.DESCRIPTION.getName(), FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION);
ScenarioWithIndex scenarioWithIndex = createScesimDataWithIndex(toReturn, simulationDescriptor, ScenarioWithIndex::new);
// Add GIVEN Fact
createEmptyColumn(simulationDescriptor, scenarioWithIndex, 1, GIVEN, simulationDescriptor.getFactMappings().size());
// Add EXPECT Fact
createEmptyColumn(simulationDescriptor, scenarioWithIndex, 2, EXPECT, simulationDescriptor.getFactMappings().size());
return toReturn;
}
use of org.drools.scenariosimulation.api.model.ScesimModelDescriptor in project drools-wb by kiegroup.
the class SimulationSettingsCreationStrategy method createBackground.
default Background createBackground(Path context, String dmnFilePath) {
Background toReturn = new Background();
ScesimModelDescriptor simulationDescriptor = toReturn.getScesimModelDescriptor();
int index = toReturn.getUnmodifiableData().size() + 1;
BackgroundData backgroundData = toReturn.addData();
BackgroundDataWithIndex backgroundDataWithIndex = new BackgroundDataWithIndex(index, backgroundData);
// Add GIVEN Fact
createEmptyColumn(simulationDescriptor, backgroundDataWithIndex, 1, GIVEN, simulationDescriptor.getFactMappings().size());
return toReturn;
}
use of org.drools.scenariosimulation.api.model.ScesimModelDescriptor in project drools-wb by kiegroup.
the class ScenarioRunnerServiceImplTest method runTestWithScenarios.
@Test
public void runTestWithScenarios() {
when(buildInfoServiceMock.getBuildInfo(any())).thenReturn(buildInfoMock);
when(buildInfoMock.getKieContainer()).thenReturn(kieContainerMock);
ScesimModelDescriptor simulationDescriptor = new ScesimModelDescriptor();
List<ScenarioWithIndex> scenarios = new ArrayList<>();
SimulationRunResult test = scenarioRunnerService.runTest("test", mock(Path.class), simulationDescriptor, scenarios, settingsLocal, backgroundLocal);
assertNotNull(test.getTestResultMessage());
assertNotNull(test.getScenarioWithIndex());
assertNotNull(test.getSimulationRunMetadata());
}
use of org.drools.scenariosimulation.api.model.ScesimModelDescriptor in project drools-wb by kiegroup.
the class DMNSimulationSettingsCreationStrategy method addEmptyColumnsIfNeeded.
/**
* If DMN model is empty, contains only inputs or only outputs this method add one GIVEN and/or EXPECT empty column
* @param simulation
* @param scenarioWithIndex
*/
protected void addEmptyColumnsIfNeeded(Simulation simulation, ScenarioWithIndex scenarioWithIndex) {
boolean hasGiven = false;
boolean hasExpect = false;
ScesimModelDescriptor simulationDescriptor = simulation.getScesimModelDescriptor();
for (FactMapping factMapping : simulationDescriptor.getFactMappings()) {
FactMappingType factMappingType = factMapping.getExpressionIdentifier().getType();
if (!hasGiven && GIVEN.equals(factMappingType)) {
hasGiven = true;
} else if (!hasExpect && EXPECT.equals(factMappingType)) {
hasExpect = true;
}
}
if (!hasGiven) {
createEmptyColumn(simulationDescriptor, scenarioWithIndex, 1, GIVEN, findNewIndexOfGroup(simulationDescriptor, GIVEN));
}
if (!hasExpect) {
createEmptyColumn(simulationDescriptor, scenarioWithIndex, 2, EXPECT, findNewIndexOfGroup(simulationDescriptor, EXPECT));
}
}
Aggregations