Fixed Issue 66: Records not excluded with inverted text facet.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@1064 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
a682d6b36f
commit
217fb7b25c
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -312,7 +312,7 @@ ListFacet.prototype._update = function(resetScroll) {
|
||||
}
|
||||
|
||||
html.push('<a href="javascript:{}" class="facet-choice-label">' + encodeHtml(label) + '</a>');
|
||||
html.push('<span class="facet-choice-count">' + count + '</span>');
|
||||
html.push('<span class="facet-choice-count">' + (invert ? "-" : "") + count + '</span>');
|
||||
|
||||
html.push('</div>');
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user