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:
parent
5ec73daabe
commit
0c70d281c7
@ -8,6 +8,8 @@ Fixes:
|
|||||||
- Issue 41: "Envelope quotation marks are removed by CSV importer"
|
- Issue 41: "Envelope quotation marks are removed by CSV importer"
|
||||||
- Issue 19: "CSV import is too basic"
|
- Issue 19: "CSV import is too basic"
|
||||||
- Issue 15: "Ability to rename projects"
|
- 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:
|
Changes:
|
||||||
- Moved unit tests from JUnit to TestNG
|
- Moved unit tests from JUnit to TestNG
|
||||||
|
@ -17,6 +17,7 @@ import com.metaweb.gridworks.protograph.CellValueNode;
|
|||||||
import com.metaweb.gridworks.protograph.FreebaseProperty;
|
import com.metaweb.gridworks.protograph.FreebaseProperty;
|
||||||
import com.metaweb.gridworks.protograph.FreebaseTopicNode;
|
import com.metaweb.gridworks.protograph.FreebaseTopicNode;
|
||||||
import com.metaweb.gridworks.protograph.ValueNode;
|
import com.metaweb.gridworks.protograph.ValueNode;
|
||||||
|
import com.metaweb.gridworks.util.JSONUtilities;
|
||||||
|
|
||||||
public class MqlreadLikeTransposedNodeFactory implements TransposedNodeFactory {
|
public class MqlreadLikeTransposedNodeFactory implements TransposedNodeFactory {
|
||||||
protected List<JSONObject> rootObjects = new LinkedList<JSONObject>();
|
protected List<JSONObject> rootObjects = new LinkedList<JSONObject>();
|
||||||
@ -126,7 +127,8 @@ public class MqlreadLikeTransposedNodeFactory implements TransposedNodeFactory {
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
obj = new JSONObject();
|
obj = new JSONObject();
|
||||||
try {
|
try {
|
||||||
obj.put(VALUE, cell.value.toString());
|
JSONUtilities.putField(obj, VALUE, cell.value);
|
||||||
|
|
||||||
obj.put(TYPE, node.valueType);
|
obj.put(TYPE, node.valueType);
|
||||||
if ("/type/text".equals(node.valueType)) {
|
if ("/type/text".equals(node.valueType)) {
|
||||||
obj.put(LANG, node.lang);
|
obj.put(LANG, node.lang);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.metaweb.gridworks.util;
|
package com.metaweb.gridworks.util;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -108,4 +109,24 @@ public class JSONUtilities {
|
|||||||
}
|
}
|
||||||
writer.endArray();
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user