Examples of OrientGraph


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

  public static final String URL = "memory:" + IndexAgainstEdges.class.getSimpleName();

  @Test
  public void indexes() {
    OrientGraph g = new OrientGraph(URL, "admin", "admin");
    try {
      if (g.getVertexType("Profile") == null)
        g.createVertexType("Profile");
      if (g.getEdgeType("Friend") == null) {
        final OrientEdgeType f = g.createEdgeType("Friend");
        f.createProperty("in", OType.LINK);
        f.createProperty("out", OType.LINK);
        f.createIndex("Friend.in_out", OClass.INDEX_TYPE.UNIQUE, "in", "out");

      }

      OrientVertex luca = g.addVertex("class:Profile", "name", "Luca");
      OrientVertex jay = g.addVertex("class:Profile", "name", "Jay");
      OrientEdge friend = (OrientEdge) luca.addEdge("Friend", jay);

      assertFalse(friend.isLightweight());

    } finally {
      g.shutdown();
    }
  }
View Full Code Here

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

  public GraphFunctionsTest() {
  }

  @BeforeClass
  public static void before() {
    graph = new OrientGraph(DB_URL);

    if (graph.getEdgeType("SubEdge") == null)
      graph.createEdgeType("SubEdge");
    if (graph.getVertexType("SubVertex") == null)
      graph.createVertexType("SubVertex");
View Full Code Here

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

    Assert.assertTrue(ODocumentHelper.hasSameContentOf(doc, database, testDocument, database, null));
  }

  public void stackOverflowDuringToString() {
    final OrientGraph graph = new OrientGraph(database);

    OrientVertex a = graph.addVertex("A");
    OrientVertex b = graph.addVertex("B");
    OrientVertex c = graph.addVertex("C");

    a.addEdge("link", b);
    a.addEdge("link", c);
    b.addEdge("link", a);
    b.addEdge("link", c);
View Full Code Here

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

    return list;
  }

  public ODocument create() throws Throwable {
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    OrientGraph db = DbHelper.getOrientGraphConnection();
    try{
        ODocument doc = new ODocument(this.MODEL_NAME);
        ODocument vertex = db.addVertex("class:" + CLASS_VERTEX_NAME,FIELD_TO_DOCUMENT_FIELD,doc).getRecord();
        doc.field(FIELD_LINK_TO_VERTEX,vertex);
        doc.field(FIELD_CREATION_DATE,new Date());
        UUID token = UUID.randomUUID();
        if (Logger.isDebugEnabled()) Logger.debug("CreateUUID.onRecordBeforeCreate: " + doc.getIdentity() + " -->> " + token.toString());
        doc.field(BaasBoxPrivateFields.ID.toString(),token.toString());
        doc.field(BaasBoxPrivateFields.AUTHOR.toString(),db.getRawGraph().getUser().getName());
          return doc;
    }catch (Throwable e){
      throw e;
    }finally{
      if (Logger.isTraceEnabled()) Logger.trace("Method End");
View Full Code Here

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

    if (Logger.isTraceEnabled()) Logger.trace("Method End");
  }
 
  public void delete(ORID rid) throws Throwable{
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    OrientGraph db = DbHelper.getOrientGraphConnection();
    //retrieve the vertex associated to this node
    try{
      DbHelper.requestTransaction();
      OrientVertex vertex = db.getVertex(((ODocument)db.getRawGraph().load(rid))
                            .field(FIELD_LINK_TO_VERTEX));
      db.removeVertex(vertex);
      db.getRawGraph().delete(rid);
      DbHelper.commitTransaction();
    }catch (Throwable e){
      DbHelper.rollbackTransaction();
      throw e;
    }
View Full Code Here

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

    return (contentType.startsWith("image/"));
  }
 
  public static OrientVertex getNodeVertex(String nodeId) throws DocumentNotFoundException{
    GenericDao dao = GenericDao.getInstance();
    OrientGraph conn = DbHelper.getOrientGraphConnection();
    ORID nodeORID = dao.getRidNodeByUUID(nodeId);
    if (nodeORID==null) throw new DocumentNotFoundException(nodeId + " is not a valid Id");
    ODocument nodeDoc = dao.get(nodeORID);
    if (nodeDoc==null) throw new DocumentNotFoundException(nodeId + " is not a valid Id");
    return conn.getVertex(nodeDoc.field(NodeDao.FIELD_LINK_TO_VERTEX));
  }
View Full Code Here

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

  }
 


  public static OrientGraph getOrientGraphConnection(){
    return new OrientGraph(getODatabaseDocumentTxConnection(),false);
  }
View Full Code Here

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

    return create(username, password, null);
  };


  public ODocument create(String username, String password, String role) throws UserAlreadyExistsException {
    OrientGraph db = DbHelper.getOrientGraphConnection();
    if (existsUserName(username)) throw new UserAlreadyExistsException("User " + username + " already exists");
    OUser user=null;
    if (role==null) user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{DefaultRoles.REGISTERED_USER.toString()});
    else {
      ORole orole = RoleDao.getRole(role);
      if (orole==null) throw new InvalidParameterException("Role " + role + " does not exists");
      user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{role});
    }
   
    ODocument doc = new ODocument(this.MODEL_NAME);
    ODocument vertex = db.addVertex("class:"+CLASS_VERTEX_NAME,FIELD_TO_DOCUMENT_FIELD,doc).getRecord();
    doc.field(FIELD_LINK_TO_VERTEX,vertex);
    doc.field(FIELD_CREATION_DATE,new Date());

    doc.field(USER_LINK,user.getDocument().getIdentity());
    doc.save();
View Full Code Here

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

    graphPool = new OReentrantResourcePool<ODatabaseDocumentTx, OrientBaseGraph>(maxPool,
        new OResourcePoolListener<ODatabaseDocumentTx, OrientBaseGraph>() {

          @Override
          public OrientGraph createNewResource(final ODatabaseDocumentTx iKey, final Object... iAdditionalArgs) {
            return new OrientGraph(iKey);
          }

          @Override
          public boolean reuseResource(final ODatabaseDocumentTx iKey, final Object[] iAdditionalArgs,
              final OrientBaseGraph iReusedGraph) {
View Full Code Here

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

      // another user (db=v2 your=v0)
      OGlobalConfiguration.CACHE_LOCAL_ENABLED.setValue(false);

      // calling the open method opens the connection to graphdb. looks like the
      // implementation of shutdown will call the orientdb close method.
      return new OrientGraph(graphFile, username, password);

    } catch (Exception ex) {
      throw new GraphConfigurationException(ex);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.