@Override protected FormDefinition getRootForm() { FormDefinition form = new FormDefinition(); FieldDefinition field = fieldManager.getDefinitionByValueType(new DefaultFieldTypeInfo(String.class.getName())); field.setName("string"); field.setBinding("string"); form.getFields().add(field); field = fieldManager.getDefinitionByValueType(new DefaultFieldTypeInfo(Integer.class.getName())); field.setName("integer"); field.setBinding("integer"); form.getFields().add(field); field = fieldManager.getDefinitionByValueType(new DefaultFieldTypeInfo(Date.class.getName())); field.setName("date"); field.setBinding("date"); form.getFields().add(field); field = fieldManager.getDefinitionByValueType(new DefaultFieldTypeInfo(Boolean.class.getName())); field.setName("boolean"); field.setBinding("boolean"); form.getFields().add(field); return form; }
protected void initializeContextForms(T settings, MapModelRenderingContext renderingContext) { JsonParser parser = new JsonParser(); Gson gson = new Gson(); JsonElement element = parser.parse(settings.getFormContent()); JsonArray forms = element.getAsJsonArray(); forms.forEach( jsonForm -> { String content = gson.toJson(jsonForm); if (!StringUtils.isEmpty(content)) { FormDefinition formDefinition = formSerializer.deserialize(content); if (formDefinition != null) { if (formDefinition.getName().startsWith(getFormName(settings) + "-taskform")) { renderingContext.setRootForm(formDefinition); } else { renderingContext.getAvailableForms().put(formDefinition.getId(), formDefinition); } } } }); }
@Override public void setRootForm(FormDefinition rootForm) { this.rootFormId = rootForm.getId(); availableForms.put(rootFormId, rootForm); }