Search in sources :

Example 1 with PreparationListByFolder

use of org.talend.dataprep.command.preparation.PreparationListByFolder 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);
}
Also used : PreparationDTO(org.talend.dataprep.api.preparation.PreparationDTO) PreparationListByFolder(org.talend.dataprep.command.preparation.PreparationListByFolder) FolderChildrenList(org.talend.dataprep.api.service.command.folder.FolderChildrenList) CreateChildFolder(org.talend.dataprep.api.service.command.folder.CreateChildFolder) Folder(org.talend.dataprep.api.folder.Folder) GetFolder(org.talend.dataprep.api.service.command.folder.GetFolder) RenameFolder(org.talend.dataprep.api.service.command.folder.RenameFolder) RemoveFolder(org.talend.dataprep.api.service.command.folder.RemoveFolder) PreparationListByFolder(org.talend.dataprep.command.preparation.PreparationListByFolder) PreparationListItemDTO(org.talend.dataprep.api.preparation.PreparationListItemDTO) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 Folder (org.talend.dataprep.api.folder.Folder)1 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)1 PreparationListItemDTO (org.talend.dataprep.api.preparation.PreparationListItemDTO)1 CreateChildFolder (org.talend.dataprep.api.service.command.folder.CreateChildFolder)1 FolderChildrenList (org.talend.dataprep.api.service.command.folder.FolderChildrenList)1 GetFolder (org.talend.dataprep.api.service.command.folder.GetFolder)1 RemoveFolder (org.talend.dataprep.api.service.command.folder.RemoveFolder)1 RenameFolder (org.talend.dataprep.api.service.command.folder.RenameFolder)1 PreparationListByFolder (org.talend.dataprep.command.preparation.PreparationListByFolder)1 Timed (org.talend.dataprep.metrics.Timed)1