Search in sources :

Example 1 with DefaultMetaData

use of org.apache.camel.component.extension.metadata.DefaultMetaData in project syndesis by syndesisio.

the class SqlConnectorMetaDataExtension method meta.

@Override
public Optional<MetaData> meta(final Map<String, Object> properties) {
    final String sqlStatement = (String) properties.get("query");
    MetaData metaData = EMPTY_METADATA;
    if (sqlStatement != null) {
        try (Connection connection = SqlSupport.createConnection(properties)) {
            final DatabaseMetaData meta = connection.getMetaData();
            final String defaultSchema = DatabaseMetaDataHelper.getDefaultSchema(meta.getDatabaseProductName(), String.valueOf(properties.get("user")));
            final String schemaPattern = (String) properties.getOrDefault("schema-pattern", defaultSchema);
            final SqlStatementParser parser = new SqlStatementParser(connection, schemaPattern, sqlStatement);
            final SqlStatementMetaData sqlStatementMetaData = parseStatement(parser);
            metaData = new DefaultMetaData(null, null, sqlStatementMetaData);
        } catch (final SQLException e) {
            throw new SyndesisServerException(e.getMessage(), e);
        }
    }
    return Optional.of(metaData);
}
Also used : SqlStatementMetaData(io.syndesis.connector.sql.common.SqlStatementMetaData) SQLException(java.sql.SQLException) DefaultMetaData(org.apache.camel.component.extension.metadata.DefaultMetaData) DatabaseMetaData(java.sql.DatabaseMetaData) SqlStatementMetaData(io.syndesis.connector.sql.common.SqlStatementMetaData) SyndesisServerException(io.syndesis.common.util.SyndesisServerException) Connection(java.sql.Connection) DefaultMetaData(org.apache.camel.component.extension.metadata.DefaultMetaData) SqlStatementParser(io.syndesis.connector.sql.common.SqlStatementParser) DatabaseMetaData(java.sql.DatabaseMetaData)

Example 2 with DefaultMetaData

use of org.apache.camel.component.extension.metadata.DefaultMetaData in project syndesis by syndesisio.

the class SqlStoredConnectorMetaDataExtension method meta.

@Override
public Optional<MetaData> meta(final Map<String, Object> properties) {
    final Map<String, StoredProcedureMetadata> list = SqlSupport.getStoredProcedures(properties);
    final MetaData metaData = new DefaultMetaData(null, null, list);
    return Optional.of(metaData);
}
Also used : DefaultMetaData(org.apache.camel.component.extension.metadata.DefaultMetaData) DefaultMetaData(org.apache.camel.component.extension.metadata.DefaultMetaData) StoredProcedureMetadata(io.syndesis.connector.sql.common.stored.StoredProcedureMetadata)

Aggregations

DefaultMetaData (org.apache.camel.component.extension.metadata.DefaultMetaData)2 SyndesisServerException (io.syndesis.common.util.SyndesisServerException)1 SqlStatementMetaData (io.syndesis.connector.sql.common.SqlStatementMetaData)1 SqlStatementParser (io.syndesis.connector.sql.common.SqlStatementParser)1 StoredProcedureMetadata (io.syndesis.connector.sql.common.stored.StoredProcedureMetadata)1 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1