Java Code Examples for com.querydsl.core.types.Order#ASC

The following examples show how to use com.querydsl.core.types.Order#ASC . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuerydslQueryBackend.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example 2
Source File: QuerydslQueryBackend.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
@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);
	}
}
 
Example 3
Source File: QuerydslUtil.java    From eds-starter6-jpa with Apache License 2.0 5 votes vote down vote up
@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()]);
}