Package com.senseidb.util

Examples of com.senseidb.util.JsonTemplateProcessor.process()


    "    x *= $ten; " +
    "    return timeScore; " +
    "  END ";
    String templateMappings = "{\"templateMapping\": {    \"color\": \"'red'\",    \"ten\": 10, \"params\":\"srcid:1234, timeVal:9999, _half_time:8888, coolTag:'zzz'\"  }}";
    JsonTemplateProcessor jsonTemplateProcessor = new JsonTemplateProcessor();
    String modifiedJson = (String) jsonTemplateProcessor.process(bqlStmt, jsonTemplateProcessor.getTemplates(new JSONObject(templateMappings)));
    JSONObject json = _compiler.compile(modifiedJson);
    JSONObject expected = new JSONObject("{\"query\":{\"query_string\":{\"query\":\"\",\"relevance\":{\"model\":{\"function_params\":[\"srcid\",\"timeVal\",\"_half_time\",\"coolTag\",\"tags\"],\"facets\":{\"mstring\":[\"tags\"]},\"variables\":{\"int\":[\"srcid\"],\"string\":[\"coolTag\"],\"long\":[\"timeVal\",\"_half_time\"]},\"function\":\"int myInt = 0;     float delta = System.currentTimeMillis() - timeVal;     float t = delta > 0 ? delta : 0;     float numHours = t / (1000 * 3600);     float timeScore = (float) Math.exp(-(numHours/_half_time));     if (tags.contains(coolTag))       return 999999;     int x = 0;     x += 5;     x *= 10;     return timeScore;\"},\"values\":{\"_half_time\":8888,\"timeVal\":9999,\"coolTag\":\"zzz\",\"srcid\":1234}}}},\"selections\":[{\"term\":{\"color\":{\"value\":\"red\"}}}],\"meta\":{\"select_list\":[\"color\",\"year\"]}}");
    assertTrue(_comp.isEquals(json, expected));
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.