Search in sources :

Example 1 with ConfigTypeNodes

use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.

the class ConfigurationTypeResourceTest method webSocketGetIndex.

@Test
void webSocketGetIndex() {
    final ConfigTypeNodes index = ws.read(ConfigTypeNodes.class, "get", "/configurationtype/index", "");
    assertIndex(index);
    validateJdbcHierarchy(index);
}
Also used : ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes) Test(org.junit.jupiter.api.Test)

Example 2 with ConfigTypeNodes

use of org.talend.sdk.component.server.front.model.ConfigTypeNodes 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()));
}
Also used : Locale(java.util.Locale) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) PropertiesService(org.talend.sdk.component.server.service.PropertiesService) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) HashMap(java.util.HashMap) FamilyBundle(org.talend.sdk.component.runtime.internationalization.FamilyBundle) Inject(javax.inject.Inject) ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes) LocaleMapper(org.talend.sdk.component.server.service.LocaleMapper) QueryParam(javax.ws.rs.QueryParam) Collections.singleton(java.util.Collections.singleton) Collectors.toMap(java.util.stream.Collectors.toMap) Consumes(javax.ws.rs.Consumes) ConfigurationDao(org.talend.sdk.component.server.dao.ConfigurationDao) Locale(java.util.Locale) Map(java.util.Map) DefaultValue(javax.ws.rs.DefaultValue) Config(org.talend.sdk.component.design.extension.repository.Config) APPLICATION_JSON(javax.ws.rs.core.MediaType.APPLICATION_JSON) ActionsService(org.talend.sdk.component.server.service.ActionsService) Collectors.toSet(java.util.stream.Collectors.toSet) POST(javax.ws.rs.POST) Container(org.talend.sdk.component.container.Container) Optional.ofNullable(java.util.Optional.ofNullable) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ErrorDictionary(org.talend.sdk.component.server.front.model.ErrorDictionary) ErrorPayload(org.talend.sdk.component.server.front.model.error.ErrorPayload) RepositoryModel(org.talend.sdk.component.design.extension.RepositoryModel) Collectors.toList(java.util.stream.Collectors.toList) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) SimplePropertyDefinition(org.talend.sdk.component.server.front.model.SimplePropertyDefinition) Function.identity(java.util.function.Function.identity) WebApplicationException(javax.ws.rs.WebApplicationException) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ComponentManager(org.talend.sdk.component.runtime.manager.ComponentManager) ConfigTypeNode(org.talend.sdk.component.server.front.model.ConfigTypeNode) FamilyBundle(org.talend.sdk.component.runtime.internationalization.FamilyBundle) ConfigTypeNode(org.talend.sdk.component.server.front.model.ConfigTypeNode) Config(org.talend.sdk.component.design.extension.repository.Config) ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes)

Example 3 with ConfigTypeNodes

use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.

the class UiSpecServiceTest method configuration.

@Test
void configuration() throws Exception {
    final ConfigTypeNodes load = load("config.json", ConfigTypeNodes.class);
    final String family = load.getNodes().entrySet().stream().filter(e -> e.getValue().getParentId() == null).map(e -> e.getValue().getId()).findFirst().orElseThrow(() -> new IllegalArgumentException("No family"));
    final Ui payload = service.convert(family, load.getNodes().values().stream().filter(e -> "amRiYyNkYXRhc3RvcmUjamRiYw".equals(e.getId())).findFirst().orElseThrow(() -> new IllegalArgumentException("No amRiYyNkYXRhc3RvcmUjamRiYw config"))).toCompletableFuture().get();
    assertTrue(payload.getJsonSchema().getProperties().containsKey("connection"), "connection");
    assertEquals(4, payload.getUiSchema().iterator().next().getItems().size());
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Disabled(org.junit.jupiter.api.Disabled) JsonbConfig(javax.json.bind.JsonbConfig) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) ComponentDetail(org.talend.sdk.component.server.front.model.ComponentDetail) ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes) Collections.singleton(java.util.Collections.singleton) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Collectors.toSet(java.util.stream.Collectors.toSet) JsonbBuilder(javax.json.bind.JsonbBuilder) Iterator(java.util.Iterator) Collection(java.util.Collection) JsonSchema(org.talend.sdk.component.form.model.jsonschema.JsonSchema) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) UiSchema(org.talend.sdk.component.form.model.uischema.UiSchema) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Stream(java.util.stream.Stream) TreeMap(java.util.TreeMap) Ui(org.talend.sdk.component.form.model.Ui) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Jsonb(javax.json.bind.Jsonb) Comparator(java.util.Comparator) InputStream(java.io.InputStream) Ui(org.talend.sdk.component.form.model.Ui) ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigTypeNodes

use of org.talend.sdk.component.server.front.model.ConfigTypeNodes 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());
}
Also used : ConfigTypeNode(org.talend.sdk.component.server.front.model.ConfigTypeNode) ConfigTypeNodes(org.talend.sdk.component.server.front.model.ConfigTypeNodes) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigTypeNodes (org.talend.sdk.component.server.front.model.ConfigTypeNodes)4 Test (org.junit.jupiter.api.Test)3 Collection (java.util.Collection)2 Collections.singleton (java.util.Collections.singleton)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Stream (java.util.stream.Stream)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 Collections.singletonMap (java.util.Collections.singletonMap)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Locale (java.util.Locale)1 Optional.ofNullable (java.util.Optional.ofNullable)1 TreeMap (java.util.TreeMap)1