當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。