use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method loadFactMappingsWidth.
/**
* It retrieves the stored columnWidths and assigns them to every grid column.
*/
public void loadFactMappingsWidth() {
for (final GridColumn<?> column : getColumns()) {
final int columnIndex = getColumns().indexOf(column);
final FactMapping factMapping = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
if (factMapping.getColumnWidth() != null) {
column.setWidth(factMapping.getColumnWidth());
}
}
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method setCellValue.
@Override
public Range setCellValue(int rowIndex, int columnIndex, GridCellValue<?> value) {
return setCell(rowIndex, columnIndex, () -> {
ScenarioGridCell newCell = new ScenarioGridCell((ScenarioGridCellValue) value);
FactMapping factMappingByIndex = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
if (ScenarioSimulationSharedUtils.isCollectionOrMap((factMappingByIndex.getClassName()))) {
newCell.setListMap(ScenarioSimulationSharedUtils.isList((factMappingByIndex.getClassName())));
}
return newCell;
});
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method commonAddColumn.
/**
* This method <i>add</i> or <i>insert</i> a new column to the grid <b>and</b> to the underlying model, depending on the index value.
* If index == -1 -> add, otherwise insert.
* @param index
* @param column
* @param ei
*/
protected void commonAddColumn(final int index, final GridColumn<?> column, ExpressionIdentifier ei) {
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
String instanceTitle = ((ScenarioGridColumn) column).getInformationHeaderMetaData().getTitle();
String propertyTitle = ((ScenarioGridColumn) column).getPropertyHeaderMetaData().getTitle();
final int columnIndex = index == -1 ? getColumnCount() : index;
try {
final FactMapping createdFactMapping = simulationDescriptor.addFactMapping(columnIndex, instanceTitle, ((ScenarioGridColumn) column).getFactIdentifier(), ei);
createdFactMapping.setExpressionAlias(propertyTitle);
if (index == -1) {
// This is actually an append
super.appendColumn(column);
} else {
super.insertColumn(index, column);
}
final Range instanceLimits = getInstanceLimits(columnIndex);
IntStream.range(instanceLimits.getMinRowIndex(), instanceLimits.getMaxRowIndex() + 1).filter(currentIndex -> currentIndex != columnIndex).forEach(currentIndex -> simulationDescriptor.getFactMappingByIndex(currentIndex).setFactAlias(createdFactMapping.getFactAlias()));
} catch (Exception e) {
eventBus.fireEvent(new ScenarioNotificationEvent("Error during column creation: " + e.getMessage(), NotificationEvent.NotificationType.ERROR));
eventBus.fireEvent(new ScenarioGridReloadEvent(getGridWidget()));
return;
}
final List<E> unmodifiableScesimData = abstractScesimModel.getUnmodifiableData();
String placeHolder = ((ScenarioGridColumn) column).getPlaceHolder();
IntStream.range(0, unmodifiableScesimData.size()).forEach(rowIndex -> setCell(rowIndex, columnIndex, () -> new ScenarioGridCell(new ScenarioGridCellValue(null, placeHolder))));
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method synchronizeFactMappingWidth.
/**
* It updates a column related <code>factMapping</code> columnWidth
* @param column
*/
public void synchronizeFactMappingWidth(final GridColumn<?> column) {
if (!column.isVisible()) {
return;
}
final int columnIndex = getColumns().indexOf(column);
final FactMapping factMapping = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
factMapping.setColumnWidth(column.getWidth());
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method isSameSelectedColumnType.
/**
* Returns <code>true</code> if type of the property mapped to the column at given index is the same as the provided one
* @param columnIndex
* @param className
* @return
*/
public boolean isSameSelectedColumnType(int columnIndex, String className) {
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
final FactMapping factMappingByIndex = simulationDescriptor.getFactMappingByIndex(columnIndex);
return factMappingByIndex.getClassName().equals(className);
}
Aggregations