Search in sources :

Example 6 with QualifiedName

use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.

the class S3ConnectorTableService method create.

@Override
public void create(@Nonnull final ConnectorContext context, @Nonnull final TableInfo tableInfo) {
    log.debug("Start: Create table {}", tableInfo.getName());
    Preconditions.checkArgument(tableInfo.getSerde() == null || !Strings.isNullOrEmpty(tableInfo.getSerde().getOwner()), "Table owner is null or empty");
    final QualifiedName tableName = tableInfo.getName();
    if (tableDao.getBySourceDatabaseTableName(catalogName, tableName.getDatabaseName(), tableName.getTableName()) != null) {
        throw new TableAlreadyExistsException(tableName);
    }
    final Database database = databaseDao.getBySourceDatabaseName(catalogName, tableName.getDatabaseName());
    if (database == null) {
        throw new DatabaseNotFoundException(QualifiedName.ofDatabase(catalogName, tableName.getDatabaseName()));
    }
    tableDao.save(infoConverter.fromTableInfo(database, tableInfo));
    log.debug("End: Create table {}", tableInfo.getName());
}
Also used : TableAlreadyExistsException(com.netflix.metacat.common.server.connectors.exception.TableAlreadyExistsException) QualifiedName(com.netflix.metacat.common.QualifiedName) DatabaseNotFoundException(com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException) Database(com.netflix.metacat.connector.s3.model.Database)

Example 7 with QualifiedName

use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.

the class MetacatV1Resource method createTable.

@Override
public TableDto createTable(final String catalogName, final String databaseName, final String tableName, final TableDto table) {
    final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofTable(catalogName, databaseName, tableName));
    return requestWrapper.processRequest(name, "createTable", () -> {
        Preconditions.checkArgument(table != null, "Table cannot be null");
        Preconditions.checkArgument(tableName != null && !tableName.isEmpty(), "table name is required");
        Preconditions.checkArgument(table.getName() != null && tableName.equalsIgnoreCase(table.getName().getTableName()), "Table name does not match the name in the table");
        return tableService.create(name, table);
    });
}
Also used : QualifiedName(com.netflix.metacat.common.QualifiedName)

Example 8 with QualifiedName

use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.

the class MetacatV1Resource method updateDatabase.

@Override
public void updateDatabase(final String catalogName, final String databaseName, final DatabaseCreateRequestDto databaseUpdateRequestDto) {
    final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
    requestWrapper.processRequest(name, "updateDatabase", () -> {
        final DatabaseDto newDto = new DatabaseDto();
        newDto.setName(name);
        newDto.setDefinitionMetadata(databaseUpdateRequestDto.getDefinitionMetadata());
        databaseService.update(name, newDto);
        return null;
    });
}
Also used : QualifiedName(com.netflix.metacat.common.QualifiedName) DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto)

Example 9 with QualifiedName

use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.

the class MetacatV1Resource method updateCatalog.

@Override
public void updateCatalog(final String catalogName, final CreateCatalogDto createCatalogDto) {
    final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofCatalog(catalogName));
    requestWrapper.processRequest(name, "updateDatabase", () -> {
        createCatalogDto.setName(name);
        catalogService.update(name, createCatalogDto);
        return null;
    });
}
Also used : QualifiedName(com.netflix.metacat.common.QualifiedName)

Example 10 with QualifiedName

use of com.netflix.metacat.common.QualifiedName in project metacat by Netflix.

the class MetacatV1Resource method deleteDatabase.

@Override
public void deleteDatabase(final String catalogName, final String databaseName) {
    final QualifiedName name = requestWrapper.qualifyName(() -> QualifiedName.ofDatabase(catalogName, databaseName));
    requestWrapper.processRequest(name, "deleteDatabase", () -> {
        databaseService.delete(name);
        return null;
    });
}
Also used : QualifiedName(com.netflix.metacat.common.QualifiedName)

Aggregations

QualifiedName (com.netflix.metacat.common.QualifiedName)85 List (java.util.List)31 Lists (com.google.common.collect.Lists)25 Collectors (java.util.stream.Collectors)24 Map (java.util.Map)23 Nonnull (javax.annotation.Nonnull)23 Strings (com.google.common.base.Strings)20 Slf4j (lombok.extern.slf4j.Slf4j)20 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)19 TableDto (com.netflix.metacat.common.dto.TableDto)19 ConnectorContext (com.netflix.metacat.common.server.connectors.ConnectorContext)17 Pageable (com.netflix.metacat.common.dto.Pageable)16 Sort (com.netflix.metacat.common.dto.Sort)16 Maps (com.google.common.collect.Maps)14 Connection (java.sql.Connection)14 SQLException (java.sql.SQLException)14 NonNull (lombok.NonNull)14 TableNotFoundException (com.netflix.metacat.common.server.connectors.exception.TableNotFoundException)13 Nullable (javax.annotation.Nullable)13 DatabaseNotFoundException (com.netflix.metacat.common.server.connectors.exception.DatabaseNotFoundException)12