本文整理汇总了Java中ch.ralscha.extdirectspring.bean.SortDirection类的典型用法代码示例。如果您正苦于以下问题:Java SortDirection类的具体用法?Java SortDirection怎么用?Java SortDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortDirection类属于ch.ralscha.extdirectspring.bean包,在下文中一共展示了SortDirection类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPageable
import ch.ralscha.extdirectspring.bean.SortDirection; //导入依赖的package包/类
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
import ch.ralscha.extdirectspring.bean.SortDirection; //导入依赖的package包/类
@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
import ch.ralscha.extdirectspring.bean.SortDirection; //导入依赖的package包/类
@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
import ch.ralscha.extdirectspring.bean.SortDirection; //导入依赖的package包/类
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;
}