use of org.drools.scenariosimulation.api.model.FactMappingType in project drools by kiegroup.
the class AbstractRunnerHelper method groupByFactIdentifierAndFilter.
protected Map<FactIdentifier, List<FactMappingValue>> groupByFactIdentifierAndFilter(List<FactMappingValue> factMappingValues, FactMappingType type) {
Map<FactIdentifier, List<FactMappingValue>> groupByFactIdentifier = new HashMap<>();
for (FactMappingValue factMappingValue : factMappingValues) {
FactIdentifier factIdentifier = factMappingValue.getFactIdentifier();
if (isFactMappingValueToSkip(factMappingValue)) {
continue;
}
ExpressionIdentifier expressionIdentifier = factMappingValue.getExpressionIdentifier();
if (expressionIdentifier == null) {
throw new IllegalArgumentException("ExpressionIdentifier malformed");
}
if (!Objects.equals(expressionIdentifier.getType(), type)) {
continue;
}
groupByFactIdentifier.computeIfAbsent(factIdentifier, key -> new ArrayList<>()).add(factMappingValue);
}
return groupByFactIdentifier;
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class ScenarioGridTest method getScenarioGridColumnLocal.
@Test
public void getScenarioGridColumnLocal() {
String columnId = factMappingDescription.getExpressionIdentifier().getName();
String instanceTitle = factMappingDescription.getFactIdentifier().getName();
String propertyTitle = "PROPERTY TITLE";
final FactMappingType type = factMappingDescription.getExpressionIdentifier().getType();
String columnGroup = type.name();
scenarioGridSpy.getScenarioGridColumnLocal(instanceTitle, propertyTitle, columnId, columnGroup, type, ScenarioSimulationEditorConstants.INSTANCE.insertValue());
verify(scenarioGridSpy, times(1)).getHeaderBuilderLocal(eq(instanceTitle), eq(propertyTitle), eq(columnId), eq(columnGroup), eq(type));
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class ScenarioGridTest method setup.
@Before
public void setup() {
simulation = getSimulation();
when(scenarioGridColumnMock.getPropertyHeaderMetaData()).thenReturn(propertyHeaderMetadataMock);
when(scenarioGridModelMock.getAbstractScesimModel()).thenReturn(Optional.of(simulation));
when(scenarioGridModelMock.getGridWidget()).thenReturn(GridWidget.SIMULATION);
when(scenarioGridModelMock.getScenarioExpressionCellTextAreaSingletonDOMElementFactory()).thenReturn(expressionCellTextAreaSingletonDOMElementFactoryMock);
when(scenarioGridModelMock.getCollectionEditorSingletonDOMElementFactory()).thenReturn(collectionEditorSingletonDOMElementFactory);
factIdentifierGiven = FactIdentifier.create("GIVEN", "GIVEN");
factIdentifierInteger = FactIdentifier.create("Integer", "java.lang.Integer");
factMappingDescription = new FactMapping(EXPRESSION_ALIAS_DESCRIPTION, FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION);
factMappingGiven = new FactMapping(EXPRESSION_ALIAS_GIVEN, factIdentifierGiven, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
factMappingInteger = new FactMapping(EXPRESSION_ALIAS_INTEGER, factIdentifierInteger, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
scenarioGridSpy = spy(new ScenarioGrid(scenarioGridModelMock, scenarioGridLayerMock, scenarioGridRendererMock, scenarioContextMenuRegistryMock) {
@Override
protected <T extends AbstractScesimData> void appendRow(int rowIndex, T scesimData) {
// do nothing
}
@Override
protected ScenarioSimulationBuilders.HeaderBuilder getHeaderBuilderLocal(String instanceTitle, String propertyTitle, String columnId, String columnGroup, FactMappingType factMappingType) {
return headerBuilderMock;
}
@Override
protected ScenarioGridColumn getScenarioGridColumnLocal(ScenarioSimulationBuilders.HeaderBuilder headerBuilder, String placeHolder) {
return scenarioGridColumnMock;
}
@Override
protected BaseGridRendererHelper getBaseGridRendererHelper() {
return rendererHelperMock;
}
@Override
public Viewport getViewport() {
return viewportMock;
}
@Override
protected ScenarioHeaderMetaData getColumnScenarioHeaderMetaData(final ScenarioGridColumn scenarioGridColumn, final int rowIndex) {
return propertyHeaderMetadataMock;
}
@Override
protected EnableTestToolsEvent getEnableTestToolsEvent(final ScenarioGrid scenarioGrid, final ScenarioGridColumn scenarioGridColumn, final ScenarioHeaderMetaData scenarioHeaderMetaData, int uiColumnIndex, String group) {
return new EnableTestToolsEvent();
}
@Override
public Layer getLayer() {
return scenarioGridLayerMock;
}
});
when(rendererHelperMock.getRenderingInformation()).thenReturn(renderingInformationMock);
when(renderingInformationMock.getHeaderRowsHeight()).thenReturn(HEADER_ROWS_HEIGHT);
when(renderingInformationMock.getFloatingBlockInformation()).thenReturn(floatingBlockInformationMock);
when(propertyHeaderMetadataMock.getColumnGroup()).thenReturn(GRID_COLUMN_GROUP);
scenarioGridSpy.setEventBus(eventBusMock);
}
use of org.drools.scenariosimulation.api.model.FactMappingType in project drools-wb by kiegroup.
the class DeleteColumnCommand method createColumnIfEmptyGroup.
/**
* Creates a new column in the group if there is none.
*
* @param context
* @param status
* @param newColumnPosition
*/
protected void createColumnIfEmptyGroup(ScenarioSimulationContext context, ScenarioSimulationContext.Status status, int newColumnPosition) {
if (context.getAbstractScesimGridModelByGridWidget(gridWidget).getGroupSize(status.getColumnGroup()) < 1) {
FactMappingType factMappingType = FactMappingType.valueOf(status.getColumnGroup().toUpperCase());
Map.Entry<String, String> validPlaceholders = context.getAbstractScesimGridModelByGridWidget(gridWidget).getValidPlaceholders();
String instanceTitle = validPlaceholders.getKey();
String propertyTitle = validPlaceholders.getValue();
context.getAbstractScesimGridModelByGridWidget(gridWidget).insertColumn(newColumnPosition, getScenarioGridColumnLocal(instanceTitle, propertyTitle, String.valueOf(new Date().getTime()), status.getColumnGroup(), factMappingType, context.getScenarioHeaderTextBoxSingletonDOMElementFactory(gridWidget), context.getScenarioCellTextAreaSingletonDOMElementFactory(gridWidget), ScenarioSimulationEditorConstants.INSTANCE.defineValidType()));
}
}
Aggregations