Search in sources :

Example 1 with ODataDeleteEntityComponent

use of io.syndesis.connector.odata.ODataDeleteEntityComponent in project syndesis by syndesisio.

the class ODataDeleteEntityConnectorAutoConfiguration method postConstructODataDeleteEntityComponent.

@PostConstruct
public void postConstructODataDeleteEntityComponent() {
    Map<String, Object> parameters = new HashMap<>();
    for (Map.Entry<String, ODataDeleteEntityConnectorConfigurationCommon> entry : configuration.getConfigurations().entrySet()) {
        parameters.clear();
        ODataDeleteEntityComponent connector = new ODataDeleteEntityComponent(entry.getKey());
        connector.setCamelContext(camelContext);
        try {
            IntrospectionSupport.getProperties(entry.getValue(), parameters, null, false);
            CamelPropertiesHelper.setCamelProperties(camelContext, connector, parameters, false);
            connector.setOptions(parameters);
            if (ObjectHelper.isNotEmpty(customizers)) {
                for (ConnectorCustomizer<ODataDeleteEntityComponent> customizer : customizers) {
                    boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity." + entry.getKey() + ".customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity." + entry.getKey() + ".customizer");
                    if (useCustomizer) {
                        LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
                        customizer.customize(connector);
                    }
                }
            }
            camelContext.addComponent(entry.getKey(), connector);
        } catch (Exception e) {
            throw new BeanCreationException(entry.getKey(), e.getMessage(), e);
        }
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) ODataDeleteEntityComponent(io.syndesis.connector.odata.ODataDeleteEntityComponent) HashMap(java.util.HashMap) BeanCreationException(org.springframework.beans.factory.BeanCreationException) HasId(org.apache.camel.spi.HasId) HashMap(java.util.HashMap) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ODataDeleteEntityComponent

use of io.syndesis.connector.odata.ODataDeleteEntityComponent in project syndesis by syndesisio.

the class ODataDeleteEntityConnectorAutoConfiguration method configureODataDeleteEntityComponent.

@Lazy
@Bean(name = "odata-delete-entity-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean
public ODataDeleteEntityComponent configureODataDeleteEntityComponent() throws Exception {
    ODataDeleteEntityComponent connector = new ODataDeleteEntityComponent();
    connector.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null, false);
    CamelPropertiesHelper.setCamelProperties(camelContext, connector, parameters, false);
    connector.setOptions(parameters);
    if (ObjectHelper.isNotEmpty(customizers)) {
        for (ConnectorCustomizer<ODataDeleteEntityComponent> customizer : customizers) {
            boolean useCustomizer = (customizer instanceof HasId) ? HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity.customizer", ((HasId) customizer).getId()) : HierarchicalPropertiesEvaluator.evaluate(applicationContext.getEnvironment(), "camel.connector.customizer", "camel.connector.odata-delete-entity.customizer");
            if (useCustomizer) {
                LOGGER.debug("Configure connector {}, with customizer {}", connector, customizer);
                customizer.customize(connector);
            }
        }
    }
    return connector;
}
Also used : HasId(org.apache.camel.spi.HasId) ODataDeleteEntityComponent(io.syndesis.connector.odata.ODataDeleteEntityComponent) HashMap(java.util.HashMap) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ODataDeleteEntityComponent (io.syndesis.connector.odata.ODataDeleteEntityComponent)2 HashMap (java.util.HashMap)2 HasId (org.apache.camel.spi.HasId)2 Map (java.util.Map)1 PostConstruct (javax.annotation.PostConstruct)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1