@Test public void filterDoesNotAddAFilterWhenTheFacetValueIsNotAListFacetValue() { GraphTraversal<Vertex, Vertex> traversal = newGraph() .withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_NAME, serializedListOf("value1", "value2"))) .withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_NAME, serializedListOf("value2", "value3"))) .withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_NAME, serializedListOf("value1", "value3", "value4"))) .build().traversal().V(); List<FacetValue> facetValues = Lists.newArrayList((FacetValue) () -> FACET_NAME); instance.filter(traversal, facetValues); assertThat(traversal.toList(), containsInAnyOrder( likeVertex().withTimId("id1"), likeVertex().withTimId("id2"), likeVertex().withTimId("id3"))); }
@Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues) { Optional<FacetValue> first = facetValues.stream() .filter(facetValue -> Objects.equals(facetValue.getName(), facetName)) .findFirst(); if (!first.isPresent()) { return; } FacetValue facetValue = first.get(); if (!(facetValue instanceof ListFacetValue)) { return; } List<String> values = ((ListFacetValue) facetValue).getValues(); if (values.isEmpty()) { return; } graphTraversal .where(__.<String>has(propertyName, P.test((o1, o2) -> o1 instanceof String && o2 instanceof List && ((List<?>) o2).stream().anyMatch(value -> ((String) o1).contains("\"" + value + "\"")), values))); }
MultiValueListFacetDescription extends AbstractFacetDescription { @Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues) { Optional<FacetValue> first = facetValues.stream() .filter(facetValue -> Objects.equals(facetValue.getName(), facetName)) .findFirst(); if (!first.isPresent()) { return; } FacetValue facetValue = first.get(); if (!(facetValue instanceof ListFacetValue)) { return; } List<String> values = ((ListFacetValue) facetValue).getValues(); if (values.isEmpty()) { return; } graphTraversal .where(__.<String>has(propertyName, P.test((o1, o2) -> o1 instanceof String && o2 instanceof List && ((List<?>) o2).stream().anyMatch(value -> ((String) o1).contains("\"" + value + "\"")), values))); } }
MultiValueListFacetDescription extends AbstractFacetDescription { @Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues) { Optional<FacetValue> first = facetValues.stream() .filter(facetValue -> Objects.equals(facetValue.getName(), facetName)) .findFirst(); if (!first.isPresent()) { return; } FacetValue facetValue = first.get(); if (!(facetValue instanceof ListFacetValue)) { return; } List<String> values = ((ListFacetValue) facetValue).getValues(); if (values.isEmpty()) { return; } graphTraversal .where(__.<String>has(propertyName, P.test((o1, o2) -> o1 instanceof String && o2 instanceof List && ((List<?>) o2).stream().anyMatch(value -> ((String) o1).contains("\"" + value + "\"")), values))); } MultiValueListFacetDescription(String facetName, String propertyName); }
MultiValueListFacetDescription extends AbstractFacetDescription { @Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues) { Optional<FacetValue> first = facetValues.stream() .filter(facetValue -> Objects.equals(facetValue.getName(), facetName)) .findFirst(); if (!first.isPresent()) { return; } FacetValue facetValue = first.get(); if (!(facetValue instanceof ListFacetValue)) { return; } List<String> values = ((ListFacetValue) facetValue).getValues(); if (values.isEmpty()) { return; } graphTraversal .where(__.<String>has(propertyName, P.test((o1, o2) -> o1 instanceof String && o2 instanceof List && ((List<?>) o2).stream().anyMatch(value -> ((String) o1).contains("\"" + value + "\"")), values))); } MultiValueListFacetDescription(String facetName, String propertyName); @Override void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues); }
MultiValueListFacetDescription extends AbstractFacetDescription { @Override public void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues) { Optional<FacetValue> first = facetValues.stream() .filter(facetValue -> Objects.equals(facetValue.getName(), facetName)) .findFirst(); if (!first.isPresent()) { return; } FacetValue facetValue = first.get(); if (!(facetValue instanceof ListFacetValue)) { return; } List<String> values = ((ListFacetValue) facetValue).getValues(); if (values.isEmpty()) { return; } graphTraversal .where(__.<String>has(propertyName, P.test((o1, o2) -> o1 instanceof String && o2 instanceof List && ((List<?>) o2).stream().anyMatch(value -> ((String) o1).contains("\"" + value + "\"")), values))); } MultiValueListFacetDescription(String facetName, String propertyName); @Override void filter(GraphTraversal<Vertex, Vertex> graphTraversal, List<FacetValue> facetValues);  }