Search in sources :

Example 1 with Property

use of nl.knaw.huygens.timbuctoo.search.description.Property in project timbuctoo by HuygensING.

the class PropertyTest method getTraversalReturnsATraversalThatLetsTheParserDetermineTheOrder.

@Test
public void getTraversalReturnsATraversalThatLetsTheParserDetermineTheOrder() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY, "123")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY, "1234")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY, "254")).build().traversal().V();
    Property instance = Property.localProperty().withName(PROPERTY).withParser(new IntegerParser()).build();
    GraphTraversal<?, ?> orderTraversal = instance.getTraversal();
    List<Vertex> vertices = traversal.order().by(orderTraversal, Order.incr).toList();
    assertThat(vertices, contains(likeVertex().withTimId("id1"), likeVertex().withTimId("id3"), likeVertex().withTimId("id2")));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Test(org.junit.Test)

Example 2 with Property

use of nl.knaw.huygens.timbuctoo.search.description.Property in project timbuctoo by HuygensING.

the class FullTextSearchDescription method createLocalFullTextSearchDescriptionWithBackupProperty.

public static FullTextSearchDescription createLocalFullTextSearchDescriptionWithBackupProperty(String name, String propertyName, String backUpPropertyName) {
    Property prop1 = localProperty().withName(propertyName).build();
    Property prop2 = localProperty().withName(backUpPropertyName).build();
    return new FullTextSearchDescription(name, prop1, prop2);
}
Also used : Property.localProperty(nl.knaw.huygens.timbuctoo.search.description.Property.localProperty) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Property.derivedProperty(nl.knaw.huygens.timbuctoo.search.description.Property.derivedProperty)

Example 3 with Property

use of nl.knaw.huygens.timbuctoo.search.description.Property in project timbuctoo by HuygensING.

the class FullTextSearchDescription method createDerivedFullTextSearchDescriptionWithBackupProperty.

public static FullTextSearchDescription createDerivedFullTextSearchDescriptionWithBackupProperty(String name, String propertyName, String backupPropertyName, String... relations) {
    Property prop1 = derivedProperty(relations).withName(propertyName).build();
    Property prop2 = derivedProperty(relations).withName(backupPropertyName).build();
    return new FullTextSearchDescription(name, prop1, prop2);
}
Also used : Property.localProperty(nl.knaw.huygens.timbuctoo.search.description.Property.localProperty) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Property.derivedProperty(nl.knaw.huygens.timbuctoo.search.description.Property.derivedProperty)

Example 4 with Property

use of nl.knaw.huygens.timbuctoo.search.description.Property in project timbuctoo by HuygensING.

the class PropertyTest method getTraversalReturnsATraversalThatOrdersByStringValue.

@Test
public void getTraversalReturnsATraversalThatOrdersByStringValue() {
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY, "123")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY, "1234")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY, "254")).build().traversal().V();
    Property instance = Property.localProperty().withName(PROPERTY).build();
    GraphTraversal<?, ?> orderTraversal = instance.getTraversal();
    List<Vertex> vertices = traversal.order().by(orderTraversal, Order.incr).toList();
    assertThat(vertices, contains(likeVertex().withTimId("id1"), likeVertex().withTimId("id2"), likeVertex().withTimId("id3")));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Order(org.apache.tinkerpop.gremlin.process.traversal.Order) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) VertexMatcher.likeVertex(nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Property(nl.knaw.huygens.timbuctoo.search.description.Property) Test(org.junit.Test)

Aggregations

Property (nl.knaw.huygens.timbuctoo.search.description.Property)4 List (java.util.List)2 Property.derivedProperty (nl.knaw.huygens.timbuctoo.search.description.Property.derivedProperty)2 Property.localProperty (nl.knaw.huygens.timbuctoo.search.description.Property.localProperty)2 PropertyParser (nl.knaw.huygens.timbuctoo.search.description.PropertyParser)2 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)2 VertexMatcher.likeVertex (nl.knaw.huygens.timbuctoo.util.VertexMatcher.likeVertex)2 Order (org.apache.tinkerpop.gremlin.process.traversal.Order)2 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)2 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)2 Matchers.contains (org.hamcrest.Matchers.contains)2 Test (org.junit.Test)2