use of io.syndesis.common.model.connection.Connection in project syndesis-qe by syndesisio.
the class SalesforceSteps method createSfStepWithAction.
@Given("^create SF \"([^\"]*)\" action step on field: \"([^\"]*)\"$")
public void createSfStepWithAction(String action, String field) {
final Connector salesforceConnector = connectorsEndpoint.get("salesforce");
final Connection salesforceConnection = connectionsEndpoint.get(RestConstants.getInstance().getSALESFORCE_CONNECTION_ID());
final Action sfAction = TestUtils.findConnectorAction(salesforceConnector, action);
final Map<String, String> properties = TestUtils.map("sObjectName", field);
final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(sfAction, properties, RestConstants.getInstance().getSALESFORCE_CONNECTION_ID());
final Step salesforceStep = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(salesforceConnection).action(generateStepAction(sfAction, connectorDescriptor)).configuredProperties(properties).build();
steps.getStepDefinitions().add(new StepDefinition(salesforceStep, connectorDescriptor));
}
use of io.syndesis.common.model.connection.Connection in project syndesis-qe by syndesisio.
the class AbstractStep method createStep.
public void createStep() {
// Some steps do not have connector / connection
Connector connector = properties.get(StepProperty.CONNECTOR_ID) == null ? null : connectorsEndpoint.get((String) properties.get(StepProperty.CONNECTOR_ID));
Connection connection = properties.get(StepProperty.CONNECTION_ID) == null ? null : connectionsEndpoint.get((String) properties.get(StepProperty.CONNECTION_ID));
Action action;
// If the action is not String, then we already have action object, so just use it
if (properties.get(StepProperty.ACTION) != null && !(properties.get(StepProperty.ACTION) instanceof String)) {
action = (Action) properties.get(StepProperty.ACTION);
} else {
// It may not have an action
action = properties.get(StepProperty.ACTION) == null ? null : findConnectorAction(connector, (String) properties.get(StepProperty.ACTION));
if (action != null) {
// Get the action with datashapes configured
action = generateStepAction(action, getConnectorDescriptor(action, (Map) properties.get(StepProperty.PROPERTIES), (String) properties.get(StepProperty.CONNECTION_ID)));
}
}
final Step.Builder stepBuilder = new Step.Builder();
stepBuilder.stepKind(properties.get(StepProperty.KIND) == null ? StepKind.endpoint : (StepKind) properties.get(StepProperty.KIND));
stepBuilder.id(properties.get(StepProperty.STEP_ID) == null ? UUID.randomUUID().toString() : (String) properties.get(StepProperty.STEP_ID));
stepBuilder.name(properties.get(StepProperty.STEP_NAME) == null ? UUID.randomUUID().toString() : (String) properties.get(StepProperty.STEP_NAME));
if (connection != null) {
stepBuilder.connection(connection);
}
if (action != null) {
stepBuilder.action(action);
}
if (properties.get(StepProperty.PROPERTIES) != null) {
stepBuilder.configuredProperties((Map) properties.get(StepProperty.PROPERTIES));
}
if (properties.get(StepProperty.EXTENSION) != null) {
stepBuilder.extension((Extension) properties.get(StepProperty.EXTENSION));
}
if (properties.get(StepProperty.KIND) == StepKind.mapper) {
steps.getStepDefinitions().add(new StepDefinition(stepBuilder.build(), new DataMapperDefinition()));
} else {
steps.getStepDefinitions().add(new StepDefinition(stepBuilder.build()));
}
properties.clear();
}
use of io.syndesis.common.model.connection.Connection in project syndesis-qe by syndesisio.
the class ConnectionsPublicApiSteps method checkConnectionProperties.
/**
* DataTable -> | property1 | value |
* | property2 | value |
*/
@Then("^check that (\\w+) connection contains properties$")
public void checkConnectionProperties(String connectionName, DataTable tagsData) {
List<List<String>> connectionProperties = tagsData.cells();
Connection connection = connectionsEndpoint.getConnectionByName(connectionName);
for (List<String> connectionProperty : connectionProperties) {
assertThat(connection.getConfiguredProperties()).containsEntry(connectionProperty.get(0), connectionProperty.get(1));
}
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class ConnectorStepHandler method handle.
@SuppressWarnings("PMD")
@Override
public Optional<ProcessorDefinition> handle(Step step, ProcessorDefinition route, IntegrationRouteBuilder builder, final String index) {
// Model
final Connection connection = step.getConnection().get();
final Connector connector = connection.getConnector().get();
final ConnectorAction action = step.getActionAs(ConnectorAction.class).get();
final ConnectorDescriptor descriptor = action.getDescriptor();
// Camel
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, connector, descriptor);
final List<String> customizers = CollectionsUtils.aggregate(ArrayList::new, connector.getConnectorCustomizers(), descriptor.getConnectorCustomizers());
final Map<String, String> properties = CollectionsUtils.aggregate(connection.getConfiguredProperties(), step.getConfiguredProperties());
final Map<String, ConfigurationProperty> configurationProperties = CollectionsUtils.aggregate(connector.getProperties(), action.getProperties());
// Workaround for https://github.com/syndesisio/syndesis/issues/1713
for (Map.Entry<String, ConfigurationProperty> entry : configurationProperties.entrySet()) {
if (ObjectHelper.isNotEmpty(entry.getValue().getDefaultValue())) {
properties.putIfAbsent(entry.getKey(), entry.getValue().getDefaultValue());
}
}
// if the option is marked as secret use property placeholder as the
// value is added to the integration secret.
properties.entrySet().stream().filter(Predicates.or(connector::isSecret, action::isSecret)).forEach(e -> e.setValue(String.format("{{%s-%s.%s}}", scheme, index, e.getKey())));
// raw values.
properties.entrySet().stream().filter(Predicates.or(connector::isRaw, action::isRaw)).forEach(e -> e.setValue(String.format("RAW(%s)", e.getValue())));
// Connector/Action properties have the precedence
connector.getConfiguredProperties().forEach(properties::put);
descriptor.getConfiguredProperties().forEach(properties::put);
try {
final Map<String, Object> proxyProperties = new HashMap<>(properties);
// Set input/output data shape if the component proxy implements
// Input/OutputDataShapeAware
descriptor.getInputDataShape().ifPresent(ds -> trySetInputDataShape(component, ds));
descriptor.getOutputDataShape().ifPresent(ds -> trySetOutputDataShape(component, ds));
// Try to set properties to the component
setProperties(context, component, proxyProperties);
for (String customizerType : customizers) {
final ComponentProxyCustomizer customizer = resolveCustomizer(context, customizerType);
// Set the camel context if the customizer implements
// the CamelContextAware interface.
ObjectHelper.trySetCamelContext(customizer, context);
// Set input/output data shape if the customizer implements
// Input/OutputDataShapeAware
descriptor.getInputDataShape().ifPresent(ds -> trySetInputDataShape(customizer, ds));
descriptor.getOutputDataShape().ifPresent(ds -> trySetOutputDataShape(customizer, ds));
// Try to set properties to the component
setProperties(context, customizer, proxyProperties);
// Invoke the customizer
customizer.customize(component, proxyProperties);
}
component.setCamelContext(context);
component.setOptions(proxyProperties);
// Remove component
context.removeComponent(component.getComponentId());
context.removeService(component);
// Register component
context.addService(component, true, true);
context.addComponent(component.getComponentId(), component);
if (route == null) {
route = builder.from(componentId);
} else {
route = route.to(componentId);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
return Optional.ofNullable(route);
}
use of io.syndesis.common.model.connection.Connection in project syndesis by syndesisio.
the class ConnectionHandler method list.
@Override
public ListResult<ConnectionOverview> list(@Context UriInfo uriInfo) {
final DataManager dataManager = getDataManager();
final ListResult<Connection> connections = fetchAll(Connection.class, uriInfo);
final List<ConnectionOverview> overviews = new ArrayList<>(connections.getTotalCount());
for (Connection connection : connections.getItems()) {
final String id = connection.getId().get();
final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
// set the connector
DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
// set the board
DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
overviews.add(builder.build());
}
return ListResult.of(overviews);
}
Aggregations