当前位置: 首页>>代码示例>>Java>>正文


Java OrderSpecifier类代码示例

本文整理汇总了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;
}
 
开发者ID:egopulse,项目名称:querydsl-rethinkdb,代码行数:26,代码来源:ReqlSerializingHelper.java

示例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());
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:19,代码来源:QuerydslSortContextTest.java

示例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());
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:20,代码来源:QuerydslSortContextTest.java

示例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()]);
}
 
开发者ID:spring-projects,项目名称:spring-data-keyvalue,代码行数:27,代码来源:KeyValueQuerydslUtils.java

示例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);
}
 
开发者ID:ssaarela,项目名称:javersion,代码行数:17,代码来源:AbstractVersionStoreJdbc.java

示例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);
	}
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:10,代码来源:QuerydslQueryBackend.java

示例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")));
        }
    }
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:13,代码来源:RequirementSearchQueryFactory.java

示例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);
}
 
开发者ID:Coreoz,项目名称:Plume,代码行数:8,代码来源:CrudDaoHibernate.java

示例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);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:14,代码来源:SpringUtil.java

示例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);
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:15,代码来源:QuerydslSortBuilder.java

示例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());

}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:29,代码来源:MongoDaoTest.java

示例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--;
    }
}
 
开发者ID:vineey,项目名称:archelix-rsql,代码行数:32,代码来源:MongoDaoTest.java

示例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();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:11,代码来源:AbstractEntityDaoImpl.java

示例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();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:13,代码来源:JpaDaoSupport.java

示例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;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:JpaDaoSupport.java


注:本文中的com.querydsl.core.types.OrderSpecifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。