Skip to content

Commit

Permalink
System datasets available for tunning has been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mnloures committed Jan 23, 2020
1 parent 3dd3386 commit fb8c6d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/main/java/org/strep/repositories/DatasetRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,14 @@ public interface DatasetRepository extends CrudRepository<Dataset, String> {
*/
@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<String> 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<Dataset> findDatasetsByNames(Collection<String> datasetNames);


}
10 changes: 3 additions & 7 deletions src/main/java/org/strep/web/DatasetController.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,12 @@ public String filterDatasetsByLicense(Authentication authentication, Model model
StringBuilder message = new StringBuilder();
ArrayList<Dataset> allDatasets = new ArrayList<>();
List<String> 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<License> checkedDatasetsLicenses=licenseRepository.getDatasetLicenses(filteredDatasets);


int position = 0;
boolean exit = false;
Expand Down

0 comments on commit fb8c6d7

Please sign in to comment.