Search in sources :

Example 46 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class LocalDateInterval method toJson.

@Override
public JsonValue toJson() {
    JsonValue object = createObject();
    object.put("start", startDate.toString());
    object.put("end", endDate.toString());
    return object;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 47 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class GeoPoint method toJson.

@Override
public JsonValue toJson() {
    JsonValue object = createObject();
    object.put("latitude", latitude);
    object.put("longitude", longitude);
    return object;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 48 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class GeoPointType method parseJsonValue.

@Override
public FieldValue parseJsonValue(JsonValue value) {
    JsonValue object = (JsonValue) value;
    GeoPoint point = new GeoPoint(object.get("latitude").asNumber(), object.get("longitude").asNumber());
    return point;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 49 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class QuantityType method getParametersAsJson.

@Override
public JsonValue getParametersAsJson() {
    JsonValue object = createObject();
    object.put("units", Strings.nullToEmpty(units));
    object.put("aggregation", aggregation.toString());
    return object;
}
Also used : JsonValue(org.activityinfo.json.JsonValue)

Example 50 with JsonValue

use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.

the class ContentSecurityServlet method doPost.

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String requestJson = CharStreams.toString(new InputStreamReader(req.getInputStream(), Charsets.UTF_8));
    JsonValue request = parse(requestJson);
    JsonValue report = request.get("csp-report");
    StringBuilder message = new StringBuilder();
    if (authProvider.isAuthenticated()) {
        message.append("User: ").append(authProvider.get().getEmail());
    } else {
        message.append("User: ").append("Not authenticated.");
    }
    message.append("Content-Security Violation\n");
    for (Map.Entry<String, JsonValue> entry : report.entrySet()) {
        message.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
    }
    LOGGER.severe(message.toString());
}
Also used : InputStreamReader(java.io.InputStreamReader) JsonValue(org.activityinfo.json.JsonValue) Map(java.util.Map)

Aggregations

JsonValue (org.activityinfo.json.JsonValue)117 Test (org.junit.Test)24 ResourceId (org.activityinfo.model.resource.ResourceId)19 FormClass (org.activityinfo.model.form.FormClass)13 FormField (org.activityinfo.model.form.FormField)9 FieldValue (org.activityinfo.model.type.FieldValue)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 QuantityType (org.activityinfo.model.type.number.QuantityType)5 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Annotation (java.lang.annotation.Annotation)3 ArrayList (java.util.ArrayList)3 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)3 JaxRsJsonReader (org.activityinfo.server.endpoint.rest.JaxRsJsonReader)3 TypedRecordUpdate (org.activityinfo.store.spi.TypedRecordUpdate)3 EmbeddedEntity (com.google.appengine.api.datastore.EmbeddedEntity)2 URL (java.net.URL)2 JsonException (org.activityinfo.json.JsonException)2 JsonMappingException (org.activityinfo.json.JsonMappingException)2