@Test public void testGetNodesWithOnlyName() { Page<Node> resultPage = graphController.getNodes("v*", PageRequest.of(0, 30)); assertThat(resultPage, notNullValue()); assertThat(resultPage.getTotalElements(), is(5L)); assertThat(resultPage.getTotalPages(), is(1)); List<Node> nodes = resultPage.getContent(); assertThat(nodes, hasSize(5)); }
@GetMapping(value = "/nodes") public Page<Node> getNodes(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.info("Get all nodes. Query: {}, Paging: {}", query, pageable); List<Node> resultList; if (query != null) { String normalizedQuery = normalizeQuery(query); resultList = new ArrayList<>(index.findNodes(normalizedQuery)); } else { resultList = new ArrayList<>(dependencyGraph.getAllNodes()); } resultList.sort(Comparator.comparing(AbstractGraphElement::getName)); int startIndex = (int) pageable.getOffset(); if (startIndex > resultList.size()) { startIndex = resultList.size(); } int stopIndex = startIndex + pageable.getPageSize(); if (stopIndex > resultList.size()) { stopIndex = resultList.size(); } List<Node> subList = resultList.subList(startIndex, stopIndex); return new PageImpl<>(subList, pageable, resultList.size()); }
GraphController { @GetMapping(value = "/nodes") public Page<Node> getNodes(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.info("Get all nodes. Query: {}, Paging: {}", query, pageable); List<Node> resultList; if (query != null) { String normalizedQuery = normalizeQuery(query); resultList = new ArrayList<>(index.findNodes(normalizedQuery)); } else { resultList = new ArrayList<>(dependencyGraph.getAllNodes()); } resultList.sort(Comparator.comparing(AbstractGraphElement::getName)); int startIndex = (int) pageable.getOffset(); if (startIndex > resultList.size()) { startIndex = resultList.size(); } int stopIndex = startIndex + pageable.getPageSize(); if (stopIndex > resultList.size()) { stopIndex = resultList.size(); } List<Node> subList = resultList.subList(startIndex, stopIndex); return new PageImpl<>(subList, pageable, resultList.size()); } }
GraphController { @GetMapping(value = "/nodes") public Page<Node> getNodes(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.info("Get all nodes. Query: {}, Paging: {}", query, pageable); List<Node> resultList; if (query != null) { String normalizedQuery = normalizeQuery(query); resultList = new ArrayList<>(index.findNodes(normalizedQuery)); } else { resultList = new ArrayList<>(dependencyGraph.getAllNodes()); } resultList.sort(Comparator.comparing(AbstractGraphElement::getName)); int startIndex = (int) pageable.getOffset(); if (startIndex > resultList.size()) { startIndex = resultList.size(); } int stopIndex = startIndex + pageable.getPageSize(); if (stopIndex > resultList.size()) { stopIndex = resultList.size(); } List<Node> subList = resultList.subList(startIndex, stopIndex); return new PageImpl<>(subList, pageable, resultList.size()); }  }
GraphController { @GetMapping(value = "/nodes") public Page<Node> getNodes(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.info("Get all nodes. Query: {}, Paging: {}", query, pageable); List<Node> resultList; if (query != null) { String normalizedQuery = normalizeQuery(query); resultList = new ArrayList<>(index.findNodes(normalizedQuery)); } else { resultList = new ArrayList<>(dependencyGraph.getAllNodes()); } resultList.sort(Comparator.comparing(AbstractGraphElement::getName)); int startIndex = (int) pageable.getOffset(); if (startIndex > resultList.size()) { startIndex = resultList.size(); } int stopIndex = startIndex + pageable.getPageSize(); if (stopIndex > resultList.size()) { stopIndex = resultList.size(); } List<Node> subList = resultList.subList(startIndex, stopIndex); return new PageImpl<>(subList, pageable, resultList.size()); }  @Value("${de.qaware.qav.graph.filename}") void setFilename(String filename); @PostConstruct void init(); @GetMapping(value = "/info") GraphInfoDTO getInfo(); @GetMapping(value = "/node") NodeDTO getNode(@RequestParam(value = "name") String name); @GetMapping(value = "/edge") DependencyDTO getEdge(@RequestParam("from") String from,
                                 @RequestParam("to") String to); @GetMapping(value = "/nodes") Page<Node> getNodes(@RequestParam(value = "q", required = false) String query,
                               Pageable pageable); }
GraphController { @GetMapping(value = "/nodes") public Page<Node> getNodes(@RequestParam(value = "q", required = false) String query, Pageable pageable) { LOGGER.info("Get all nodes. Query: {}, Paging: {}", query, pageable); List<Node> resultList; if (query != null) { String normalizedQuery = normalizeQuery(query); resultList = new ArrayList<>(index.findNodes(normalizedQuery)); } else { resultList = new ArrayList<>(dependencyGraph.getAllNodes()); } resultList.sort(Comparator.comparing(AbstractGraphElement::getName)); int startIndex = (int) pageable.getOffset(); if (startIndex > resultList.size()) { startIndex = resultList.size(); } int stopIndex = startIndex + pageable.getPageSize(); if (stopIndex > resultList.size()) { stopIndex = resultList.size(); } List<Node> subList = resultList.subList(startIndex, stopIndex); return new PageImpl<>(subList, pageable, resultList.size()); }  @Value("${de.qaware.qav.graph.filename}") void setFilename(String filename); @PostConstruct void init(); @GetMapping(value = "/info") GraphInfoDTO getInfo(); @GetMapping(value = "/node") NodeDTO getNode(@RequestParam(value = "name") String name); @GetMapping(value = "/edge") DependencyDTO getEdge(@RequestParam("from") String from,
                                 @RequestParam("to") String to); @GetMapping(value = "/nodes") Page<Node> getNodes(@RequestParam(value = "q", required = false) String query,
                               Pageable pageable);  }