diff --git a/main/src/com/metaweb/gridworks/browsing/facets/ListFacet.java b/main/src/com/metaweb/gridworks/browsing/facets/ListFacet.java index e446e4e5a..03abdb9dd 100644 --- a/main/src/com/metaweb/gridworks/browsing/facets/ListFacet.java +++ b/main/src/com/metaweb/gridworks/browsing/facets/ListFacet.java @@ -14,6 +14,7 @@ import com.metaweb.gridworks.browsing.FilteredRecords; import com.metaweb.gridworks.browsing.FilteredRows; import com.metaweb.gridworks.browsing.RecordFilter; import com.metaweb.gridworks.browsing.RowFilter; +import com.metaweb.gridworks.browsing.filters.AllRowsRecordFilter; import com.metaweb.gridworks.browsing.filters.AnyRowRecordFilter; import com.metaweb.gridworks.browsing.filters.ExpressionEqualRowFilter; import com.metaweb.gridworks.browsing.util.ExpressionNominalValueGrouper; @@ -167,7 +168,10 @@ public class ListFacet implements Facet { @Override public RecordFilter getRecordFilter(Project project) { RowFilter rowFilter = getRowFilter(project); - return rowFilter == null ? null : new AnyRowRecordFilter(rowFilter); + return rowFilter == null ? null : + (_invert ? + new AllRowsRecordFilter(rowFilter) : + new AnyRowRecordFilter(rowFilter)); } @Override diff --git a/main/src/com/metaweb/gridworks/browsing/filters/AllRowsRecordFilter.java b/main/src/com/metaweb/gridworks/browsing/filters/AllRowsRecordFilter.java new file mode 100644 index 000000000..1ec72def9 --- /dev/null +++ b/main/src/com/metaweb/gridworks/browsing/filters/AllRowsRecordFilter.java @@ -0,0 +1,24 @@ +package com.metaweb.gridworks.browsing.filters; + +import com.metaweb.gridworks.browsing.RecordFilter; +import com.metaweb.gridworks.browsing.RowFilter; +import com.metaweb.gridworks.model.Project; +import com.metaweb.gridworks.model.Record; + +public class AllRowsRecordFilter implements RecordFilter { + final protected RowFilter _rowFilter; + + public AllRowsRecordFilter(RowFilter rowFilter) { + _rowFilter = rowFilter; + } + + @Override + public boolean filterRecord(Project project, Record record) { + for (int r = record.fromRowIndex; r < record.toRowIndex; r++) { + if (!_rowFilter.filterRow(project, r, project.rows.get(r))) { + return false; + } + } + return true; + } +} diff --git a/main/src/com/metaweb/gridworks/browsing/filters/ExpressionEqualRowFilter.java b/main/src/com/metaweb/gridworks/browsing/filters/ExpressionEqualRowFilter.java index 3f7c783a1..d23db40ad 100644 --- a/main/src/com/metaweb/gridworks/browsing/filters/ExpressionEqualRowFilter.java +++ b/main/src/com/metaweb/gridworks/browsing/filters/ExpressionEqualRowFilter.java @@ -47,7 +47,9 @@ public class ExpressionEqualRowFilter implements RowFilter { } public boolean filterRow(Project project, int rowIndex, Row row) { - return _invert != internalFilterRow(project, rowIndex, row); + return _invert ? + internalInvertedFilterRow(project, rowIndex, row) : + internalFilterRow(project, rowIndex, row); } public boolean internalFilterRow(Project project, int rowIndex, Row row) { @@ -79,6 +81,35 @@ public class ExpressionEqualRowFilter implements RowFilter { return testValue(value); } + public boolean internalInvertedFilterRow(Project project, int rowIndex, Row row) { + Cell cell = _cellIndex < 0 ? null : row.getCell(_cellIndex); + + Properties bindings = ExpressionUtils.createBindings(project); + ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell); + + Object value = _evaluable.evaluate(bindings); + if (value != null) { + if (value.getClass().isArray()) { + Object[] a = (Object[]) value; + for (Object v : a) { + if (testValue(v)) { + return false; + } + } + return true; + } else if (value instanceof Collection) { + for (Object v : ExpressionUtils.toObjectCollection(value)) { + if (testValue(v)) { + return false; + } + } + return true; + } // else, fall through + } + + return !testValue(value); + } + protected boolean testValue(Object v) { if (ExpressionUtils.isError(v)) { return _selectError; diff --git a/main/webapp/modules/core/scripts/facets/list-facet.js b/main/webapp/modules/core/scripts/facets/list-facet.js index 7e694968e..2b9eb6966 100644 --- a/main/webapp/modules/core/scripts/facets/list-facet.js +++ b/main/webapp/modules/core/scripts/facets/list-facet.js @@ -312,7 +312,7 @@ ListFacet.prototype._update = function(resetScroll) { } html.push('' + encodeHtml(label) + ''); - html.push('' + count + ''); + html.push('' + (invert ? "-" : "") + count + ''); html.push(''); };