Search in sources :

Example 1 with DescribeTableControllerServiceRequestBuilder

use of com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder in project kylo by Teradata.

the class DBCPConnectionPoolService method getTableNamesForControllerService.

/**
 * Returns a list of table names matching a pattern
 *
 * @param serviceId   a NiFi controller service id
 * @param serviceName a NiFi controller service name
 * @param schema      A schema pattern to look for
 * @param tableName   A table pattern to look for
 * @return a list of schema.table names matching the pattern for the database
 */
public List<String> getTableNamesForControllerService(String serviceId, String serviceName, String schema, String tableName) {
    ControllerServiceDTO controllerService = getControllerService(serviceId, serviceName);
    if (controllerService != null) {
        DescribeTableControllerServiceRequestBuilder builder = new DescribeTableControllerServiceRequestBuilder(controllerService);
        DescribeTableControllerServiceRequest serviceProperties = builder.schemaName(schema).tableName(tableName).build();
        return getTableNamesForControllerService(serviceProperties);
    } else {
        log.error("Cannot getTable Names for Controller Service. Unable to obtain Controller Service for serviceId or Name ({} , {})", serviceId, serviceName);
    }
    return null;
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) DescribeTableControllerServiceRequestBuilder(com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder)

Example 2 with DescribeTableControllerServiceRequestBuilder

use of com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder in project kylo by Teradata.

the class DBCPConnectionPoolService method getTableNamesForDatasource.

/**
 * Returns a list of table names for the specified data source.
 *
 * @param datasource the data source
 * @param schema     the schema name, or {@code null} for all schemas
 * @param tableName  a table pattern to look for
 * @return a list of schema.table names, or {@code null} if not accessible
 */
@Nullable
public List<String> getTableNamesForDatasource(@Nonnull final JdbcDatasource datasource, @Nullable final String schema, @Nullable final String tableName) {
    final Optional<ControllerServiceDTO> controllerService = Optional.ofNullable(datasource.getControllerServiceId()).map(id -> getControllerService(id, null));
    if (controllerService.isPresent()) {
        final DescribeTableControllerServiceRequestBuilder builder = new DescribeTableControllerServiceRequestBuilder(controllerService.get());
        final DescribeTableControllerServiceRequest serviceProperties = builder.schemaName(schema).tableName(tableName).password(datasource.getPassword()).useEnvironmentProperties(false).build();
        return getTableNamesForControllerService(serviceProperties);
    } else {
        log.error("Cannot get table names for data source: {}", datasource);
        return null;
    }
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) DescribeTableControllerServiceRequestBuilder(com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder) Nullable(javax.annotation.Nullable)

Example 3 with DescribeTableControllerServiceRequestBuilder

use of com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder in project kylo by Teradata.

the class DBCPConnectionPoolService method describeTableForControllerService.

/**
 * Describe the database table and fields available for a given NiFi controller service
 *
 * @param serviceId   a NiFi controller service id
 * @param serviceName a NiFi controller service name
 * @param schema      A schema  to look for
 * @param tableName   A table  to look for
 * @return the database table and fields
 */
public TableSchema describeTableForControllerService(String serviceId, String serviceName, String schema, String tableName) {
    ControllerServiceDTO controllerService = getControllerService(serviceId, serviceName);
    if (controllerService != null) {
        DescribeTableControllerServiceRequestBuilder builder = new DescribeTableControllerServiceRequestBuilder(controllerService);
        DescribeTableControllerServiceRequest serviceProperties = builder.schemaName(schema).tableName(tableName).build();
        return describeTableForControllerService(serviceProperties);
    } else {
        log.error("Cannot describe Table for Controller Service. Unable to obtain Controller Service for serviceId or Name ({} , {})", serviceId, serviceName);
    }
    return null;
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) DescribeTableControllerServiceRequestBuilder(com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder)

Example 4 with DescribeTableControllerServiceRequestBuilder

use of com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder in project kylo by Teradata.

the class DBCPConnectionPoolService method getSchemaNamesForDatasource.

/**
 * Returns a list of schema names for the specified data source.
 *
 * @param datasource the data source
 * @return a list of schema names, or {@code null} if not accessible
 */
@Nullable
public List<String> getSchemaNamesForDatasource(@Nonnull final JdbcDatasource datasource) {
    final Optional<ControllerServiceDTO> controllerService = Optional.ofNullable(datasource.getControllerServiceId()).map(id -> getControllerService(id, null));
    if (controllerService.isPresent()) {
        final DescribeTableControllerServiceRequestBuilder builder = new DescribeTableControllerServiceRequestBuilder(controllerService.get());
        final DescribeTableControllerServiceRequest serviceProperties = builder.password(datasource.getPassword()).useEnvironmentProperties(false).build();
        return getSchemaNamesForControllerService(serviceProperties);
    } else {
        log.error("Cannot get table names for data source: {}", datasource);
        return null;
    }
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) DescribeTableControllerServiceRequestBuilder(com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder) Nullable(javax.annotation.Nullable)

Example 5 with DescribeTableControllerServiceRequestBuilder

use of com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder in project kylo by Teradata.

the class DBCPConnectionPoolService method describeTableForDatasource.

/**
 * Describes the specified database table accessed through the specified data source.
 *
 * @param datasource the data source
 * @param schema     the schema name, or {@code null} to search all schemas
 * @param tableName  the table name
 * @return the database table and fields, or {@code null} if not found
 */
public TableSchema describeTableForDatasource(@Nonnull final JdbcDatasource datasource, @Nullable final String schema, @Nonnull final String tableName) {
    final Optional<ControllerServiceDTO> controllerService = Optional.ofNullable(datasource.getControllerServiceId()).map(id -> getControllerService(id, null));
    if (controllerService.isPresent()) {
        final DescribeTableControllerServiceRequestBuilder builder = new DescribeTableControllerServiceRequestBuilder(controllerService.get());
        final DescribeTableControllerServiceRequest serviceProperties = builder.schemaName(schema).tableName(tableName).password(datasource.getPassword()).useEnvironmentProperties(false).build();
        return describeTableForControllerService(serviceProperties);
    } else {
        log.error("Cannot describe table for data source: {}", datasource);
        return null;
    }
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) DescribeTableControllerServiceRequestBuilder(com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder)

Aggregations

DescribeTableControllerServiceRequestBuilder (com.thinkbiganalytics.feedmgr.nifi.controllerservice.DescribeTableControllerServiceRequest.DescribeTableControllerServiceRequestBuilder)5 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)5 Nullable (javax.annotation.Nullable)2