public List<ConfigTypeNode> findChildren(final String formId, final ConfigTypeNodes nodes) { return nodes .getNodes() .values() .stream() .filter(node -> node.getParentId() != null && node.getParentId().equals(formId)) .sorted(comparing(ConfigTypeNode::getDisplayName).thenComparing(ConfigTypeNode::getName)) .collect(toList()); } }
})) .collect(() -> { final ConfigTypeNodes nodes = new ConfigTypeNodes(); nodes.setNodes(new HashMap<>()); return nodes; }, (root, children) -> root.getNodes().putAll(children.collect(toMap(ConfigTypeNode::getId, identity()))), (first, second) -> first.getNodes().putAll(second.getNodes()));
public CompletionStage<Collection<SimplePropertyDefinition>> getConfigurationSpec(final String id) { return client .path("configurationtype/details") .queryParam("identifiers", id) .queryParam("language", "en") .request(APPLICATION_JSON_TYPE) .rx() .get(ConfigTypeNodes.class) .thenApply(list -> list.getNodes().values().iterator().next().getProperties()); }
public ConfigTypeNode getFamilyOf(final String id, final ConfigTypeNodes nodes) { ConfigTypeNode family = nodes.getNodes().get(id); while (family != null && family.getParentId() != null) { family = nodes.getNodes().get(family.getParentId()); } if (family == null) { throw new WebApplicationException(Response .status(INTERNAL_SERVER_ERROR) .entity(new ProxyErrorPayload(NO_FAMILY_FOR_CONFIGURATION.name(), "No family found for this configuration identified by id:" + id)) .header(ErrorProcessor.Constants.HEADER_TALEND_COMPONENT_SERVER_ERROR, false) .build()); } return family; // require ot null/web app ex }
public CompletionStage<ConfigTypeNode> getDetails(final String language, final String id, final Function<String, String> placeholderProvider) { return getAllConfigurations(language, placeholderProvider).thenApply(configNodes -> { final ConfigTypeNode node = configNodes.getNodes().get(id); if (node == null) { throw new WebApplicationException(Response .status(Response.Status.BAD_REQUEST) .entity(new ProxyErrorPayload(ProxyErrorDictionary.CONFIGURATION_NOT_FOUND.name(), "Configuration not found")) .build()); } return node; }); } }
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()))); }
final String name = it.getMetadata().getOrDefault("configurationtype::name", "default"); return nodes .getNodes() .values() .stream()
final List<ConfigTypeNode> childrenSpec = configurationService.findChildren(form.getFormId(), nodes); final ConfigTypeNode parentSpec = nodes.getNodes().get(form.getFormId()); switch (childrenSpec.size()) { case 0: default: // add a dropdown to select the dataset return createChildrenChooserForm(context, childrenSpec, nodes.getNodes().get(form.getFormId()), entityId, selectedId, nodes);