Project

General

Profile

« Previous | Next » 

Revision 49612

managed param is not required

View differences:

modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/repository/DatasourceApiRepository.java
12 12
public interface DatasourceApiRepository extends JpaRepository<DatasourceApi, String> {
13 13

  
14 14
	@Query("select distinct da.baseurl from DatasourceApi da where lower(contactemail) = lower(?1) and managed = ?2")
15
	Slice<String> findDistinctBaseurlByContactemailContainingAllIgnoreCase(String contactemail, boolean managed, Pageable pageable);
15
	Slice<String> searchBaseUrlManaged(String contactemail, boolean managed, Pageable pageable);
16 16

  
17
	@Query("select distinct da.baseurl from DatasourceApi da where lower(contactemail) = lower(?1)")
18
	Slice<String> searchBaseUrl(String contactemail, Pageable pageable);
17 19
}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/clients/DatasourceDao.java
233 233
		return null;
234 234
	}
235 235

  
236
	public List<String> findBaseURLs(final String contactemail, final boolean managed, final Pageable pageable) throws ApiException {
237
		final Slice<String> baseurl =
238
				datasourceApiRepository.findDistinctBaseurlByContactemailContainingAllIgnoreCase(contactemail, managed, pageable);
239
		return baseurl.getContent().stream()
236
	public List<String> findBaseURLs(final String contactemail, final Boolean managed, final Pageable pageable) throws ApiException {
237
		return _findBaseURLs(contactemail, managed, pageable).getContent().stream()
240 238
				.filter(StringUtils::isNotBlank)
241 239
				.collect(Collectors.toList());
242 240
	}
243 241

  
242
	private Slice<String> _findBaseURLs(final String contactemail, final Boolean managed, final Pageable pageable) throws ApiException {
243
		return managed != null ?
244
				datasourceApiRepository.searchBaseUrlManaged(contactemail, managed, pageable) :
245
				datasourceApiRepository.searchBaseUrl(contactemail, pageable);
246
	}
247

  
248

  
244 249
	public List<CountryTerm> browseCountries() {
245 250
		return countryTermRepository.findAll();
246 251
	}
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApi.java
56 56
    @ApiResponses(value = {
57 57
            @ApiResponse(code = 200, message = "OK", response = String[].class),
58 58
            @ApiResponse(code = 500, message = "unexpected error", response = Response.class) })
59
    List<String> searchBaseUrls(String userEmail, boolean managed, int page, int size) throws ApiException;
59
    List<String> searchBaseUrls(String userEmail, Boolean managed, int page, int size) throws ApiException;
60 60

  
61 61
    @ApiOperation(value = "terms and count for the given field", notes = "Returns the list of BrowseTerms.", response = BrowseTerm[].class)
62 62
    @ApiResponses(value = {
modules/dnet-openaire-exporter/trunk/src/main/java/eu/dnetlib/openaire/exporter/datasource/DatasourcesApiController.java
79 79

  
80 80
	@Override
81 81
	@RequestMapping(value = "/api/baseurl/{page}/{size}", produces = { "application/json" }, method = RequestMethod.GET)
82
	public List<String> searchBaseUrls(@RequestParam final String userEmail, @RequestParam final boolean managed, @PathVariable final int page, @PathVariable final int size) throws ApiException {
82
	public List<String> searchBaseUrls(@RequestParam final String userEmail, @RequestParam(required = false) final Boolean managed, @PathVariable final int page, @PathVariable final int size) throws ApiException {
83 83
		return dsDao.findBaseURLs(userEmail, managed, new PageRequest(page, size));
84 84
	}
85 85

  

Also available in: Unified diff