private CompletionStage<LinkedHashMap<String, String>> findPotentialIdsAndNames(final ConfigTypeNode node, final UiSpecContext context) { return referenceService .findReferencesByTypeAndName(node.getConfigurationType(), node.getId(), context) .thenApply(values -> ofNullable(values.getItems()) .map(items -> items .stream() .collect(toMap(Values.Item::getId, Values.Item::getLabel, (a, b) -> { throw new IllegalArgumentException("Conflict is not possible here"); }, LinkedHashMap::new))) .orElseGet(LinkedHashMap::new)); }
public Nodes getRootConfiguration(final ConfigTypeNodes configs, final Function<String, String> iconProvider) { final Map<String, ConfigTypeNode> families = ofNullable(configs) .map(c -> c.getNodes().values().stream()) .orElseGet(Stream::empty) .filter(node -> node.getParentId() == null) .collect(toMap(ConfigTypeNode::getId, identity())); return new Nodes(configs .getNodes() .values() .stream() .flatMap(node -> node .getEdges() .stream() .map(edgeId -> configs.getNodes().get(edgeId)) .filter(config -> config.getParentId() != null && families.containsKey(config.getParentId()))) .map(root -> { final ConfigTypeNode family = families.get(root.getParentId()); return new Node(root.getId(), root.getDisplayName(), family.getId(), family.getDisplayName(), iconProvider.apply(family.getId()), root.getEdges(), root.getVersion(), root.getName()); }) .collect(toMap(Node::getId, identity()))); }
private CompletionStage<UiNode> toUiNode(final UiSpecContext context, final ConfigTypeNode detail, final ComponentIndices iconComponents, final ConfigTypeNode family) { return toUiSpec(detail, family, context) .thenApply(ui -> new UiNode(ui, new Node(detail.getId(), detail.getDisplayName(), family.getId(), family.getDisplayName(), ofNullable(family.getId()) .map(id -> configurationService.findIcon(id, iconComponents)) .orElse(null), detail.getEdges(), detail.getVersion(), detail.getName()))); }
private CompletionStage<NewForm> toNewForm(final String family, final UiSpecContext context, final ConfigTypeNode node, final String refId, final ConfigTypeNode parentFormSpec) { return self .getNewForm(context, node.getId()) .thenCompose(newForm -> handleReferences(family, context, node, refId, parentFormSpec, newForm)); }
@Override public int compareTo(final ComparableConfigTypeNode o) { if (o == null) { return -1; } if (o == this || delegate == o.getDelegate()) { return 0; } if (isNested(this, o)) { return -1; } if (isNested(o, this)) { return 1; } // just to sort globally final int myPropCount = delegate.getProperties().size(); final int otherPropCount = o.getDelegate().getProperties().size(); if (myPropCount == otherPropCount) { return delegate.getId().compareTo(o.getDelegate().getId()); } return myPropCount - otherPropCount; }
.removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family);
public ConfigTypeNode enrich(final ConfigTypeNode node, final String lang) { return doEnrich(node.getConfigurationType(), lang, patch -> { final ConfigTypeNode copy = new ConfigTypeNode(node.getId(), node.getVersion(), node.getParentId(), node.getConfigurationType(), node.getName(), node.getDisplayName(), node.getEdges(), new ArrayList<>(), new ArrayList<>(node.getActions())); patch.doPatchProperties(copy.getProperties(), node.getProperties()); patch.appendBuiltInActions(copy.getActions()); return copy; }).orElse(node); }
.thenCompose(detail -> configurations .getAllConfigurations(context.getLanguage(), context.getPlaceholderProvider()) .thenApply(nodes -> configurationService.getFamilyOf(detail.getId(), nodes)) .thenCompose(familyNode -> filterProperties(familyNode.getName(), detail.getProperties(), context)
private CompletionStage<UiNode> toUiNode(final String language, final ConfigTypeNode node, final ConfigTypeNodes nodes, final ComponentIndices componentIndices, final boolean noFamily, final Function<String, String> placeholderProvider) { final ConfigTypeNode family = noFamily ? defaultFamily : configurationService.getFamilyOf(node.getParentId(), nodes); final String icon = noFamily ? null : configurationService.findIcon(family.getId(), componentIndices); final Node configType = new Node(node.getId(), node.getDisplayName(), family.getId(), family.getDisplayName(), icon, node.getEdges(), node.getVersion(), node.getName()); return uiSpecService .convert(family.getName(), language, modelEnricherService.enrich(node, language), new UiSpecContext(language, placeholderProvider)) .thenApply(uiSpec -> new UiNode(uiSpec, configType)); }
private CompletionStage<NewForm> createChildrenChooserForm(final UiSpecContext context, final List<ConfigTypeNode> childrenSpec, final ConfigTypeNode parentSpec, final String parentEntityId, final String selectedId, final ConfigTypeNodes nodes) { final ConfigTypeNode refChild = childrenSpec .stream() .filter(it -> it.getId().equals(selectedId)) .findFirst() .orElseGet(() -> childrenSpec.iterator().next()); final ConfigTypeNode family = configurationService.getFamilyOf(refChild.getId(), nodes); final ConfigTypeNode formModel = modelEnricherService.enrich(refChild, context.getLanguage()); formModel .getProperties() .add(createChildrenChooserProperty(childrenSpec, parentEntityId, context.getLanguage(), selectedId, modelEnricherService.findPropertyPrefixForEnrichingProperty(refChild.getConfigurationType()))); return componentClient .getAllComponents(context.getLanguage(), context.getPlaceholderProvider()) .thenCompose(components -> uiSpecService .convert(family.getName(), context.getLanguage(), formModel, context) .thenApply(ui -> new UiNode(ui, new Node(selectedId, refChild.getDisplayName(), family.getId(), family.getDisplayName(), ofNullable(family.getId()) .map(id -> configurationService.findIcon(id, components)) .orElse(null), emptyList(), null, refChild.getName())))) .thenApply(this::toNewFormResponse) .thenCompose( newForm -> handleReferences(configurationService.getFamilyOf(refChild.getId(), nodes).getName(), context, refChild, parentEntityId, parentSpec, newForm)); }
.stream() .filter(node -> configurationService .getFamilyOf(node.getId(), nodes) .getName() .equals(family) && type.equals(node.getConfigurationType())
case 1: return configurationClient .getDetails(context.getLanguage(), parentSpec.getId(), context.getPlaceholderProvider()) .thenCompose( parent -> configurationClient .getDetails(context.getLanguage(), childrenSpec.iterator().next().getId(), context.getPlaceholderProvider()) .thenCompose( child -> toNewForm( configurationService .getFamilyOf(child.getId(), nodes) .getName(), context, child, entityId, parent)));
.collect(toJsonObject()); return onPersistEvent .fireAsync(new OnPersist(requestContext, jsonb, node.getId(), enrichment, node.getProperties(), configurationFormatter.flatten(configuration)), notificationOptions)
public CompletionStage<ConfigTypeNode> filterNestedConfigurations(final String family, final ConfigTypeNode node, final UiSpecContext context) { return propertiesService .filterProperties(family, node.getProperties(), context) .thenApply(props -> new ConfigTypeNode(node.getId(), node.getVersion(), node.getParentId(), node.getConfigurationType(), node.getName(), node.getDisplayName(), node.getEdges(), props, node.getActions())); }