Package com.tinkerpop.blueprints.impls.orient

Examples of com.tinkerpop.blueprints.impls.orient.OrientGraph


  }


  @BeforeMethod
  public void init() {
    database = new OrientGraph(url);
    database.setUseLightweightEdges(false);
  }
View Full Code Here


      Assert.assertTrue(v.getSchemaClass().isSubClassOf(vehicleClass));
    }

    database.shutdown();

    database = new OrientGraph(url);
    database.setUseLightweightEdges(false);

    database.getRawGraph().getMetadata().getSchema().reload();

    result = database.getRawGraph().query(new OSQLSynchQuery<ODocument>("select from GraphVehicle"));
View Full Code Here

    super(url);
  }

  @BeforeClass
  public void init() {
    OrientGraph graph = new OrientGraph(database);
    graph.setUseLightweightEdges(false);


    graph.createVertexType("Movie");
    graph.createVertexType("Actor");

    tomCruise = graph.addVertex("class:Actor", "name", "Tom Cruise").getRecord();
    totalElements++;
    megRyan = graph.addVertex("class:Actor", "name", "Meg Ryan").getRecord();
    totalElements++;
    nicoleKidman = graph.addVertex("class:Actor", "name", "Nicol Kidman").getRecord();
    totalElements++;

    ODocument topGun = graph.addVertex("class:Movie", "name", "Top Gun", "year", 1986).getRecord();
    totalElements++;
    ODocument missionImpossible = graph.addVertex("class:Movie", "name", "Mission: Impossible", "year", 1996).getRecord();
    totalElements++;
    ODocument youHaveGotMail = graph.addVertex("class:Movie", "name", "You've Got Mail","year", 1998).getRecord();
    totalElements++;

    graph.addEdge(null,graph.getVertex(tomCruise), graph.getVertex(topGun), "actorIn");
    totalElements++;
    graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(topGun), "actorIn");
    totalElements++;
    graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(missionImpossible), "actorIn");
    totalElements++;
    graph.addEdge(null, graph.getVertex(megRyan), graph.getVertex(youHaveGotMail), "actorIn");
    totalElements++;

    graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(megRyan),"friend");
    totalElements++;
    graph.addEdge(null, graph.getVertex(tomCruise), graph.getVertex(nicoleKidman), "married").setProperty("year", 1990);
    totalElements++;

    graph.commit();
  }
View Full Code Here

      }
    }

    for (int s = 0; s < SERVERS; ++s) {
      OrientGraphFactory factory = new OrientGraphFactory("plocal:target/server" + s + "/databases/" + getDatabaseName());
      OrientGraph g = factory.getTx();

      try {
        for (int i = 0; i < SERVERS; ++i) {
          try {
            final OrientVertex v = g.addVertex("class:" + "Client" + i);
            Assert.assertTrue(false);
          } catch (OValidationException e) {
            // EXPECTED
          }
        }
      } finally {
        g.shutdown();
      }
    }
  }
View Full Code Here

public class TestDeleteEdge {

  @Test
  public void t() {
    final OrientGraph graph = new OrientGraph("memory:" + TestDeleteEdge.class.getSimpleName(), "admin", "admin");

    for (int i = 0; i < 10; i++) {
      OrientVertex v1 = graph.addVertex("class:TestVertex");
      OrientVertex v2 = graph.addVertex("class:TestVertex");
      OrientVertex v3 = graph.addVertex("class:TestVertex");
      OrientVertex v4 = graph.addVertex("class:TestVertex");

      Map<String, Object> p1 = new HashMap<String, Object>();
      p1.put("based_on", "0001");
      OrientEdge e1 = v1.addEdge(null, v2, "TestEdge", null, p1);
      e1.save();

      Map<String, Object> p2 = new HashMap<String, Object>();
      p2.put("based_on", "0002");
      OrientEdge e2 = v3.addEdge(null, v4, "TestEdge", null, p2);
      e2.save();

      graph.commit();

      graph.command(new OCommandSQL("delete edge TestEdge where based_on = '0001'")).execute();

      Iterable<OrientVertex> edges = graph.command(new OCommandSQL("select count(*) from TestEdge where based_on = '0001'"))
          .execute();
      assertTrue(edges.iterator().hasNext());
      assertEquals(edges.iterator().next().getProperty("count"), 0l);
    }

    graph.shutdown();
  }
View Full Code Here

  public void tearDown() throws Exception {
    graph.shutdown();
  }

  private void setUpDatabase() {
    graph = new OrientGraph("memory:OSQLFunctionDijkstraTest");
    graph.createEdgeType("weight");

    v1 = graph.addVertex(null);
    v2 = graph.addVertex(null);
    v3 = graph.addVertex(null);
View Full Code Here

  @BeforeClass
  public static void beforeClass() {
    final String dbName = GraphTxAbstractTest.class.getSimpleName();
    final String storageType = getStorageType();
    final String buildDirectory = System.getProperty("buildDirectory", ".");
    graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);
    graph.drop();
    graph = new OrientGraph(storageType + ":" + buildDirectory + "/" + dbName);

  }
View Full Code Here

    graph.shutdown();
  }

  @Test
  public void t() {
    OrientGraph graph = new OrientGraph("memory:" + TestOutInChain.class.getSimpleName(), "admin", "admin");

    Vertex vUser = graph.addVertex("class:User");
    Vertex vCar = graph.addVertex("class:Car");
    graph.addEdge("class:Owns", vUser, vCar, null);

    graph.commit();

    Iterable<Vertex> res = graph.command(new OCommandSQL("select expand( out('Owns') ) from User")).execute();
    assertTrue(res.iterator().hasNext());
    assertEquals("Car", res.iterator().next().getProperty("@class").toString());

    Iterable<Vertex> resEdge = graph.command(new OCommandSQL("select expand( inE('Owns') ) from Car")).execute();
    assertTrue(resEdge.iterator().hasNext());

    // when out('Owns') is executed we have Car vertex (see above)
    // after that inE('Owns') should return Owns edge (see above)
    // but test fails
    resEdge = graph.command(new OCommandSQL("select expand( out('Owns').inE('Owns') ) from User")).execute();
    assertTrue(resEdge.iterator().hasNext());// assertion error here
  }
View Full Code Here

public class SQLGraphFunctionsTest {
  private OrientGraph graph;

  public SQLGraphFunctionsTest() {
    String url = "memory:" + SQLGraphFunctionsTest.class.getSimpleName();
    graph = new OrientGraph(url);

    OrientVertex v1 = graph.addVertex(null, "name", "A");
    OrientVertex v2 = graph.addVertex(null, "name", "B");
    OrientVertex v3 = graph.addVertex(null, "name", "C");
    OrientVertex v4 = graph.addVertex(null, "name", "D-D");
View Full Code Here

  private static OrientVertex jay;
  private static OrientVertex steve;

  @BeforeClass
  public static void setUp() throws Exception {
    graph = new OrientGraph("memory:" + VertexPredicateTest.class.getSimpleName());
    graph.createEdgeType("Friend");

    luca = graph.addVertex(null, "name", "Luca");
    bill = graph.addVertex(null, "name", "Bill");
    luca.addEdge("Friend", bill);
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.impls.orient.OrientGraph

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.