use of org.kie.workbench.common.forms.dynamic.service.context.generation.dynamic.FieldValueProcessor 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.dynamic.service.context.generation.dynamic.FieldValueProcessor 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.dynamic.service.context.generation.dynamic.FieldValueProcessor in project kie-wb-common by kiegroup.
the class AbstractBackendFormRenderingContextManagerTest method initTest.
@Before
public void initTest() {
List<FieldValueProcessor> processors = Arrays.asList(new SubFormFieldValueProcessor(), new MultipleSubFormFieldValueProcessor());
fieldValueProcessors = mock(Instance.class);
when(fieldValueProcessors.iterator()).then(proc -> processors.iterator());
formValuesProcessor = new FormValuesProcessorImpl(fieldValueProcessors);
contextManager = new BackendFormRenderingContextManagerImpl(formValuesProcessor, new ContextModelConstraintsExtractorImpl());
formData = generateFormData();
classLoader = mock(ClassLoader.class);
long timestamp = contextManager.registerContext(getRootForm(), formData, classLoader, getNestedForms()).getTimestamp();
context = contextManager.getContext(timestamp);
assertNotNull("Context cannot be null", context);
}
Aggregations