Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Edge


    }

    public void testFireEdgePropertyRemoved() {
        graph.addListener(graphChangedListener);

        Edge edge = createEdge();

        edge.setProperty("weight", System.currentTimeMillis());

        edge.removeProperty("weight");

        assertEquals(0, graphChangedListener.edgePropertyRemovedEventRecorded());
        ((EventTransactionalGraph) graph).commit();
        assertEquals(1, graphChangedListener.edgePropertyRemovedEventRecorded());
    }
View Full Code Here


                Assert.assertEquals(v.getProperty(key), found.getProperty(key));
            }
        }

        for (Edge e : graph.getEdges()) {
            Edge found = emptyGraph.getEdge(e.getId());

            Assert.assertNotNull(e);

            for (String key : found.getPropertyKeys()) {
                Assert.assertEquals(e.getProperty(key), found.getProperty(key));
            }
        }

    }
View Full Code Here

    }

    public void testFireEdgeRemoved() {
        graph.addListener(graphChangedListener);

        Edge edge = createEdge();

        graph.removeEdge(edge);

        assertEquals(0, graphChangedListener.edgeRemovedEventRecorded());
        ((EventTransactionalGraph) graph).commit();
View Full Code Here

    public void testTransactionSeriesWithSuccess() {
        graph.addListener(graphChangedListener);

        createEdge();
        Edge e = createEdge();
        e.setProperty("test", "it");
        e.setProperty("test", "that");

        Vertex v = createVertex();
        v.setProperty("test", "it");

        assertEquals(0, graphChangedListener.addEdgeEventRecorded());
View Full Code Here

            // no properties should be here
            Assert.assertEquals(null, found.getProperty("name"));
        }

        for (Edge e : graph.getEdges()) {
            Edge found = emptyGraph.getEdge(e.getId());

            Assert.assertNotNull(e);

            for (String key : found.getPropertyKeys()) {
                Assert.assertEquals(e.getProperty(key), found.getProperty(key));
            }

            // no properties should be here
            Assert.assertEquals(null, found.getProperty("weight"));
        }

    }
View Full Code Here

    public void testTransactionSeriesWithFailure() {
        graph.addListener(graphChangedListener);

        createEdge();
        Edge e = createEdge();
        e.setProperty("test", "it");
        e.setProperty("test", "that");

        Vertex v = createVertex();
        v.setProperty("test", "it");

        assertEquals(0, graphChangedListener.addEdgeEventRecorded());
View Full Code Here

        v1.removeProperty("aaa");

        Vertex v2 = graph.addVertex(20);
        Vertex v3 = graph.addVertex(30);

        Edge e1 = graph.addEdge(100, v1, v2, "friend");
        e1.setProperty("eee", "fff");
        e1.setProperty("ggg", "hhh");
        e1.setProperty("ggg", "hhhh");
        e1.removeProperty("eee");

        Edge e2 = graph.addEdge(101, v1, v2, "enemy");

        graph.removeEdge(e2);
        graph.removeVertex(v3);

        assertEquals(0, graphChangedListener.getOrder().size());
View Full Code Here

            if (null == v) {
                if (!firstClassEdges) {
                    return new StatementIteration();
                }

                Edge e = edgeForURI((URI) subject);
                if (null == e) {
                    return new StatementIteration();
                } else {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), allEdgeStatements);
                    return new StatementIteration(s);
View Full Code Here

                if (null == v) {
                    if (!firstClassEdges) {
                        return new StatementIteration();
                    }

                    Edge e = edgeForURI((URI) subject);
                    if (null == e) {
                        return new StatementIteration();
                    } else {
                        Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), edgeTypes);
                        return new StatementIteration(s);
                    }
                } else {
                    Source<Vertex> s = new Source<Vertex>(new SingleItemIterator<Vertex>(v), vertexTypes);
                    return new StatementIteration(s);
                }
            } else if (predicate.equals(PropertyGraphSail.ID)) {
                Vertex v = vertexForURI((URI) subject);
                if (null == v) {
                    if (!firstClassEdges) {
                        return new StatementIteration();
                    }

                    Edge e = edgeForURI((URI) subject);
                    if (null == e) {
                        return new StatementIteration();
                    } else {
                        Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), edgeIds);
                        return new StatementIteration(s);
                    }
                } else {
                    Source<Vertex> s = new Source<Vertex>(new SingleItemIterator<Vertex>(v), vertexIds);
                    return new StatementIteration(s);
                }
            } else if (predicate.equals(PropertyGraphSail.LABEL)) {
                if (!firstClassEdges) {
                    return new StatementIteration();
                }

                Edge e = edgeForURI((URI) subject);
                if (null == e) {
                    return new StatementIteration();
                } else {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), labels);
                    return new StatementIteration(s);
                }
            } else if (predicate.equals(PropertyGraphSail.HEAD)) {
                if (!firstClassEdges) {
                    return new StatementIteration();
                }

                Edge e = edgeForURI((URI) subject);
                if (null == e) {
                    return new StatementIteration();
                } else {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), heads);
                    return new StatementIteration(s);
                }
            } else if (predicate.equals(PropertyGraphSail.TAIL)) {
                if (!firstClassEdges) {
                    return new StatementIteration();
                }

                Edge e = edgeForURI((URI) subject);
                if (null == e) {
                    return new StatementIteration();
                } else {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), tails);
                    return new StatementIteration(s);
                }
            } else if (isPropertyPredicate(predicate)) {
                String key = keyFromPredicate(predicate);
                Vertex v = vertexForURI((URI) subject);
                if (null == v) {
                    if (!firstClassEdges) {
                        return new StatementIteration();
                    }

                    Edge e = edgeForURI((URI) subject);
                    if (null == e) {
                        return new StatementIteration();
                    } else {
                        Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), edgePropertiesWithKey(key, predicate));
                        return new StatementIteration(s);
View Full Code Here

                                                                           final Value object) throws SailException {
        if (subject instanceof URI) {
            Collection<Source> sources = new LinkedList<Source>();

            Vertex v = vertexForURI((URI) subject);
            Edge e = edgeForURI((URI) subject);
            Object val = literalToObject(object);
            Vertex vObj = object instanceof URI ? vertexForURI((URI) object) : null;

            // vertex id
            if (null != val && null != v) {
                if (v.getId().equals(val)) {
                    Source<Vertex> s = new Source<Vertex>(new SingleItemIterator<Vertex>(v), vertexIds);
                    sources.add(s);
                }
            }

            // vertex type
            if (null != v && object instanceof URI && ((URI) object).equals(PropertyGraphSail.VERTEX)) {
                Source<Vertex> s = new Source<Vertex>(new SingleItemIterator<Vertex>(v), vertexTypes);
                sources.add(s);
            }

            // vertex properties
            if (null != val && null != v) {
                Source<Vertex> vertices = new Source<Vertex>(
                        new SingleItemIterator<Vertex>(v),
                        vertexPropertiesWithValue(val, (Literal) object));
                sources.add(vertices);
            }

            if (firstClassEdges) {
                // edge id
                if (null != val && null != e) {
                    if (e.getId().equals(val)) {
                        Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), edgeIds);
                        sources.add(s);
                    }
                }

                // label
                if (null != val && (val instanceof String)) {
                    if (null != e && e.getLabel().equals(val)) {
                        Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), labels);
                        sources.add(s);
                    }
                }

                // head
                if (null != e && null != vObj && e.getVertex(Direction.IN).equals(vObj)) {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), heads);
                    sources.add(s);
                }

                // tail
                if (null != e && null != vObj && e.getVertex(Direction.OUT).equals(vObj)) {
                    Source<Edge> s = new Source<Edge>(new SingleItemIterator<Edge>(e), tails);
                    sources.add(s);
                }

                // edge type
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.