Package org.neo4j.cypher.javacompat

Examples of org.neo4j.cypher.javacompat.ExecutionEngine


    @Before
    public void setUp()
    {
        gen.get().setGraph( db );
        engine = new ExecutionEngine( db );
        try (Transaction tx = db.beginTx())
        {
            StyledImageExporter exporter = new StyledImageExporter( db );
            exporter.setExportDir( "target/docs/images/" );
            exporter.saveImage( GeoPipeline.start( intersectionLayer ).toFeatureCollection(),
View Full Code Here


        IndexManager indexMan = db.index();
        Index<Node> index;
        Transaction tx = db.beginTx();
        index = indexMan.forNodes("layer1", config);
        assertNotNull(index);
        ExecutionEngine engine = new ExecutionEngine(db);
        ExecutionResult result1 = engine.execute("create (malmo{name:'Malmö',lat:56.2, lon:15.3})-[:TRAIN]->(stockholm{name:'Stockholm',lat:59.3,lon:18.0}) return malmo");
        Node malmo = (Node) result1.iterator().next().get("malmo");
        index.add(malmo, "dummy", "value");
        tx.success();
        tx.close();
        tx = db.beginTx();
        Map<String, Object> params = new HashMap<String, Object>();
        //within Envelope
        params.put(LayerNodeIndex.ENVELOPE_PARAMETER, new Double[]{15.0,
                16.0, 56.0, 57.0});
        IndexHits<Node> hits = index.query(LayerNodeIndex.WITHIN_QUERY, params);
        assertTrue(hits.hasNext());

        // within BBOX
        hits = index.query(LayerNodeIndex.BBOX_QUERY,
                "[15.0, 16.0, 56.0, 57.0]");
        assertTrue(hits.hasNext());

        //within any WKT geometry
        hits = index.query(LayerNodeIndex.WITHIN_WKT_GEOMETRY_QUERY,
                "POLYGON ((15 56, 15 57, 16 57, 16 56, 15 56))");
        assertTrue(hits.hasNext());
        //polygon with hole, excluding n1
        hits = index.query(LayerNodeIndex.WITHIN_WKT_GEOMETRY_QUERY,
                "POLYGON ((15 56, 15 57, 16 57, 16 56, 15 56)," +
                        "(15.1 56.1, 15.1 56.3, 15.4 56.3, 15.4 56.1, 15.1 56.1))");
        assertFalse(hits.hasNext());


        //within distance
        params.clear();
        params.put(LayerNodeIndex.POINT_PARAMETER, new Double[]{56.5, 15.5});
        params.put(LayerNodeIndex.DISTANCE_IN_KM_PARAMETER, 100.0);
        hits = index.query(LayerNodeIndex.WITHIN_DISTANCE_QUERY,
                params);
        assertTrue(hits.hasNext());

        ExecutionResult result = engine.execute("start malmo=node:layer1('bbox:[15.0, 16.0, 56.0, 57.0]') match p=malmo--other return malmo, other");
        assertTrue(result.iterator().hasNext());
        result = engine.execute("start malmo=node:layer1('withinDistance:[56.0, 15.0,1000.0]') match p=malmo--other return malmo, other");
        assertTrue(result.iterator().hasNext());
        System.out.println(result.dumpToString());
    }
View Full Code Here

            Node robin = db.createNode();
            robin.setProperty("wkt", "POINT(44.44 33.33)");
            robin.setProperty("name", "robin");
            index.add(robin, "dummy", "value");

            ExecutionEngine engine = new ExecutionEngine(db);
            assertTrue(engine.execute("start n=node:layer3('withinDistance:[33.32, 44.44, 5.0]') return n").columnAs("n").hasNext());

            NodeProxy row = (org.neo4j.kernel.impl.core.NodeProxy) engine.execute("start n=node:layer3('withinDistance:[33.32, 44.44, 5.0]') return n").columnAs("n").next();
            assertEquals("robin", row.getProperty("name"));
            assertEquals("POINT(44.44 33.33)", row.getProperty("wkt"));

            //update the node
            robin.setProperty("wkt", "POINT(55.55 33.33)");
            index.add(robin, "dummy", "value");
            assertFalse(engine.execute("start n=node:layer3('withinDistance:[33.32, 44.44, 5.0]') return n").columnAs("n").hasNext());
            assertTrue(engine.execute("start n=node:layer3('withinDistance:[33.32, 55.55, 5.0]') return n").columnAs("n").hasNext());
            tx.success();
        }

    }
View Full Code Here

        return getReferenceNode(db, "rtree");
    }

    public static Node getReferenceNode(GraphDatabaseService db, String name) {
        if (engine == null || db != dbRef) {
            engine = new ExecutionEngine(db);
            ReferenceNodes.dbRef = db;
        }
        ExecutionResult result = engine.execute("MERGE (ref:ReferenceNode {name:{name}}) RETURN ref", map("name", name));
        return IteratorUtil.single(result.<Node>columnAs("ref"));
    }
View Full Code Here

            }
        };
        t.start();t.join();
        Transaction tx = gdb.beginTx();
        try {
            final ExecutionResult result = new ExecutionEngine(gdb).execute("start n=node:Test('name:*') return n");
            assertEquals(0,IteratorUtil.count(result));
            assertEquals("Test", gdb.index().nodeIndexNames()[0]);
        } finally {
            tx.success();tx.close();
        }
View Full Code Here

     * @throws AssertionError in case the graphs are not the same.
     */
    public static void assertSameGraph(GraphDatabaseService database, String sameGraphCypher) {
        GraphDatabaseService otherDatabase = new TestGraphDatabaseFactory().newImpermanentDatabase();

        new ExecutionEngine(otherDatabase).execute(sameGraphCypher);

        try {
            assertSameGraph(database, otherDatabase, InclusionPolicies.all());
        } finally {
            otherDatabase.shutdown();
View Full Code Here

     * @throws AssertionError in case the graphs are not the same.
     */
    public static void assertSameGraph(GraphDatabaseService database, String sameGraphCypher, InclusionPolicies inclusionPolicies) {
        GraphDatabaseService otherDatabase = new TestGraphDatabaseFactory().newImpermanentDatabase();

        new ExecutionEngine(otherDatabase).execute(sameGraphCypher);

        try {
            assertSameGraph(database, otherDatabase, inclusionPolicies);
        } finally {
            otherDatabase.shutdown();
View Full Code Here

     * @throws AssertionError in case the "cypher" graph is not a subgraph of the "database" graph.
     */
    public static void assertSubgraph(GraphDatabaseService database, String subgraphCypher) {
        GraphDatabaseService otherDatabase = new TestGraphDatabaseFactory().newImpermanentDatabase();

        new ExecutionEngine(otherDatabase).execute(subgraphCypher);

        try {
            assertSubgraph(database, otherDatabase, InclusionPolicies.all());
        } finally {
            otherDatabase.shutdown();
View Full Code Here

     * @throws AssertionError in case the "cypher" graph is not a subgraph of the "database" graph.
     */
    public static void assertSubgraph(GraphDatabaseService database, String subgraphCypher, InclusionPolicies inclusionPolicies) {
        GraphDatabaseService otherDatabase = new TestGraphDatabaseFactory().newImpermanentDatabase();

        new ExecutionEngine(otherDatabase).execute(subgraphCypher);

        try {
            assertSubgraph(database, otherDatabase, inclusionPolicies);
        } finally {
            otherDatabase.shutdown();
View Full Code Here

     */
    @Override
    public void prepareDatabase(GraphDatabaseService database, final Map<String, Object> params) {
        super.prepareDatabase(database, params);

        executionEngine = new ExecutionEngine(database);
    }
View Full Code Here

TOP

Related Classes of org.neo4j.cypher.javacompat.ExecutionEngine

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.