use of org.talend.dataprep.api.service.command.folder.FolderChildrenList in project data-prep by Talend.
the class FolderAPI method listPreparationsByFolder.
/**
* List all the folders and preparations out of the given id.
*
* @param id Where to list folders and preparations.
*/
// @formatter:off
@RequestMapping(value = "/api/folders/{id}/preparations", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
@ApiOperation(value = "Get all preparations for a given id.", notes = "Returns the list of preparations for the given id the current user is allowed to see.")
@Timed
public PreparationsByFolder listPreparationsByFolder(//
@PathVariable @ApiParam(name = "id", value = "The destination to search preparations from.") final String id, //
@ApiParam(value = "Sort key (by name or date), defaults to 'date'.") @RequestParam(defaultValue = "creationDate") final Sort sort, @ApiParam(value = "Order for sort key (desc or asc), defaults to 'desc'.") @RequestParam(defaultValue = "desc") final Order order) {
if (LOG.isDebugEnabled()) {
LOG.debug("Listing preparations in destination {} (pool: {} )...", id, getConnectionStats());
}
LOG.info("Listing preparations in folder {}", id);
final FolderChildrenList commandListFolders = getCommand(FolderChildrenList.class, id, sort, order);
final Stream<Folder> folders = toStream(Folder.class, mapper, commandListFolders);
final PreparationListByFolder listPreparations = getCommand(PreparationListByFolder.class, id, sort, order);
final Stream<PreparationListItemDTO> preparations = //
toStream(PreparationDTO.class, mapper, listPreparations).map(dto -> beanConversionService.convert(dto, PreparationListItemDTO.class, APIService::injectDataSetName));
return new PreparationsByFolder(folders, preparations);
}
Aggregations