@SuppressWarnings("unchecked") private io.syndesis.integration.model.steps.Step createConnector(StepVisitorContext visitorContext, Step step, Connection connection, Connector connector, ConnectorAction action) { final Map<String, String> properties = aggregate(connection.getConfiguredProperties(), step.getConfiguredProperties()); final String scheme = Optionals.first(action.getDescriptor().getComponentScheme(), connector.getComponentScheme()).get(); // if the option is marked as secret use property placeholder as the // value is added to the integration secret. if (visitorContext.getGeneratorContext().getGeneratorProperties().isSecretMaskingEnabled()) { properties.entrySet() .stream() .filter(Predicates.or(connector::isSecret, action::isSecret)) .forEach(e -> e.setValue(String.format("{{%s-%d.%s}}", scheme, visitorContext.getIndex(), e.getKey()))); } //Connector/Action properties have the precedence connector.getConfiguredProperties().forEach(properties::put); action.getDescriptor().getConfiguredProperties().forEach(properties::put); return new io.syndesis.camel.component.proxy.runtime.Connector( scheme + "-" + visitorContext.getIndex(), scheme, Map.class.cast(properties), Optionals.first(action.getDescriptor().getConnectorFactory(), connector.getConnectorFactory()).orElse(null), action.getDescriptor().getConnectorCustomizers() ); }
@Override public Collection<io.syndesis.integration.model.steps.Step> visit(StepVisitorContext visitorContext) { final List<io.syndesis.integration.model.steps.Step> steps = new ArrayList<>(); final Step step = visitorContext.getStep(); final Connection connection = step.getConnection().orElseThrow(() -> new IllegalArgumentException("Missing connection for step:" + step)); final Connector connector = resolveConnector(connection, visitorContext.getGeneratorContext().getDataManager()); final ConnectorAction action = step.getAction() .filter(ConnectorAction.class::isInstance) .map(ConnectorAction.class::cast) .orElseThrow(() -> new IllegalArgumentException("Missing action for step:" + step)); if (Optionals.first(action.getDescriptor().getComponentScheme(), connector.getComponentScheme()).isPresent()) { // Connector steps.add(createConnector(visitorContext, step, connection, connector, action)); } else { // Endpoint steps.add(createEndpoint(visitorContext, step, connection, connector, action)); } // Add an inline splitter if defined action.getDescriptor().getSplit() .map(this::createSplitter) .ifPresent(steps::add); return steps; }
final String componentScheme = action.getDescriptor().getComponentScheme().get(); final Map<String, String> configuredProperties = step.getConfiguredProperties(); final Map<String, String> properties = action.filterEndpointProperties(configuredProperties); properties.putAll(descriptor.getConfiguredProperties());
final String scheme = Optionals.first(descriptor.getComponentScheme(), connector.getComponentScheme()).get(); final CamelContext context = builder.getContext(); final String componentId = scheme + "-" + index; final ComponentProxyComponent component = resolveComponent(componentId, scheme, context, descriptor); final List<String> customizers = CollectionsUtils.aggregate(ArrayList::new, connector.getConnectorCustomizers(), descriptor.getConnectorCustomizers()); final Map<String, String> properties = CollectionsUtils.aggregate(connection.getConfiguredProperties(), step.getConfiguredProperties()); descriptor.getConfiguredProperties().forEach(properties::put);
defaultDescriptor.getPropertyDefinitionSteps() .forEach(step -> step.getProperties().forEach((k, v) -> parameters.putIfAbsent(k, null))); if (shouldEnrichDataShape(defaultDescriptor.getInputDataShape(), input)) { enriched.inputDataShape(input); if (shouldEnrichDataShape(defaultDescriptor.getOutputDataShape(), output)) { enriched.outputDataShape(output);
final Connector connector = resolveConnector(connection, dataManager); if (connector.getComponentScheme().isPresent() || descriptor.getComponentScheme().isPresent()) { final String componentScheme = Optionals.first(descriptor.getComponentScheme(), connector.getComponentScheme()).get(); final String componentScheme = descriptor.getCamelConnectorPrefix();
final String componentScheme = action.getDescriptor().getCamelConnectorPrefix(); final Map<String, String> configuredProperties = CollectionsUtils.aggregate(connection.getConfiguredProperties(), step.getConfiguredProperties()); final Map<String, String> properties = CollectionsUtils.aggregate(connector.filterEndpointProperties(configuredProperties), action.filterEndpointProperties(configuredProperties)); properties.putAll(descriptor.getConfiguredProperties());
@Override public boolean canHandle(Step step) { if (!"endpoint".equals(step.getStepKind()) && !"connector".equals(step.getStepKind())) { return false; } if (step.getConnection().isPresent()) { return false; } if (!step.getAction().filter(ConnectorAction.class::isInstance).isPresent()) { return false; } ConnectorAction action = step.getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).get(); if (action.getDescriptor() == null) { return false; } return action.getDescriptor().getComponentScheme().isPresent(); }
private ComponentProxyComponent resolveComponent(String componentId, String componentScheme, CamelContext context, ConnectorDescriptor descriptor) { ComponentProxyFactory factory = ComponentProxyComponent::new; if (descriptor.getConnectorFactory().isPresent()) { final String factoryType = descriptor.getConnectorFactory().get(); final ClassResolver resolver = context.getClassResolver(); Class<? extends ComponentProxyFactory> type = resolver.resolveClass(factoryType, ComponentProxyFactory.class); if (type == null) { throw new IllegalArgumentException("Unable to resolve a ComponentProxyFactory of type: " + factoryType); } factory = context.getInjector().newInstance(type); if (factory == null) { throw new IllegalArgumentException("Unable to instantiate a ComponentProxyFactory of type: " + factoryType); } } return factory.newInstance(componentId, componentScheme); }
@SuppressWarnings("PMD") protected Optional<ProcessorDefinition> handleSplit(ConnectorDescriptor descriptor, ProcessorDefinition route, IntegrationRouteBuilder builder) { // Handle split if (descriptor.getSplit().isPresent()) { final Split split = descriptor.getSplit().get(); final SimpleStep.Builder splitBuilder = new SimpleStep.Builder().stepKind("split"); split.getLanguage().ifPresent(s -> splitBuilder.putConfiguredProperty("language", s)); split.getExpression().ifPresent(s -> splitBuilder.putConfiguredProperty("expression", s)); route = new SplitStepHandler() .handle( splitBuilder.build(), route, builder) .orElse(route); } return Optional.of(route); } }
"descriptor"); assertThat(generatedAction.getDescriptor().getPropertyDefinitionSteps()) .as("Generated and expected action definition property definition steps for action with id: " + actionId + " differs") .isEqualTo(expectedAction.getDescriptor().getPropertyDefinitionSteps()); if (expectedAction.getDescriptor().getInputDataShape().isPresent()) { final DataShape generatedInputDataShape = generatedAction.getDescriptor().getInputDataShape().get(); final DataShape expectedInputDataShape = expectedAction.getDescriptor().getInputDataShape().get(); if (expectedAction.getDescriptor().getOutputDataShape().isPresent()) { final DataShape generatedOutputDataShape = generatedAction.getDescriptor().getOutputDataShape().get(); final DataShape expectedOutputDataShape = expectedAction.getDescriptor().getOutputDataShape().get(); assertThat(generatedOutputDataShape) .as("Generated and expected output data shape for action with id: " + actionId + " differs")
@SuppressWarnings("unchecked") private io.syndesis.integration.model.steps.Step createEndpoint(StepVisitorContext visitorContext, Step step, Connection connection, Connector connector, ConnectorAction action) { final Map<String, String> configuredProperties = aggregate(connection.getConfiguredProperties(), step.getConfiguredProperties()); final Map<String, String> properties = aggregate(connector.filterEndpointProperties(configuredProperties), action.filterEndpointProperties(configuredProperties)); final String componentScheme = action.getDescriptor().getCamelConnectorPrefix(); // if the option is marked as secret use property placeholder as the // value is added to the integration secret. if (visitorContext.getGeneratorContext().getGeneratorProperties().isSecretMaskingEnabled()) { properties.entrySet() .stream() .filter(Predicates.or(connector::isEndpointProperty, action::isEndpointProperty)) .filter(Predicates.or(connector::isSecret, action::isSecret)) .forEach(e -> e.setValue(String.format("{{%s-%d.%s}}", componentScheme, visitorContext.getIndex(), e.getKey()))); } // any configuredProperties on action descriptor are considered final ConnectorDescriptor descriptor = action.getDescriptor(); properties.putAll(descriptor.getConfiguredProperties()); if (hasComponentProperties(configuredProperties, connector, action)) { return new io.syndesis.integration.model.steps.Endpoint(String.format("%s-%d", componentScheme, visitorContext.getIndex()), Map.class.cast(properties)); } else { return new io.syndesis.integration.model.steps.Endpoint(componentScheme, Map.class.cast(properties)); } }
@Override public boolean canHandle(Step step) { if (!"endpoint".equals(step.getStepKind()) && !"connector".equals(step.getStepKind())) { return false; } if (!step.getConnection().isPresent()) { return false; } if (!step.getConnection().get().getConnector().isPresent()) { return false; } if (!step.getAction().filter(ConnectorAction.class::isInstance).isPresent()) { return false; } return !Optionals.first( step.getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).get().getDescriptor().getComponentScheme(), step.getConnection().get().getConnector().get().getComponentScheme() ).isPresent(); }
@Override public boolean canHandle(Step step) { if (!"endpoint".equals(step.getStepKind()) && !"connector".equals(step.getStepKind())) { return false; } if (!step.getConnection().isPresent()) { return false; } if (!step.getConnection().get().getConnector().isPresent()) { return false; } if (!step.getAction().filter(ConnectorAction.class::isInstance).isPresent()) { return false; } return Optionals.first( step.getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).get().getDescriptor().getComponentScheme(), step.getConnection().get().getConnector().get().getComponentScheme() ).isPresent(); }