org.geoserver.monitor.Query类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(271)

本文整理了Java中org.geoserver.monitor.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:org.geoserver.monitor.Query
类名称:Query

Query介绍

暂无

代码示例

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsFilterAnd() throws Exception {
  3. assertEquals(1, dao.getRequests(new Query().filter("path", "/foo", Comparison.EQ)
  4. .filter("widgets", "resources", Comparison.IN)).size());
  5. }

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsJoinIN() throws Exception {
  3. List<String> resources = Arrays.asList("widgets", "things");
  4. List<RequestData> datas = dao.getRequests(new Query().properties("resource")
  5. .aggregate("count()").filter("resource", resources, Comparison.IN)
  6. .group("resource").sort("resource", SortOrder.ASC));
  7. assertEquals(2, datas.size());
  8. assertEquals("things", datas.get(0).getResources().get(0));
  9. assertEquals("widgets", datas.get(1).getResources().get(0));
  10. }

代码示例来源:origin: org.geoserver.extension/gs-monitor-core

  1. @Test
  2. public void testGetRequestsPaged() throws Exception {
  3. List<RequestData> datas =
  4. dao.getRequests(new Query().page(5l, 2l).sort("startTime", SortOrder.ASC));
  5. assertCoveredInOrder(datas, 6, 7);
  6. }

代码示例来源:origin: org.geoserver.community/gs-monitor-hibernate

  1. public long getCount(Query q) {
  2. q = q.clone();
  3. q.getAggregates().clear();
  4. q.getProperties().clear();
  5. q.getGroupBy().clear();
  6. q.setSortBy(null);
  7. q.setSortOrder(null);
  8. q.aggregate("count()");
  9. org.hibernate.Query query = toQuery(q);
  10. long count = ((Number) query.uniqueResult()).longValue();
  11. // factor in offset, count
  12. if (q.getOffset() != null) {
  13. count = Math.max(0, count - q.getOffset());
  14. }
  15. if (q.getCount() != null) {
  16. count = Math.min(count, q.getCount());
  17. }
  18. return count;
  19. }

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsCount() throws Exception {
  3. final List<Object> aggs = new ArrayList();
  4. RequestDataVisitor v = new RequestDataVisitor() {
  5. public void visit(RequestData data, Object... aggregates) {
  6. aggs.addAll(Arrays.asList(aggregates));
  7. }
  8. };
  9. dao.getRequests(new Query().aggregate("count()").filter("path","/foo", Comparison.EQ), v);
  10. assertEquals(1, aggs.size());
  11. assertEquals(4, ((Number)aggs.get(0)).intValue());
  12. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetRequestsSorted() throws Exception {
  3. assertCoveredInOrder(dao.getRequests(new Query().filter("id", 11l, Comparison.LT)
  4. .sort("path", SortOrder.ASC)), 8, 5, 4, 9, 1, 7, 6, 10, 3, 2);
  5. }

代码示例来源:origin: org.geoserver.extension/gs-monitor-core

  1. @Test
  2. public void testGetRequestsBetween2() throws Exception {
  3. // test that the query is inclusive, and test sorting
  4. List<RequestData> datas =
  5. dao.getRequests(
  6. new Query()
  7. .between(
  8. toDate("2010-07-23T15:56:44"),
  9. toDate("2010-07-23T16:16:44"))
  10. .sort("startTime", SortOrder.ASC));
  11. assertCoveredInOrder(datas, 4, 5, 6);
  12. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testToQueryString() throws Exception {
  3. Date from = toDate("2010-07-23T15:56:44");
  4. Date to = toDate("2010-07-23T16:16:44");
  5. Query q = new Query().between(from, to);
  6. q.filter("service", "WFS", Comparison.EQ).and("status", "RUNNING", Comparison.EQ)
  7. .and("path", Arrays.asList("/foo", "/bar"), Comparison.IN);
  8. String qs = RequestResource.toQueryString(q);
  9. assertEquals('?', qs.charAt(0));
  10. qs = qs.substring(1);
  11. Map<String,String> kvp = new HashMap();
  12. for (String s : qs.split("&")) {
  13. kvp.put(s.split("=")[0], s.split("=")[1]);
  14. }
  15. assertEquals(from, RequestResource.DATE_FORMAT.parse(kvp.get("from")));
  16. assertEquals(to, RequestResource.DATE_FORMAT.parse(kvp.get("to")));
  17. assertEquals("service:EQ:WFS;status:EQ:RUNNING;path:IN:/foo,/bar", kvp.get("filter"));
  18. }
  19. }

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsFilterOr() throws Exception {
  3. assertEquals(4, dao.getRequests(new Query().filter("path", "/seven", Comparison.EQ)
  4. .or("widgets", "resources", Comparison.IN)).size());
  5. }

代码示例来源:origin: org.geoserver.extension/gs-monitor-core

  1. @Test
  2. public void testGetRequestsBetween() throws Exception {
  3. List<RequestData> datas =
  4. dao.getRequests(
  5. new Query()
  6. .between(
  7. toDate("2010-07-23T15:55:00"),
  8. toDate("2010-07-23T16:17:00")));
  9. assertCoveredInOrder(datas, 6, 5, 4);
  10. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. public void testGetAllCSVQuery() throws Exception {
  2. RequestResource.CSVFormat format = new RequestResource.CSVFormat(
  3. new String[]{"id", "path", "startTime"}, monitor);
  4. ByteArrayOutputStream out = new ByteArrayOutputStream();
  5. format.toRepresentation(new Query()).write(out);
  6. BufferedReader in = new BufferedReader(new InputStreamReader(
  7. new ByteArrayInputStream(out.toByteArray())));
  8. String line = in.readLine();
  9. assertEquals("id,path,startTime", line);
  10. Iterator<RequestData> it = monitor.getDAO().getRequests().iterator();
  11. while((line = in.readLine()) != null) {
  12. assertTrue(it.hasNext());
  13. RequestData data = it.next();
  14. String expected = data.getId() + "," + data.getPath() + "," +
  15. DateUtil.serializeDateTime(data.getStartTime());
  16. assertEquals(expected, line);
  17. }
  18. assertFalse(it.hasNext());
  19. }

代码示例来源:origin: org.geoserver.extension/gs-monitor-core

  1. @Test
  2. public void testGetRequestsSorted() throws Exception {
  3. assertCoveredInOrder(
  4. dao.getRequests(
  5. new Query().filter("id", 11l, Comparison.LT).sort("path", SortOrder.ASC)),
  6. 8,
  7. 5,
  8. 4,
  9. 9,
  10. 1,
  11. 7,
  12. 6,
  13. 10,
  14. 3,
  15. 2);
  16. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetRequestsBetween2() throws Exception {
  3. //test that the query is inclusive, and test sorting
  4. List<RequestData> datas = dao.getRequests(new Query().between(
  5. toDate("2010-07-23T15:56:44"), toDate("2010-07-23T16:16:44"))
  6. .sort("startTime", SortOrder.ASC));
  7. assertCoveredInOrder(datas, 4, 5, 6);
  8. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetRequestsBetween() throws Exception {
  3. List<RequestData> datas = dao.getRequests(new Query().between(
  4. toDate("2010-07-23T15:55:00"), toDate("2010-07-23T16:17:00")));
  5. assertCoveredInOrder(datas, 6, 5, 4);
  6. }

代码示例来源:origin: org.geoserver.extension/gs-monitor-core

  1. @Test
  2. public void testGetRequestsFilterNull() throws Exception {
  3. assertEquals(0, dao.getRequests(new Query().filter("path", null, Comparison.EQ)).size());
  4. assertEquals(
  5. testData.getData().size(),
  6. dao.getRequests(new Query().filter("path", null, Comparison.NEQ)).size());
  7. }

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsJoin2() throws Exception {
  3. final List<RequestData> datas = new ArrayList();
  4. final List<Object> aggs = new ArrayList();
  5. dao.getRequests(new Query().properties("resource").aggregate("count()")
  6. .filter("resource", null, Comparison.NEQ).group("resource"), new RequestDataVisitor() {
  7. public void visit(RequestData data, Object... aggregates) {
  8. datas.add(data);
  9. aggs.add(aggregates[0]);
  10. }
  11. });
  12. //assertEquals(3, datas.size());
  13. for (RequestData data : datas) {
  14. System.out.println(data.getResources());
  15. }
  16. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetRequestsPaged() throws Exception {
  3. List<RequestData> datas = dao.getRequests(
  4. new Query().page(5l, 2l).sort("startTime", SortOrder.ASC));
  5. assertCoveredInOrder(datas, 6, 7);
  6. }

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetRequestsFilterNull() throws Exception {
  3. assertEquals(0, dao.getRequests(new Query().filter("path", null, Comparison.EQ)).size());
  4. assertEquals(testData.getData().size(),
  5. dao.getRequests(new Query().filter("path", null, Comparison.NEQ)).size());
  6. }

代码示例来源:origin: org.geoserver.extension/monitor-hibernate

  1. @Test
  2. public void testGetRequestsJoin() throws Exception {
  3. List<RequestData> datas = dao.getRequests(new Query().properties("path", "resource")
  4. .filter("path","/foo", Comparison.EQ). group("path", "resource")
  5. .sort("resource", SortOrder.ASC));
  6. assertEquals(3, datas.size());
  7. assertEquals("stuff", datas.get(0).getResources().get(0));
  8. assertEquals("things", datas.get(1).getResources().get(0));
  9. assertEquals("widgets", datas.get(2).getResources().get(0));
  10. }
  11. @Test

代码示例来源:origin: org.geoserver.extension/monitor-core

  1. @Test
  2. public void testGetCount() throws Exception {
  3. assertEquals(4, dao.getCount(new Query().filter("path","/foo", Comparison.EQ)));
  4. }

相关文章