use of org.springframework.data.domain.Pageable in project spring-data-commons by spring-projects.
the class PageableHandlerMethodArgumentResolverUnitTests method returnsCorrectPageSizeForOneIndexParameters.
// DATACMNS-761
@Test
public void returnsCorrectPageSizeForOneIndexParameters() {
PageableHandlerMethodArgumentResolver resolver = getResolver();
resolver.setOneIndexedParameters(true);
MockHttpServletRequest request = new MockHttpServletRequest();
request.addParameter("size", "10");
Pageable result = resolver.resolveArgument(supportedMethodParameter, null, new ServletWebRequest(request), null);
assertThat(result.getPageSize()).isEqualTo(10);
}
use of org.springframework.data.domain.Pageable in project goci by EBISPOT.
the class SolrIndexer method mapAllTraits.
private int mapAllTraits(ExecutorService taskExecutor, Collection<String> pubmedIds) throws InterruptedException {
// Sort sort = new Sort(new Sort.Order("trait"));
if (runTraits) {
Pageable pager = new PageRequest(0, pageSize);
if (!pubmedIds.isEmpty()) {
int totalElements = 0;
for (String pmid : pubmedIds) {
Page<DiseaseTrait> diseaseTraitPage = diseaseTraitRepository.findByStudiesPublicationIdPubmedId(pmid, pager);
CountDownLatch latch = new CountDownLatch(diseaseTraitPage.getTotalPages());
taskExecutor.execute(new TraitThread(diseaseTraitPage.getContent(), latch, pager.getPageNumber()));
if (sysOutLogging) {
System.out.println("mapping " + diseaseTraitPage.getTotalPages() + " disease trait pages");
}
while (diseaseTraitPage.hasNext()) {
if (maxPages != -1 && diseaseTraitPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
diseaseTraitPage = diseaseTraitRepository.findByStudiesPublicationIdPubmedId(pmid, pager);
taskExecutor.execute(new TraitThread(diseaseTraitPage.getContent(), latch, pager.getPageNumber()));
}
totalElements += diseaseTraitPage.getTotalElements();
latch.await();
}
return totalElements;
} else {
Page<DiseaseTrait> diseaseTraitPage = diseaseTraitRepository.findAll(pager);
CountDownLatch latch = new CountDownLatch(diseaseTraitPage.getTotalPages());
taskExecutor.execute(new TraitThread(diseaseTraitPage.getContent(), latch, pager.getPageNumber()));
if (sysOutLogging) {
System.out.println("mapping " + diseaseTraitPage.getTotalPages() + " disease trait pages");
}
while (diseaseTraitPage.hasNext()) {
if (maxPages != -1 && diseaseTraitPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
diseaseTraitPage = diseaseTraitRepository.findAll(pager);
taskExecutor.execute(new TraitThread(diseaseTraitPage.getContent(), latch, pager.getPageNumber()));
}
latch.await();
return (int) diseaseTraitPage.getTotalElements();
}
} else {
return 0;
}
}
use of org.springframework.data.domain.Pageable in project goci by EBISPOT.
the class SolrIndexer method mapStudies.
/**
* If no publication ids are provided all studies will be mapped
* @param pubmedIds
* @return
*/
Integer mapStudies(Collection<String> pubmedIds) {
if (runStudies) {
Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "publicationId.publicationDate"));
Pageable pager = new PageRequest(0, pageSize);
Page<Study> studyPage = null;
int totalElements = 0;
if (!pubmedIds.isEmpty()) {
for (String pmid : pubmedIds) {
studyPage = studyService.findPublishedStudiesByPublicationId(pmid, pager);
totalElements += _mapPagedStudies(pmid, studyPage, pager);
}
} else {
studyPage = studyService.findPublishedStudies(pager);
totalElements = _mapPagedStudies(null, studyPage, pager);
}
return totalElements;
} else {
return 0;
}
}
use of org.springframework.data.domain.Pageable in project goci by EBISPOT.
the class SolrIndexer method mapAllAssociations.
@Transactional
private int mapAllAssociations(ExecutorService taskExecutor, Collection<String> pubmedIds) throws InterruptedException {
// Sort sort = new Sort(new Sort.Order("id"));
if (runAssociations) {
Pageable pager = new PageRequest(0, pageSize);
if (!pubmedIds.isEmpty()) {
int totalElements = 0;
for (String pmid : pubmedIds) {
Page<Association> associationPage = associationService.findPublishedAssociationsPublicationId(pmid, pager);
CountDownLatch latch = new CountDownLatch(associationPage.getTotalPages());
taskExecutor.execute(new AssociationThread(associationPage.getContent(), latch, pager.getPageNumber()));
if (sysOutLogging) {
System.out.println("mapping " + associationPage.getTotalPages() + " association pages");
}
while (associationPage.hasNext()) {
if (maxPages != -1 && associationPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
associationPage = associationService.findPublishedAssociationsPublicationId(pmid, pager);
taskExecutor.execute(new AssociationThread(associationPage.getContent(), latch, pager.getPageNumber()));
}
latch.await();
totalElements += associationPage.getTotalElements();
}
return totalElements;
} else {
Page<Association> associationPage = associationService.findPublishedAssociations(pager);
CountDownLatch latch = new CountDownLatch(associationPage.getTotalPages());
taskExecutor.execute(new AssociationThread(associationPage.getContent(), latch, pager.getPageNumber()));
if (sysOutLogging) {
System.out.println("mapping " + associationPage.getTotalPages() + " association pages");
}
while (associationPage.hasNext()) {
if (maxPages != -1 && associationPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
associationPage = associationService.findPublishedAssociations(pager);
taskExecutor.execute(new AssociationThread(associationPage.getContent(), latch, pager.getPageNumber()));
}
latch.await();
return (int) associationPage.getTotalElements();
}
} else {
return 0;
}
}
use of org.springframework.data.domain.Pageable in project goci by EBISPOT.
the class SolrIndexer method mapAssociations.
Integer mapAssociations(Collection<String> pubmedIds) {
if (runAssociations) {
Sort sort = new Sort(new Sort.Order("id"));
Pageable pager = new PageRequest(0, pageSize);
Page<Association> associationPage = null;
int totalElements = 0;
if (!pubmedIds.isEmpty()) {
for (String pmid : pubmedIds) {
associationPage = associationService.findPublishedAssociationsPublicationId(pmid, pager);
totalElements += _mapPagedAssociations(pmid, associationPage, pager);
}
} else {
associationPage = associationService.findPublishedAssociations(pager);
totalElements = _mapPagedAssociations(null, associationPage, pager);
}
return totalElements;
} else {
return 0;
}
}
Aggregations