use of org.talend.tql.model.Expression in project data-prep by Talend.
the class PreparationService method listAll.
public Stream<UserPreparation> listAll(PreparationSearchCriterion searchCriterion, Sort sort, Order order) {
LOGGER.debug("Get list of preparations (with details).");
Stream<Preparation> preparationStream;
if (searchCriterion.getName() == null && searchCriterion.getDataSetId() == null) {
preparationStream = preparationRepository.list(Preparation.class);
} else {
Expression filter = null;
if (searchCriterion.getName() != null) {
filter = getNameFilter(searchCriterion.getName(), searchCriterion.isNameExactMatch());
}
if (searchCriterion.getDataSetId() != null) {
Expression dataSetFilter = eq("dataSetId", searchCriterion.getDataSetId());
filter = filter == null ? dataSetFilter : and(filter, dataSetFilter);
}
preparationStream = preparationRepository.list(Preparation.class, filter);
}
// filter on path
if (searchCriterion.getFolderPath() != null || searchCriterion.getFolderId() != null) {
Map<String, Folder> preparationsFolder = folderRepository.getPreparationsFolderPaths();
if (searchCriterion.getFolderPath() != null) {
preparationStream = preparationStream.filter(p -> preparationsFolder.get(p.getId()).getPath().equals(searchCriterion.getFolderPath()));
}
if (searchCriterion.getFolderId() != null) {
preparationStream = preparationStream.filter(p -> preparationsFolder.get(p.getId()).getId().equals(searchCriterion.getFolderId()));
}
}
return // Needed to order on
preparationStream.map(p -> beanConversionService.convert(p, UserPreparation.class)).sorted(getPreparationComparator(sort, order, p -> getDatasetMetadata(p.getDataSetId())));
}
Aggregations