use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormValuesProcessorImpl method readFormValues.
@Override
public Map<String, Object> readFormValues(FormDefinition form, Map<String, Object> rawValues, BackendFormRenderingContext context) {
final Map<String, Object> result = new HashMap<>();
rawValues.forEach((String key, final Object value) -> {
FieldDefinition field = form.getFieldByBinding(key);
Object fieldValue = value;
if (field != null) {
if (value != null) {
FieldValueProcessor processor = fieldValueProcessors.get(field.getClass());
if (processor != null) {
fieldValue = processor.toFlatValue(field, value, context);
}
}
result.put(key, fieldValue);
}
});
return result;
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormValuesProcessorImpl method writeFormValues.
@Override
public Map<String, Object> writeFormValues(FormDefinition form, Map<String, Object> formValues, Map<String, Object> rawValues, BackendFormRenderingContext context) {
final Map<String, Object> result = new HashMap<>();
formValues.forEach((key, value) -> {
FieldDefinition field = form.getFieldByBinding(key);
if (field != null) {
if (value != null) {
FieldValueProcessor processor = fieldValueProcessors.get(field.getClass());
if (processor != null) {
value = processor.toRawValue(field, value, rawValues.get(key), context);
}
}
}
result.put(key, value);
});
return result;
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class MultipleSubformBackendFormRenderingContextManagerTest method getNestedForms.
@Override
protected FormDefinition[] getNestedForms() {
JavaFormModel model = new PortableJavaModel(Person.class.getName());
FormDefinition creationForm = new FormDefinition(model);
creationForm.setId("person-creation");
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Long.class.getName()));
field.setName("id");
field.setBinding("id");
creationForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("name");
field.setBinding("name");
creationForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("lastName");
field.setBinding("lastName");
creationForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
field.setName("birthday");
field.setBinding("birthday");
creationForm.getFields().add(field);
FormDefinition editionForm = new FormDefinition(model);
editionForm.setId("person-edition");
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Long.class.getName()));
field.setName("id");
field.setBinding("id");
editionForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("name");
field.setBinding("name");
editionForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("lastName");
field.setBinding("lastName");
editionForm.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
field.setName("birthday");
field.setBinding("birthday");
editionForm.getFields().add(field);
return new FormDefinition[] { creationForm, editionForm };
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class NestedFormBackendFormRenderingContextManagerTest method getNestedForms.
@Override
protected FormDefinition[] getNestedForms() {
FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
form.setId(Person.class.getName());
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("name");
field.setBinding("name");
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
field.setName("lastName");
field.setBinding("lastName");
form.getFields().add(field);
field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
field.setName("birthday");
field.setBinding("birthday");
form.getFields().add(field);
return new FormDefinition[] { form };
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class NestedFormBackendFormRenderingContextManagerTest method getRootForm.
@Override
protected FormDefinition getRootForm() {
FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), false));
field.setName("person");
field.setBinding("person");
SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
subForm.setNestedForm(Person.class.getName());
form.getFields().add(field);
return form;
}
Aggregations