use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class Resource method toJson.
@Override
public JsonValue toJson() {
JsonValue object = Json.createObject();
object.put("id", id.asString());
object.put("parentId", parentId.asString());
object.put("label", label);
object.put("type", type.name());
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class UserPermissionModel method toJson.
@Override
public JsonValue toJson() {
JsonValue grantsArray = Json.createArray();
for (GrantModel grant : grants) {
grantsArray.add(grant.toJson());
}
JsonValue object = Json.createObject();
object.put("userId", userId);
object.put("databaseId", databaseId);
object.put("grants", grantsArray);
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class EnumTypeTest method deserializationCheckboxes.
@Test
public void deserializationCheckboxes() {
JsonValue object = createObject();
object.put("presentation", "CHECKBOX");
object.put("cardinality", "SINGLE");
object.put("values", Json.createArray());
EnumType enumType = EnumType.TYPE_CLASS.deserializeType(object);
assertThat(enumType.getPresentation(), equalTo(EnumType.Presentation.RADIO_BUTTON));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class FormClassTest method serializationWithMissingLabel.
@Test
public void serializationWithMissingLabel() {
FormClass formClass = new FormClass(ResourceId.generateId());
formClass.setLabel("Form");
FormField field = new FormField(ResourceId.generateId());
field.setType(TextType.SIMPLE);
formClass.addElement(field);
JsonValue jsonObject = formClass.toJson();
FormClass reform = FormClass.fromJson(jsonObject);
assertThat(reform.getFields(), hasSize(1));
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class FormTreeTest method toJson.
@Test
public void toJson() {
FormTreeBuilder builder = new FormTreeBuilder(forms);
FormTree formTree = builder.queryTree(forms.student.getId());
checkStudentTree(formTree);
JsonValue object = JsonFormTreeBuilder.toJson(formTree);
System.out.println(JsonUtil.stringify(object, 2));
FormTree reTree = JsonFormTreeBuilder.fromJson(object);
checkStudentTree(reTree);
}
Aggregations