@Override public ConnectorAction get(String id) { ConnectorAction result = Getter.super.get(id); if (result == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } if (result.getDescriptor().getConnectorId().equals(connectorId)){ return result; } throw new WebApplicationException(Response.Status.NOT_FOUND); }
public final ConnectorAction mandatoryLookupAction(Connector connector, String actionId) { for (ConnectorAction action : connector.getActions()) { if (action.getId().isPresent() && action.getId().get().equals(actionId)) { return action; } } throw new IllegalArgumentException("Unable to find action: " + actionId); }
private static String allTags(final ConnectorAction left) { return trimToNull(left.getTags().stream().collect(Collectors.joining())); }
.filter(a -> a.idEquals(id)) .findAny() .orElseThrow(() -> new EntityNotFoundException("Action with id: " + id)); final ConnectorDescriptor defaultDescriptor = action.getDescriptor(); if (!action.getTags().contains("dynamic")) { return defaultDescriptor; if (action.getPattern()!=null) { parameters.put(action.getPattern().getDeclaringClass().getSimpleName(), action.getPattern().name());
final ConnectorDescriptor descriptor = action.getDescriptor(); final String componentScheme = action.getDescriptor().getComponentScheme().get(); final Map<String, String> configuredProperties = step.getConfiguredProperties(); final Map<String, String> properties = action.filterEndpointProperties(configuredProperties);
final String actionId = expectedAction.getId().get().replace("_id_", generated.getId().get()); final Optional<ConnectorAction> maybeGeneratedAction = generated.actionById(actionId); assertThat(maybeGeneratedAction).as("No action with id: " + actionId + " was generated").isPresent(); "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")
private static String name(final ConnectorAction action) { return trimToNull(action.getName()); } }
@GET @Produces(MediaType.APPLICATION_JSON) @Path(value = "/{connectorId}/actions/{actionId}/filters/options") public FilterOptions getFilterOptions(@PathParam("connectorId") @ApiParam(required = true) final String connectorId, @PathParam("actionId") @ApiParam(required = true) final String actionId) { final FilterOptions.Builder builder = new FilterOptions.Builder().addOp(Op.DEFAULT_OPTS); final Connector connector = getDataManager().fetch(Connector.class, connectorId); if (connector == null) { return builder.build(); } connector.actionById(actionId).filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).ifPresent(action -> { action.getOutputDataShape().ifPresent(dataShape -> { final List<String> paths = inspectors.getPaths(dataShape.getKind().toString(), dataShape.getType(), dataShape.getSpecification(), dataShape.getExemplar()); builder.addAllPaths(paths); }); }); return builder.build(); }
@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)); } }
private static String name(final ConnectorAction action) { return trimToNull(action.getName()); } }
@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(); }
final Connector connector = connection.getConnector().get(); final ConnectorAction action = step.getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).get(); final ConnectorDescriptor descriptor = action.getDescriptor(); 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));
protected IntegrationDeployment newIntegration(Step... steps) { for (int i = 0; i < steps.length; i++) { steps[i].getConnection().filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); steps[i].getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); steps[i].getExtension().filter(r -> r.getId().isPresent()).ifPresent( resource -> resourceManager.put(resource.getId().get(), resource) ); if (steps[i] instanceof SimpleStep) { steps[i] = new SimpleStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } else if (steps[i] instanceof ExpressionFilterStep) { steps[i] = new ExpressionFilterStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } else if (steps[i] instanceof RuleFilterStep) { steps[i] = new RuleFilterStep.Builder().createFrom(steps[i]).putMetadata(Step.METADATA_STEP_INDEX, Integer.toString(i + 1)).build(); } } return new IntegrationDeployment.Builder() .integrationId("test-integration") .name("Test Integration") .spec(new IntegrationDeploymentSpec.Builder() .description("This is a test integration!") .steps(Arrays.asList(steps)) .build()) .lastUpdated(new Date(0)) .lastUpdated(new Date(0)) .build(); }
private static String allTags(final ConnectorAction left) { return trimToNull(left.getTags().stream().collect(Collectors.joining())); }
@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 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; }
@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(); }
@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() ); }
final Connection connection = step.getConnection().get(); final ConnectorAction action = ConnectorAction.class.cast(step.getAction().get()); final ConnectorDescriptor descriptor = action.getDescriptor(); final Connector connector = resolveConnector(connection, dataManager);
final Connector connector = connection.getConnector().get(); final ConnectorAction action = step.getAction().filter(ConnectorAction.class::isInstance).map(ConnectorAction.class::cast).get(); final ConnectorDescriptor descriptor = action.getDescriptor();