Package org.fao.geonet.domain.statistic

Examples of org.fao.geonet.domain.statistic.SearchRequest


        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest1.getRequestDate()), 1)));
    }

    @Test
    public void testGetRequestDateToRequestCountBetweenByDay() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1980-11-13T01:11:00"));
        searchRequest3 = _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1980-11-16T01:11:00"));
        searchRequest4 = _requestRepo.save(searchRequest4);

        final List<Pair<DateInterval.Day, Integer>> fullInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Day(), searchRequest1.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(3, fullInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest1.getRequestDate()), 2)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest4.getRequestDate()), 1)));


        final List<Pair<DateInterval.Day, Integer>> shortInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Day(), searchRequest3.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(2, shortInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest4.getRequestDate()), 1)));

        final List<Pair<DateInterval.Day, Integer>> outOfRangeInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Day(), new ISODate("1990-01-01"), new ISODate("1990-01-02"));
        assertEquals(0, outOfRangeInterval.size());
    }
View Full Code Here


    @Autowired
    SearchRequestRepository _requestRepo;

    @Test
    public void testIsMoreRecentThanOrEqualTo() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1.setRequestDate(new ISODate("1980-06-12T11:34:00"));
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2.setRequestDate(new ISODate("1980-06-12T11:37:00"));
        request2 = _requestRepo.save(request2);

        SearchRequest request3 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request3.setRequestDate(new ISODate("1981-06-12T11:34:00"));
        request3 = _requestRepo.save(request3);

        assertEquals(2, _requestRepo.count(isMoreRecentThanOrEqualTo(request2.getRequestDate())));
        assertEquals(1, _requestRepo.count(isMoreRecentThanOrEqualTo(request3.getRequestDate())));
        assertEquals(3, _requestRepo.count(isMoreRecentThanOrEqualTo(request1.getRequestDate())));
        final Sort sort = new Sort(Sort.Direction.DESC, SearchRequest_.requestDate.getName());
        final List<SearchRequest> all = _requestRepo.findAll(isMoreRecentThanOrEqualTo(request2.getRequestDate()), sort);

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

        assertEquals(request2.getId(), all.get(1).getId());
    }

    @Test
    public void testIsOlderThanOrEqualTo() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1.setRequestDate(new ISODate("1980-06-12T11:34:00"));
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2.setRequestDate(new ISODate("1980-06-12T11:37:00"));
        request2 = _requestRepo.save(request2);

        SearchRequest request3 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request3.setRequestDate(new ISODate("1981-06-12T11:34:00"));
        request3 = _requestRepo.save(request3);

        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);
View Full Code Here

        assertEquals(request1.getId(), all.get(1).getId());
    }

    @Test
    public void testIsAutogenerated() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1.setAutogenerated(false);
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2.setAutogenerated(true);
        request2 = _requestRepo.save(request2);

        List<SearchRequest> found = _requestRepo.findAll(isAutogenerated(true));
        assertEquals(1, found.size());
        assertEquals(request2.getId(), found.get(0).getId());

        found = _requestRepo.findAll(isAutogenerated(false));
        assertEquals(1, found.size());
        assertEquals(request1.getId(), found.get(0).getId());
    }
View Full Code Here

        assertEquals(request1.getId(), found.get(0).getId());
    }

    @Test
    public void testHasService() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2 = _requestRepo.save(request2);

        List<SearchRequest> found = _requestRepo.findAll(hasService(request2.getService()));
        assertEquals(1, found.size());
        assertEquals(request2.getId(), found.get(0).getId());

        found = _requestRepo.findAll(hasService(request1.getService()));
        assertEquals(1, found.size());
        assertEquals(request1.getId(), found.get(0).getId());
    }
View Full Code Here

        assertEquals(request1.getId(), found.get(0).getId());
    }

    @Test
    public void testHasHits() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2 = _requestRepo.save(request2);

        List<SearchRequest> found = _requestRepo.findAll(SearchRequestSpecs.hasHits(request2.getHits()));
        assertEquals(1, found.size());
        assertEquals(request2.getId(), found.get(0).getId());

        found = _requestRepo.findAll(SearchRequestSpecs.hasHits(request1.getHits()));
        assertEquals(1, found.size());
        assertEquals(request1.getId(), found.get(0).getId());
    }
View Full Code Here

        assertEquals(request1.getId(), found.get(0).getId());
    }

    @Test
    public void testIsSimple() throws Exception {
        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request1.setSimple(false);
        request1 = _requestRepo.save(request1);

        SearchRequest request2 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        request2.setSimple(true);
        request2 = _requestRepo.save(request2);

        List<SearchRequest> found = _requestRepo.findAll(isSimple(true));
        assertEquals(1, found.size());
        assertEquals(request2.getId(), found.get(0).getId());

        found = _requestRepo.findAll(isSimple(false));
        assertEquals(1, found.size());
        assertEquals(request1.getId(), found.get(0).getId());
    }
View Full Code Here

        SearchRequestRepository requestRepo = context.getBean(SearchRequestRepository.class);
        // prepares a transaction to log all or nothing into database.

        //Connection con = null;
        //--- generate a new metadata id
        SearchRequest request = new SearchRequest();
        request.setAutogenerated(this.autoGenQuery);
        request.setHits(this.hits);
        request.setIpAddress(this.ip);
        request.setLang(this.language);
        request.setLuceneQuery(this.luceneQuery);
        request.setMetadataType(this.mdType.name());
        request.setRequestDate(new ISODate(this.date.getTime(), false));
        request.setService(this.service);
        request.setSimple(this.isSimpleQuery());
        request.setSortBy(this.sortBy);
        request.setSpatialFilter(this.spatialFilter);

        // stores each QueryInfo object into the database
        if (this.queryInfos != null && !this.autoGenQuery) {
            request.addAll(this.queryInfos);
        } else {
            if (this.autoGenQuery) {
                if (Log.isDebugEnabled(Geonet.SEARCH_LOGGER)) {
                    Log.debug(Geonet.SEARCH_LOGGER, "Guiservice/autogenerated query not inserted into database: " + this.luceneQuery);
                }
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.statistic.SearchRequest

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.