@Test public void convertToPageable() { String rqlFilter = "(employee.number=='1' and employee.names =size= 1) or (employee.number=='2' and employee.names =size= 2)"; String limit = "limit(0, 10)"; String sort = "sort(+employee.number)"; RqlInput rqlInput = new RqlInput() .setFilter(rqlFilter) .setLimit(limit) .setSort(sort); Map<String , Path> pathMapping = ImmutableMap.<String, Path>builder() .put("employee.number", QEmployee.employee.employeeNumber) .put("employee.names", QEmployee.employee.names) .build(); QuerydslMappingResult querydslMappingResult = querydslRqlParser.parse(rqlInput, new QuerydslMappingParam().setRootPath(QEmployee.employee).setPathMapping(pathMapping)); Pageable pageable = SpringUtil.toPageable(querydslMappingResult.getOrderSpecifiers(), querydslMappingResult.getPage()); Assert.assertEquals(0, pageable.getOffset()); Assert.assertEquals(10, pageable.getPageSize()); Sort pageableSort = pageable.getSort(); Assert.assertEquals(Sort.Direction.ASC, pageableSort.getOrderFor("employeeNumber").getDirection()); }
public static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page) { List<Sort.Order> orders = new ArrayList<>(); for(OrderSpecifier orderSpecifier : orderSpecifiers) { String expressionPath = orderSpecifier.getTarget().toString(); String[] paths = expressionPath.split("\\."); String property = paths[paths.length - 1]; orders.add(new Sort.Order(Sort.Direction.valueOf(orderSpecifier.getOrder().toString()), property)); } Sort sort = new Sort(orders); return new PageRequest(page.getOffset().intValue(), page.getLimit().intValue(), sort); }
SpringUtil { public static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page) { List<Sort.Order> orders = new ArrayList<>(); for(OrderSpecifier orderSpecifier : orderSpecifiers) { String expressionPath = orderSpecifier.getTarget().toString(); String[] paths = expressionPath.split("\\."); String property = paths[paths.length - 1]; orders.add(new Sort.Order(Sort.Direction.valueOf(orderSpecifier.getOrder().toString()), property)); } Sort sort = new Sort(orders); return new PageRequest(page.getOffset().intValue(), page.getLimit().intValue(), sort); } }
SpringUtil { public static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page) { List<Sort.Order> orders = new ArrayList<>(); for(OrderSpecifier orderSpecifier : orderSpecifiers) { String expressionPath = orderSpecifier.getTarget().toString(); String[] paths = expressionPath.split("\\."); String property = paths[paths.length - 1]; orders.add(new Sort.Order(Sort.Direction.valueOf(orderSpecifier.getOrder().toString()), property)); } Sort sort = new Sort(orders); return new PageRequest(page.getOffset().intValue(), page.getLimit().intValue(), sort); }  }
SpringUtil { public static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page) { List<Sort.Order> orders = new ArrayList<>(); for(OrderSpecifier orderSpecifier : orderSpecifiers) { String expressionPath = orderSpecifier.getTarget().toString(); String[] paths = expressionPath.split("\\."); String property = paths[paths.length - 1]; orders.add(new Sort.Order(Sort.Direction.valueOf(orderSpecifier.getOrder().toString()), property)); } Sort sort = new Sort(orders); return new PageRequest(page.getOffset().intValue(), page.getLimit().intValue(), sort); }  static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page); }
SpringUtil { public static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page) { List<Sort.Order> orders = new ArrayList<>(); for(OrderSpecifier orderSpecifier : orderSpecifiers) { String expressionPath = orderSpecifier.getTarget().toString(); String[] paths = expressionPath.split("\\."); String property = paths[paths.length - 1]; orders.add(new Sort.Order(Sort.Direction.valueOf(orderSpecifier.getOrder().toString()), property)); } Sort sort = new Sort(orders); return new PageRequest(page.getOffset().intValue(), page.getLimit().intValue(), sort); }  static Pageable toPageable(List<OrderSpecifier> orderSpecifiers, QueryModifiers page);  }