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);
}
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);
}
Aggregations