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


Java OrderSpecifier类代码示例

本文整理汇总了Java中com.mysema.query.types.OrderSpecifier的典型用法代码示例。如果您正苦于以下问题:Java OrderSpecifier类的具体用法?Java OrderSpecifier怎么用?Java OrderSpecifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OrderSpecifier类属于com.mysema.query.types包,在下文中一共展示了OrderSpecifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluate

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
public void evaluate(String expression, QueryDslContext context, ParserConfig config) {
    List<Node> nodeList = Evaluator.parse(expression, config);
    for (Node node : nodeList) {
        if (node instanceof LogicalNode) {
            Predicate filter = node.accept(visitor, context);
            if (node instanceof OrNode) {
                context.addOr(filter);
            } else {
                context.addAnd(filter);
            }
        } else if (node instanceof FilterNode) {
            Predicate filterNode = node.accept(visitor, context);
            context.addAnd(filterNode);
        } else if (node instanceof OrderNode) {
            LinkedList order = (LinkedList<OrderSpecifier>) node.accept(visitor, context);
            context.setOrderSpecifiers(order);
        } else if (node instanceof LimitNode) {
            QueryModifiers modifiers = (QueryModifiers) (Object) node.accept(visitor, context);
            context.setQueryModifiers(modifiers);
        } else if (node instanceof ProjectionNode) {
            Expression projection = (QBean) node.accept(visitor, context);
            context.setProjection(projection);
        }
    }
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:26,代码来源:QueryDslEvaluator.java

示例2: createOrderSpecifier

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T, E extends Comparable<?>> OrderSpecifier<?> createOrderSpecifier(
        PathBuilder<T> entityPath, String fieldName, Class<E> fieldType,
        Order order) {
    OrderSpecifier<?> orderBy = null;

    // Get the OrderSpecifier
    if (order == Order.ASC) {
        orderBy = entityPath.getComparable(fieldName, fieldType).asc();
    }
    else if (order == Order.DESC) {
        orderBy = entityPath.getComparable(fieldName, fieldType).desc();
    }
    return orderBy;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:19,代码来源:QuerydslUtilsBeanImpl.java

示例3: getOrderSpecs

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
public static final List<OrderSpecifier<?>> getOrderSpecs(RelationalPathBase<?> pathBase, QueryExample example) {
    List<OrderSpecifier<?>> specifiers = new ArrayList<OrderSpecifier<?>>();
    List<Path<?>> columns = pathBase.getColumns();
    List<OrderBy> orderBies = example.getOrderBies();
    for (OrderBy orderBy : orderBies) {
        for (Path<?> path : columns) {
            if (checkColumn(path, orderBy.getField())) {
                if (path instanceof ComparableExpressionBase
                        && Comparable.class
                        .isAssignableFrom(path.getType())) {
                    specifiers.add(caseOrderBy(orderBy, (ComparableExpressionBase<? extends Comparable>) path));
                }
            }
        }
    }
    return specifiers;
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:QueryExampleHelper.java

示例4: caseOrderBy

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
/**
 * 设置排序
 *
 * @param orderBy        排序条件
 * @param expressionBase 排序字段
 * @return OrderSpecifier
 */
@SuppressWarnings("rawtypes")
private static OrderSpecifier<?> caseOrderBy(OrderBy orderBy,
                                             ComparableExpressionBase<? extends Comparable> expressionBase) {
    OrderSpecifier<?> specifier = null;
    switch (orderBy.getOrder()) {
        case ASC:
            specifier = expressionBase.asc();
            break;
        case DESC:
            specifier = expressionBase.desc();
            break;
        default:
            break;
    }
    return specifier;

}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:25,代码来源:QueryExampleHelper.java

示例5: parse

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
public JPAQuery parse(String expression, QueryDslContext context, ParserConfig config) {
    QueryDslEvaluator evaluator = new QueryDslEvaluator();
    evaluator.evaluate(expression, context, config);

    JPAQuery query = new JPAQuery(em)
            .from(context.getEntityPath());

    if (context.getPredicate() != null) {
        query.where(context.getPredicate());
    }

    if (context.getQueryModifiers() != null) {
        query.restrict(context.getQueryModifiers());
    }

    if (context.getOrderSpecifiers() != null && !context.getOrderSpecifiers().isEmpty()) {
        query.orderBy(context.getOrderSpecifiers().toArray(new OrderSpecifier[0]));
    }

    return query;
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:22,代码来源:JPAQueryDslParser.java

示例6: createOrderSpecifier

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
/**
 * Create an order-by-element in a Query instance
 * 
 * @param entityPath Full path to entity and associations. For example:
 *        {@code Pet} , {@code Pet.owner}
 * @param fieldName Property name in the given entity path. For example:
 *        {@code weight} in {@code Pet} entity, {@code age} in
 *        {@code Pet.owner} entity.
 * @param fieldType Property value {@code Class}. Must implements
 *        {@link Comparable}
 * @param order ascending or descending order
 * @return
 */
public static <T, E extends Comparable<?>> OrderSpecifier<?> createOrderSpecifier(
        PathBuilder<T> entityPath, String fieldName, Class<E> fieldType,
        Order order) {
    OrderSpecifier<?> orderBy = null;

    // Get the OrderSpecifier
    if (order == Order.ASC) {
        orderBy = entityPath.getComparable(fieldName, fieldType).asc();
    }
    else if (order == Order.DESC) {
        orderBy = entityPath.getComparable(fieldName, fieldType).desc();
    }
    return orderBy;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:28,代码来源:QuerydslUtils.java

示例7: addSorting

import com.mysema.query.types.OrderSpecifier; //导入依赖的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())));
			}

		}
	}
}
 
开发者ID:khun777,项目名称:edsutil,代码行数:36,代码来源:BaseCRUDService.java

示例8: createOrderSpecifiers

import com.mysema.query.types.OrderSpecifier; //导入依赖的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()]);
}
 
开发者ID:khun777,项目名称:edsutil,代码行数:40,代码来源:QueryUtil.java

示例9: addSpec

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
private void addSpec(final SQLQuery sqlQuery) {
    for (BooleanExpression expression : QueryExampleHelper.getExpressions(pathBase, example)) {
        sqlQuery.where(expression);
    }
    addLimit(example, sqlQuery);
    addOffset(example, sqlQuery);
    for (OrderSpecifier<?> spec : QueryExampleHelper.getOrderSpecs(pathBase, example)) {
        sqlQuery.orderBy(spec);
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:11,代码来源:CountTransaction.java

示例10: addSpec

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
private void addSpec(SQLQuery sqlQuery) {
    for (BooleanExpression expression : QueryExampleHelper.getExpressions(pathBase, example)) {
        sqlQuery.where(expression);
    }
    if (example.isDistinct()) {
        sqlQuery.distinct();
    }
    addLimit(example, sqlQuery);
    addOffset(example, sqlQuery);
    for (OrderSpecifier<?> spec : QueryExampleHelper.getOrderSpecs(pathBase, example)) {
        sqlQuery.orderBy(spec);
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:14,代码来源:QueryTransaction.java

示例11: sort

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
public void sort(OrderSpecifier<?>... order) {
    Object[] propertyId = new Object[order.length];
    boolean[] ascending = new boolean[order.length];
    for (int i = 0; i < order.length; i++) {
        propertyId[i] = ((Path)order[i].getTarget()).getMetadata().getName();
        ascending[i] = order[i].getOrder() == Order.ASC;
    }
    super.sort(propertyId, ascending);
}
 
开发者ID:mysema,项目名称:vaadin-querydsl-prototype,代码行数:10,代码来源:QuerydslJPAContainer.java

示例12: createOrderSpec

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
private OrderSpecifier<?> createOrderSpec(SortParam sort) {

		SortBy sortBy = EnumCodeUtil.getCodeMap(SortBy.class, SortBy.ID).get(sort.getBy());

		ComparableExpressionBase<?> sortKey;
		if (sortBy == SortBy.ID) {
			sortKey = et1.id;
		} else if (sortBy == SortBy.TEXT10) {
			sortKey = et1.text10;
		} else if (sortBy == SortBy.INT64) {
			sortKey = et1.int64;
		} else if (sortBy == SortBy.DECIMAL1) {
			sortKey = et1.decimal1;
		} else if (sortBy == SortBy.DECIMAL3) {
			sortKey = et1.decimal3;
		} else if (sortBy == SortBy.DT) {
			sortKey = et1.dt;
		} else if (sortBy == SortBy.TM) {
			sortKey = et1.tm;
		} else if (sortBy == SortBy.DTM) {
			sortKey = et1.dtm;
		} else {
			sortKey = et1.id;
		}

		if (sort.getOrder() == SortOrder.ASC) {
			return sortKey.asc();
		} else if (sort.getOrder() == SortOrder.DESC) {
			return sortKey.desc();
		} else {
			return sortKey.asc();
		}
	}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:34,代码来源:BasicEx40ServiceImpl.java

示例13: orderBy

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
private OrderSpecifier<Integer> orderBy(List<Long> id) {
	Cases<Integer, NumberExpression<Integer>> cases = null;
	for (int i = 0; i < id.size(); i++) {
		if (cases == null) {
			cases = cases().when(et1.id.eq(id.get(i))).then(i);
		} else {
			cases = cases.when(et1.id.eq(id.get(i))).then(i);
		}
	}
	return cases.otherwise(id.size()).asc();
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:12,代码来源:BasicEx61ServiceImpl.java

示例14: orderBy

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
@Override
public Q orderBy(OrderSpecifier<?>... o) {
	return queryMixin.orderBy(o);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:5,代码来源:AbstractAsyncSQLQuery.java

示例15: getPaginatedResult

import com.mysema.query.types.OrderSpecifier; //导入依赖的package包/类
@Override
public Page<Tuple> getPaginatedResult(QueryParameters parameters, JPAQuery jpaQuery, Expression<?>... args) {
	Optional<OrderSpecifier> orderSpecifier = getOrderSpecifier(parameters, args);
	if (orderSpecifier.isPresent()) {
		jpaQuery.orderBy(orderSpecifier.get());
	}
	List<Tuple> result = jpaQuery.offset(parameters.getDisplayStart()).limit(parameters.getSize()).list(args);
	return new PageImpl<>(result, pageableFactory.getPageable(parameters), jpaQuery.count());
}
 
开发者ID:fernaspiazu,项目名称:recruiting-old-style,代码行数:10,代码来源:PaginationServiceImpl.java


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