Commit d9f59c29 authored by Danilo Trombino's avatar Danilo Trombino
Browse files

Fix on Associative Logic (Map Widget) +

Fix on Location Field parsing (Non NGSI REST Ds)
parent e94b5916
......@@ -126,9 +126,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
var formattedSelection = {};
var datasetSelection = selections[widgetDataset.label];
for(var s in datasetSelection){
var columnObject = scope.getColumnObjectFromName(scope.ngModel.content.columnSelectedOfDataset,s);
var columnObject = $scope.getColumnObjectFromName($scope.ngModel.content.columnSelectedOfDataset,s);
if (!columnObject){
columnObject = scope.getColumnObjectFromName(widgetDataset.metadata.fieldsMeta,s);
columnObject = $scope.getColumnObjectFromName(widgetDataset.metadata.fieldsMeta,s);
}
formattedSelection[columnObject.aliasToShow || columnObject.alias] = {"values":[], "type": columnObject.fieldType};
......
......@@ -27,8 +27,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.apache.log4j.Logger;
......@@ -36,6 +38,9 @@ import org.joda.time.Instant;
import org.json.JSONArray;
import org.json.JSONException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
......@@ -289,6 +294,31 @@ public class JSONPathDataReader extends AbstractDataReader {
} else {
parsedData = Arrays.asList(parsed);
}
//If a column contains an Object then cast to a JSON string
for(Object r : parsedData) {
LinkedHashMap<Object, Object> record = (LinkedHashMap<Object, Object>)r;
Set<Object> columnNames = record.keySet();
for(Object column : columnNames) {
Object obj = record.get(column);
if(obj instanceof Map) {
ObjectMapper mapper = new ObjectMapper();
try {
obj = mapper.writeValueAsString((LinkedHashMap)obj);
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
System.out.println("Impossible to parse in JSON");
e.printStackTrace();
}
//obj = new Gson().toJson(obj,LinkedHashMap.class);
record.put(column, obj);
}
}
}
return parsedData;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment