use of com.netflix.metacat.common.server.connectors.ConnectorDatabaseService in project metacat by Netflix.
the class DatabaseServiceImpl method get.
@Override
public DatabaseDto get(@Nonnull final QualifiedName name, final boolean includeUserMetadata) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final MetacatCatalogConfig config = connectorManager.getCatalogConfig(name.getCatalogName());
final ConnectorDatabaseService service = connectorManager.getDatabaseService(name.getCatalogName());
final ConnectorTableService tableService = connectorManager.getTableService(name.getCatalogName());
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
final List<QualifiedName> tableNames = tableService.listNames(connectorContext, name, null, null, null);
List<QualifiedName> viewNames = Collections.emptyList();
if (config.isIncludeViewsWithTables()) {
// TODO JdbcMetadata returns ImmutableList.of() for views. We should change it to fetch views.
try {
viewNames = service.listViewNames(connectorContext, name);
} catch (UnsupportedOperationException ignored) {
}
}
// Check to see if schema exists
if (tableNames.isEmpty() && viewNames.isEmpty() && !exists(name)) {
throw new DatabaseNotFoundException(name);
}
final DatabaseDto dto = converterUtil.toDatabaseDto(service.get(connectorContext, name));
dto.setType(connectorManager.getCatalogConfig(name).getType());
dto.setTables(Stream.concat(tableNames.stream(), viewNames.stream()).map(QualifiedName::getTableName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
if (includeUserMetadata) {
log.info("Populate user metadata for schema {}", name);
userMetadataService.populateMetadata(dto);
}
return dto;
}
Aggregations