Search in sources :

Example 1 with FormField

use of com.liferay.apio.architect.form.FormField in project com-liferay-apio-architect by liferay.

the class FormWriter method write.

/**
 * Writes the {@link Form} to a string.
 *
 * @return the JSON representation of the {@code Form}
 */
public String write() {
    JSONObjectBuilder jsonObjectBuilder = new JSONObjectBuilder();
    _formMessageMapper.onStart(jsonObjectBuilder, _form, _requestInfo.getHttpHeaders());
    String url = createFormURL(_requestInfo.getServerURL(), _form);
    _formMessageMapper.mapFormURL(jsonObjectBuilder, url);
    String title = _form.getTitle(_requestInfo.getLanguage());
    _formMessageMapper.mapFormTitle(jsonObjectBuilder, title);
    String description = _form.getDescription(_requestInfo.getLanguage());
    _formMessageMapper.mapFormDescription(jsonObjectBuilder, description);
    List<FormField> formFields = _form.getFormFields();
    formFields.forEach(formField -> _formMessageMapper.mapFormField(jsonObjectBuilder, formField));
    _formMessageMapper.onFinish(jsonObjectBuilder, _form, _requestInfo.getHttpHeaders());
    JsonObject jsonObject = jsonObjectBuilder.build();
    return jsonObject.toString();
}
Also used : JSONObjectBuilder(com.liferay.apio.architect.message.json.JSONObjectBuilder) JsonObject(com.google.gson.JsonObject) FormField(com.liferay.apio.architect.form.FormField)

Aggregations

JsonObject (com.google.gson.JsonObject)1 FormField (com.liferay.apio.architect.form.FormField)1 JSONObjectBuilder (com.liferay.apio.architect.message.json.JSONObjectBuilder)1