use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class AbstractInsertColumnCommand method commonInsertColumnCommand.
public void commonInsertColumnCommand(ScenarioSimulationContext context, ScenarioSimulationContext.Status status, int index) {
FactMappingType factMappingType = FactMappingType.valueOf(status.getColumnGroup().toUpperCase());
Map.Entry<String, String> validPlaceholders = context.getAbstractScesimGridModelByGridWidget(gridWidget).getValidPlaceholders();
String instanceTitle = validPlaceholders.getKey();
String propertyTitle = validPlaceholders.getValue();
final ScenarioGridColumn scenarioGridColumnLocal = getScenarioGridColumnLocal(instanceTitle, propertyTitle, status.getColumnId(), status.getColumnGroup(), factMappingType, context.getScenarioHeaderTextBoxSingletonDOMElementFactory(gridWidget), context.getScenarioCellTextAreaSingletonDOMElementFactory(gridWidget), ScenarioSimulationEditorConstants.INSTANCE.defineValidType());
context.getAbstractScesimGridModelByGridWidget(gridWidget).insertColumn(index, scenarioGridColumnLocal);
context.getSelectedScenarioGridLayer().ifPresent(layer -> layer.getScenarioGrid().selectCurrentHeaderCellGroup());
}
use of org.drools.scenariosimulation.api.model.FactMappingType 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));
}
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class ScenarioGridTest method setHeaderColumn.
@Test
public void setHeaderColumn() {
String columnId = factMappingDescription.getExpressionIdentifier().getName();
FactMappingType type = factMappingDescription.getExpressionIdentifier().getType();
String columnGroup = type.name();
scenarioGridSpy.setType(ScenarioSimulationModel.Type.RULE);
scenarioGridSpy.setHeaderColumn(1, factMappingDescription, true);
verify(scenarioGridSpy, times(1)).isPropertyAssigned(eq(true), eq(factMappingDescription));
verify(scenarioGridSpy, times(1)).getPlaceHolder(eq(true), eq(true), isA(FactMappingValueType.class), anyString());
verify(scenarioGridSpy, times(1)).getScenarioGridColumnLocal(eq(EXPRESSION_ALIAS_DESCRIPTION), any(), eq(columnId), eq(columnGroup), eq(type), anyString());
verify(scenarioGridColumnMock, times(1)).setColumnWidthMode(ColumnWidthMode.FIXED);
verify(scenarioGridModelMock, times(1)).getDOMElementFactory(anyString(), eq(ScenarioSimulationModel.Type.RULE), eq(FactMappingValueType.NOT_EXPRESSION));
reset(scenarioGridSpy);
reset(scenarioGridColumnMock);
reset(scenarioGridModelMock);
columnId = factMappingGiven.getExpressionIdentifier().getName();
type = factMappingGiven.getExpressionIdentifier().getType();
columnGroup = type.name();
scenarioGridSpy.setHeaderColumn(1, factMappingGiven, true);
verify(scenarioGridSpy, times(1)).isPropertyAssigned(eq(true), eq(factMappingGiven));
verify(scenarioGridSpy, times(1)).getPlaceHolder(eq(true), eq(false), eq(FactMappingValueType.NOT_EXPRESSION), anyString());
verify(scenarioGridSpy, times(1)).getScenarioGridColumnLocal(eq(EXPRESSION_ALIAS_GIVEN), any(), eq(columnId), eq(columnGroup), eq(type), anyString());
verify(scenarioGridColumnMock, never()).setColumnWidthMode(any());
verify(scenarioGridModelMock, never()).getDOMElementFactory(any(), any(), any());
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class AbstractSelectedColumnCommandTest method insertNewColumnCommon.
protected void insertNewColumnCommon(int columnIndex, boolean cloneInstance) {
int instanceNum = simulationDescriptorMock.getUnmodifiableFactMappings().size();
ScenarioGridColumn createdColumn = ((AbstractSelectedColumnCommand) commandSpy).insertNewColumn(scenarioSimulationContextLocal, gridColumnMock, columnIndex, cloneInstance);
String columnGroup = gridColumnMock.getInformationHeaderMetaData().getColumnGroup();
String originalInstanceTitle = gridColumnMock.getInformationHeaderMetaData().getTitle();
String instanceTitle = cloneInstance ? originalInstanceTitle : "INSTANCE " + instanceNum;
String propertyTitle = "PROPERTY " + instanceNum;
final FactMappingType factMappingType = FactMappingType.valueOf(columnGroup.toUpperCase());
verify(commandSpy, times(1)).getScenarioGridColumnLocal(eq(instanceTitle), eq(propertyTitle), anyString(), eq(columnGroup), eq(factMappingType), eq(scenarioHeaderTextBoxSingletonDOMElementFactorySpy), eq(scenarioCellTextAreaSingletonDOMElementFactorySpy), eq(ScenarioSimulationEditorConstants.INSTANCE.defineValidType()));
if (cloneInstance) {
verify(createdColumn, times(1)).setFactIdentifier(eq(gridColumnMock.getFactIdentifier()));
} else {
verify(createdColumn, never()).setFactIdentifier(any());
}
verify(createdColumn, times(1)).setInstanceAssigned(eq(cloneInstance));
verify(scenarioGridModelMock, times(1)).insertColumn(COLUMN_INDEX, createdColumn);
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class AbstractSelectedColumnCommand method insertNewColumn.
/**
* It inserts a new <code>ScenarioGridColumn</code> in <code>ScenarioGridModel</code>
* @param context It contains the <b>Context</b> inside which the commands will be executed
* @param selectedColumn The selected <code>ScenarioGridColumn</code> where the command was launched
* @param columnPosition Used to define in which position the new column should be added
* @param cloneInstance If true, it create a new column inside the same instance of the selected column
* @return The created <code>ScenarioGridColumn</code>
*/
protected ScenarioGridColumn insertNewColumn(ScenarioSimulationContext context, ScenarioGridColumn selectedColumn, int columnPosition, boolean cloneInstance) {
final ScenarioHeaderMetaData selectedInformationHeaderMetaData = selectedColumn.getInformationHeaderMetaData();
String columnGroup = selectedInformationHeaderMetaData.getColumnGroup();
String originalInstanceTitle = selectedInformationHeaderMetaData.getTitle();
final FactMappingType factMappingType = FactMappingType.valueOf(columnGroup.toUpperCase());
final Map.Entry<String, String> validPlaceholders = context.getAbstractScesimGridModelByGridWidget(gridWidget).getValidPlaceholders();
String instanceTitle = cloneInstance ? originalInstanceTitle : validPlaceholders.getKey();
String propertyTitle = validPlaceholders.getValue();
String placeHolder = ScenarioSimulationEditorConstants.INSTANCE.defineValidType();
final ScenarioGridColumn scenarioGridColumnLocal = getScenarioGridColumnLocal(instanceTitle, propertyTitle, String.valueOf(new Date().getTime()), columnGroup, factMappingType, context.getScenarioHeaderTextBoxSingletonDOMElementFactory(gridWidget), context.getScenarioCellTextAreaSingletonDOMElementFactory(gridWidget), placeHolder);
if (cloneInstance) {
scenarioGridColumnLocal.setFactIdentifier(selectedColumn.getFactIdentifier());
}
scenarioGridColumnLocal.setInstanceAssigned(cloneInstance);
scenarioGridColumnLocal.setPropertyAssigned(false);
context.getAbstractScesimGridModelByGridWidget(gridWidget).insertColumn(columnPosition, scenarioGridColumnLocal);
return scenarioGridColumnLocal;
}
Aggregations