ArrayList<RowAliasFilter> rowFilters = new ArrayList<RowAliasFilter>(
report.getRowAliasFilters());
// the row filters are sorted by the row aliases id
// so that the left most are first
boolean isRangeScan = true;
RangeFilters rangeFilters = new RangeFilters();
if (rowFilters != null) {
ArrayList<RowAliasFilter> lesserRowFilters = new ArrayList<RowAliasFilter>();
ArrayList<RowAliasFilter> greaterRowFilters = new ArrayList<RowAliasFilter>();
for (RowAliasFilter filter : rowFilters) {
String filterType = filter.getFilterType().getType();
if (filterType.equals("Equals")) {
lesserRowFilters.add(filter);
greaterRowFilters.add(filter);
} else if (filterType.equals("Greater Than Equals")) {
greaterRowFilters.add(filter);
} else if (filterType.equals("Less Than")) {
lesserRowFilters.add(filter);
} else {
logger.debug("Got filter type " + filterType + ", this is not a range scan");
isRangeScan = false;
}
}
if (isRangeScan) {
/*
* we have to see that a. all aliases are specified b. OR
* rightmost column specified in filters is range
*/
int lesserFiltersSize = lesserRowFilters.size();
if (lesserFiltersSize > 0) {
logger.debug("Checking if lesser filters are range scan");
isRangeScan = isRangeScan(lesserRowFilters, rowAliases, "Less Than");
if (isRangeScan) {
rangeFilters.setLesserRowFilters(lesserRowFilters);
}
}
// same for greater row
int greaterFilterSize = greaterRowFilters.size();
if (greaterFilterSize > 0) {
logger.debug("Checking if greater filters are range scan");
isRangeScan = isRangeScan(greaterRowFilters, rowAliases, "Greater Than Equals");
if (isRangeScan) {
rangeFilters.setGreaterRowFilters(greaterRowFilters);
}
}
}
}
return rangeFilters;