Package com.tinkerpop.gremlin.structure

Examples of com.tinkerpop.gremlin.structure.Graph$Features$GraphFeatures


    }

    @Test
    public void serializeVertexWithEmbeddedMap() throws Exception {
        final Graph g = TinkerGraph.open();
        final Vertex v = g.addVertex();
        final Map<String, Object> map = new HashMap<>();
        map.put("x", 500);
        map.put("y", "some");

        final ArrayList<Object> friends = new ArrayList<>();
        friends.add("x");
        friends.add(5);
        friends.add(map);

        v.property("friends", friends);

        final List list = g.V().toList();

        final ResponseMessage response = convert(list);
        assertCommon(response);

        final List<Map<String, Object>> vertexList = (List<Map<String, Object>>) response.getResult().getData();
View Full Code Here


     * Create a new instance using the {@link Settings} from Gremlin Server.
     */
    public Graphs(final Settings settings) {
        settings.graphs.entrySet().forEach(e -> {
            try {
                final Graph newGraph = GraphFactory.open(e.getValue());
                graphs.put(e.getKey(), newGraph);
                logger.info("Graph [{}] was successfully configured via [{}].", e.getKey(), e.getValue());
            } catch (RuntimeException re) {
                logger.warn(String.format("Graph [%s] configured at [%s] could not be instantiated and will not be available in Gremlin Server.  GraphFactory message: %s",
                        e.getKey(), e.getValue(), re.getMessage()), re);
View Full Code Here

    /**
     * Rollback transactions across all {@link com.tinkerpop.gremlin.structure.Graph} objects.
     */
    public void rollbackAll() {
        graphs.entrySet().forEach(e -> {
            final Graph g = e.getValue();
            if (g.features().graph().supportsTransactions())
                g.tx().rollback();
        });
    }
View Full Code Here

    /**
     * Commit transactions across all {@link com.tinkerpop.gremlin.structure.Graph} objects.
     */
    public void commitAll() {
        graphs.entrySet().forEach(e -> {
            final Graph g = e.getValue();
            if (g.features().graph().supportsTransactions())
                g.tx().commit();
        });
    }
View Full Code Here

    @Test
    @Ignore
    public void testPlay() {
        System.out.println((float)1l / (float)7l);
        Graph g = TinkerFactory.createModern();
        Traversal t = g.V().has("name","marko").out().out().values("name");
        System.out.println(t);
        t.forEachRemaining(System.out::println);
        System.out.println(t);
        System.out.println("!!!!!!!!");
        t = g.V().has("name","marko").out().out().values("name");
        System.out.println(t);
        t.forEachRemaining(System.out::println);
        System.out.println(t);
    }
View Full Code Here

        System.out.println(t);
    }

    @Test
    public void testTraversalDSL() throws Exception {
        Graph g = TinkerFactory.createClassic();
        assertEquals(2, g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().toList().size());
        g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().forEachRemaining(name -> assertTrue(name.equals("josh") || name.equals("vadas")));
        assertEquals(1, g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().toList().size());
        g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().forEachRemaining(name -> assertEquals("lop", name));
    }
View Full Code Here

     * This test helps with data conversions on Grateful Dead.  No Assertions...run as needed. Never read from the
     * GraphML source as it will always use a String identifier.
     */
    @Test
    public void shouldWriteGratefulDead() throws IOException {
        final Graph g = TinkerGraph.open();
        final GraphReader reader = KryoReader.build().create();
        try (final InputStream stream = AbstractGremlinTest.class.getResourceAsStream("/com/tinkerpop/gremlin/structure/io/kryo/grateful-dead.gio")) {
            reader.readGraph(stream, g);
        }

        final Graph ng = TinkerGraph.open();
        g.V().sideEffect(ov -> {
            final Vertex v = ov.get();
            if (v.label().equals("song"))
                ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "song", "name", v.value("name"), "performances", v.property("performances").orElse(0), "songType", v.property("songType").orElse(""));
            else if (v.label().equals("artist"))
                ng.addVertex(T.id, Integer.parseInt(v.id().toString()), T.label, "artist", "name", v.value("name"));
            else
                throw new RuntimeException("damn");
        }).iterate();

        g.E().sideEffect(oe -> {
            final Edge e = oe.get();
            final Vertex v2 = ng.v(Integer.parseInt(e.inV().next().id().toString()));
            final Vertex v1 = ng.v(Integer.parseInt(e.outV().next().id().toString()));

            if (e.label().equals("followedBy"))
                v1.addEdge("followedBy", v2, T.id, Integer.parseInt(e.id().toString()), "weight", e.value("weight"));
            else if (e.label().equals("sungBy"))
                v1.addEdge("sungBy", v2, T.id, Integer.parseInt(e.id().toString()));
View Full Code Here

            graphClass = Class.forName(clazz);
        } catch (final ClassNotFoundException e) {
            throw new RuntimeException(String.format("GraphFactory could not find [%s] - Ensure that the jar is in the classpath", clazz));
        }

        final Graph g;
        try {
            // will basically use Graph.open(Configuration c) to instantiate, but could
            // technically use any method on any class with the same signature.
            g = (Graph) graphClass.getMethod("open", Configuration.class).invoke(null, configuration);
        } catch (final NoSuchMethodException e1) {
            throw new RuntimeException(String.format("GraphFactory can only instantiate Graph implementations from classes that have a static open() method that takes a single Apache Commons Configuration argument - [%s] does not seem to have one", clazz));
        } catch (final Exception e2) {
            throw new RuntimeException(String.format("GraphFactory could not instantiate this Graph implementation [%s]", clazz), e2);
        }

        final Graph returnedGraph;
        if (strategies != null && strategies.length == 1) {
            final StrategyWrappedGraph swg = new StrategyWrappedGraph(g);
            swg.getStrategy().setGraphStrategy(strategies[0]);
            returnedGraph = swg;
        } else if (strategies != null && strategies.length > 1) {
View Full Code Here

    @LoadGraphWith(MODERN)
    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
    public void g_v1_outE_subgraphXknowsX() throws Exception {
        final Configuration config = graphProvider.newGraphConfiguration("subgraph", this.getClass(), name.getMethodName());
        graphProvider.clear(config);
        Graph subgraph = graphProvider.openTestGraph(config);
        Traversal<Vertex, Graph> traversal = get_g_v1_outE_subgraphXknowsX_name_capXsgX(convertToVertexId("marko"), subgraph);
        printTraversalForm(traversal);
        subgraph = traversal.next();
        assertVertexEdgeCounts(3, 2).accept(subgraph);
        subgraph.E().forEachRemaining(e -> {
            assertEquals("knows", e.label());
            assertEquals("marko", e.outV().values("name").next());
            assertEquals(new Integer(29), e.outV().<Integer>values("age").next());
            assertEquals("person", e.outV().label().next());
View Full Code Here

    @LoadGraphWith(MODERN)
    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
    public void g_V_inE_subgraphXcreatedX_name() throws Exception {
        final Configuration config = graphProvider.newGraphConfiguration("subgraph", this.getClass(), name.getMethodName());
        graphProvider.clear(config);
        final Graph subgraph = graphProvider.openTestGraph(config);
        Traversal<Vertex, String> traversal = get_g_V_inE_subgraphXcreatedX_name(subgraph);
        printTraversalForm(traversal);
        traversal.iterate();

        assertVertexEdgeCounts(5, 4).accept(traversal.sideEffects().get("sg"));
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.structure.Graph$Features$GraphFeatures

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.