use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method checkSamePropertyHeader.
/**
* Check if given <b>headerName</b> is the same as the <b>element steps</b> mapped to the given column
* @param columnIndex
* @param propertyNameElements
* @throws IllegalStateException if the given <b>propertyNameElements</b> (corrected for the class name) represents the <b>element steps</b> of the given column
*/
public void checkSamePropertyHeader(int columnIndex, List<String> propertyNameElements) {
ScesimModelDescriptor simulationDescriptor = abstractScesimModel.getScesimModelDescriptor();
final FactMapping factMapping = simulationDescriptor.getFactMappingByIndex(columnIndex);
List<String> columnPropertyName = factMapping.getExpressionElementsWithoutClass().stream().map(ExpressionElement::getStep).collect(Collectors.toList());
if (!Objects.equals(columnPropertyName, propertyNameElements)) {
throw new IllegalStateException(String.join(".", propertyNameElements) + " is not the same property of the current column.");
}
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method resetError.
/**
* It resets the <code>FactMappingValue</code> status for a specific CELL
* @param rowIndex
* @param columnIndex
*/
public void resetError(int rowIndex, int columnIndex) {
E scesimDataByIndex = abstractScesimModel.getDataByIndex(rowIndex);
FactMapping factMapping = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
Optional<FactMappingValue> factMappingValue = scesimDataByIndex.getFactMappingValue(factMapping);
factMappingValue.ifPresent(FactMappingValue::resetStatus);
refreshErrors();
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method updateFactMapping.
/**
* If the <code>FactIdentifier</code> of the given <code>FactMapping</code> equals the one at <b>index</b>, update the <code>FactMapping.FactAlias</code> at <b>index</b>
* position with the provided <b>value</b>
* @param simulationDescriptor
* @param factMappingReference
* @param index
* @param value
*/
protected void updateFactMapping(ScesimModelDescriptor simulationDescriptor, FactMapping factMappingReference, int index, String value, ScenarioHeaderMetaData.MetadataType metadataType) {
final FactIdentifier factIdentifierReference = factMappingReference.getFactIdentifier();
FactMapping factMappingToCheck = simulationDescriptor.getFactMappingByIndex(index);
final FactIdentifier factIdentifierToCheck = factMappingToCheck.getFactIdentifier();
boolean toUpdate = (Objects.equals(FactIdentifier.EMPTY, factIdentifierReference) && (Objects.equals(factIdentifierToCheck, factIdentifierReference) && Objects.equals(factMappingReference.getFactAlias(), factMappingToCheck.getFactAlias()))) || (Objects.equals(factIdentifierToCheck, factIdentifierReference));
if (toUpdate) {
switch(metadataType) {
case INSTANCE:
((ScenarioGridColumn) columns.get(index)).getInformationHeaderMetaData().setTitle(value);
factMappingToCheck.setFactAlias(value);
break;
case PROPERTY:
if (Objects.equals(factMappingToCheck.getFullExpression(), factMappingReference.getFullExpression())) {
((ScenarioGridColumn) columns.get(index)).getPropertyHeaderMetaData().setTitle(value);
factMappingToCheck.setExpressionAlias(value);
}
break;
default:
break;
}
}
}
use of org.drools.scenariosimulation.api.model.FactMapping in project drools-wb by kiegroup.
the class AbstractScesimGridModel method deleteCell.
@Override
public Range deleteCell(int rowIndex, int columnIndex) {
FactMapping factMapping = abstractScesimModel.getScesimModelDescriptor().getFactMappingByIndex(columnIndex);
abstractScesimModel.getDataByIndex(rowIndex).removeFactMappingValueByIdentifiers(factMapping.getFactIdentifier(), factMapping.getExpressionIdentifier());
return super.deleteCell(rowIndex, columnIndex);
}
use of org.drools.scenariosimulation.api.model.FactMapping 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));
}
}
Aggregations