Search in sources :

Example 1 with DataResultSnapshot

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();
}
Also used : DataResultSnapshot(org.apache.apex.malhar.lib.appdata.schemas.DataResultSnapshot) JSONObject(org.codehaus.jettison.json.JSONObject) GPOMutable(org.apache.apex.malhar.lib.appdata.gpo.GPOMutable) JSONArray(org.codehaus.jettison.json.JSONArray)

Aggregations

GPOMutable (org.apache.apex.malhar.lib.appdata.gpo.GPOMutable)1 DataResultSnapshot (org.apache.apex.malhar.lib.appdata.schemas.DataResultSnapshot)1 JSONArray (org.codehaus.jettison.json.JSONArray)1 JSONObject (org.codehaus.jettison.json.JSONObject)1