1
|
package eu.dnetlib.openaire.funders;
|
2
|
|
3
|
import java.util.List;
|
4
|
import java.util.stream.Collectors;
|
5
|
|
6
|
import eu.dnetlib.openaire.funders.domain.ConversionUtils;
|
7
|
import eu.dnetlib.openaire.funders.domain.ExtendedFunderDetails;
|
8
|
import eu.dnetlib.openaire.funders.domain.FunderDetails;
|
9
|
import org.apache.commons.logging.Log;
|
10
|
import org.apache.commons.logging.LogFactory;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
import org.springframework.data.domain.PageRequest;
|
13
|
import org.springframework.stereotype.Component;
|
14
|
|
15
|
@Component
|
16
|
public class FunderDao {
|
17
|
|
18
|
private static final Log log = LogFactory.getLog(FunderDao.class);
|
19
|
|
20
|
@Autowired
|
21
|
private FunderRepository funderRepository;
|
22
|
|
23
|
public ExtendedFunderDetails getExtendedFunderDetails(final String funderId) throws FundersApiException {
|
24
|
return ConversionUtils.asExtendedFunderDetails(funderRepository.getOne(funderId));
|
25
|
}
|
26
|
|
27
|
public List<FunderDetails> listFunderDetails(final int page, final int size) throws FundersApiException {
|
28
|
return funderRepository.findAll(PageRequest.of(page, size))
|
29
|
.getContent()
|
30
|
.stream()
|
31
|
.map(ConversionUtils::asFunderDetails)
|
32
|
.collect(Collectors.toList());
|
33
|
}
|
34
|
|
35
|
public List<String> listFunderIds(final int page, final int size) throws FundersApiException {
|
36
|
return funderRepository.findAll(PageRequest.of(page, size))
|
37
|
.getContent()
|
38
|
.stream()
|
39
|
.map(f -> f.getId())
|
40
|
.collect(Collectors.toList());
|
41
|
}
|
42
|
|
43
|
}
|