use of org.jboss.errai.databinding.client.PropertyType in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method initContext.
public void initContext(MapModelRenderingContext context) {
FormDefinition form = context.getRootForm();
Map<String, PropertyType> modelProperties = generateModelDefinition(form, context);
Map<String, Object> content = DataBinder.forMap(modelProperties).getModel();
Map<String, Object> contextModel = context.getModel() != null ? context.getModel() : new HashMap<>();
prepareMapContent(content, form, contextModel, context);
context.setModel(content);
}
use of org.jboss.errai.databinding.client.PropertyType in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method generateModelDefinition.
protected Map<String, PropertyType> generateModelDefinition(FormDefinition form, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) {
if (availableModels.containsKey(form.getId())) {
return availableModels.get(form.getId());
}
Map<String, PropertyType> formTypes = new HashMap<>();
availableModels.put(form.getId(), formTypes);
form.getFields().forEach(field -> {
PropertyType propertyType = null;
if (basicProperties.containsKey(field.getStandaloneClassName())) {
propertyType = new PropertyType(basicProperties.get(field.getStandaloneClassName()));
} else if (propertiesGenerator.containsKey(field.getClass())) {
PropertyGenerator generator = propertiesGenerator.get(field.getClass());
propertyType = generator.generatePropertyType(field);
} else if (field instanceof SubFormFieldDefinition) {
propertyType = getModeldefinitionFor((SubFormFieldDefinition) field, context, availableModels);
} else if (field instanceof MultipleSubFormFieldDefinition) {
propertyType = new PropertyType(List.class);
}
if (propertyType != null) {
formTypes.put(field.getBinding(), propertyType);
}
});
return formTypes;
}
use of org.jboss.errai.databinding.client.PropertyType in project kie-wb-common by kiegroup.
the class MapModelBindingHelperTest method checkBindableProxy.
protected void checkBindableProxy(MapBindableProxy model) {
assertFalse(model.getBeanProperties().isEmpty());
checkSimpleTypeProperty(model.getBeanProperties().get(EMPLOYEE_NAME), String.class);
checkSimpleTypeProperty(model.getBeanProperties().get(EMPLOYEE_SURNAME), String.class);
checkSimpleTypeProperty(model.getBeanProperties().get(EMPLOYEE_AGE_BINDING), Integer.class);
checkSimpleTypeProperty(model.getBeanProperties().get(EMPLOYEE_BIRTHDAY), Date.class);
checkSimpleTypeProperty(model.getBeanProperties().get(EMPLOYEE_MARRIED), Boolean.class);
PropertyType addressPropertyType = model.getBeanProperties().get(EMPLOYEE_ADDRESS);
assertNotNull(addressPropertyType);
assertTrue(addressPropertyType instanceof MapPropertyType);
MapPropertyType address = (MapPropertyType) addressPropertyType;
checkSimpleTypeProperty(address.getPropertyTypes().get(ADDRESS_STREET), String.class);
checkSimpleTypeProperty(address.getPropertyTypes().get(ADDRESS_NUM), Integer.class);
}
use of org.jboss.errai.databinding.client.PropertyType in project kie-wb-common by kiegroup.
the class MapModelBindingHelper method getModeldefinitionFor.
public MapPropertyType getModeldefinitionFor(MultipleSubFormFieldDefinition subFormField, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) {
FormDefinition creationForms = context.getAvailableForms().get(subFormField.getCreationForm());
Map<String, PropertyType> modelDefinition = generateModelDefinition(creationForms, context, availableModels);
FormDefinition editionForm = context.getAvailableForms().get(subFormField.getCreationForm());
modelDefinition.putAll(generateModelDefinition(editionForm, context, availableModels));
modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_OBJECT_IDX, new PropertyType(Integer.class));
modelDefinition.put(MapModelRenderingContext.FORM_ENGINE_EDITED_OBJECT, new PropertyType(Boolean.class));
return new MapPropertyType(modelDefinition);
}
Aggregations