Issue 28: mql-like preview is not properly unquoting numbers.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@807 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-05-17 23:47:09 +00:00
parent 5ec73daabe
commit 0c70d281c7
3 changed files with 26 additions and 1 deletions

View File

@ -8,6 +8,8 @@ Fixes:
- Issue 41: "Envelope quotation marks are removed by CSV importer"
- Issue 19: "CSV import is too basic"
- Issue 15: "Ability to rename projects"
- Issue 16: "Column name collision when adding data from Freebase"
- Issue 28: "mql-like preview is not properly unquoting numbers"
Changes:
- Moved unit tests from JUnit to TestNG

View File

@ -17,6 +17,7 @@ import com.metaweb.gridworks.protograph.CellValueNode;
import com.metaweb.gridworks.protograph.FreebaseProperty;
import com.metaweb.gridworks.protograph.FreebaseTopicNode;
import com.metaweb.gridworks.protograph.ValueNode;
import com.metaweb.gridworks.util.JSONUtilities;
public class MqlreadLikeTransposedNodeFactory implements TransposedNodeFactory {
protected List<JSONObject> rootObjects = new LinkedList<JSONObject>();
@ -126,7 +127,8 @@ public class MqlreadLikeTransposedNodeFactory implements TransposedNodeFactory {
if (obj == null) {
obj = new JSONObject();
try {
obj.put(VALUE, cell.value.toString());
JSONUtilities.putField(obj, VALUE, cell.value);
obj.put(TYPE, node.valueType);
if ("/type/text".equals(node.valueType)) {
obj.put(LANG, node.lang);

View File

@ -1,5 +1,6 @@
package com.metaweb.gridworks.util;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -108,4 +109,24 @@ public class JSONUtilities {
}
writer.endArray();
}
static public void putField(JSONObject obj, String key, Object value) throws JSONException {
if (value instanceof Integer) {
obj.put(key, ((Integer) value).intValue());
} else if (value instanceof Long) {
obj.put(key, ((Long) value).intValue());
} else if (value instanceof Number) {
obj.put(key, ((Double) value).doubleValue());
} else if (value instanceof Boolean) {
obj.put(key, (Boolean) value);
} else if (value instanceof Date) {
obj.put(key, ParsingUtilities.dateToString((Date) value));
} else if (value instanceof Calendar) {
obj.put(key, ParsingUtilities.dateToString(((Calendar) value).getTime()));
} else if (value instanceof String) {
obj.put(key, (String) value);
} else {
obj.put(key, value.toString());
}
}
}