本文整理汇总了Java中com.querydsl.core.types.OrderSpecifier类的典型用法代码示例。如果您正苦于以下问题:Java OrderSpecifier类的具体用法?Java OrderSpecifier怎么用?Java OrderSpecifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OrderSpecifier类属于com.querydsl.core.types包,在下文中一共展示了OrderSpecifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reql
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
public static ReqlExpr reql(Table table, QueryMixin<?> queryMixin) {
ReqlExpr query = table;
Predicate whereClause = queryMixin.getMetadata().getWhere();
if (whereClause != null) {
query = query.filter(reql(queryMixin.getMetadata().getWhere()));
}
Long limit = queryMixin.getMetadata().getModifiers().getLimit();
if (limit != null) {
query = query.limit(limit);
}
Long offset = queryMixin.getMetadata().getModifiers().getOffset();
if (offset != null) {
query = query.skip(offset);
}
List<OrderSpecifier<?>> orderBys = queryMixin.getMetadata().getOrderBy();
if (!orderBys.isEmpty()) {
query = serializer.toSort(orderBys, query);
}
return query;
}
示例2: sortToOrderSpecifier_Ascending
import com.querydsl.core.types.OrderSpecifier; //导入依赖的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());
}
示例3: sortToOrderSpecifier_Descending
import com.querydsl.core.types.OrderSpecifier; //导入依赖的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());
}
示例4: toOrderSpecifier
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
/**
* Transforms a plain {@link Order} into a QueryDsl specific {@link OrderSpecifier}.
*
* @param sort must not be {@literal null}.
* @param builder must not be {@literal null}.
* @return empty {@code OrderSpecifier<?>[]} when sort is {@literal null}.
*/
static OrderSpecifier<?>[] toOrderSpecifier(Sort sort, PathBuilder<?> builder) {
Assert.notNull(sort, "Sort must not be null.");
Assert.notNull(builder, "Builder must not be null.");
List<OrderSpecifier<?>> specifiers = null;
if (sort instanceof QSort) {
specifiers = ((QSort) sort).getOrderSpecifiers();
} else {
specifiers = new ArrayList<>();
for (Order order : sort) {
specifiers.add(toOrderSpecifier(order, builder));
}
}
return specifiers.toArray(new OrderSpecifier<?>[specifiers.size()]);
}
示例5: fetchVersionsAndParents
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
protected List<Group> fetchVersionsAndParents(boolean optimized, BooleanExpression predicate, OrderSpecifier<?> orderBy) {
SQLQuery<?> qry = options.queryFactory
.from(options.version)
.where(predicate)
.orderBy(orderBy);
if (optimized) {
qry.leftJoin(options.parent).on(options.parent.revision.eq(options.version.revision), options.parent.status.goe(ACTIVE));
qry.where(options.version.status.goe(ACTIVE));
} else {
qry.leftJoin(options.parent).on(options.parent.revision.eq(options.version.revision), options.parent.status.loe(ACTIVE));
qry.where(options.version.status.loe(ACTIVE));
}
return qry.transform(versionAndParents);
}
示例6: newSort
import com.querydsl.core.types.OrderSpecifier; //导入依赖的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);
}
}
示例7: appendOrder
import com.querydsl.core.types.OrderSpecifier; //导入依赖的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")));
}
}
}
示例8: CrudDaoHibernate
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
public CrudDaoHibernate(EntityPathBase<T> queryDslEntity, TransactionManagerHibernate transactionManager, OrderSpecifier<?> defaultOrder) {
this.queryDslEntity = queryDslEntity;
this.transactionManager = transactionManager;
this.defaultOrder = defaultOrder;
this.idPath = new IdPath(queryDslEntity);
}
示例9: toPageable
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
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);
}
示例10: visit
import com.querydsl.core.types.OrderSpecifier; //导入依赖的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);
}
示例11: rqlMongo
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
@Test
@UsingDataSet(locations = {"/testData.json"}, loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void rqlMongo() {
String rqlFilter = "contact.name == 'A*'";
String limit = "limit(0, 10)";
String sort = "sort(+contact.id)";
RqlInput rqlInput = new RqlInput()
.setFilter(rqlFilter)
.setLimit(limit)
.setSort(sort);
QuerydslRqlParser querydslRqlParser = new DefaultQuerydslRqlParser();
QuerydslMappingResult querydslMappingResult = querydslRqlParser.parse(rqlInput, new QuerydslMappingParam().setRootPath(user).setPathMapping(ContactMongoDao.PATH_MAP));
QueryModifiers page = querydslMappingResult.getPage();
List<OrderSpecifier> orderSpecifiers = querydslMappingResult.getOrderSpecifiers();
Page<Contact> contactPage = contactMongoDao.findAll(querydslMappingResult.getPredicate(), SpringUtil.toPageable(orderSpecifiers, page));
List<Contact> contactList = contactPage.getContent();
assertNotNull(contactList);
assertEquals(1, contactList.size());
assertEquals(1L, contactList.get(0).getId().longValue());
}
示例12: rqlMongoAll
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
@Test
@UsingDataSet(locations = "/testData.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void rqlMongoAll() {
String limit = "limit(0, 10)";
String sort = "sort(-contact.id)";
RqlInput rqlInput = new RqlInput()
.setLimit(limit)
.setSort(sort);
QuerydslRqlParser querydslRqlParser = new DefaultQuerydslRqlParser();
QuerydslMappingResult querydslMappingResult = querydslRqlParser.parse(rqlInput, new QuerydslMappingParam().setRootPath(user).setPathMapping(ContactMongoDao.PATH_MAP));
List<OrderSpecifier> orderSpecifiers = querydslMappingResult.getOrderSpecifiers();
QueryModifiers page = querydslMappingResult.getPage();
Page<Contact> contactPage = contactMongoDao.findAll(SpringUtil.toPageable(orderSpecifiers, page));
List<Contact> contacts = contactPage.getContent();
assertNotNull(contacts);
assertEquals(3, contacts.size());
long id = 3L;
for (Contact contact : contacts) {
assertEquals(id, contact.getId().longValue());
assertTrue(StringUtils.isNotEmpty(contact.getName()));
assertTrue(StringUtils.isNotEmpty(contact.getEmail()));
assertTrue(StringUtils.isNotEmpty(contact.getAddress()));
assertNotNull(contact.getGender());
assertNotNull(contact.getAge());
id--;
}
}
示例13: list
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
protected <T extends E> List<T> list(EntityPath<T> entityPath, Long limit, Long offset) {
OrderSpecifier<?> order = null;
if (GenericEntity.class.isAssignableFrom(entityPath.getType())) {
// cast possible puisqu'on vient de vérifier le type de objectclass
@SuppressWarnings("unchecked")
QGenericEntity qGenericEntity = new QGenericEntity((Path<? extends GenericEntity<?, ?>>) (Object) entityPath);
order = qGenericEntity.id.asc();
}
return queryByPredicateOrdered(entityPath, null, limit, offset, order).fetch();
}
示例14: listEntity
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
public <T> List<T> listEntity(Class<T> objectClass) {
PathBuilder<T> pathBuilder = new PathBuilder<T>(objectClass, "rootAlias");
OrderSpecifier<?> order = null;
if (GenericEntity.class.isAssignableFrom(objectClass)) {
// cast possible puisqu'on vient de vérifier le type de objectclass
@SuppressWarnings("unchecked")
QGenericEntity qGenericEntity = new QGenericEntity((Path<? extends GenericEntity<?, ?>>) (Object) pathBuilder);
order = qGenericEntity.id.asc();
}
return queryByPredicateOrdered(pathBuilder, null, order).fetch();
}
示例15: queryByPredicateOrdered
import com.querydsl.core.types.OrderSpecifier; //导入依赖的package包/类
protected <T> JPAQuery<T> queryByPredicateOrdered(EntityPath<T> entityPath, Predicate predicate, Long limit, Long offset, OrderSpecifier<?>... orderSpecifiers) {
JPAQuery<T> query = queryByPredicate(entityPath, predicate, limit, offset);
if (orderSpecifiers != null && orderSpecifiers.length > 0) {
query.orderBy(orderSpecifiers);
}
return query;
}