public MapBindableProxy( final Map<String, PropertyType> propertyTypes ) { agent = new BindableProxyAgent<>(this, new HashMap<>()); agent.propertyTypes.putAll(propertyTypes); agent .propertyTypes .entrySet() .stream() .filter(entry -> entry.getValue() instanceof MapPropertyType) .forEach(entry -> agent.binders.put(entry.getKey(), DataBinder.forMap(((MapPropertyType) entry.getValue()).getPropertyTypes()))); }
public MapPropertyType getModeldefinitionFor(SubFormFieldDefinition subFormField, MapModelRenderingContext context, Map<String, Map<String, PropertyType>> availableModels) { FormDefinition subForm = context.getAvailableForms().get(subFormField.getNestedForm()); return new MapPropertyType(generateModelDefinition(subForm, context, availableModels)); }
public MapBindableProxy( final Map<String, PropertyType> propertyTypes ) { agent = new BindableProxyAgent<>(this, new HashMap<>()); agent.propertyTypes.putAll(propertyTypes); agent .propertyTypes .entrySet() .stream() .filter(entry -> entry.getValue() instanceof MapPropertyType) .forEach(entry -> agent.binders.put(entry.getKey(), DataBinder.forMap(((MapPropertyType) entry.getValue()).getPropertyTypes()))); }
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); } }
@Override public MapBindableProxy getProxyDefinition() { return (MapBindableProxy) DataBinder.forMap(dynamicDefinition.getPropertyTypes()).getModel(); }
private static PropertyType getPropertyType(final BindableProxy<?> proxy, final String property) { final BindableProxyAgent<?> agent = proxy.getBindableProxyAgent(); if (property.contains(".")) { final int firstDot = property.indexOf("."); final String topLevelProperty = property.substring(0, firstDot); final String childProperty = property.substring(firstDot+1); final PropertyType topLevelType = getPropertyType(proxy, topLevelProperty); final BindableProxy<?> topLevelProxy; if (topLevelType instanceof MapPropertyType) { topLevelProxy = (BindableProxy<?>) DataBinder.forMap(((MapPropertyType) topLevelType).getPropertyTypes()).getModel(); } else { topLevelProxy = BindableProxyFactory.getBindableProxy(topLevelType.getType().getName()); } return getPropertyType(topLevelProxy, childProperty); } else if (agent.propertyTypes.containsKey(property)) { return agent.propertyTypes.get(property); } else { final String type = proxy.getClass().getSuperclass().getSimpleName(); throw new NonExistingPropertyException(type, property); } }
private static PropertyType getPropertyType(final BindableProxy<?> proxy, final String property) { final BindableProxyAgent<?> agent = proxy.getBindableProxyAgent(); if (property.contains(".")) { final int firstDot = property.indexOf("."); final String topLevelProperty = property.substring(0, firstDot); final String childProperty = property.substring(firstDot+1); final PropertyType topLevelType = getPropertyType(proxy, topLevelProperty); final BindableProxy<?> topLevelProxy; if (topLevelType instanceof MapPropertyType) { topLevelProxy = (BindableProxy<?>) DataBinder.forMap(((MapPropertyType) topLevelType).getPropertyTypes()).getModel(); } else { topLevelProxy = BindableProxyFactory.getBindableProxy(topLevelType.getType().getName()); } return getPropertyType(topLevelProxy, childProperty); } else if (agent.propertyTypes.containsKey(property)) { return agent.propertyTypes.get(property); } else { final String type = proxy.getClass().getSuperclass().getSimpleName(); throw new NonExistingPropertyException(type, property); } }
@Override public MapBindableProxy getProxyForModel(Map<String, Object> model) { Map<String, Object> content = DataBinder.forMap(dynamicDefinition.getPropertyTypes()).getModel(); helper.prepareMapContent(content, context.getAvailableForms().get(field.getCreationForm()), model, context); return (MapBindableProxy) content; }
if (nestedBinder == null) { if (propertyType instanceof MapPropertyType) { nestedBinder = DataBinder.forMap(((MapPropertyType) propertyType).getPropertyTypes()); final MapBindableProxy mapProxy = new MapBindableProxy(((MapPropertyType) propertyType).getPropertyTypes()); mapProxy.agent.target = (Map<String, Object>) value; nestedBinder.setModel(mapProxy, StateSync.FROM_MODEL, true);
if (nestedBinder == null) { if (propertyType instanceof MapPropertyType) { nestedBinder = DataBinder.forMap(((MapPropertyType) propertyType).getPropertyTypes()); final MapBindableProxy mapProxy = new MapBindableProxy(((MapPropertyType) propertyType).getPropertyTypes()); mapProxy.agent.target = (Map<String, Object>) value; nestedBinder.setModel(mapProxy, StateSync.FROM_MODEL, true);