Package org.springframework.data.domain

Examples of org.springframework.data.domain.Sort


        assertEquals(2, _requestRepo.count(isOlderThanOrEqualTo(request2.getRequestDate())));
        assertEquals(3, _requestRepo.count(isOlderThanOrEqualTo(request3.getRequestDate())));
        assertEquals(1, _requestRepo.count(isOlderThanOrEqualTo(request1.getRequestDate())));

        final Sort sort = new Sort(Sort.Direction.DESC, SearchRequest_.requestDate.getName());
        final List<SearchRequest> all = _requestRepo.findAll(isOlderThanOrEqualTo(request2.getRequestDate()), sort);

        assertEquals(2, all.size());
        assertEquals(request2.getId(), all.get(0).getId());
        assertEquals(request1.getId(), all.get(1).getId());
View Full Code Here


        Metadata metadata = _repo.save(updateChangeDate(newMetadata(), "1990-12-13"));
        Metadata metadata2 = _repo.save(updateChangeDate(newMetadata(), "1980-12-13"));
        Metadata metadata3 = _repo.save(updateChangeDate(newMetadata(), "1995-12-13"));

        final Sort sortByIdAsc = new Sort(Sort.Direction.DESC, Metadata_.id.getName());
        PageRequest page1 = new PageRequest(0, 2, sortByIdAsc);
        PageRequest page2 = new PageRequest(1, 2, sortByIdAsc);
        Page<Pair<Integer, ISODate>> firstPage = _repo.findAllIdsAndChangeDates(page1);
        Page<Pair<Integer, ISODate>> secondPage = _repo.findAllIdsAndChangeDates(page2);

        assertEquals(2, firstPage.getNumberOfElements());
        assertEquals(0, firstPage.getNumber());
        assertEquals(2, firstPage.getTotalPages());
        assertEquals(3, firstPage.getTotalElements());
        assertTrue(firstPage.isFirstPage());
        assertFalse(firstPage.isLastPage());
        assertTrue(firstPage.hasContent());

        assertEquals(1, secondPage.getNumberOfElements());
        assertEquals(1, secondPage.getNumber());
        assertEquals(2, secondPage.getTotalPages());
        assertEquals(3, secondPage.getTotalElements());
        assertFalse(secondPage.isFirstPage());
        assertTrue(secondPage.isLastPage());
        assertTrue(secondPage.hasContent());

        assertEquals((Integer) metadata3.getId(), firstPage.getContent().get(0).one());
        assertEquals((Integer) metadata2.getId(), firstPage.getContent().get(1).one());
        assertEquals((Integer) metadata.getId(), secondPage.getContent().get(0).one());

        assertEquals(metadata3.getDataInfo().getChangeDate(), firstPage.getContent().get(0).two());
        assertEquals(metadata2.getDataInfo().getChangeDate(), firstPage.getContent().get(1).two());
        assertEquals(metadata.getDataInfo().getChangeDate(), secondPage.getContent().get(0).two());

        final Sort sortByChangeDate = SortUtils.createSort(Metadata_.dataInfo, MetadataDataInfo_.changeDate);
        page1 = new PageRequest(0, 1, sortByChangeDate);
        page2 = new PageRequest(0, 3, sortByChangeDate);
        firstPage = _repo.findAllIdsAndChangeDates(page1);
        secondPage = _repo.findAllIdsAndChangeDates(page2);
View Full Code Here

        }

        // Sorting
        String sortBy = sortByParameter(params);

        Sort order = null;
        if(sortBy.equals("date")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.changeDate);
        } else if(sortBy.equals("popularity")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.popularity);
        } else if(sortBy.equals("rating")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.rating);
        } else {
            throw new IllegalArgumentException("Unknown sortBy parameter: "+sortBy);
        }

        List<Metadata> metadataList = context.getBean(MetadataRepository.class).findAll(spec, order);
View Full Code Here

            spec = spec.and(OperationAllowedSpecs.hasGroupId(grpId));
        }
        final List<Integer> list = operationAllowedRepository.findAllIds(spec, OperationAllowedId_.metadataId);

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Sort sortByChangeDateDesc = new Sort(Sort.Direction.DESC, Metadata_.dataInfo.getName()+"."+MetadataDataInfo_.changeDate);

        Element result = metadataRepository.findAllAsXml(MetadataSpecs.hasMetadataIdIn(list), sortByChangeDateDesc);


        Element formatEl = new Element("format");
View Full Code Here

    }

    public Element exec(Element params, ServiceContext context)
            throws Exception {

        final Sort sort = new Sort(Sort.Direction.ASC, Metadata_.dataInfo.getName() + "." + MetadataDataInfo_.root.getName());

        final List<Metadata> metadatas = context.getBean(MetadataRepository.class).findAll(hasType(MetadataType.SUB_TEMPLATE), sort);
        Element subTemplateTypes = new Element("getTypes");

        for (Metadata metadata : metadatas) {
View Full Code Here

        final Sort.Order harvestDateOrder = new Sort.Order(Sort.Direction.DESC, createPath(HarvestHistory_.harvestDate));
        final Sort.Order harvesterUuidOrder = new Sort.Order(createPath(HarvestHistory_.harvesterUuid));
        final Sort.Order harvesterTypeSort = new Sort.Order(createPath(HarvestHistory_.harvesterType));

        Sort springSort;
        if (sortCriteria.equals("date")) {
            springSort = new Sort(harvestDateOrder, harvesterUuidOrder);
        } else {
            springSort = new Sort(harvesterTypeSort, harvestDateOrder);
        }

        Element result;
        if ((uuid == null) || (uuid.equals(""))) {
            result = historyRepository.findAllAsXml(springSort);
View Full Code Here

        ISODate beginLoginDateIso = new ISODate(beginLoginDate);
        ISODate endLoginDateIso = new ISODate(endLoginDate);
        Set<Integer> groupList = ReportUtils.groupsForFilter(context, params);

        // Retrieve users
        final Sort sort = new Sort(Sort.Direction.ASC, SortUtils.createPath(User_.lastLoginDate));
        final List<User> records = context.getBean(UserRepository.class).findAll(
                UserSpecs.loginDateBetweenAndByGroups(beginLoginDateIso, endLoginDateIso, groupList), sort);

        // Process metadata results for the report
        Element response = new Element(Jeeves.Elem.RESPONSE);
View Full Code Here

        MetadataStatus status1 = newMetadataStatus();
        status1 = _repo.save(status1);


        final Sort sort = SortUtils.createSort(MetadataStatus_.id, MetadataStatusId_.metadataId);
        assertEquals(2, _repo.findAllById_MetadataId(status.getId().getMetadataId(), sort).size());
        assertEquals(1, _repo.findAllById_MetadataId(status1.getId().getMetadataId(), sort).size());
    }
View Full Code Here

        assertEquals("1", list.get(0).getName());
        assertEquals("2", list.get(1).getName());
        assertEquals("3", list.get(2).getName());
        assertEquals("4", list.get(3).getName());

        List<HarvesterSetting> list2 = _repo.findAll(new Sort(Direction.DESC, SortUtils.createPath(Setting_.name)));
        assertEquals("4", list2.get(0).getName());
        assertEquals("3", list2.get(1).getName());
        assertEquals("2", list2.get(2).getName());
        assertEquals("1", list2.get(3).getName());
    }
View Full Code Here

        ISODate beginDateIso = new ISODate(beginDate);
        ISODate endDateIso = new ISODate(endDate);
        Set<Integer> groupList = ReportUtils.groupsForFilter(context, params);

        // Retrieve metadata file uploads
        final Sort sort = new Sort(Sort.Direction.ASC, SortUtils.createPath(MetadataFileUpload_.uploadDate));
        final List<MetadataFileUpload> records = context.getBean(MetadataFileUploadRepository.class).findAll(
                MetadataFileUploadSpecs.uploadDateBetweenAndByGroups(beginDateIso, endDateIso, groupList), sort);

        // Process metadata results for the report
        Element response = new Element(Jeeves.Elem.RESPONSE);
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.