Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Edge


     * Totally crazy confident non-nullity lack of test : this method is
     * only called when cascade type is either PERSIST or MERGE. In both
     * cases the call to getVertexFor will create the vertex if missing. As
     * a consequence there is no need for nullity check.
     */
    Edge link = null;
    // Get previously existing vertex
    List<Edge> matching = CollectionUtils.asList(service.getStrategy().getOutEdgesFor(rootVertex, p));
    // property is single-valued, so iteration can be done at most one
    if (matching.size() == 1) {
      // There is an existing edge, change its target and maybe delete
      // previous one
      Edge existing = matching.get(0);
      if (valueVertex != null && existing.getVertex(Direction.IN).equals(valueVertex)) {
        // Nothing to do
        link = existing;
      } else {
        // delete old edge (if it exists)
        GraphUtils.removeSafely(database, existing);
View Full Code Here


     *             in combination with {@link InVertex} and {@link OutVertex}.
   */
  public <F> F addEdge(final Object id, final Vertex outVertex,
      final Vertex inVertex, final String label,
      final Direction direction, final Class<F> kind) {
    Edge edge = addEdge(id, outVertex, inVertex, label);
    for (FrameInitializer initializer : config.getFrameInitializers()) {
      initializer.initElement(kind, this, edge);
    }
    return this.frame(edge, direction, kind);
  }
View Full Code Here

    FramedGraphFactory factory = new FramedGraphFactory(new TypedGraphModuleBuilder().withClass(A.class).withClass(B.class)
        .withClass(C.class).build());
    FramedGraph<Graph> framedGraph = factory.create(graph);
    Vertex v1 = graph.addVertex(null);
    Vertex v2 = graph.addVertex(null);
    Edge cE = graph.addEdge(null, v1, v2, "label");
    cE.setProperty("type", "C");
    Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
    assertTrue(c instanceof C);
  }
View Full Code Here

        FramedGraph<Graph> framedGraph = factory.create(graph);
        Vertex v1 = graph.addVertex(null);

        Vertex v2 = graph.addVertex(null);
        v2.setProperty("type", "A");
        Edge cE = graph.addEdge(null, v1, v2, "label");
        cE.setProperty("type", "C");
        Base c = framedGraph.getEdge(cE.getId(), Direction.OUT, Base.class);
        assertTrue(c instanceof C);
        assertTrue(((C) c).getInVertex() instanceof A);

    }
View Full Code Here

            Vertex dstBVertex = dstTx.getVertices("name", "B").iterator().next();
            Assert.assertNotNull(dstBVertex);
            Assert.assertEquals(dstBVertex.getProperty("name"), "B");
            Assert.assertEquals(dstBVertex.getProperty("age"), 50);

            Edge dstABEdge = dstAVertex.getEdges(Direction.OUT).iterator().next();
            Assert.assertNotNull(dstABEdge);
            Assert.assertEquals(dstABEdge.getLabel(), "friends");

            Assert.assertFalse(dstBVertex.getEdges(Direction.OUT).iterator().hasNext());

            Assert.assertFalse(dstTx.getVertices("name", "C").iterator().hasNext());
            Assert.assertFalse(dstTx.getVertices("name", "D").iterator().hasNext());
View Full Code Here

            Vertex dstBVertex = dstTx.getVertices("name", "B").iterator().next();
            Assert.assertNotNull(dstBVertex);
            Assert.assertEquals(dstBVertex.getProperty("name"), "B");
            Assert.assertEquals(dstBVertex.getProperty("age"), 50);

            Edge dstABEdge = dstAVertex.getEdges(Direction.OUT).iterator().next();
            Assert.assertNotNull(dstABEdge);
            Assert.assertEquals(dstABEdge.getLabel(), "friends");

            Vertex dstCVertex = dstTx.getVertices("name", "C").iterator().next();
            Assert.assertNotNull(dstCVertex);
            Assert.assertEquals(dstCVertex.getProperty("name"), "C");
            Assert.assertEquals(dstCVertex.getProperty("age"), 36);

            Edge dstBCEdge = dstBVertex.getEdges(Direction.OUT).iterator().next();
            Assert.assertNotNull(dstBCEdge);
            Assert.assertEquals(dstBCEdge.getLabel(), "enemies");

            Assert.assertFalse(dstCVertex.getEdges(Direction.OUT).iterator().hasNext());

            Assert.assertFalse(dstTx.getVertices("name", "D").iterator().hasNext());
        } finally {
View Full Code Here

        Vertex dstBobVertex = dstTx.getVertices("name", "Bob").iterator().next();
        Assert.assertNotNull(dstBobVertex);
        Assert.assertEquals(dstBobVertex.getProperty("name"), "Bob");
        Assert.assertEquals(dstBobVertex.getProperty("age"), 50);

        Edge dstEdge = dstJoeVertex.getEdges(Direction.BOTH).iterator().next();
        Assert.assertNotNull(dstEdge);
        Assert.assertEquals(dstEdge.getLabel(), "friends");
        Assert.assertEquals(dstEdge.getVertex(Direction.IN), dstJoeVertex);
        Assert.assertEquals(dstEdge.getVertex(Direction.OUT), dstBobVertex);

       dstTx.rollback();
    }
View Full Code Here

        Vertex dstOutVertex = copyVertex(srcTx, dstTx, srcOutVertex, step);

        if (!edges.contains(srcEdge.getId())) {
            edges.add(srcEdge.getId());

            Edge dstEdge = dstTx.addEdge(
                    srcEdge.getId(),
                    dstOutVertex,
                    dstInVertex,
                    srcEdge.getLabel());
View Full Code Here

    public void defaultFilter(final FaunusVertex vertex) {
        if (!this.doesFilter) return;
        vertex.removeEdges(Tokens.Action.KEEP, this.direction, this.labels);
        Iterator<Edge> itty;
        Edge edge;
        if (this.hasContainers.size() > 0) {
            itty = vertex.getEdges(this.direction).iterator();
            while (itty.hasNext()) {
                edge = itty.next();
                for (final HasContainer hasContainer : this.hasContainers) {
View Full Code Here

            }
            this.graph.shutdown();
        }

        public Edge getOrCreateEdge(final FaunusEdge faunusEdge, final Vertex blueprintsOutVertex, final Vertex blueprintsInVertex, final Mapper<NullWritable, FaunusVertex, NullWritable, FaunusVertex>.Context context) throws InterruptedException {
            final Edge blueprintsEdge;
            if (null == engine) {
                blueprintsEdge = this.graph.addEdge(null, blueprintsOutVertex, blueprintsInVertex, faunusEdge.getLabel());
                context.getCounter(Counters.EDGES_WRITTEN).increment(1l);
                for (final String property : faunusEdge.getPropertyKeys()) {
                    blueprintsEdge.setProperty(property, faunusEdge.getProperty(property));
                    context.getCounter(Counters.EDGE_PROPERTIES_WRITTEN).increment(1l);
                }
            } else {
                try {
                    final Bindings bindings = engine.createBindings();
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Edge

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.