use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class SerialNumberType method getParametersAsJson.
@Override
public JsonValue getParametersAsJson() {
JsonValue object = createObject();
if (!Strings.isNullOrEmpty(prefixFormula)) {
object.put("prefixFormula", prefixFormula);
}
object.put("digits", digits);
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class GeoAreaType method parseJsonValue.
@Override
public FieldValue parseJsonValue(JsonValue value) {
JsonValue object = value;
JsonValue bbox = object.get("bbox");
return new GeoArea(Extents.fromJsonObject(bbox));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class RootResource method update.
@POST
@Path("/update")
@Consumes(MediaType.APPLICATION_JSON)
public Response update(String json) {
final JsonValue jsonElement = Json.parse(json);
Updater updater = backend.newUpdater();
try {
updater.execute(jsonElement);
} catch (InvalidUpdateException e) {
throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(e.getMessage()).build());
}
return Response.ok().build();
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class FormConverterTest method deserializationEnumTypeNoChoices.
@Test
public void deserializationEnumTypeNoChoices() {
EnumType type = new EnumType(Cardinality.SINGLE, EnumType.Presentation.AUTOMATIC, Collections.<EnumItem>emptyList());
JsonValue jsonObject = type.getParametersAsJson();
EmbeddedEntity entity = FormConverter.toEmbeddedEntity(jsonObject);
JsonValue fromEntity = FormConverter.fromEmbeddedEntity(entity);
EnumType reType = EnumType.TYPE_CLASS.deserializeType(fromEntity);
assertThat(reType.getCardinality(), equalTo(Cardinality.SINGLE));
assertThat(reType.getPresentation(), equalTo(EnumType.Presentation.AUTOMATIC));
assertThat(reType.getValues(), hasSize(0));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class ExportAuditLog method toJson.
@Override
public JsonValue toJson() {
JsonValue object = createObject();
object.put("databaseId", databaseId);
return object;
}
Aggregations