private boolean matchAction(final Map.Entry<String, String> v, final ActionReference a) { return actionMatch(v.getValue(), a) && v.getKey().substring("action::".length()).equals(a.getType()); }
private Stream<UiSchema.Trigger> createValidationTrigger(final SimplePropertyDefinition property) { return ofNullable(property.getMetadata().get("action::validation")) .flatMap(v -> actions .stream() .filter(a -> actionMatch(v, a) && "validation".equals(a.getType())) .findFirst()) .map(ref -> Stream.of(toTrigger(properties, property, ref))) .orElseGet(Stream::empty); }
private Stream<UiSchema.Trigger> createSuggestionTriggers(final SimplePropertyDefinition property) { return ofNullable(property.getMetadata().get("action::suggestions")) .flatMap(v -> actions .stream() .filter(a -> actionMatch(v, a) && "suggestions".equals(a.getType())) .findFirst()) .map(ref -> Stream .of(toTrigger(properties, property, ref)) .peek(trigger -> trigger.setOnEvent("focus"))) .orElseGet(Stream::empty); }
protected UiSchema.Trigger toTrigger(final Collection<SimplePropertyDefinition> properties, final SimplePropertyDefinition prop, final ActionReference ref) { final UiSchema.Trigger trigger = new UiSchema.Trigger(); trigger .setAction(prop .getMetadata() .entrySet() .stream() .filter(it -> matchAction(it, ref)) .findFirst() .map(Map.Entry::getValue) .orElseGet(ref::getName)); trigger.setFamily(ref.getFamily()); trigger.setType(ref.getType()); trigger .setParameters(toParams(properties, prop, ref, prop.getMetadata().get("action::" + ref.getType() + "::parameters"))); return trigger; }
&& properties.stream().noneMatch(p -> p.getPath().equals(propertiesPrefix))) { throw new IllegalArgumentException("No resolved parameters for " + prop.getPath() + " in " + ref.getFamily() + "/" + ref.getType() + "/" + ref.getName());
private Optional<UiSchema> addUpdate(final PropertyContext<?> root) { final SimplePropertyDefinition property = root.getProperty(); return ofNullable(property.getMetadata().get("action::update")) .flatMap(v -> (actions == null ? Stream.<ActionReference> empty() : actions.stream()) .filter(a -> a.getName().equals(v) && "update".equals(a.getType())) .findFirst()) .map(action -> { final UiSchema.Trigger trigger = toTrigger(properties, root.getProperty(), action); final String path = property.getPath(); trigger .setOptions(singletonList(new UiSchema.Option.Builder() .withPath(path.endsWith("[]") ? path.substring(0, path.length() - "[]".length()) : path) .withType(property.getType().toLowerCase(ROOT)) .build())); final UiSchema button = new UiSchema(); button .setTitle(action.getDisplayName() == null ? action.getName() + " (" + action.getType() + ')' : action.getDisplayName()); button.setWidget("button"); button.setTriggers(singletonList(trigger)); return button; }); }
private Collection<ActionReference> findActions(final String family, final Set<ActionReference> actions, final Container container, final Locale locale, final FamilyBundle familyBundle) { final ContainerComponentRegistry registry = container.get(ContainerComponentRegistry.class); return registry .getServices() .stream() .flatMap(s -> s.getActions().stream()) .filter(s -> s.getFamily().equals(family)) .filter(s -> actions .stream() .anyMatch(e -> s.getFamily().equals(e.getFamily()) && s.getType().equals(e.getType()) && s.getAction().equals(e.getName()))) .map(s -> new ActionReference(s.getFamily(), s.getAction(), s.getType(), familyBundle.actionDisplayName(s.getType(), s.getAction()).orElse(s.getAction()), propertiesService .buildProperties(s.getParameters(), container.getLoader(), locale, null) .collect(toList()))) .collect(toList()); }
actions .stream() .filter(a -> a.getName().equals(schemaActionName) && "schema".equals(a.getType())) .findFirst() .ifPresent(ref -> {
private void addHealthCheck(final PropertyContext<?> root, final Collection<UiSchema> items) { ofNullable(root.getProperty().getMetadata().get("action::healthcheck")) .flatMap(v -> (actions == null ? Stream.<ActionReference> empty() : actions.stream()) .filter(a -> a.getName().equals(v) && "healthcheck".equals(a.getType())) .findFirst()) .ifPresent(ref -> {