本文整理汇总了Java中com.querydsl.core.types.Order类的典型用法代码示例。如果您正苦于以下问题:Java Order类的具体用法?Java Order怎么用?Java Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Order类属于com.querydsl.core.types包,在下文中一共展示了Order类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortToOrderSpecifier_Ascending
import com.querydsl.core.types.Order; //导入依赖的package包/类
@Test
public void sortToOrderSpecifier_Ascending() {
String sortExpression = "sort(+employeeNumber)";
DefaultSortParser sortParser = new DefaultSortParser();
Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
.put("employeeNumber", QEmployee.employee.employeeNumber)
.build();
OrderSpecifierList orderSpecifierList = sortParser.parse(sortExpression, QuerydslSortContext.withMapping(mappings));
assertNotNull(orderSpecifierList);
List<OrderSpecifier> orderSpecifiers = orderSpecifierList.getOrders();
assertNotNull(orderSpecifiers);
assertEquals(1, orderSpecifiers.size());
OrderSpecifier orderSpecifier = orderSpecifiers.get(0);
assertEquals(Order.ASC, orderSpecifier.getOrder());
assertEquals(QEmployee.employee.employeeNumber, orderSpecifier.getTarget());
}
示例2: sortToOrderSpecifier_Descending
import com.querydsl.core.types.Order; //导入依赖的package包/类
@Test
public void sortToOrderSpecifier_Descending() {
String sortExpression = "sort(-employee.id)";
DefaultSortParser sortParser = new DefaultSortParser();
Map<String, Path> mappings = ImmutableMap.<String, Path>builder()
.put("employee.id", QEmployee.employee.employeeNumber)
.build();
OrderSpecifierList orderSpecifierList = sortParser.parse(sortExpression, QuerydslSortContext.withMapping(mappings));
assertNotNull(orderSpecifierList);
List<OrderSpecifier> orderSpecifiers = orderSpecifierList.getOrders();
assertNotNull(orderSpecifiers);
assertEquals(1, orderSpecifiers.size());
OrderSpecifier orderSpecifier = orderSpecifiers.get(0);
assertEquals(Order.DESC, orderSpecifier.getOrder());
assertEquals(QEmployee.employee.employeeNumber, orderSpecifier.getTarget());
}
示例3: newSort
import com.querydsl.core.types.Order; //导入依赖的package包/类
@Override
public OrderSpecifier<?> newSort(Expression<?> expr, Direction dir) {
if (dir == Direction.ASC) {
return new OrderSpecifier(Order.ASC, expr);
}
else {
return new OrderSpecifier(Order.DESC, expr);
}
}
示例4: appendOrder
import com.querydsl.core.types.Order; //导入依赖的package包/类
private void appendOrder() {
if (quickFilter.getSortProperty() != null) {
Order order = quickFilter.isAscending() ? Order.ASC : Order.DESC;
query.orderBy(new OrderSpecifier<>(order, Expressions.stringPath(quickFilter.getSortProperty())));
} else if (!Boolean.TRUE.equals(ctx.getCount())) {
if (quickFilter.isRascunho()) {
query.orderBy(new OrderSpecifier<>(Order.ASC, Expressions.stringPath("creationDate")));
} else {
query.orderBy(new OrderSpecifier<>(Order.ASC, Expressions.stringPath("processBeginDate")));
}
}
}
示例5: visit
import com.querydsl.core.types.Order; //导入依赖的package包/类
@Override
public OrderSpecifierList visit(SortNodeList node, QuerydslSortParam filterParam) {
List<SortNode> sortNodes = node.getNodes();
List<OrderSpecifier> orderSpecifiers = new ArrayList<>();
Map<String, Path> mapping = filterParam.getMapping();
for(SortNode sortNode : sortNodes){
Order order = SortNode.Order.DESC.equals(sortNode.getOrder()) ? Order.DESC : Order.ASC;
Path path = mapping.get(sortNode.getField());
OrderSpecifier orderSpecifier = new OrderSpecifier(order, path);
orderSpecifiers.add(orderSpecifier);
}
return new OrderSpecifierList(orderSpecifiers);
}
示例6: createOrderSpecifiers
import com.querydsl.core.types.Order; //导入依赖的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()]);
}
示例7: lockEntitiesForUpdate
import com.querydsl.core.types.Order; //导入依赖的package包/类
protected Map<Id, Long> lockEntitiesForUpdate(EntityStoreOptions<Id, M, V> options, Collection<Id> docIds) {
return options.queryFactory
.from(options.entity)
.where(predicate(IN, options.entity.id, constant(docIds)))
.orderBy(new OrderSpecifier<>(Order.ASC, options.entity.id))
.forUpdate()
.transform(groupBy(options.entity.id).as(maxLocalOrdinalByEntity(options)));
}
示例8: applyPagination
import com.querydsl.core.types.Order; //导入依赖的package包/类
/**
* Applies the given {@link Pageable} to the given {@link JPQLQuery}.
* Allows to map the attributes to order as provided in the {@link Pageable}
* to real entity attributes. This might be used to work with projections
* or DTOs whose attributes don't have the same name as the entity ones.
*
* It allows to map to more than one entity attribute. As an example, if
* the DTO used to create the {@link Pageable} has a fullName attribute, you
* could map that attribute to two entity attributes: name and surname.
* In this case, the {@link Pageable} defines an order by a fullName
* attribute, but que query will order by name and surname instead.
*
* @param pageable the ordering and paging
* @param query
* @param attributeMapping definition of a mapping of order attribute names
* to real entity ones
* @return the updated query
*/
protected JPQLQuery<T> applyPagination(Pageable pageable, JPQLQuery<T> query,
Map<String, Path<?>[]> attributeMapping) {
if (pageable == null) {
return query;
}
Pageable mappedPageable;
Sort sort = pageable.getSort();
if (sort != null) {
List<Sort.Order> mappedOrders = new ArrayList<Sort.Order>();
for (Sort.Order order : sort) {
if (!attributeMapping.containsKey(order.getProperty())) {
LOG.warn(
"The property (%1) is not included in the attributeMapping, will order "
+ "using the property as it is",
order.getProperty());
mappedOrders.add(order);
} else {
Path<?>[] paths = attributeMapping.get(order.getProperty());
for (Path<?> path : paths) {
Sort.Order mappedOrder =
new Sort.Order(order.getDirection(), preparePropertyPath(path));
mappedOrders.add(mappedOrder);
}
}
}
if (mappedOrders.isEmpty()) {
// No properties to order by are available, so don't apply ordering and return the query
// as it is
return query;
}
mappedPageable =
new PageRequest(pageable.getPageNumber(), pageable.getPageSize(), new Sort(mappedOrders));
return applyPagination(mappedPageable, query);
} else {
return applyPagination(pageable, query);
}
}
示例9: applyOrderById
import com.querydsl.core.types.Order; //导入依赖的package包/类
/**
* Adds to a query an order by the entity identifier related to this repository.
* This is useful as the default last order in queries where pagination is
* applied, so you have always an absolute order. Otherwise, the order
* of the results depends on the database criteria, which might change
* even between pages, returning confusing results for the user.
* @param query
* @return the updated query
*/
@SuppressWarnings({"rawtypes", "unchecked"})
protected JPQLQuery<T> applyOrderById(JPQLQuery<T> query) {
PathBuilder<Object> idPath = getEntityId();
return query.orderBy(new OrderSpecifier(Order.ASC, idPath, NullHandling.NullsFirst));
}