use of org.springframework.web.bind.annotation.RequestParam in project data-prep by Talend.
the class FolderService method search.
/**
* Search for folders.
*
* @param name the folder name to search.
* @param strict strict mode means the name is the full name.
* @return the folders whose part of their name match the given path.
*/
@RequestMapping(value = "/folders/search", method = GET)
@ApiOperation(value = "Search Folders with parameter as part of the name")
@Timed
public Stream<Folder> search(@RequestParam(required = false, defaultValue = "") final String name, @RequestParam(required = false, defaultValue = "false") final Boolean strict, @RequestParam(required = false) final String path) {
Stream<Folder> folders;
if (path == null) {
folders = folderRepository.searchFolders(name, strict);
} else {
folders = folderRepository.searchFolders(name, strict).filter(f -> f.getPath().equals(path));
}
AtomicInteger foldersFound = new AtomicInteger(0);
folders = folders.peek(folder -> {
folder.setNbPreparations(folderRepository.count(folder.getId(), PREPARATION));
foldersFound.incrementAndGet();
});
LOGGER.info("Found {} folder(s) searching for {}", foldersFound, name);
return folders;
}
use of org.springframework.web.bind.annotation.RequestParam in project data-prep by Talend.
the class DataSetService method get.
/**
* Returns the <b>full</b> data set content for given id.
*
* @param metadata If <code>true</code>, includes data set metadata information.
* @param dataSetId A data set id.
* @return The full data set.
*/
@RequestMapping(value = "/datasets/{id}/content", method = RequestMethod.GET)
@ApiOperation(value = "Get a data set by id", notes = "Get a data set content based on provided id. Id should be a UUID returned by the list operation. Not valid or non existing data set id returns empty content.")
@Timed
@ResponseBody
public Callable<DataSet> get(@RequestParam(defaultValue = "true") @ApiParam(name = "metadata", value = "Include metadata information in the response") boolean metadata, @RequestParam(defaultValue = "false") @ApiParam(name = "includeInternalContent", value = "Include internal content in the response") boolean includeInternalContent, //
@RequestParam(defaultValue = "-1") @ApiParam(name = STORAGE_LIMIT, value = STORAGE_LIMIT) long limit, @ApiParam(value = "Filter for retrieved content.") @RequestParam(value = "filter", defaultValue = "") String filter, @PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the requested data set") String dataSetId) {
return () -> {
final Marker marker = Markers.dataset(dataSetId);
LOG.debug(marker, "Get data set #{}", dataSetId);
Stream<DataSetRow> stream = null;
try {
DataSetMetadata dataSetMetadata = dataSetMetadataRepository.get(dataSetId);
assertDataSetMetadata(dataSetMetadata, dataSetId);
// Build the result
DataSet dataSet = new DataSet();
if (metadata) {
dataSet.setMetadata(conversionService.convert(dataSetMetadata, UserDataSetMetadata.class));
}
// Disable line limit
stream = contentStore.stream(dataSetMetadata, limit);
// on-demand analyzer for dataset (See TDP-4404, migration problems)
if (dataSetMetadata.getRowMetadata().getColumns().stream().anyMatch(c -> c.getStatistics().getWordPatternFrequencyTable().isEmpty())) {
stream = insertWordPatternAnalysis(dataSetMetadata, stream);
}
if (!includeInternalContent) {
LOG.debug("Skip internal content when serving data set #{} content.", dataSetId);
stream = stream.map(r -> {
final Map<String, Object> values = r.values();
final Map<String, Object> filteredValues = new HashMap<>(values);
// Remove technical properties from returned values.
values.forEach((k, v) -> {
if (k != null && k.startsWith(FlagNames.INTERNAL_PROPERTY_PREFIX)) {
filteredValues.remove(k);
}
});
// Include TDP_ID anyway
filteredValues.put(FlagNames.TDP_ID, r.getTdpId());
return new DataSetRow(r.getRowMetadata(), filteredValues);
});
}
// Filter content
stream = stream.filter(filterService.build(filter, dataSetMetadata.getRowMetadata()));
dataSet.setRecords(stream);
return dataSet;
} catch (Exception e) {
if (stream != null) {
stream.close();
}
throw e;
} finally {
LOG.debug(marker, "Get done.");
}
};
}
Aggregations