Search in sources :

Example 1 with FormDescriptor

use of edu.stanford.bmir.protege.web.shared.form.FormDescriptor in project webprotege by protegeproject.

the class FormDescriptorDeserializer method deserialize.

@Override
public FormDescriptor deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
    if (!jsonElement.isJsonObject()) {
        throw createParseException(jsonElement, "Object");
    }
    JsonObject object = jsonElement.getAsJsonObject();
    String id = object.getAsJsonPrimitive("id").getAsString();
    JsonArray fieldsArray = object.getAsJsonArray("fields");
    List<FormElementDescriptor> formElementDescriptors = new ArrayList<>();
    for (JsonElement fieldElement : fieldsArray) {
        FormElementDescriptor elementDescriptor = jsonDeserializationContext.deserialize(fieldElement, FormElementDescriptor.class);
        formElementDescriptors.add(elementDescriptor);
    }
    return new FormDescriptor(new FormId(id), formElementDescriptors);
}
Also used : FormDescriptor(edu.stanford.bmir.protege.web.shared.form.FormDescriptor) ArrayList(java.util.ArrayList) FormElementDescriptor(edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor) FormId(edu.stanford.bmir.protege.web.shared.form.FormId)

Aggregations

FormDescriptor (edu.stanford.bmir.protege.web.shared.form.FormDescriptor)1 FormId (edu.stanford.bmir.protege.web.shared.form.FormId)1 FormElementDescriptor (edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor)1 ArrayList (java.util.ArrayList)1