use of org.talend.dataprep.api.service.api.EnrichedDataSetMetadata in project data-prep by Talend.
the class DataSetAPI method listSummary.
@RequestMapping(value = "/api/datasets/summary", method = GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "List data sets summary.", produces = APPLICATION_JSON_VALUE, notes = "Returns a list of data sets summary the user can use.")
@Timed
public Callable<Stream<EnrichedDataSetMetadata>> listSummary(@ApiParam(value = "Sort key (by name or date), defaults to 'date'.") @RequestParam(defaultValue = "creationDate") Sort sort, @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(defaultValue = "desc") Order order, @ApiParam(value = "Filter on name containing the specified name") @RequestParam(defaultValue = "") String name, @ApiParam(value = "Filter on certified data sets") @RequestParam(defaultValue = "false") boolean certified, @ApiParam(value = "Filter on favorite data sets") @RequestParam(defaultValue = "false") boolean favorite, @ApiParam(value = "Filter on recent data sets") @RequestParam(defaultValue = "false") boolean limit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Listing datasets summary (pool: {})...", getConnectionStats());
}
return () -> {
GenericCommand<InputStream> listDataSets = getCommand(DataSetList.class, sort, order, name, certified, favorite, limit);
return //
Flux.from(CommandHelper.toPublisher(UserDataSetMetadata.class, mapper, listDataSets)).map(m -> {
LOG.debug("found dataset {} in the summary list" + m.getName());
// Add the related preparations list to the given dataset metadata.
final PreparationSearchByDataSetId getPreparations = getCommand(PreparationSearchByDataSetId.class, m.getId());
return //
Flux.from(CommandHelper.toPublisher(Preparation.class, mapper, getPreparations)).collectList().map(preparations -> {
final List<Preparation> list = //
preparations.stream().filter(//
p -> p.getSteps() != null).collect(Collectors.toList());
return new EnrichedDataSetMetadata(m, list);
}).block();
}).toStream(1);
};
}
Aggregations