@Override public GetCatalogsResp execute() throws Exception { final GetCatalogsResp.Builder respBuilder = GetCatalogsResp.newBuilder(); final Predicate<String> catalogNamePred = MetadataProviderConditions .getLikePredicate(req.hasCatalogNameFilter() ? req.getCatalogNameFilter() : null); final Iterable<Catalog> records = FluentIterable.<Catalog>from(table.<Catalog>asIterable(catalogName, username, datasetListing, null)) .filter(new Predicate<Catalog>() { @Override public boolean apply(Catalog input) { return catalogNamePred.apply(input.CATALOG_NAME); } }); List<CatalogMetadata> metadata = new ArrayList<>(); for(Catalog c : records) { final CatalogMetadata.Builder catBuilder = CatalogMetadata.newBuilder(); catBuilder.setCatalogName(c.CATALOG_NAME); catBuilder.setDescription(c.CATALOG_DESCRIPTION); catBuilder.setConnect(c.CATALOG_CONNECT); metadata.add(catBuilder.build()); } // Reorder results according to JDBC spec Collections.sort(metadata, CATALOGS_ORDERING); respBuilder.setQueryId(queryId); respBuilder.addAllCatalogs(metadata); respBuilder.setStatus(RequestStatus.OK); return respBuilder.build(); } }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.dremio.exec.proto.UserProtos.GetCatalogsResp prototype) {
public static Builder newBuilder(com.dremio.exec.proto.UserProtos.GetCatalogsResp prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public com.dremio.exec.proto.UserProtos.GetCatalogsResp.Builder newMessage() { return com.dremio.exec.proto.UserProtos.GetCatalogsResp.newBuilder(); } public java.lang.String getFieldName(int number)
@Override protected GetCatalogsResp getException(UserException ex) { final GetCatalogsResp.Builder respBuilder = GetCatalogsResp.newBuilder(); respBuilder.setStatus(RequestStatus.FAILED); respBuilder.setError(createPBError("get catalogs", ex)); return respBuilder.build(); }