use of com.netflix.metacat.common.NameDateDto in project metacat by Netflix.
the class MViewServiceImpl method list.
@Override
public List<NameDateDto> list(@Nonnull final QualifiedName name) {
final MetacatRequestContext metacatRequestContext = MetacatContextManager.getContext();
final QualifiedName viewDbName = QualifiedName.ofDatabase(name.getCatalogName(), VIEW_DB_NAME);
final ConnectorTableService service = connectorManager.getTableService(name.getCatalogName());
List<QualifiedName> tableNames = Lists.newArrayList();
try {
final ConnectorContext connectorContext = converterUtil.toConnectorContext(metacatRequestContext);
tableNames = service.listNames(connectorContext, viewDbName, null, null, null);
} catch (Exception ignored) {
// ignore. Return an empty list if database 'franklinviews' does not exist
}
if (!name.isDatabaseDefinition() && name.isCatalogDefinition()) {
return tableNames.stream().map(viewName -> {
final NameDateDto dto = new NameDateDto();
dto.setName(viewName);
return dto;
}).collect(Collectors.toList());
} else {
final String prefix = String.format("%s_%s_", name.getDatabaseName(), MoreObjects.firstNonNull(name.getTableName(), ""));
return tableNames.stream().filter(qualifiedTableName -> qualifiedTableName.getTableName().startsWith(prefix)).map(qualifiedTableName -> {
final NameDateDto dto = new NameDateDto();
dto.setName(QualifiedName.ofView(qualifiedTableName.getCatalogName(), name.getDatabaseName(), name.getTableName(), qualifiedTableName.getTableName().substring(prefix.length())));
return dto;
}).collect(Collectors.toList());
}
}
Aggregations