KieServerDataSetProvider extends AbstractKieServerService implements DataSetProvider { protected void handleDataSetGroup(final DataSetDef def, final DataSetGroup dataSetGroup, final List<QueryParam> filterParams, final List<DataColumn> extraColumns) { if (dataSetGroup != null) { if (dataSetGroup.getColumnGroup() != null) { if (dataSetGroup.getColumnGroup().getIntervalSize() != null) { filterParams.add(new QueryParam(dataSetGroup.getColumnGroup().getSourceId(), "group", Arrays.asList(dataSetGroup.getColumnGroup().getColumnId(), dataSetGroup.getColumnGroup().getIntervalSize(), dataSetGroup.getColumnGroup().getMaxIntervals()))); } else { filterParams.add(new QueryParam(dataSetGroup.getColumnGroup().getSourceId(), "group", Arrays.asList(dataSetGroup.getColumnGroup().getColumnId()))); } } for (GroupFunction groupFunction : dataSetGroup.getGroupFunctions()) { if (groupFunction.getFunction() != null) { filterParams.add(new QueryParam(groupFunction.getSourceId(), groupFunction.getFunction().toString(), Arrays.asList(groupFunction.getColumnId()))); extraColumns.add(new DataColumnImpl(groupFunction.getSourceId(), ColumnType.NUMBER)); } else { filterParams.add(new QueryParam(groupFunction.getSourceId(), null, Arrays.asList(groupFunction.getColumnId()))); extraColumns.add(new DataColumnImpl(groupFunction.getSourceId(), getGroupFunctionColumnType(def, dataSetGroup.getColumnGroup(), groupFunction))); } } } }  @Override DataSetProviderType getType(); @Override DataSetMetadata getDataSetMetadata(DataSetDef def); @Override DataSet lookupDataSet(DataSetDef def,
                                 DataSetLookup lookup); @Override boolean isDataSetOutdated(DataSetDef def); static final DataSetProviderType TYPE; }
@Test public void testGroupWithInterval() { DataSetGroup dataSetGroup = new DataSetGroup(); dataSetGroup.setColumnGroup(new ColumnGroup(COLUMN_TEST, COLUMN_TEST, GroupStrategy.DYNAMIC, 30, DateIntervalType.DAY.name())); List<QueryParam> filterParams = new ArrayList<>(); List<DataColumn> extraColumns = new ArrayList<>(); kieServerDataSetProvider.handleDataSetGroup(dataSetDef, dataSetGroup, filterParams, extraColumns); assertEquals(1, filterParams.size()); assertEquals(COLUMN_TEST, filterParams.get(0).getColumn()); assertEquals("group", filterParams.get(0).getOperator()); assertEquals(3, filterParams.get(0).getValue().size()); assertEquals(COLUMN_TEST, filterParams.get(0).getValue().get(0)); assertEquals(DateIntervalType.DAY.name(), filterParams.get(0).getValue().get(1)); assertEquals(30, filterParams.get(0).getValue().get(2)); }
@Test public void testGroupWithNotSetInterval() { DataSetGroup dataSetGroup = new DataSetGroup(); dataSetGroup.setColumnGroup(new ColumnGroup(COLUMN_TEST, COLUMN_TEST, GroupStrategy.DYNAMIC)); List<QueryParam> filterParams = new ArrayList<>(); List<DataColumn> extraColumns = new ArrayList<>(); kieServerDataSetProvider.handleDataSetGroup(dataSetDef, dataSetGroup, filterParams, extraColumns); assertEquals(1, filterParams.size()); assertEquals(COLUMN_TEST, filterParams.get(0).getColumn()); assertEquals("group", filterParams.get(0).getOperator()); assertEquals(1, filterParams.get(0).getValue().size()); assertEquals(COLUMN_TEST, filterParams.get(0).getValue().get(0)); }