use of org.apache.apex.malhar.lib.appdata.schemas.DataResultSnapshot in project apex-malhar by apache.
the class DataResultSnapshotSerializer method serializeHelper.
private String serializeHelper(Message result, ResultFormatter resultFormatter) throws Exception {
DataResultSnapshot gResult = (DataResultSnapshot) result;
JSONObject jo = new JSONObject();
jo.put(Result.FIELD_ID, gResult.getId());
jo.put(Result.FIELD_TYPE, gResult.getType());
JSONArray ja = new JSONArray();
for (GPOMutable value : gResult.getValues()) {
JSONObject dataValue = GPOUtils.serializeJSONObject(value, ((DataQuerySnapshot) gResult.getQuery()).getFields(), resultFormatter);
ja.put(dataValue);
}
jo.put(DataResultSnapshot.FIELD_DATA, ja);
if (!gResult.isOneTime()) {
jo.put(Result.FIELD_COUNTDOWN, gResult.getCountdown());
}
return jo.toString();
}
Aggregations