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()))); }
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); }
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()))); }
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())); }
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)); }