private CompletionStage<Ui> toUiSpec(final ConfigTypeNode detail, final ConfigTypeNode family, final UiSpecContext context) { return configurationService .filterNestedConfigurations(family.getName(), detail, context) .thenCompose(newDetail -> uiSpecService .convert(family.getName(), context.getLanguage(), newDetail, context)); }
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); }
.getAllConfigurations(context.getLanguage(), context.getPlaceholderProvider()) .thenApply(nodes -> configurationService.getFamilyOf(detail.getId(), nodes)) .thenCompose(familyNode -> filterProperties(familyNode.getName(), detail.getProperties(), context) .thenCompose(props -> replaceReferences(context, props,
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> 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)); }
.getMetadata() .getOrDefault("configurationtype::name", "") .equals(parentFormSpec.getName()) && it .getMetadata()
private CompletionStage<UiNode> findUiSpec(final String id, final UiSpecContext context) { if (id.isEmpty()) { return CompletableFuture .completedFuture(datastoreNode) .thenApply(node -> modelEnricherService.enrich(node, context.getLanguage())) .thenCompose(detail -> toUiNode(context, detail, null, noFamily)); } final CompletionStage<ComponentIndices> allComponents = componentClient.getAllComponents(context.getLanguage(), context.getPlaceholderProvider()); return configurationClient .getAllConfigurations(context.getLanguage(), context.getPlaceholderProvider()) .thenApply(nodes -> configurationService.getFamilyOf(id, nodes)) .thenCompose(familyNode -> getEnrichedNode(id, context, familyNode.getName()) .thenCompose(detail -> allComponents .thenCompose(components -> toUiNode(context, detail, components, familyNode)))); }
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)); }
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())); }
configurationService .getFamilyOf(child.getId(), nodes) .getName(), context, child, entityId, parent))); default: // add a dropdown to select the dataset
@Override public CompletionStage<Map<String, String>> resolveConfiguration(final RequestContext context, final String id) { final UiSpecContext uiSpecContext = new UiSpecContext(context.language(), context::findPlaceholder); return onFindByIdEvent .fireAsync(new OnFindById(context, id)) .thenCompose(byId -> byId .getFormId() .thenCompose(formId -> configurationClient .getAllConfigurations(context.language(), context::findPlaceholder) .thenApply(nodes -> configurationService.getFamilyOf(formId, nodes)) .thenCompose(family -> configurationClient .getDetails(context.language(), formId, context::findPlaceholder) .thenCompose(detail -> configurationService .filterNestedConfigurations(family.getName(), detail, uiSpecContext))) .thenCompose(detail -> byId .getProperties() .thenCompose(props -> configurationService .replaceReferences(uiSpecContext, detail, props))))); }