use of org.talend.sdk.component.server.front.model.ConfigTypeNode in project component-runtime by Talend.
the class ConfigurationTypeResourceTest method validateJdbcHierarchy.
private void validateJdbcHierarchy(final ConfigTypeNodes index) {
final ConfigTypeNode jdbcRoot = index.getNodes().get("amRiYw");
assertNotNull(jdbcRoot);
assertEquals(singleton("amRiYyNkYXRhc3RvcmUjamRiYw"), jdbcRoot.getEdges());
assertEquals("jdbc", jdbcRoot.getName());
final ConfigTypeNode jdbcConnection = index.getNodes().get("amRiYyNkYXRhc3RvcmUjamRiYw");
assertNotNull(jdbcConnection);
assertEquals(singleton("amRiYyNkYXRhc2V0I2pkYmM"), jdbcConnection.getEdges());
assertEquals("jdbc", jdbcConnection.getName());
assertEquals("JDBC DataStore", jdbcConnection.getDisplayName());
assertEquals("datastore", jdbcConnection.getConfigurationType());
final ConfigTypeNode jdbcDataSet = index.getNodes().get("amRiYyNkYXRhc2V0I2pkYmM");
assertNotNull(jdbcDataSet);
assertEquals(-1, jdbcDataSet.getVersion());
assertEquals("jdbc", jdbcDataSet.getName());
assertEquals("JDBC DataSet", jdbcDataSet.getDisplayName());
assertEquals("dataset", jdbcDataSet.getConfigurationType());
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNode in project component-runtime by Talend.
the class ConfigurationTypeResource method toNodes.
private ConfigTypeNodes toNodes(final String language, final Predicate<String> filter, final boolean lightPayload) {
final Locale locale = localeMapper.mapLocale(language);
return manager.find(Stream::of).filter(c -> c.get(RepositoryModel.class) != null).map(c -> c.get(RepositoryModel.class).getFamilies().stream().filter(f -> !f.getConfigs().isEmpty()).flatMap(family -> {
final FamilyBundle resourcesBundle = family.getMeta().findBundle(c.getLoader(), locale);
final Stream<ConfigTypeNode> familyNode;
if (filter.test(family.getId())) {
final ConfigTypeNode node = new ConfigTypeNode();
node.setId(family.getId());
node.setName(family.getMeta().getName());
node.setDisplayName(resourcesBundle.displayName().orElse(family.getMeta().getName()));
node.setEdges(family.getConfigs().stream().map(Config::getId).collect(toSet()));
familyNode = Stream.of(node);
} else {
familyNode = Stream.empty();
}
return Stream.concat(familyNode, createNode(family.getId(), family.getMeta().getName(), family.getConfigs().stream(), resourcesBundle, c, locale, filter, lightPayload));
})).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()));
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNode in project component-runtime by Talend.
the class ConfigurationTypeResource method createNode.
private Stream<ConfigTypeNode> createNode(final String parentId, final String family, final Stream<Config> configs, final FamilyBundle resourcesBundle, final Container container, final Locale locale, final Predicate<String> idFilter, final boolean lightPayload) {
final ClassLoader loader = container.getLoader();
if (configs == null) {
return Stream.empty();
}
return configs.flatMap(c -> {
final Stream<ConfigTypeNode> configNode;
if (idFilter.test(c.getId())) {
final ConfigTypeNode node = new ConfigTypeNode();
node.setId(c.getId());
node.setVersion(c.getVersion());
node.setConfigurationType(c.getKey().getConfigType());
node.setName(c.getKey().getConfigName());
node.setParentId(parentId);
node.setDisplayName(resourcesBundle.configurationDisplayName(c.getKey().getConfigType(), c.getKey().getConfigName()).orElse(c.getKey().getConfigName()));
if (!lightPayload) {
node.setActions(actionsService.findActions(family, container, locale, c));
// force configuration as root prefix
final int prefixLen = c.getMeta().getPath().length();
node.setProperties(propertiesService.buildProperties(singleton(c.getMeta()), loader, locale, null).map(p -> new SimplePropertyDefinition("configuration" + p.getPath().substring(prefixLen), p.getName(), p.getDisplayName(), p.getType(), p.getDefaultValue(), p.getValidation(), p.getMetadata(), p.getPlaceholder(), p.getProposalDisplayNames())).collect(toList()));
}
node.setEdges(c.getChildConfigs().stream().map(Config::getId).collect(toSet()));
configNode = Stream.of(node);
} else {
configNode = Stream.empty();
}
return Stream.concat(configNode, createNode(c.getId(), family, c.getChildConfigs().stream(), resourcesBundle, container, locale, idFilter, lightPayload));
});
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNode in project component-runtime by Talend.
the class ConfigurationTypeResourceTest method webSocketDetail.
@Test
void webSocketDetail() {
final ConfigTypeNodes index = ws.read(ConfigTypeNodes.class, "get", "/configurationtype/details?identifiers=amRiYyNkYXRhc3RvcmUjamRiYw", "");
assertEquals(1, index.getNodes().size());
final ConfigTypeNode jdbcConnection = index.getNodes().get("amRiYyNkYXRhc3RvcmUjamRiYw");
assertNotNull(jdbcConnection);
assertEquals("[{\"description\":\"D1\",\"driver\":\"d1\"},{\"description\":\"D2\",\"driver\":\"d2\"}]", jdbcConnection.getProperties().stream().filter(p -> "configuration.configurations".equals(p.getPath())).findFirst().get().getDefaultValue());
}
Aggregations