use of com.thinkbiganalytics.metadata.api.datasource.DatasourceCriteria in project kylo by Teradata.
the class DataSourceProvider method findAllDataSources.
/**
* Gets the list of available connectors.
*/
@Nonnull
public Page<DataSource> findAllDataSources(@Nonnull final Pageable pageable, @Nullable final String filter) {
// Filter catalog data sources
final Supplier<Stream<DataSource>> catalogDataSources = () -> metadataService.read(() -> metadataProvider.findAll().stream().map(modelTransform.dataSourceToRestModel()));
// Filter feed data sources
final DatasourceCriteria feedDataSourcesCriteria = feedDataSourceProvider.datasetCriteria().type(UserDatasource.class);
final Supplier<Stream<DataSource>> feedDataSources = () -> feedDataSourceProvider.getDatasources(feedDataSourcesCriteria).stream().filter(containsIgnoreCase(Datasource::getName, filter)).map(datasource -> toDataSource(datasource, DatasourceModelTransform.Level.BASIC)).filter(Objects::nonNull);
// Sort and paginate
final List<DataSource> filteredDataSources = Stream.concat(catalogDataSources.get(), feedDataSources.get()).sorted(Comparator.comparing(DataSource::getTitle)).skip(pageable.getOffset()).limit(pageable.getPageSize()).peek(findConnector()).collect(Collectors.toList());
return new PageImpl<>(filteredDataSources, pageable, catalogDataSources.get().count() + feedDataSources.get().count());
}
Aggregations