Search in sources :

Example 1 with FormElementDescriptor

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

the class FormPresenter method createFormAndSetFormData.

/**
 * Creates the form from scratch and fills in the specified form data.
 *
 * @param formDescriptor The descriptor that describes the form.
 * @param formData       The form data to be filled into the form.
 */
private void createFormAndSetFormData(@Nonnull FormDescriptor formDescriptor, @Nonnull FormData formData) {
    formView.clear();
    for (FormElementDescriptor elementDescriptor : formDescriptor.getElements()) {
        Optional<FormDataValue> dataValue = formData.getFormElementData(elementDescriptor.getId());
        createFormEditor(elementDescriptor, dataValue);
    }
}
Also used : FormDataValue(edu.stanford.bmir.protege.web.shared.form.data.FormDataValue) FormElementDescriptor(edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor)

Example 2 with FormElementDescriptor

use of edu.stanford.bmir.protege.web.shared.form.field.FormElementDescriptor 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

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