use of org.springframework.data.domain.PageRequest in project ignite by apache.
the class IgniteSpringDataQueriesSelfTest method testSelectSeveralFields.
/** */
public void testSelectSeveralFields() {
List<List> lists = repo.selectSeveralField("^[a-z]+$", new PageRequest(2, 6));
assertEquals(6, lists.size());
for (List list : lists) {
assertEquals(2, list.size());
assertTrue(list.get(0) instanceof Integer);
}
}
use of org.springframework.data.domain.PageRequest in project ignite by apache.
the class IgniteSpringDataQueriesSelfTest method testPageable.
/** */
public void testPageable() {
PageRequest pageable = new PageRequest(1, 5, Sort.Direction.DESC, "firstName");
HashSet<String> firstNames = new HashSet<>();
List<Person> pageable1 = repo.findByFirstNameRegex("^[a-z]+$", pageable);
assertEquals(5, pageable1.size());
for (Person person : pageable1) {
firstNames.add(person.getFirstName());
assertTrue(person.getFirstName().matches("^[a-z]+$"));
}
List<Person> pageable2 = repo.findByFirstNameRegex("^[a-z]+$", pageable.next());
assertEquals(5, pageable2.size());
for (Person person : pageable2) {
firstNames.add(person.getFirstName());
assertTrue(person.getFirstName().matches("^[a-z]+$"));
}
assertEquals(10, firstNames.size());
}
use of org.springframework.data.domain.PageRequest in project ocvn by devgateway.
the class GenericOCDSController method textSearchQuery.
/**
* Creates a mongodb query for searching based on text index, sorts the results by score
*
* @param request
* @return
*/
protected Query textSearchQuery(final TextSearchRequest request) {
PageRequest pageRequest = new PageRequest(request.getPageNumber(), request.getPageSize());
Query query = null;
if (request.getText() == null) {
query = new Query();
} else {
query = TextQuery.queryText(new TextCriteria().matching(request.getText())).sortByScore();
}
query.with(pageRequest);
return query;
}
use of org.springframework.data.domain.PageRequest in project ocvn by devgateway.
the class SortableJpaRepositoryDataProvider method iterator.
/**
* @see SortableDataProvider#iterator(long, long)
*/
@Override
public Iterator<? extends T> iterator(final long first, final long count) {
int page = (int) ((double) first / WebConstants.PAGE_SIZE);
Page<T> findAll = jpaRepository.findAll(filterState.getSpecification(), new PageRequest(page, WebConstants.PAGE_SIZE, translateSort()));
return findAll.iterator();
}
use of org.springframework.data.domain.PageRequest in project ocvn by devgateway.
the class AbstractOrganizationSearchController method organizationSearchTextByType.
protected List<Organization> organizationSearchTextByType(final TextSearchRequest request, Organization.OrganizationType type) {
Query query = null;
if (request.getText() == null) {
query = new Query();
} else {
//this is for Full Text Search, in case we need this later, right now it's not very useful
//query = TextQuery.queryText(new TextCriteria().matching(request.getText())).sortByScore();
query = new Query().addCriteria(Criteria.where("name").regex(Pattern.compile(request.getText(), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE)));
}
if (type != null) {
query.addCriteria(Criteria.where("roles").is(type)).with(new PageRequest(request.getPageNumber(), request.getPageSize()));
}
List<Organization> orgs = mongoTemplate.find(query, Organization.class);
return orgs;
}
Aggregations