Search in sources :

Example 1 with OTraverse

use of com.orientechnologies.orient.core.command.traverse.OTraverse in project orientdb by orientechnologies.

the class TraverseTest method traverseAPIIterating.

@Test
public void traverseAPIIterating() {
    int cycles = 0;
    for (OIdentifiable id : new OTraverse().target(database.browseClass("Movie").iterator()).predicate(new OCommandPredicate() {

        @Override
        public Object evaluate(OIdentifiable iRecord, ODocument iCurrentResult, OCommandContext iContext) {
            return ((Integer) iContext.getVariable("depth")) <= 2;
        }
    })) {
        cycles++;
    }
    Assert.assertTrue(cycles > 0);
}
Also used : OCommandContext(com.orientechnologies.orient.core.command.OCommandContext) OTraverse(com.orientechnologies.orient.core.command.traverse.OTraverse) OCommandPredicate(com.orientechnologies.orient.core.command.OCommandPredicate) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 2 with OTraverse

use of com.orientechnologies.orient.core.command.traverse.OTraverse in project orientdb by orientechnologies.

the class TraverseTest method traverseAPIAllFromActorNoWhere.

public void traverseAPIAllFromActorNoWhere() {
    List<OIdentifiable> result1 = new OTraverse().fields("*").target(tomCruise.getIdentity()).execute();
    Assert.assertEquals(result1.size(), totalElements);
}
Also used : OTraverse(com.orientechnologies.orient.core.command.traverse.OTraverse) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 3 with OTraverse

use of com.orientechnologies.orient.core.command.traverse.OTraverse in project orientdb by orientechnologies.

the class TraverseTest method traverseAPIandSQLIterating.

@Test
public void traverseAPIandSQLIterating() {
    int cycles = 0;
    for (OIdentifiable id : new OTraverse().target(database.browseClass("Movie").iterator()).predicate(new OSQLPredicate("$depth <= 2"))) {
        cycles++;
    }
    Assert.assertTrue(cycles > 0);
}
Also used : OSQLPredicate(com.orientechnologies.orient.core.sql.filter.OSQLPredicate) OTraverse(com.orientechnologies.orient.core.command.traverse.OTraverse) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) Test(org.testng.annotations.Test)

Aggregations

OTraverse (com.orientechnologies.orient.core.command.traverse.OTraverse)3 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)3 Test (org.testng.annotations.Test)2 OCommandContext (com.orientechnologies.orient.core.command.OCommandContext)1 OCommandPredicate (com.orientechnologies.orient.core.command.OCommandPredicate)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 OSQLPredicate (com.orientechnologies.orient.core.sql.filter.OSQLPredicate)1