本文整理汇总了Java中ch.ralscha.extdirectspring.bean.SortDirection.ASCENDING属性的典型用法代码示例。如果您正苦于以下问题:Java SortDirection.ASCENDING属性的具体用法?Java SortDirection.ASCENDING怎么用?Java SortDirection.ASCENDING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类ch.ralscha.extdirectspring.bean.SortDirection
的用法示例。
在下文中一共展示了SortDirection.ASCENDING属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPageable
public static Pageable createPageable(ExtDirectStoreReadRequest request) {
List<Order> orders = new ArrayList<>();
for (SortInfo sortInfo : request.getSorters()) {
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
orders.add(new Order(Direction.ASC, sortInfo.getProperty()));
}
else {
orders.add(new Order(Direction.DESC, sortInfo.getProperty()));
}
}
// Ext JS pages starts with 1, Spring Data starts with 0
int page = Math.max(request.getPage() - 1, 0);
if (orders.isEmpty()) {
return new PageRequest(page, request.getLimit());
}
Sort sort = new Sort(orders);
return new PageRequest(page, request.getLimit(), sort);
}
示例2: createOrderSpecifiers
@SuppressWarnings({ "rawtypes", "unchecked" })
public static OrderSpecifier[] createOrderSpecifiers(
ExtDirectStoreReadRequest request, Class<?> clazz,
EntityPathBase<?> entityPathBase, Map<String, String> mapGuiColumn2Dbfield,
Set<String> sortIgnoreProperties) {
List<OrderSpecifier> orders;
if (!request.getSorters().isEmpty()) {
orders = new ArrayList<>();
PathBuilder<?> entityPath = new PathBuilder<>(clazz,
entityPathBase.getMetadata());
for (SortInfo sortInfo : request.getSorters()) {
if (!sortIgnoreProperties.contains(sortInfo.getProperty())) {
Order order;
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
order = Order.ASC;
}
else {
order = Order.DESC;
}
String property = mapGuiColumn2Dbfield.get(sortInfo.getProperty());
if (property == null) {
property = sortInfo.getProperty();
}
orders.add(new OrderSpecifier(order, entityPath.get(property)));
}
}
}
else {
orders = Collections.emptyList();
}
return orders.toArray(new OrderSpecifier[orders.size()]);
}
示例3: addSorting
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addSorting(ExtDirectStoreReadRequest request, JPQLQuery query,
PathBuilder<?> pathBuilder) {
Class<?> clazz = getTypeClass();
if (!request.getSorters().isEmpty()) {
for (SortInfo sortInfo : request.getSorters()) {
Order order;
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
order = Order.ASC;
}
else {
order = Order.DESC;
}
Field field = ReflectionUtils.findField(clazz, sortInfo.getProperty());
SortProperty sortProperty = field.getAnnotation(SortProperty.class);
if (sortProperty != null) {
String[] splittedValue = sortProperty.value().split("\\.");
field = ReflectionUtils.findField(clazz, splittedValue[0]);
PathBuilder path = new PathBuilder(field.getType(), splittedValue[0]);
query.leftJoin(pathBuilder.get(splittedValue[0]), path);
query.orderBy(new OrderSpecifier(order, path.get(splittedValue[1])));
}
else {
query.orderBy(new OrderSpecifier(order, pathBuilder.get(sortInfo
.getProperty())));
}
}
}
}
示例4: getSorts
public static List<Bson> getSorts(ExtDirectStoreReadRequest request) {
List<Bson> sorts = new ArrayList<>();
for (SortInfo sortInfo : request.getSorters()) {
if (sortInfo.getDirection() == SortDirection.ASCENDING) {
sorts.add(Sorts.ascending(sortInfo.getProperty()));
}
else {
sorts.add(Sorts.descending(sortInfo.getProperty()));
}
}
return sorts;
}