Package org.springframework.data.domain

Examples of org.springframework.data.domain.Sort


    }

    boolean fetchWithPagination = true;

    public List<UserActivity> fetchData() {
        Sort s = new Sort(new Sort.Order(Sort.Direction.DESC, "created"));

        DynaqueResult<UserActivity> dynaUa = userActivityRepository.dynamically(
                "user_activity_filter",
                s,
                fetchWithPagination ? PagingUtil.fromPaging(pgActivity) : null,
View Full Code Here


    @Wire
    Textbox txtSearch;

    public void prepareData() {
        Referensi grup = referensiUtil.fromCombo(txtGrup);
        Sort s = new Sort(Sort.Order.create(Sort.Direction.ASC, Arrays.asList(new String[]{"urut"})));
        Long lg = grup != null ? grup.getNum() : 0L;
        List<Referensi> ugs = referensiRepository.dynamically(ReferensiRepository.REFERENSI_FILTER, s, PagingUtil.fromPaging(pgData),
                new RegularParameterValues()
                        .add(EqualParameterValue.create("grup", lg))
                        .add(LikeParameterValue.create("nama", txtSearch.getText()))
View Full Code Here

        {
            return defaultSort;
        }

        boolean hasId = false;
        Sort sort = null;
        String[] split = sortString.split(",");
        for (String s1 : split)
        {
            String[] props = s1.split(":");
            String name = props[0].trim();
            if(name.equals("id"))
                hasId = true;
            boolean desc = props.length == 2 && props[1].equalsIgnoreCase("desc");

            Map<String,SortBuilder> sortBuilders = entityPlugin.getSortBuilders();
            SortBuilder sortBuilder = sortBuilders.get(name);
            if(sortBuilder == null)
                throw new BadRequestException(String.format("%s is not a valid sort field.",name));

            Sort s = sortBuilder.buildSort(name,desc);
            if (sort == null)
            {
                sort = s;
            }
            else
View Full Code Here

    searchCriteria.setCategoryId(categoryId);
    searchCriteria.setFromPostDate(fromPostDate);
    searchCriteria.setToPostDate(toPostDate);
   
    // Process order by
    Sort sort = null;
    String orderBy = sortBy;
    if (orderBy != null && orderBy.equals("postDateString")) orderBy = "postDate";
   
    if (orderBy != null && order != null) {
      if (order.equals("desc")) {
        sort = new Sort(Sort.Direction.DESC, orderBy);
      } else
        sort = new Sort(Sort.Direction.ASC, orderBy);
    }
   
    // Constructs page request for current page
    // Note: page number for Spring Data JPA starts with 0, while jqGrid starts with 1
    PageRequest pageRequest = null;
View Full Code Here

  public void shouldReturnPageWithOneItemWithSortingAppliedOnTwoProperties() {
    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john6", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(0, 5, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(1);
    assertThat(page.getTotalElements()).isEqualTo(1);
    assertThat(page.getSize()).isEqualTo(5);
View Full Code Here

    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john13", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 2, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john14", SOME_DATE_OF_BIRTH, SOME_REPUTATION    , true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john15", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(0, 3, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(3);
    assertThat(page.getTotalElements()).isEqualTo(5);
    assertThat(page.getSize()).isEqualTo(3);
View Full Code Here

    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john13", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 2, true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john14", SOME_DATE_OF_BIRTH, SOME_REPUTATION    , true);
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john15", SOME_DATE_OF_BIRTH, SOME_REPUTATION + 1, true);

    //when
    Page<User> page = repository.findAll(new PageRequest(1, 3, new Sort(new Order(DESC, "reputation"), new Order(ASC, "user_name"))));

    //then
    assertThat(page).hasSize(2);
    assertThat(page.getTotalElements()).isEqualTo(5);
    assertThat(page.getSize()).isEqualTo(3);
View Full Code Here

  }

  @Test
  public void shouldReturnEmptyListWhenFindAllCalledWithoutPaging() throws Exception {
    //given
    final Sort sort = new Sort("reputation");

    //when
    final Iterable<User> reputation = repository.findAll(sort);

    //then
View Full Code Here

  }

  @Test
  public void shouldReturnEmptyListWhenFindAllCalledWithoutPagingButWithSortingOnMultipleProperties() throws Exception {
    //given
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "date_of_birth"));

    //when
    final Iterable<User> reputation = repository.findAll(sort);

    //then
View Full Code Here

  @Test
  public void shouldReturnSingleRecordWhenFindAllWithoutPagingButWithSorting() throws Exception {
    //given
    jdbc.update("INSERT INTO USERS VALUES (?, ?, ?, ?)", "john7", SOME_DATE_OF_BIRTH, SOME_REPUTATION, true);
    final Sort sort = new Sort(new Order(DESC, "reputation"), new Order(ASC, "date_of_birth"));

    //when
    final Iterable<User> all = repository.findAll(sort);

    //then
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.Sort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.