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); }
ofNullable(validation.getMin()).ifPresent(m -> jsonSchema.setMinimum(m.doubleValue())); ofNullable(validation.getMax()).ifPresent(m -> jsonSchema.setMaximum(m.doubleValue())); ofNullable(validation.getMinItems()).ifPresent(jsonSchema::setMinItems); ofNullable(validation.getMaxItems()).ifPresent(jsonSchema::setMaxItems); ofNullable(validation.getMinLength()).ifPresent(jsonSchema::setMinLength); ofNullable(validation.getMaxLength()).ifPresent(jsonSchema::setMaxLength); ofNullable(validation.getUniqueItems()).ifPresent(jsonSchema::setUniqueItems); ofNullable(validation.getPattern()).ifPresent(jsonSchema::setPattern);
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)); } }
if (isEnum) { if (validation == null) { validation = new PropertyValidation(); validation.setEnumValues(p.getProposals());
@Override public CompletionStage<PropertyContext<?>> convert(final CompletionStage<PropertyContext<?>> cs) { return cs.thenApply(context -> { jsonSchema.setType("string"); if (context.getProperty().getValidation() == null || context.getProperty().getValidation().getEnumValues() == null) { jsonSchema.setEnumValues(emptyList()); } else { jsonSchema.setEnumValues(context.getProperty().getValidation().getEnumValues()); } return context; }); } }
new PropertyValidation(true, null, null, null, null, null, null, null, null, emptySet()), enrichedMetadata, null, new LinkedHashMap<>()); }) .orElseGet(() -> completedFuture(new LinkedHashMap<>())) .thenApply(potentialIdsAndNames -> { it.getValidation().setEnumValues(potentialIdsAndNames.keySet()); it.setProposalDisplayNames(potentialIdsAndNames); return null;
protected CompletionStage<PropertyContext<?>> fillProposalsAndReturn(final PropertyContext<?> context, final UiSchema schema, final JsonSchema jsonSchema) { if (context.getProperty().getValidation() != null && context.getProperty().getValidation().getEnumValues() != null) { schema .setTitleMap(context.getProperty().getProposalDisplayNames() != null return nameValue; }).collect(toList()) : context.getProperty().getValidation().getEnumValues().stream().sorted().map(v -> { final UiSchema.NameValue nameValue = new UiSchema.NameValue(); nameValue.setName(v); return nameValue; }).collect(toList())); jsonSchema.setEnumValues(context.getProperty().getValidation().getEnumValues()); } else { final String actionName = context.getProperty().getMetadata().get("action::dynamic_values");
}).collect(toList()); propertyValidationCreator = config -> { final PropertyValidation validation = new PropertyValidation(); if (validationSetters.stream().filter(s -> s.apply(validation, config)).count() == 0) { return null;