Search in sources :

Example 11 with ScesimModelDescriptor

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));
    }
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)

Example 12 with ScesimModelDescriptor

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;
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) Simulation(org.drools.scenariosimulation.api.model.Simulation) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex)

Example 13 with ScesimModelDescriptor

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;
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) Background(org.drools.scenariosimulation.api.model.Background) BackgroundDataWithIndex(org.drools.scenariosimulation.api.model.BackgroundDataWithIndex) BackgroundData(org.drools.scenariosimulation.api.model.BackgroundData)

Example 14 with ScesimModelDescriptor

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());
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) Path(org.uberfire.backend.vfs.Path) SimulationRunResult(org.drools.workbench.screens.scenariosimulation.model.SimulationRunResult) ArrayList(java.util.ArrayList) ScenarioWithIndex(org.drools.scenariosimulation.api.model.ScenarioWithIndex) Test(org.junit.Test)

Example 15 with ScesimModelDescriptor

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));
    }
}
Also used : ScesimModelDescriptor(org.drools.scenariosimulation.api.model.ScesimModelDescriptor) FactMapping(org.drools.scenariosimulation.api.model.FactMapping) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType)

Aggregations

ScesimModelDescriptor (org.drools.scenariosimulation.api.model.ScesimModelDescriptor)29 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)18 ArrayList (java.util.ArrayList)11 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)11 List (java.util.List)9 Map (java.util.Map)9 FactIdentifier (org.drools.scenariosimulation.api.model.FactIdentifier)9 Set (java.util.Set)8 Simulation (org.drools.scenariosimulation.api.model.Simulation)8 Objects (java.util.Objects)7 ExpressionElement (org.drools.scenariosimulation.api.model.ExpressionElement)7 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)7 ScenarioSimulationModel (org.drools.scenariosimulation.api.model.ScenarioSimulationModel)7 ScenarioWithIndex (org.drools.scenariosimulation.api.model.ScenarioWithIndex)7 Collections (java.util.Collections)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)6 FactMappingValue (org.drools.scenariosimulation.api.model.FactMappingValue)6 Scenario (org.drools.scenariosimulation.api.model.Scenario)6 ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)5