public List<StepOverview> getSteps() { return integration.getSteps().stream().map(StepOverview::new).collect(Collectors.toList()); }
private boolean isIntegrationActiveAndUsingExtension(IntegrationDeployment integrationDeployment, Extension extension) { if (integrationDeployment == null || extension == null) { return false; } if (IntegrationDeploymentState.Published != integrationDeployment.getTargetState()) { return false; } return integrationDeployment.getSpec().getSteps().stream().anyMatch(step -> { boolean usedAsStep = extension.getExtensionId().equals( Optional.ofNullable(step) .flatMap(Step::getExtension) .map(Extension::getExtensionId) .orElse(null) ); boolean usedAsConnector = extension.getExtensionId().equals( Optional.ofNullable(step) .flatMap(Step::getConnection) .flatMap(Connection::getConnector) .flatMap(c -> c.getDependencies().stream().filter(Dependency::isExtension).findFirst()) .map(Dependency::getId) .orElse(null) ); return usedAsStep || usedAsConnector; }); }
private Collection<Dependency> collectDependencies(Integration integration) { List<Dependency> dependencies = new ArrayList<>(); for (Step step : integration.getSteps()) { step.getAction() .filter(WithDependencies.class::isInstance)
@Override public Integration get(String id) { Integration integration = Getter.super.get(id); if ( integration.isDeleted() ) { //Not sure if we need to do that for both current and desired status, //but If we don't do include the desired state, IntegrationITCase is not going to pass anytime soon. Why? //Cause that test, is using NoopHandlerProvider, so that means no controllers. throw new EntityNotFoundException(String.format("Integration %s has been deleted", integration.getId())); } // Get the latest connection configs. List<Connection> connections = integration.getConnections().stream() .map(this::toCurrentConnection) .collect(Collectors.toList()); List<Step> steps = integration.getSteps().stream() .map(this::toCurrentSteps) .collect(Collectors.toList()); return new Integration.Builder() .createFrom(integration) .connections(connections) .steps(steps) .build(); }
private void addToExport(JsonDB export, Integration integration) { addModelToExport(export, integration); for (Step step : integration.getSteps()) { Optional<Connection> c = step.getConnection(); if (c.isPresent()) { Connection connection = c.get(); addModelToExport(export, connection); Connector connector = integrationHandler.getDataManager().fetch(Connector.class, connection.getConnectorId().get()); if (connector != null) { addModelToExport(export, connector); } } Optional<Extension> e = step.getExtension(); if (e.isPresent()) { Extension extension = e.get(); addModelToExport(export, extension); } } }
Integration integration = integrationHandler.get(id); addToExport(memJsonDB, integration); resourceManager.collectDependencies(integration.getSteps()).stream() .filter(Dependency::isExtension) .map(Dependency::getId)
public Integration encrypt(Integration integration) { return new Integration.Builder() .createFrom(integration) .steps(encrypt(integration.getSteps())) .build(); }
@SuppressWarnings("PMD.UnusedPrivateMethod") private byte[] generateFlow(TarArchiveOutputStream tos, Integration integration) throws JsonProcessingException { final List<? extends Step> steps = integration.getSteps(); final Flow flow = new Flow(); if (!steps.isEmpty()) { Queue<Step> remaining = new ArrayDeque<>(steps); Step first = remaining.remove(); if (first != null) { StepVisitorContext stepContext = new StepVisitorContext.Builder() .generatorContext(new GeneratorContext.Builder() .generatorProperties(generatorProperties) .integration(integration) .tarArchiveOutputStream(tos) .flow(flow) .visitorFactoryRegistry(registry) .dataManager(dataManager) .extensionDataManager(extensionDataManager) .build()) .index(1) .step(first) .remaining(remaining) .build(); visitStep(stepContext); } } SyndesisModel syndesisModel = new SyndesisModel(); syndesisModel.addFlow(flow); return YAML_OBJECT_MAPPER.writeValueAsBytes(syndesisModel); }