use of com.netflix.metacat.connector.polaris.mappers.PolarisDatabaseMapper in project metacat by Netflix.
the class PolarisConnectorDatabaseService method get.
/**
* {@inheritDoc}.
*/
@Override
public DatabaseInfo get(final ConnectorRequestContext context, final QualifiedName name) {
try {
final PolarisDatabaseMapper mapper = new PolarisDatabaseMapper(name.getCatalogName());
final PolarisDatabaseEntity db = polarisStoreService.getDatabase(name.getDatabaseName()).orElseThrow(() -> new DatabaseNotFoundException(name));
return mapper.toInfo(db);
} catch (DatabaseNotFoundException exception) {
log.error(String.format("Not found exception for polaris database %s", name), exception);
throw exception;
} catch (Exception exception) {
throw new ConnectorException(String.format("Failed get polaris database %s", name), exception);
}
}
use of com.netflix.metacat.connector.polaris.mappers.PolarisDatabaseMapper in project metacat by Netflix.
the class PolarisConnectorDatabaseService method list.
/**
* {@inheritDoc}.
*/
@Override
public List<DatabaseInfo> list(final ConnectorRequestContext context, final QualifiedName name, @Nullable final QualifiedName prefix, @Nullable final Sort sort, @Nullable final Pageable pageable) {
try {
final PolarisDatabaseMapper mapper = new PolarisDatabaseMapper(name.getCatalogName());
List<PolarisDatabaseEntity> dbs = polarisStoreService.getAllDatabases();
if (prefix != null) {
dbs = dbs.stream().filter(n -> QualifiedName.ofDatabase(name.getCatalogName(), n.getDbName()).startsWith(prefix)).collect(Collectors.toCollection(ArrayList::new));
}
if (sort != null) {
ConnectorUtils.sort(dbs, sort, Comparator.comparing(p -> p.getDbName()));
}
return ConnectorUtils.paginate(dbs, pageable).stream().map(d -> mapper.toInfo(d)).collect(Collectors.toList());
} catch (Exception exception) {
throw new ConnectorException(String.format("Failed databases list polaris prefix %s", prefix), exception);
}
}
Aggregations