use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationRouteBuilder method loadIntegration.
protected Integration loadIntegration() throws IOException {
final Integration integration;
try (InputStream is = ResourceHelper.resolveResourceAsInputStream(getContext().getClassResolver(), configurationUri)) {
if (is != null) {
LOGGER.info("Loading integration from: {}", configurationUri);
integration = Json.reader().forType(Integration.class).readValue(is);
} else {
throw new IllegalStateException("Unable to load deployment: " + configurationUri);
}
}
return integration;
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class Application method generateIntegrationProject.
private void generateIntegrationProject(File project) throws IOException {
final ReadApiClientData reader = new ReadApiClientData();
final ArrayList<Step> steps = new ArrayList<>();
String deploymentText;
try (InputStream is = resourceLoader.getResource("io/syndesis/server/dao/deployment.json").getInputStream()) {
deploymentText = reader.from(is);
}
final List<ModelData<?>> modelList = reader.readDataFromString(deploymentText);
for (final ModelData<?> model : modelList) {
if (model.getKind() == Kind.Connector) {
final Connector connector = (Connector) model.getData();
for (final Action action : connector.getActions()) {
steps.add(new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().connector(connector).connectorId(connector.getId().get()).build()).action(action).build());
}
}
if (model.getKind() == Kind.ConnectorTemplate) {
final ConnectorTemplate template = (ConnectorTemplate) model.getData();
steps.add(new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().connectorId("connector-" + template.getId()).build()).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().camelConnectorGAV(template.getCamelConnectorGAV()).camelConnectorPrefix(template.getCamelConnectorPrefix()).build()).build()).build());
}
}
try {
final ResourcePatternResolver resolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
final Resource[] resources = resolver.getResources("classpath:/META-INF/syndesis/connector/*.json");
if (resources != null) {
for (Resource resource : resources) {
Connector connector = Json.reader().forType(Connector.class).readValue(resource.getInputStream());
if (connector != null) {
for (final Action action : connector.getActions()) {
steps.add(new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().connector(connector).connectorId(connector.getId().get()).build()).action(action).build());
}
}
}
}
} catch (FileNotFoundException ignored) {
// ignore
}
Integration integration = new Integration.Builder().id("Integration").name("Integration").description("This integration is used to prime the .m2 repo").steps(steps).build();
generate(integration, project);
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationSchedulerTest method integrationSchedulerTest.
@Test
public void integrationSchedulerTest() throws Exception {
final CamelContext context = new SpringCamelContext(applicationContext);
try {
final RouteBuilder routes = new IntegrationRouteBuilder("", Collections.emptyList()) {
@Override
protected Integration loadIntegration() throws IOException {
Integration integration = newIntegration(new Step.Builder().id("step-1").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("log").putConfiguredProperty("loggerName", "timer").build()).build()).build(), new Step.Builder().id("step-2").stepKind(StepKind.endpoint).action(new ConnectorAction.Builder().descriptor(new ConnectorDescriptor.Builder().componentScheme("mock").putConfiguredProperty("name", "timer").build()).build()).build());
return new Integration.Builder().createFrom(integration).scheduler(new Scheduler.Builder().type(Scheduler.Type.timer).expression("1s").build()).build();
}
};
// Set up the camel context
context.addRoutes(routes);
context.start();
dumpRoutes(context);
RouteDefinition routeDefinition = context.getRouteDefinition("test-integration");
assertThat(routeDefinition).isNotNull();
assertThat(routeDefinition).hasFieldOrPropertyWithValue("id", "test-integration");
assertThat(routeDefinition.getInputs()).hasSize(1);
assertThat(routeDefinition.getInputs().get(0).getEndpointUri()).isEqualTo("timer:integration?period=1s");
assertThat(routeDefinition.getOutputs()).hasSize(4);
assertThat(routeDefinition.getOutputs().get(0)).hasFieldOrPropertyWithValue("endpointUri", "log:timer");
assertThat(routeDefinition.getOutputs().get(1)).isInstanceOf(ProcessDefinition.class);
assertThat(routeDefinition.getOutputs().get(2)).hasFieldOrPropertyWithValue("endpointUri", "mock:timer");
assertThat(routeDefinition.getOutputs().get(3)).isInstanceOf(ProcessDefinition.class);
assertThat(routeDefinition.getInputs().get(0)).hasFieldOrPropertyWithValue("id", "integration-scheduler");
assertThat(routeDefinition.getOutputs().get(0)).hasFieldOrPropertyWithValue("id", "step-1");
assertThat(routeDefinition.getOutputs().get(1)).hasFieldOrPropertyWithValue("id", "step-1-capture");
assertThat(routeDefinition.getOutputs().get(2)).hasFieldOrPropertyWithValue("id", "step-2");
assertThat(routeDefinition.getOutputs().get(3)).hasFieldOrPropertyWithValue("id", "step-2-capture");
} finally {
context.stop();
}
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationHandler method update.
@Override
public void update(String id, @ConvertGroup(from = Default.class, to = AllValidations.class) Integration integration) {
Integration existing = getIntegration(id);
Integration updatedIntegration = new Integration.Builder().createFrom(encryptionSupport.encrypt(integration)).version(existing.getVersion() + 1).updatedAt(System.currentTimeMillis()).build();
getDataManager().update(updatedIntegration);
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class IntegrationHandler method get.
@Override
public IntegrationOverview get(String id) {
final DataManager dataManager = getDataManager();
final Integration integration = dataManager.fetch(Integration.class, id);
if (integration == null) {
throw new EntityNotFoundException();
}
if (integration.isDeleted()) {
// Cause that test, is using NoopHandlerProvider, so that means no controllers.
throw new EntityNotFoundException(String.format("Integration %s has been deleted", integration.getId()));
}
return toCurrentIntegrationOverview(integration);
}
Aggregations