Fixed bug in list facet: list facets on columns with numeric data weren't working before.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@169 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-03-02 23:07:33 +00:00
parent b488d093c8
commit 59c5314e42
3 changed files with 17 additions and 7 deletions

View File

@ -47,15 +47,18 @@ public class ExpressionNominalRowGrouper implements RowVisitor {
if (ExpressionUtils.isError(value)) {
errorCount++;
} else if (ExpressionUtils.isNonBlankData(value)) {
DecoratedValue dValue = new DecoratedValue(value, value.toString());
String valueString = value.toString();
String label = value.toString();
DecoratedValue dValue = new DecoratedValue(value, label);
if (choices.containsKey(value)) {
choices.get(value).count++;
if (choices.containsKey(valueString)) {
choices.get(valueString).count++;
} else {
NominalFacetChoice choice = new NominalFacetChoice(dValue);
choice.count = 1;
choices.put(value, choice);
choices.put(valueString, choice);
}
} else {
blankCount++;

View File

@ -116,8 +116,9 @@ public class ListFacet implements Facet {
_choices.addAll(grouper.choices.values());
for (NominalFacetChoice choice : _selection) {
if (grouper.choices.containsKey(choice.decoratedValue.value)) {
grouper.choices.get(choice.decoratedValue.value).selected = true;
String valueString = choice.decoratedValue.value.toString();
if (grouper.choices.containsKey(valueString)) {
grouper.choices.get(valueString).selected = true;
} else {
choice.count = 0;
_choices.add(choice);

View File

@ -47,7 +47,7 @@ public class ExpressionEqualRowFilter implements RowFilter {
return _selectError;
} else if (ExpressionUtils.isNonBlankData(v)) {
for (Object match : _matches) {
if (match.equals(v)) {
if (testValue(v, match)) {
return true;
}
}
@ -56,4 +56,10 @@ public class ExpressionEqualRowFilter implements RowFilter {
return _selectBlank;
}
}
protected boolean testValue(Object v, Object match) {
return (v instanceof Number && match instanceof Number) ?
((Number) match).doubleValue() == ((Number) v).doubleValue() :
match.equals(v);
}
}