@Test void gridLayout() throws Exception { final Ui payload = service.convert(load("rest-api.json"), "en", null).toCompletableFuture().get(); final UiSchema tableDataSet = payload.getUiSchema().iterator().next(); assertEquals(2, tableDataSet.getItems().size()); final Iterator<UiSchema> tableDataSetIt = tableDataSet.getItems().iterator(); final UiSchema tableDataSetMain = tableDataSetIt.next(); assertEquals("Main", tableDataSetMain.getTitle()); assertEquals(5, tableDataSetMain.getItems().size()); assertEquals(asList("dataStore", "commonConfig", "Query", "Ordered", "Order"), tableDataSetMain.getItems().stream().map(UiSchema::getTitle).collect(toList())); final Iterator<UiSchema> mainIt = tableDataSetMain.getItems().iterator(); final UiSchema dataStore = mainIt.next(); Iterator<UiSchema> dataStoreIt = dataStore.getItems().iterator(); dataStoreIt.next(); final UiSchema credentials = dataStoreIt.next(); assertEquals("columns", credentials.getWidget()); assertEquals(asList("Username", "Password"), credentials.getItems().stream().map(UiSchema::getTitle).collect(toList())); final UiSchema tableDataSetAdvanced = tableDataSetIt.next(); assertEquals("Advanced", tableDataSetAdvanced.getTitle()); }
public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .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); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .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); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .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); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .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); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); UiSpecService<T> withConverter(final CustomPropertyConverter converter); CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node,
            final T context); CompletionStage<Ui> convert(final ComponentDetail detail, final String lang, final T context); @Override void close(); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .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); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); UiSpecService<T> withConverter(final CustomPropertyConverter converter); CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node,
            final T context); CompletionStage<Ui> convert(final ComponentDetail detail, final String lang, final T context); @Override void close();  }