Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.GraphQuery


    protected Vertex findVertex(String name, RelationshipType type) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Finding vertex for: name=" + name + ", type=" + type);
        }

        GraphQuery query = graph.query()
                .has(RelationshipProperty.NAME.getName(), name)
                .has(RelationshipProperty.TYPE.getName(), type.getName());
        Iterator<Vertex> results = query.vertices().iterator();
        return results.hasNext() ? results.next() : null// returning one since name is unique
    }
View Full Code Here


        Assert.assertTrue(actual.containsAll(Arrays.asList("imp-click-join1", "imp-click-join2")),
                "Actual does not contain expected: " + actual);
    }

    private Vertex getEntityVertex(String entityName, RelationshipType entityType) {
        GraphQuery entityQuery = getQuery()
                .has(RelationshipProperty.NAME.getName(), entityName)
                .has(RelationshipProperty.TYPE.getName(), entityType.getName());
        Iterator<Vertex> iterator = entityQuery.vertices().iterator();
        Assert.assertTrue(iterator.hasNext());

        Vertex entityVertex = iterator.next();
        Assert.assertNotNull(entityVertex);
View Full Code Here

        verifyFeedsOwnedByUserAndClassification(feedType.getName(), classification,
                Arrays.asList("impression-feed", "clicks-feed", "imp-click-join2"));
    }

    private List<String> getFeedsOwnedByAUser(String feedType) {
        GraphQuery userQuery = getQuery()
                .has(RelationshipProperty.NAME.getName(), FALCON_USER)
                .has(RelationshipProperty.TYPE.getName(), RelationshipType.USER.getName());

        List<String> feedNames = new ArrayList<String>();
        for (Vertex userVertex : userQuery.vertices()) {
            for (Vertex feed : userVertex.getVertices(Direction.IN, RelationshipLabel.USER.getName())) {
                if (feed.getProperty(RelationshipProperty.TYPE.getName()).equals(feedType)) {
                    System.out.println(FALCON_USER + " owns -> " + GraphUtils.vertexString(feed));
                    feedNames.add(feed.<String>getProperty(RelationshipProperty.NAME.getName()));
                }
View Full Code Here

        return feedNames;
    }

    private void verifyFeedsClassifiedAsSecure(String feedType, List<String> expected) {
        GraphQuery classQuery = getQuery()
                .has(RelationshipProperty.NAME.getName(), "Secure")
                .has(RelationshipProperty.TYPE.getName(), RelationshipType.TAGS.getName());

        List<String> actual = new ArrayList<String>();
        for (Vertex feedVertex : classQuery.vertices()) {
            for (Vertex feed : feedVertex.getVertices(Direction.BOTH, "classified-as")) {
                if (feed.getProperty(RelationshipProperty.TYPE.getName()).equals(feedType)) {
                    System.out.println(" Secure classification -> " + GraphUtils.vertexString(feed));
                    actual.add(feed.<String>getProperty(RelationshipProperty.NAME.getName()));
                }
View Full Code Here

*/
public class FramedGraphQueryImplTest {
 
  @Test
  public void testDelegation() {
    GraphQuery mockGraphQuery = mock(GraphQuery.class);
    FramedGraph framedGraph = new FramedGraphFactory().create(null);
   
    FramedGraphQueryImpl query = new FramedGraphQueryImpl(framedGraph, mockGraphQuery);
    stub(mockGraphQuery.has("")).toReturn(mockGraphQuery);
    query.has("");
    verify(mockGraphQuery).has("");
   
   
    stub(mockGraphQuery.has("", "bar")).toReturn(mockGraphQuery);
    query.has("", "bar");
    verify(mockGraphQuery).has("", "bar");
   
   
    Predicate predicate = new Predicate() {
     
      @Override
      public boolean evaluate(Object first, Object second) {
        return false;
      }
    };
    stub(mockGraphQuery.has("", predicate, "bar")).toReturn(mockGraphQuery);
    query.has("", predicate, "bar");
    verify(mockGraphQuery).has(eq(""), same(predicate), eq("bar"));
   
   
    stub(mockGraphQuery.has("", 2, Compare.EQUAL)).toReturn(mockGraphQuery);
    query.has("", 2, Compare.EQUAL);
    verify(mockGraphQuery).has(eq(""), same(2), eq(Compare.EQUAL));
   
    stub(mockGraphQuery.hasNot("")).toReturn(mockGraphQuery);
    query.hasNot("");
    verify(mockGraphQuery).hasNot(eq(""));
   
    stub(mockGraphQuery.hasNot("", "bar")).toReturn(mockGraphQuery);
    query.hasNot("", "bar");
    verify(mockGraphQuery).hasNot(eq(""), eq("bar"));
   
   
    stub(mockGraphQuery.interval("", "bar", "bif")).toReturn(mockGraphQuery);
    query.interval("", "bar", "bif");
    verify(mockGraphQuery).interval(eq(""), eq("bar"), eq("bif"));
   
    stub(mockGraphQuery.limit(1)).toReturn(mockGraphQuery);
    query.limit(1);
    verify(mockGraphQuery).limit(1);
   
   
   
    List<Vertex> v = new ArrayList<Vertex>();
    stub(mockGraphQuery.vertices()).toReturn(v);
    query.vertices();
    verify(mockGraphQuery).vertices();
   
    Iterable<Person> people = query.vertices(Person.class);
    verify(mockGraphQuery, times(2)).vertices();
    assertFalse(people.iterator().hasNext());
   
   
    List<Edge> e = new ArrayList<Edge>();
    stub(mockGraphQuery.edges()).toReturn(e);
    query.edges();
    verify(mockGraphQuery).edges();
   
    Iterable<Knows> knows = query.edges(Knows.class);
    verify(mockGraphQuery, times(2)).edges();
View Full Code Here

                final E e = currentIterator.next();
                if (this.count > this.lowRange)
                    return e;
            } else {
                final Graph graph = this.starts.next();
                GraphQuery query = graph.query();
                if (null != this.hasContainers) {
                    for (final HasContainer hasContainer : this.hasContainers) {
                        query = query.has(hasContainer.key, hasContainer.predicate, hasContainer.value);
                    }
                }
                if (null != this.intervalContainers) {
                    for (final IntervalContainer intervalContainer : this.intervalContainers) {
                        query = query.interval(intervalContainer.key, intervalContainer.startValue, intervalContainer.endValue);
                    }
                }
                if (this.highRange != Integer.MAX_VALUE) {
                    query = query.limit(this.highRange - this.count);
                }

                this.currentIterator = this.elementClass.equals(Vertex.class) ?
                        (Iterator<E>) query.vertices().iterator() :
                        (Iterator<E>) query.edges().iterator();
            }
        }
    }
View Full Code Here

        return new OrientElementIterable<Vertex>(this, (Iterable<?>) indexValue);
      }
    }
    // NO INDEX: EXECUTE A QUERY
    GraphQuery query = query();
    for (int i = 0; i < iKey.length; i++) {
      query.has(iKey[i], iValue[i]);
    }
    return query.vertices();
  }
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.GraphQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.