use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class TableServiceImpl method exists.
/**
* {@inheritDoc}
*/
@Override
public boolean exists(final QualifiedName name) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorTableService service = connectorManager.getTableService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
return service.exists(connectorRequestContext, name);
}
use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class ConnectorTableServiceProxy method create.
/**
* Calls the connector table service create method.
* @param name table name
* @param tableInfo table object
*/
public void create(final QualifiedName name, final TableInfo tableInfo) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorTableService service = connectorManager.getTableService(name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
service.create(connectorRequestContext, tableInfo);
}
use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class ConnectorTableServiceProxy method update.
/**
* Calls the connector table service update method.
* @param name table name
* @param tableInfo table object
* @return true if errors after this should be ignored.
*/
@CacheEvict(key = "'table.' + #name")
public boolean update(final QualifiedName name, final TableInfo tableInfo) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorTableService service = connectorManager.getTableService(name);
boolean result = false;
try {
log.info("Updating table {}", name);
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
service.update(connectorRequestContext, tableInfo);
result = connectorRequestContext.isIgnoreErrorsAfterUpdate();
} catch (UnsupportedOperationException ignored) {
// Ignore if the operation is not supported, so that we can at least go ahead and save the user metadata.
log.debug("Catalog {} does not support the table update operation.", name.getCatalogName());
}
return result;
}
use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class DatabaseServiceImpl method get.
/**
* {@inheritDoc}
*/
@Override
public DatabaseDto get(final QualifiedName name, final GetDatabaseServiceParameters getDatabaseServiceParameters) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final MetacatCatalogConfig config = connectorManager.getCatalogConfig(name);
final ConnectorDatabaseService service = connectorManager.getDatabaseService(name);
final ConnectorTableService tableService = connectorManager.getTableService(name);
// Prepare the connector request
final ConnectorRequestContext connectorRequestContext = converterUtil.toConnectorContext(metacatRequestContext);
connectorRequestContext.setIncludeMetadata(getDatabaseServiceParameters.isIncludeMetadataFromConnector());
final DatabaseDto dto = converterUtil.toDatabaseDto(service.get(connectorRequestContext, name));
dto.setType(config.getType());
if (getDatabaseServiceParameters.isIncludeTableNames()) {
final List<QualifiedName> tableNames = tableService.listNames(connectorRequestContext, 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(connectorRequestContext, name);
} catch (UnsupportedOperationException ignored) {
}
}
// Check to see if schema exists
if (tableNames.isEmpty() && viewNames.isEmpty() && !exists(name)) {
throw new DatabaseNotFoundException(name);
}
dto.setTables(Stream.concat(tableNames.stream(), viewNames.stream()).map(QualifiedName::getTableName).sorted(String.CASE_INSENSITIVE_ORDER).collect(Collectors.toList()));
}
if (getDatabaseServiceParameters.isIncludeUserMetadata()) {
log.info("Populate user metadata for schema {}", name);
userMetadataService.populateMetadata(dto, getDatabaseServiceParameters.isDisableOnReadMetadataIntercetor());
}
return dto;
}
use of com.netflix.metacat.common.server.connectors.ConnectorTableService in project metacat by Netflix.
the class TableServiceImpl method get.
@Override
public Optional<TableDto> get(@Nonnull final QualifiedName name, final boolean includeInfo, final boolean includeDefinitionMetadata, final boolean includeDataMetadata) {
validate(name);
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
final ConnectorTableService service = connectorManager.getTableService(name.getCatalogName());
final TableDto table;
if (includeInfo) {
try {
table = converterUtil.toTableDto(service.get(connectorContext, name));
} catch (NotFoundException ignored) {
return Optional.empty();
}
} else {
table = new TableDto();
table.setName(name);
}
if (includeDefinitionMetadata) {
final Optional<ObjectNode> definitionMetadata = userMetadataService.getDefinitionMetadata(name);
if (definitionMetadata.isPresent()) {
table.setDefinitionMetadata(definitionMetadata.get());
}
}
if (includeDataMetadata) {
TableDto dto = table;
if (!includeInfo) {
try {
dto = converterUtil.toTableDto(service.get(connectorContext, name));
} catch (NotFoundException ignored) {
}
}
if (dto != null && dto.getSerde() != null) {
final Optional<ObjectNode> dataMetadata = userMetadataService.getDataMetadata(dto.getSerde().getUri());
if (dataMetadata.isPresent()) {
table.setDataMetadata(dataMetadata.get());
}
}
}
return Optional.of(table);
}
Aggregations