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();
}
Aggregations