Fixed bug in text search facet where if the query is null or empty string it'd filter to nothing.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@141 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
7152c4aae2
commit
1e4b9f4e80
@ -41,15 +41,26 @@ public class TextSearchFacet implements Facet {
|
|||||||
_name = o.getString("name");
|
_name = o.getString("name");
|
||||||
_columnName = o.getString("columnName");
|
_columnName = o.getString("columnName");
|
||||||
_cellIndex = project.columnModel.getColumnByName(_columnName).getCellIndex();
|
_cellIndex = project.columnModel.getColumnByName(_columnName).getCellIndex();
|
||||||
|
|
||||||
|
if (!o.isNull("query")) {
|
||||||
_query = o.getString("query");
|
_query = o.getString("query");
|
||||||
|
}
|
||||||
|
|
||||||
_mode = o.getString("mode");
|
_mode = o.getString("mode");
|
||||||
_caseSensitive = o.getBoolean("caseSensitive");
|
_caseSensitive = o.getBoolean("caseSensitive");
|
||||||
|
if (_query != null) {
|
||||||
|
_query = _query.trim();
|
||||||
if (!_caseSensitive) {
|
if (!_caseSensitive) {
|
||||||
_query = _query.toLowerCase();
|
_query = _query.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RowFilter getRowFilter() {
|
public RowFilter getRowFilter() {
|
||||||
|
if (_query == null || _query.length() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Evaluable eval = new VariableExpr("value");
|
Evaluable eval = new VariableExpr("value");
|
||||||
|
|
||||||
if ("regex".equals(_mode)) {
|
if ("regex".equals(_mode)) {
|
||||||
@ -61,7 +72,7 @@ public class TextSearchFacet implements Facet {
|
|||||||
} else {
|
} else {
|
||||||
return new ExpressionStringComparisonRowFilter(eval, _cellIndex) {
|
return new ExpressionStringComparisonRowFilter(eval, _cellIndex) {
|
||||||
protected boolean checkValue(String s) {
|
protected boolean checkValue(String s) {
|
||||||
return s.toLowerCase().contains(_query);
|
return (_caseSensitive ? s : s.toLowerCase()).contains(_query);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user