RuntimeKieServerDataSetProvider implements DataSetProvider { protected void appendIntervalSelection(DataSetGroup intervalSel, List<QueryParam> filterParams) { if (intervalSel != null && intervalSel.isSelect()) { ColumnGroup cg = intervalSel.getColumnGroup(); List<Interval> intervalList = intervalSel.getSelectedIntervalList(); List<Comparable> names = new ArrayList<Comparable>(); Comparable min = null; Comparable max = null; for (Interval interval : intervalList) { names.add(interval.getName()); Comparable intervalMin = (Comparable) interval.getMinValue(); Comparable intervalMax = (Comparable) interval.getMaxValue(); if (intervalMin != null) { if (min == null) { min = intervalMin; } else if (min.compareTo(intervalMin) > 0) { min = intervalMin; } } if (intervalMax != null) { if (max == null) { max = intervalMax; } else if (max.compareTo(intervalMax) > 0) { max = intervalMax; } } } if (min != null && max != null && min.compareTo(max) > 0) { min = max; } ColumnFilter filter; if (min != null && max != null) { filter = FilterFactory.between(cg.getSourceId(), min, max); } else if (min != null) { filter = FilterFactory.greaterOrEqualsTo(cg.getSourceId(), min); } else if (max != null) { filter = FilterFactory.lowerOrEqualsTo(cg.getSourceId(), max); } else { filter = FilterFactory.equalsTo(cg.getSourceId(), names); } CoreFunctionFilter coreFunctionFilter = (CoreFunctionFilter) filter; filterParams.add(new QueryParam(coreFunctionFilter.getColumnId(), coreFunctionFilter.getType().toString(), coreFunctionFilter.getParameters())); } }  @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 appendEqualToIntervalSelectionTest() { String filterValue = "testValue"; DataSetGroup dataSetGroup = new DataSetGroup(); dataSetGroup.setColumnGroup(new ColumnGroup(COLUMN_TEST, COLUMN_TEST, GroupStrategy.DYNAMIC)); List<Interval> intervalList = new ArrayList<Interval>(); Interval interval = new Interval(filterValue); intervalList.add(interval); dataSetGroup.setSelectedIntervalList(intervalList); List<QueryParam> filterParams = new ArrayList<>(); kieServerDataSetProvider.appendIntervalSelection(dataSetGroup, filterParams); assertEquals(1, filterParams.size()); assertEquals(COLUMN_TEST, filterParams.get(0).getColumn()); assertEquals("EQUALS_TO", filterParams.get(0).getOperator()); assertEquals(filterValue, filterParams.get(0).getValue().get(0)); }
@Test public void appendBetweenIntervalSelectionTest() { String filterValue = "testValue"; Long minValue = Long.valueOf(0); Long maxValue = Long.valueOf(2); DataSetGroup dataSetGroup = new DataSetGroup(); dataSetGroup.setColumnGroup(new ColumnGroup(COLUMN_TEST, COLUMN_TEST, GroupStrategy.DYNAMIC)); List<Interval> intervalList = new ArrayList<Interval>(); Interval interval = new Interval(filterValue); interval.setMinValue(minValue); interval.setMaxValue(maxValue); intervalList.add(interval); dataSetGroup.setSelectedIntervalList(intervalList); List<QueryParam> filterParams = new ArrayList<>(); kieServerDataSetProvider.appendIntervalSelection(dataSetGroup, filterParams); assertEquals(1, filterParams.size()); assertEquals(COLUMN_TEST, filterParams.get(0).getColumn()); assertEquals("BETWEEN", filterParams.get(0).getOperator()); assertEquals(Double.valueOf(minValue), filterParams.get(0).getValue().get(0)); assertEquals(Double.valueOf(maxValue), filterParams.get(0).getValue().get(1)); }