private SimplePropertyDefinition createChildrenChooserProperty(final List<ConfigTypeNode> childrenTypes, final String parentEntityId, final String locale, final String selectedItem, final String propertyPrefix) { final Map<String, String> metadata = new HashMap<>(); metadata .put("action::reloadFromParentEntityIdAndType", "builtin::root::reloadFromParentEntityIdAndType(" + "parentId=" + parentEntityId + ",type=" + childrenTypes.iterator().next().getConfigurationType() + ")"); metadata.put("action::reloadFromParentEntityIdAndType::parameters", ".."); final String simpleName = "childrenType"; final String path = ofNullable(propertyPrefix).filter(it -> !it.isEmpty()).map(p -> p + '.').orElse("") + simpleName; final LinkedHashMap<String, String> values = createConfigTypesValues(childrenTypes); return new SimplePropertyDefinition(path, simpleName, i18n.actionServiceChildrenTypePropertyDisplayName(new Locale(ofNullable(locale).orElse(""))), "enum", selectedItem, new PropertyValidation(true, null, null, null, null, null, null, null, null, values.keySet()), metadata, null, values); }
}).collect(toList()); propertyValidationCreator = config -> { final PropertyValidation validation = new PropertyValidation(); if (validationSetters.stream().filter(s -> s.apply(validation, config)).count() == 0) { return null;
if (isEnum) { if (validation == null) { validation = new PropertyValidation();
new PropertyValidation(true, null, null, null, null, null, null, null, null, emptySet()), enrichedMetadata, null, new LinkedHashMap<>()); })
private void normalize(final SimplePropertyDefinition prop) { if (prop.getProposalDisplayNames() != null) { if (prop.getValidation() == null) { prop.setValidation(new PropertyValidation()); } if (prop.getValidation().getEnumValues() == null) { prop.getValidation().setEnumValues(prop.getProposalDisplayNames().keySet()); } } else if (prop.getValidation() != null && prop.getValidation().getEnumValues() != null && prop.getProposalDisplayNames() == null) { prop .setProposalDisplayNames(prop .getValidation() .getEnumValues() .stream() .collect(toMap(identity(), identity(), (a, b) -> { throw new IllegalArgumentException("Conflict is not possible here"); }, LinkedHashMap::new))); } if (prop.getMetadata() == null) { prop.setMetadata(emptyMap()); } if (prop.getName() == null) { prop.setName(prop.getPath().substring(prop.getPath().lastIndexOf('.') + 1)); } }