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


Java SortDirection.ASCENDING属性代码示例

本文整理汇总了Java中ch.ralscha.extdirectspring.bean.SortDirection.ASCENDING属性的典型用法代码示例。如果您正苦于以下问题:Java SortDirection.ASCENDING属性的具体用法?Java SortDirection.ASCENDING怎么用?Java SortDirection.ASCENDING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在ch.ralscha.extdirectspring.bean.SortDirection的用法示例。


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

示例1: createPageable

public static Pageable createPageable(ExtDirectStoreReadRequest request) {

		List<Order> orders = new ArrayList<>();
		for (SortInfo sortInfo : request.getSorters()) {

			if (sortInfo.getDirection() == SortDirection.ASCENDING) {
				orders.add(new Order(Direction.ASC, sortInfo.getProperty()));
			}
			else {
				orders.add(new Order(Direction.DESC, sortInfo.getProperty()));
			}
		}

		// Ext JS pages starts with 1, Spring Data starts with 0
		int page = Math.max(request.getPage() - 1, 0);

		if (orders.isEmpty()) {
			return new PageRequest(page, request.getLimit());
		}

		Sort sort = new Sort(orders);
		return new PageRequest(page, request.getLimit(), sort);

	}
 
开发者ID:ralscha,项目名称:eds-starter6-simple-mongodb,代码行数:24,代码来源:RepositoryUtil.java

示例2: createOrderSpecifiers

@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:ralscha,项目名称:eds-starter6-jpa,代码行数:39,代码来源:QuerydslUtil.java

示例3: addSorting

@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,代码行数:35,代码来源:BaseCRUDService.java

示例4: getSorts

public static List<Bson> getSorts(ExtDirectStoreReadRequest request) {
	List<Bson> sorts = new ArrayList<>();
	for (SortInfo sortInfo : request.getSorters()) {

		if (sortInfo.getDirection() == SortDirection.ASCENDING) {
			sorts.add(Sorts.ascending(sortInfo.getProperty()));
		}
		else {
			sorts.add(Sorts.descending(sortInfo.getProperty()));
		}
	}
	return sorts;
}
 
开发者ID:ralscha,项目名称:eds-starter6-mongodb,代码行数:13,代码来源:QueryUtil.java


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