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


Java Order类代码示例

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


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

示例1: getPageable

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
/**
 * Creates a 'LIMIT .. OFFSET .. ORDER BY ..' clause for the given
 * {@link DataTablesInput}.
 * 
 * @param input
 *            the {@link DataTablesInput} mapped from the Ajax request
 * @return a {@link Pageable}, must not be {@literal null}.
 */
@Transactional
private Pageable getPageable(DataTablesInput input) {

	List<Order> orders = new ArrayList<Order>();
	for (OrderParameter order : input.getOrder()) {
		log.debug("order column: " + order.getColumn() + "");
		ColumnParameter column = input.getColumns().get(order.getColumn());
		if (column.getOrderable()) {
			String sortColumn = column.getData();
			Direction sortDirection = Direction.fromString(order.getDir());
			orders.add(new Order(sortDirection, sortColumn));
		}
	}
	Sort sort = orders.isEmpty() ? null : new Sort(orders);
	if (input.getLength() == -1) {
		input.setStart(0);
		input.setLength(Integer.MAX_VALUE);
	}

	return new PageRequest(input.getStart() / input.getLength(), input.getLength(), sort);
}
 
开发者ID:TransparencyInternationalEU,项目名称:lobbycal,代码行数:30,代码来源:CalendarDTRepositoryImpl.java

示例2: orderByExpression

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
protected String orderByExpression(Sort sort) {
    final String noSort = "";

    if (sort == null || !sort.iterator().hasNext()) {
        return noSort;
    }
    StringBuilder sb = new StringBuilder(" ORDER BY ");

    for (Iterator<Order> it = sort.iterator(); it.hasNext(); ) {
        Order order = it.next();
        sb.append(order.getProperty()).append(' ').append(order.getDirection());
        if (it.hasNext()) {
            sb.append(COMMA);
        }
    }
    return sb.toString();
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:18,代码来源:DefaultSqlGenerator.java

示例3: findAll

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
/**
 * 方法名 : findAll
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @return
 * 参 考 : @see tk.ainiyue.admin.roles.service.SysRolesService#findAll()
 * 作 者 : Tenghui.Wang
 */

@Override
public Page<SysSeedInfo> findAll(int pageNumber, int pageSize, String searchText) {
	Sort sort = new Sort(new Order(Direction.DESC, "seedName"));
	PageRequest request = this.buildPageRequest(pageNumber, pageSize, sort);
	Page<SysSeedInfo> sourceCodes = null;
	if (searchText == null || "".equals(searchText)) {
		sourceCodes = sysSeedDao.findAll(request);
	} else {
		SysSeedInfo info = new SysSeedInfo();
		info.setSeedName(searchText);
		Example<SysSeedInfo> example = Example.of(info);
		sourceCodes = sysSeedDao.findAll(example, request);
	}
	return sourceCodes;
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:24,代码来源:SysSeedServiceImpl.java

示例4: getActiveUserStoriesByProjectNameTest

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Test
public void getActiveUserStoriesByProjectNameTest() {

    DashboardDTO dashboard = TestObjectFactory.createDashboard();

    Feature story1 = TestObjectFactory.createActiveStory();
    Feature story2 = TestObjectFactory.createActiveStory();

    List<Feature> stories = new ArrayList<>();
    stories.add(story1);
    stories.add(story2);

    when(featureRepository.findActiveUserStoriesByBoards(Arrays.asList(dashboard.getName()),
            new Sort(new Order("sStatus")))).thenReturn(stories);

    List<Feature> activeStoriesByDashboardName
            = featureService.getActiveUserStoriesByBoards(Arrays.asList(dashboard.getName()));
    verify(featureRepository, times(1))
            .findActiveUserStoriesByBoards(Arrays.asList(dashboard.getName()), new Sort(new Order("sStatus")));

    assertThat(activeStoriesByDashboardName.get(0)).isEqualTo(story1);
    assertThat(activeStoriesByDashboardName.get(1)).isEqualTo(story2);
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:24,代码来源:FeatureServiceTests.java

示例5: getOrdes

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
public static <T> List<Order> getOrdes(String orderBy) {
	if (StringUtils.isEmpty(orderBy)) {
		return Collections.emptyList();
	}
	String[] groups = orderBy.trim().split(",");
	List<Order> orders = new ArrayList<Order>(groups.length);
	for (String group : groups) {
		boolean ascending = true;
		String[] array = group.split("\\s", 2);
		String property = array[0];
		if (array.length > 1) {
			ascending ="asc".equalsIgnoreCase(array[0]);;
		}
		Order order = new Order(ascending ? Direction.ASC : Direction.DESC, property);
		orders.add(order);
	}
	return orders;
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:19,代码来源:MongoQueryFormHelper.java

示例6: createSpringSort

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
private <T, F> Sort createSpringSort(Query<T, F> q) {
    List<QuerySortOrder> sortOrders;
    if (q.getSortOrders().isEmpty()) {
        sortOrders = getDefaultSortOrders();
    } else {
        sortOrders = q.getSortOrders();
    }
    List<Order> orders = sortOrders.stream()
            .map(PageableDataProvider::queryOrderToSpringOrder)
            .collect(Collectors.toList());
    if (orders.isEmpty()) {
        return null;
    } else {
        return new Sort(orders);
    }
}
 
开发者ID:Artur-,项目名称:spring-data-provider,代码行数:17,代码来源:PageableDataProvider.java

示例7: apply

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Override
public SortOptions apply(Query<?> query) {
    SortOptions.Builder sortOptions = SortOptions.newBuilder();

    query.getSort().ifPresent(sort -> {
        for (Order order : sort) {
            SearchFieldMetadata searchFieldMetadata = searchMetadata.getField(query.getResultType(), order.getProperty());

            SortExpression.Builder expression = SortExpression.newBuilder()
                    .setExpression(searchFieldMetadata.getEncodedName())
                    .setDirection(order.getDirection().isAscending() ? ASCENDING : DESCENDING);

            applyDefaultValue(order, searchFieldMetadata.getIndexType(), expression);

            sortOptions.addSortExpression(expression.build());
        }
    });

    return sortOptions.build();
}
 
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:21,代码来源:SortOptionsCompiler.java

示例8: should_sort_health_responses

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Test
public void should_sort_health_responses() {
    // GIVEN
    Sort sort = new Sort(
            new Order(ASC, "status"),
            new Order(DESC, "totalTimeMillis"),
            new Order(ASC, "service")
    );

    // WHEN
    Comparator<HealthResponse> comparator = sortCompare.getComparator(sort);
    List<HealthResponse> sorted = ImmutableList.sortedCopyOf(comparator, givenHealthResponses());

    // THEN
    then(sorted).extracting(HealthResponse::getService).containsExactly("E", "D", "C", "B", "A");
}
 
开发者ID:ePages-de,项目名称:spring-boot-readiness,代码行数:17,代码来源:SortCompareTest.java

示例9: getPageable

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
public Pageable getPageable(Map<String, String> requestParams) {
	int page = RequestUtil.getInteger(requestParams, "pageNum", 1) - 1;
	int size = RequestUtil.getInteger(requestParams, "pageSize", 10);
	String[] orders = RequestUtil.getArray(requestParams, "sortOrder");
	String[] sorts = RequestUtil.getArray(requestParams, "sortName");

	List<Order> sortOrders = new ArrayList<Order>();
	for (int i = 0; i < sorts.length; i++) {
		String sort = sorts[i];
		String order = orders[i];
		if (order.equals("asc")) {
			sortOrders.add(new Order(Direction.ASC, sort));
		} else if (order.equals("desc")) {
			sortOrders.add(new Order(Direction.DESC, sort));
		} else {
			throw new IllegalArgumentException("Value for param 'order' is not valid : '" + order + "', must be 'asc' or 'desc'");
		}
	}

	if (sortOrders.isEmpty()) {
		return new PageRequest(page, size);
	} else {
		return new PageRequest(page, size, new Sort(sortOrders));
	}
}
 
开发者ID:wengwh,项目名称:plumdo-work,代码行数:26,代码来源:BaseResource.java

示例10: sortQuery

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
private Query<T> sortQuery(Query<T> query, Sort sort){
    if (sort == null){
        return query;
    }
    
    Order order;
    for (Iterator<Order> iter=sort.iterator(); iter.hasNext(); ){
        order=iter.next();
        String condition = order.getProperty();
        if (order.getDirection().isDescending()){
            condition = "-" + condition;
        }
        query = query.order(condition);
    }
    
    return query;
}
 
开发者ID:nhuttrung,项目名称:spring-data-objectify,代码行数:18,代码来源:SimpleObjectifyRepository.java

示例11: toSpringDataPageable

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
public <T> Pageable toSpringDataPageable(
		PaginacioParamsDto dto,
		Map<String, String> mapeigPropietatsOrdenacio) {
	List<Order> orders = new ArrayList<Order>();
	if (dto.getOrdres() != null) {
		for (OrdreDto ordre: dto.getOrdres()) {
			Direction direccio = OrdreDireccioDto.DESCENDENT.equals(ordre.getDireccio()) ? Sort.Direction.DESC : Sort.Direction.ASC;
			String propietat = ordre.getCamp();
			if (mapeigPropietatsOrdenacio != null) {
				String mapeig = mapeigPropietatsOrdenacio.get(ordre.getCamp());
				if (mapeig != null)
					propietat = mapeig;
			} else {
				propietat = ordre.getCamp();
			}
			orders.add(new Order(
					direccio,
					propietat));
		}
	}
	return new PageRequest(
			dto.getPaginaNum(),
			dto.getPaginaTamany(),
			new Sort(orders));
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:26,代码来源:PaginacioHelper.java

示例12: findAll

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Override
public Map<String, Object> findAll(int pageNumber) {
    logger.debug("Finding all valueSets with paging");
    Sort sort = new Sort(new Order(Direction.ASC, "code"));
    PageRequest pageRequest = new PageRequest(pageNumber,
            VALUE_SET_PAGE_SIZE, sort);

    Page<ValueSet> valueSets = valueSetRepository.findAll(pageRequest);

    Map<String, Object> pageResultsMap = new HashMap<String, Object>();
    pageResultsMap.put("valueSets",
            setDeletableToValueSetDto((valueSets.getContent())));
    pageResultsMap.put("totalNumberOfValueSets",
            valueSets.getTotalElements());
    pageResultsMap.put("totalPages", valueSets.getTotalPages());
    pageResultsMap.put("itemsPerPage", valueSets.getSize());
    pageResultsMap.put("currentPage", valueSets.getNumber());
    pageResultsMap.put("numberOfElements", valueSets.getNumberOfElements());

    return pageResultsMap;
}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:22,代码来源:ValueSetServiceImpl.java

示例13: findAllByName

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Override
public Map<String, Object> findAllByName(String searchTerm,
                                         String valueSetCategory, int pageNumber) {

    Sort sort = new Sort(new Order(Direction.ASC, "code"));
    PageRequest pageRequest = new PageRequest(pageNumber,
            VALUE_SET_PAGE_SIZE, sort);

    Page<ValueSet> pagedValueSets = valueSetRepository.findAllByNameLike(
            "%" + searchTerm + "%", "%" + valueSetCategory + "%",
            pageRequest);

    Map<String, Object> pageResultsMap = new HashMap<String, Object>();
    pageResultsMap.put("valueSets",
            setDeletableToValueSetDto(pagedValueSets.getContent()));
    pageResultsMap.put("totalNumberOfValueSets",
            pagedValueSets.getTotalElements());
    pageResultsMap.put("totalPages", pagedValueSets.getTotalPages());
    pageResultsMap.put("itemsPerPage", pagedValueSets.getSize());
    pageResultsMap.put("currentPage", pagedValueSets.getNumber());
    pageResultsMap.put("numberOfElements",
            pagedValueSets.getNumberOfElements());

    return pageResultsMap;

}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:27,代码来源:ValueSetServiceImpl.java

示例14: findAllByCode

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Override
public Map<String, Object> findAllByCode(String searchTerm,
                                         String valueSetCategory, int pageNumber) {

    Sort sort = new Sort(new Order(Direction.ASC, "code"));
    PageRequest pageRequest = new PageRequest(pageNumber,
            VALUE_SET_PAGE_SIZE, sort);

    Page<ValueSet> pagedValueSets = valueSetRepository.findAllByCodeLike(
            "%" + searchTerm + "%", "%" + valueSetCategory + "%",
            pageRequest);

    Map<String, Object> pageResultsMap = new HashMap<String, Object>();
    pageResultsMap.put("valueSets",
            setDeletableToValueSetDto(pagedValueSets.getContent()));
    pageResultsMap.put("totalNumberOfValueSets",
            pagedValueSets.getTotalElements());
    pageResultsMap.put("totalPages", pagedValueSets.getTotalPages());
    pageResultsMap.put("itemsPerPage", pagedValueSets.getSize());
    pageResultsMap.put("currentPage", pagedValueSets.getNumber());
    pageResultsMap.put("numberOfElements",
            pagedValueSets.getNumberOfElements());

    return pageResultsMap;
}
 
开发者ID:bhits,项目名称:pcm-api,代码行数:26,代码来源:ValueSetServiceImpl.java

示例15: findAllByAscendingSort

import org.springframework.data.domain.Sort.Order; //导入依赖的package包/类
@Test
public void findAllByAscendingSort() throws Exception {
    // given
    dbSetupTracker.skipNextLaunch();

    // when
    List<BookApi> bookApis = repository.findAll(new Sort(new Order(Sort.Direction.ASC, "id")));

    // then
    assertThat(bookApis)
        .isNotNull()
        .isNotEmpty()
        .hasSize(3)
        .extracting("id", "name", "url")
        .containsExactly(
            tuple(1, "Amazon Product Advertising API", "https://ecs.amazonaws.jp/onca/xml"),
            tuple(2, "Google Books API", "https://www.googleapis.com/books/v1/volumes"),
            tuple(3, "楽天ブックス書籍検索API", "https://app.rakuten.co.jp/services/api/BooksBook/Search/20130522")
        );
}
 
开发者ID:yukung,项目名称:daguerreo,代码行数:21,代码来源:BasicJooqRepositoryTest.java


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