Examples of OrientEdge


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

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("field1", "value1");
    map.put("field2", "value2");
    OrientVertex vertexB = database.addVertex(null, map);

    OrientEdge edgeC = database.addEdge(null, vertexA, vertexB, "E");
    edgeC.setProperty("edgeF1", "edgeV2");

    database.commit();

    Assert.assertEquals(vertexA.getProperty("field1"), "value1");
    Assert.assertEquals(vertexA.getProperty("field2"), "value2");

    Assert.assertEquals(vertexB.getProperty("field1"), "value1");
    Assert.assertEquals(vertexB.getProperty("field2"), "value2");

    Assert.assertEquals(edgeC.getProperty("edgeF1"), "edgeV2");
  }
View Full Code Here

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

          Iterable<OrientEdge> result = graph.command(
              new OCommandSQL("create edge Loves from " + vertices[i].getIdentity() + " to " + fishing.getIdentity()
                  + " set real = true")).execute();

          Assert.assertTrue(result.iterator().hasNext());
          OrientEdge e = result.iterator().next();
          Assert.assertEquals(e.getProperty("real"), true);

          final OrientVertex explain = graph.command(new OCommandSQL("explain select from " + e.getIdentity())).execute();
          System.out
              .println("explain select from " + e.getIdentity() + " -> " + ((ODocument) explain.getRecord()).field("servers"));

          result = graph.command(new OCommandSQL("select from " + e.getIdentity())).execute();

          Assert.assertTrue(result.iterator().hasNext());
          OrientEdge e2 = result.iterator().next();
          Assert.assertEquals(e2.getProperty("real"), true);

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

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

      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();
View Full Code Here

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

    ODocument firstItem = result.get(0);
    List<OrientEdge> firstResult = firstItem.field("gremlin");

    Assert.assertEquals(1, firstResult.size());
    OrientEdge edge = firstResult.get(0);
    Assert.assertEquals(new ORecordId(edge1Id, OClusterPositionFactory.INSTANCE.valueOf(0)), (ORID) edge.getId());

    ODocument secondItem = result.get(1);
    List<OrientEdge> secondResult = secondItem.field("gremlin");
    Assert.assertTrue(secondResult.isEmpty());
  }
View Full Code Here

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

  public void testEdgePhysicalRemoval() {
    graph.command(new OCommandSQL("delete from e where name = 'forceCreationOfDocument'")).execute();

    Vertex v1 = graph.addVertex(null);
    Vertex v2 = graph.addVertex(null);
    OrientEdge e = graph.addEdge(null, v1, v2, "anyLabel");
    e.setProperty("key", "forceCreationOfDocument");

    Iterable<Edge> result = graph.command(new OSQLSynchQuery<Edge>("select from e where key = 'forceCreationOfDocument'"))
        .execute();
    Assert.assertTrue(result.iterator().hasNext());
    Assert.assertTrue(result.iterator().next() instanceof Edge);

    e.remove();
    graph.commit();

    result = graph.command(new OSQLSynchQuery<Edge>("select from e where key = 'forceCreationOfDocument'")).execute();
    Assert.assertFalse(result.iterator().hasNext());
  }
View Full Code Here

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

      }

      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.OrientEdge

 
  private LinkDao(){}
 
  public ODocument createLink(String sourceId, String destId,String edgeName) throws DocumentNotFoundException {
    DbHelper.requestTransaction();
    OrientEdge edge = null;
    try{
      OrientVertex sourceVertex = StorageUtils.getNodeVertex(sourceId);
      OrientVertex destVertex = StorageUtils.getNodeVertex(destId);
      UUID token = UUID.randomUUID();
      edge = (OrientEdge)sourceVertex.addEdge(edgeName, destVertex);
      edge.getRecord().field(BaasBoxPrivateFields.ID.toString(),token.toString());
      edge.getRecord().field(BaasBoxPrivateFields.AUTHOR.toString(),DbHelper.currentUsername());
      edge.getRecord().field(BaasBoxPrivateFields.CREATION_DATE.toString(),new Date());
      edge.save();
      DbHelper.commitTransaction();
    }catch (DocumentNotFoundException e){
      DbHelper.rollbackTransaction();
      throw e;
    }
    //edge.getGraph().commit();
    return edge.getRecord();
  }
View Full Code Here

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

        if (rid != null) {
          // REMOVE PUNCTUAL RID
          OGraphCommandExecutorSQLFactory.runInTx(new OGraphCommandExecutorSQLFactory.GraphCallBack<Object>() {
            @Override
            public Object call(OrientBaseGraph graph) {
              final OrientEdge e = graph.getEdge(rid);
              if (e != null) {
                e.remove();
                removed = 1;
              }

              return null;
            }
          });
        } else {
          // MULTIPLE EDGES
          final Set<OrientEdge> edges = new HashSet<OrientEdge>();
          if (query == null) {
            OGraphCommandExecutorSQLFactory.runInTx(new OGraphCommandExecutorSQLFactory.GraphCallBack<Object>() {
              @Override
              public Object call(OrientBaseGraph graph) {
                Set<OIdentifiable> fromIds = null;
                if (fromExpr != null)
                  fromIds = OSQLEngine.getInstance().parseRIDTarget(graph.getRawGraph(), fromExpr, context, iArgs);
                Set<OIdentifiable> toIds = null;
                if (toExpr != null)
                  toIds = OSQLEngine.getInstance().parseRIDTarget(graph.getRawGraph(), toExpr, context, iArgs);

                if (fromIds != null && toIds != null) {
                  // REMOVE ALL THE EDGES BETWEEN VERTICES
                  for (OIdentifiable fromId : fromIds) {
                    final OrientVertex v = graph.getVertex(fromId);
                    if (v != null)
                      for (Edge e : v.getEdges(Direction.OUT)) {
                        final OIdentifiable inV = ((OrientEdge) e).getInVertex();
                        if (inV != null && toIds.contains(inV.getIdentity()))
                          edges.add((OrientEdge) e);
                      }
                  }
                } else if (fromIds != null) {
                  // REMOVE ALL THE EDGES THAT START FROM A VERTEXES
                  for (OIdentifiable fromId : fromIds) {
                    final OrientVertex v = graph.getVertex(fromId);
                    if (v != null)
                      edges.add((OrientEdge) v.getEdges(Direction.OUT));
                  }
                } else if (toIds != null) {
                  // REMOVE ALL THE EDGES THAT ARRIVE TO A VERTEXES
                  for (OIdentifiable toId : toIds) {
                    final OrientVertex v = graph.getVertex(toId);
                    if (v != null) {
                      edges.add((OrientEdge) v.getEdges(Direction.IN));
                    }
                  }
                } else
                  throw new OCommandExecutionException("Invalid target: " + toIds);

                if (compiledFilter != null) {
                  // ADDITIONAL FILTERING
                  for (Iterator<OrientEdge> it = edges.iterator(); it.hasNext();) {
                    final OrientEdge edge = it.next();
                    if (!(Boolean) compiledFilter.evaluate((ODocument) edge.getRecord(), null, context))
                      it.remove();
                  }
                }

                // DELETE THE FOUND EDGES
                removed = edges.size();
                for (OrientEdge edge : edges)
                  edge.remove();

                return null;
              }
            });
          } else {
View Full Code Here

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

      if (!(Boolean) compiledFilter.evaluate((ODocument) id.getRecord(), null, context))
        return true;
    }

    if (id.getIdentity().isValid()) {
      final OrientEdge e = graph.getEdge(id);

      if (e != null) {
        e.remove();
        removed++;
      }
    }

    return true;
View Full Code Here

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

          boolean reloaded = false;

          for (int retry = 0;; retry++) {
            try {

              final OrientEdge e = g.addEdge(null, vOut, vIn, iEdgeLabel);

              addInCache(vOut.getProperty(keyFieldName), vOut.getVertexInstance());
              addInCache(vIn.getProperty(keyFieldName), vIn.getVertexInstance());

              edgesCreated.incrementAndGet();

              return e;

            } catch (OConcurrentModificationException e) {
              concurrentException.incrementAndGet();
              reloadVertices(vOut, vIn, iEdgeLabel, retry, e);
              reloaded = true;
            } catch (ORecordDuplicatedException e) {
              indexUniqueException.incrementAndGet();
              reloadVertices(vOut, vIn, iEdgeLabel, retry, e);
              reloaded = true;
            } catch (Exception e) {
              unknownException.incrementAndGet();
              OLogManager.instance().warn(
                  this,
                  "Error on addEdge(" + iOutVertex + "," + iInVertex + "," + iEdgeLabel + "), retrying (retry=" + retry + "/"
                      + maxRetries + ") Thread: " + Thread.currentThread().getId());
              e.printStackTrace();
            }
          }
        } finally {
          g.shutdown();
          endAsynchOperation();
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.