diff --git a/src/main/java/org/strep/repositories/DatasetRepository.java b/src/main/java/org/strep/repositories/DatasetRepository.java index 4b91c6e..24cb343 100644 --- a/src/main/java/org/strep/repositories/DatasetRepository.java +++ b/src/main/java/org/strep/repositories/DatasetRepository.java @@ -196,5 +196,14 @@ public interface DatasetRepository extends CrudRepository { */ @Query(value="SELECT SUM(IF(redistribute,0,1)) FROM license,dataset WHERE license.name=dataset.id AND dataset.name IN (?1)", nativeQuery=true) public int checkIfRedistributionIsNotAllowed(Collection datasetNames); + + /** + * Get datasets filtered by Name + * @param datasetNames The datasets that is going to be combined + * @return The list of datasets filtered by name + */ + @Query(value="SELECT dataset.* FROM dataset WHERE dataset.name IN (?1)", nativeQuery=true) + public ArrayList findDatasetsByNames(Collection datasetNames); + } diff --git a/src/main/java/org/strep/web/DatasetController.java b/src/main/java/org/strep/web/DatasetController.java index eb9488f..fe669a9 100644 --- a/src/main/java/org/strep/web/DatasetController.java +++ b/src/main/java/org/strep/web/DatasetController.java @@ -567,16 +567,12 @@ public String filterDatasetsByLicense(Authentication authentication, Model model StringBuilder message = new StringBuilder(); ArrayList allDatasets = new ArrayList<>(); List filteredDatasets = new ArrayList<>(); - UserDetails userDetails = (UserDetails) authentication.getPrincipal(); - String username = userDetails.getUsername(); + datasetRepository.findDatasetsByNames(Arrays.asList(datasets)).forEach(allDatasets::add); - datasetRepository.getSystemDatasets(username,Dataset.TYPE_SYSTEM).forEach(allDatasets::add); - - for (String datasetName : checkedDatasets) { - filteredDatasets.add(datasetName); - } + filteredDatasets.addAll(Arrays.asList(checkedDatasets)); ArrayList checkedDatasetsLicenses=licenseRepository.getDatasetLicenses(filteredDatasets); + int position = 0; boolean exit = false;