use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class ActivityInfoClientAsyncImpl method getFormTree.
@Override
public Promise<FormTree> getFormTree(final ResourceId formId) {
return get(formUrl(formId) + "/tree", jsonElement -> {
JsonValue root = jsonElement;
JsonValue forms = root.get("forms");
final Map<ResourceId, FormClass> formMap = new HashMap<>();
for (Map.Entry<String, JsonValue> entry : forms.entrySet()) {
FormClass formClass = FormClass.fromJson(entry.getValue());
formMap.put(formClass.getId(), formClass);
}
FormTreeBuilder builder = new FormTreeBuilder(new FormClassProvider() {
@Override
public FormClass getFormClass(ResourceId formId1) {
FormClass formClass = formMap.get(formId1);
assert formClass != null;
return formClass;
}
});
return builder.queryTree(formId);
});
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class NewFormRecord method fromJson.
public static NewFormRecord fromJson(JsonValue jsonElement) {
JsonValue jsonObject = jsonElement;
NewFormRecord model = new NewFormRecord();
model.id = JsonParsing.toNullableString(jsonObject.get("id"));
model.parentRecordId = JsonParsing.toNullableString(jsonObject.get("parentRecordId"));
model.keyId = JsonParsing.toNullableString(jsonObject.get("keyId"));
model.fieldValues = jsonObject.get("fieldValues");
return model;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class ActivityInfoClient method getFormSchema.
public FormClass getFormSchema(ResourceId formId) {
String json = client.resource(root).path("resources").path("form").path(formId.asString()).path("schema").accept(MediaType.APPLICATION_JSON_TYPE).get(String.class);
JsonValue jsonObject = parse(json);
FormClass formClass = FormClass.fromJson(jsonObject);
return formClass;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class TableModel method toJson.
@Value.Lazy
@Override
public JsonValue toJson() {
JsonValue object = Json.createObject();
object.put("formId", getFormId().asString());
if (getColumns().size() != 0) {
JsonValue columnArray = Json.createArray();
for (TableColumn tableColumn : getColumns()) {
columnArray.add(tableColumn.toJson());
}
object.put("columns", columnArray);
}
return object;
}
use of org.activityinfo.json.JsonValue in project activityinfo by bedatadriven.
the class GrantModel method toJson.
@Override
public JsonValue toJson() {
JsonValue operationsArray = Json.createArray();
for (Operation operation : operations) {
operationsArray.add(Json.create(operation.name()));
}
JsonValue object = Json.createObject();
object.put("folderId", resourceId.asString());
object.put("operations", operationsArray);
return object;
}
Aggregations