@Test @SuppressWarnings("unchecked") public void sortAddsASortParameterToTheSearchResultsForEachOfTheSortParameters() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("id1") .withProperty(PROPERTY_1, "value1.2") .withProperty(PROPERTY_2, "value2")) .withVertex(v -> v.withTimId("id2") .withProperty(PROPERTY_1, "value1") .withProperty(PROPERTY_2, "value2.1")) .withVertex(v -> v.withTimId("id3") .withProperty(PROPERTY_1, "value1") .withProperty(PROPERTY_2, "value2")) .build() .traversal() .V(); List<SortParameter> sortParameters = Lists.newArrayList( new SortParameter(SORT_FIELD_1, asc), new SortParameter(SORT_FIELD_2, asc)); instance.sort(traversal, sortParameters); List<Vertex> actual = traversal.toList(); assertThat(actual, contains( likeVertex().withTimId("id3"), likeVertex().withTimId("id2"), likeVertex().withTimId("id1"))); }
public void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters) { if (sortParameters.isEmpty()) { return; } List<SortTraversal> traversals = collectTraversals(sortParameters); if (traversals.isEmpty()) { return; } searchResult.order(); for (SortTraversal sortTraversal : traversals) { for (GraphTraversal<Object, Object> traversal : sortTraversal.traversals) { searchResult.by(traversal, sortTraversal.order); } } }
SortDescription { public void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters) { if (sortParameters.isEmpty()) { return; } List<SortTraversal> traversals = collectTraversals(sortParameters); if (traversals.isEmpty()) { return; } searchResult.order(); for (SortTraversal sortTraversal : traversals) { for (GraphTraversal<Object, Object> traversal : sortTraversal.traversals) { searchResult.by(traversal, sortTraversal.order); } } } }
SortDescription { public void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters) { if (sortParameters.isEmpty()) { return; } List<SortTraversal> traversals = collectTraversals(sortParameters); if (traversals.isEmpty()) { return; } searchResult.order(); for (SortTraversal sortTraversal : traversals) { for (GraphTraversal<Object, Object> traversal : sortTraversal.traversals) { searchResult.by(traversal, sortTraversal.order); } } } SortDescription(List<SortFieldDescription> sortFieldDescriptions); }
SortDescription { public void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters) { if (sortParameters.isEmpty()) { return; } List<SortTraversal> traversals = collectTraversals(sortParameters); if (traversals.isEmpty()) { return; } searchResult.order(); for (SortTraversal sortTraversal : traversals) { for (GraphTraversal<Object, Object> traversal : sortTraversal.traversals) { searchResult.by(traversal, sortTraversal.order); } } } SortDescription(List<SortFieldDescription> sortFieldDescriptions); void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters); }
SortDescription { public void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters) { if (sortParameters.isEmpty()) { return; } List<SortTraversal> traversals = collectTraversals(sortParameters); if (traversals.isEmpty()) { return; } searchResult.order(); for (SortTraversal sortTraversal : traversals) { for (GraphTraversal<Object, Object> traversal : sortTraversal.traversals) { searchResult.by(traversal, sortTraversal.order); } } } SortDescription(List<SortFieldDescription> sortFieldDescriptions); void sort(GraphTraversal<Vertex, Vertex> searchResult, List<SortParameter> sortParameters);  }