use of org.kie.workbench.common.forms.dynamic.service.shared.impl.MapModelRenderingContext in project kie-wb-common by kiegroup.
the class BackendFormRenderingContextManagerImpl method registerContext.
@Override
public BackendFormRenderingContext registerContext(FormDefinition rootForm, Map<String, Object> formData, ClassLoader classLoader, Map<String, String> params, FormDefinition... nestedForms) {
MapModelRenderingContext clientRenderingContext = new MapModelRenderingContext(String.valueOf(System.currentTimeMillis()));
clientRenderingContext.setRootForm(rootForm);
Arrays.stream(nestedForms).forEach(form -> clientRenderingContext.getAvailableForms().put(form.getId(), form));
BackendFormRenderingContextImpl context = new BackendFormRenderingContextImpl(System.currentTimeMillis(), clientRenderingContext, formData, classLoader, params);
Map<String, Object> clientFormData = new HashMap<>();
rootForm.getFields().stream().filter(fieldDefinition -> !StringUtils.isEmpty(fieldDefinition.getBinding())).forEach(fieldDefinition -> {
Object value = formData.get(fieldDefinition.getBinding());
FieldValueMarshaller marshaller = registry.getMarshaller(fieldDefinition);
if (marshaller != null) {
marshaller.init(value, fieldDefinition, rootForm, context);
context.getRootFormMarshallers().put(fieldDefinition.getBinding(), marshaller);
value = marshaller.toFlatValue();
}
clientFormData.put(fieldDefinition.getBinding(), value);
});
constraintsExtractor.readModelConstraints(clientRenderingContext, classLoader);
clientRenderingContext.setModel(clientFormData);
contexts.put(context.getTimestamp(), context);
return context;
}
use of org.kie.workbench.common.forms.dynamic.service.shared.impl.MapModelRenderingContext in project kie-wb-common by kiegroup.
the class MapModelBindingHelperTest method init.
@Before
public void init() {
helper = new MapModelBindingHelper() {
@Override
protected void lookupPropertyGenerators() {
// avoiding errai CDI lookup
}
};
helper.initialize();
context = new MapModelRenderingContext("");
context.setRootForm(employeeForm);
context.getAvailableForms().put(addressForm.getId(), addressForm);
}
use of org.kie.workbench.common.forms.dynamic.service.shared.impl.MapModelRenderingContext in project kie-wb-common by kiegroup.
the class PreviewFormPresenter method preview.
public void preview(FormRenderingContext context) {
MapModelRenderingContext mapContext = new MapModelRenderingContext("edit");
mapContext.getAvailableForms().putAll(context.getAvailableForms());
mapContext.setRootForm(context.getRootForm());
mapContext.setModel(new HashMap<>());
view.preview(mapContext);
}
Aggregations