Package org.neo4j.cypher.javacompat

Examples of org.neo4j.cypher.javacompat.ExecutionResult


    }


    private void dumpDB() {
        ExecutionResult cypher = new ExecutionEngine(graphdb()).execute("MATCH (n)-[r]->() return n,type(r),r");
        System.out.println(cypher.dumpToString());
    }
View Full Code Here


        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

    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

    @SuppressWarnings("unchecked")
    @Override
    public Result<Map<String, Object>> query(String statement, Map<String, Object> params) {
        try {
            ExecutionResult result = parseAndExecuteQuery(statement,params);
            return new QueryResultBuilder<Map<String,Object>>(result,resultConverter);
        } catch (Exception e) {
            throw new InvalidDataAccessResourceUsageException("Error executing statement " + statement, e);
        }
    }
View Full Code Here

        if (engine == null || db != dbRef) {
            engine = new ExecutionEngine(db);
            dbRef = db;
        }

        ExecutionResult result = engine.execute(query, map("name", name));
        return IteratorUtil.single(result.<Node>columnAs("ref"));
    }
View Full Code Here

  @Override
  public ClosableIterator<Tuple> executeBackendQuery(BackendCustomQuery customQuery, QueryParameters queryParameters) {
    Map<String, Object> parameters = getNamedParameterValuesConvertedByGridType( queryParameters );
    String nativeQuery = buildNativeQuery( customQuery, queryParameters );
    ExecutionResult result = neo4jCRUD.executeQuery( nativeQuery, parameters );

    if ( customQuery.getSingleEntityKeyMetadataOrNull() != null ) {
      return new NodesTupleIterator( result );
    }
    return new MapsTupleIterator( result );
View Full Code Here

  }
  public Result query(final GraphDatabaseService graphDb, final String query, final Map<String, Object> params) {
    ArrayList<Object[]> results = new ArrayList<>();
    ArrayList<String> columnNames = new ArrayList<>();
    ExecutionEngine engine = new ExecutionEngine(graphDb);
    ExecutionResult result = engine.execute(query, params);

    Boolean firstRow = true;
    for(Map<String, Object> row : result) {
      ArrayList<Object> rowResult = new ArrayList<>();
      for(Map.Entry<String, Object> column : row.entrySet()) {
View Full Code Here

                List<String> columns = new ArrayList<String>();
                //
                if ( currentAlias.getConnectionMode() != ConnectionMode.REMOTE )
                {
                    ExecutionEngine engine = new ExecutionEngine( graphDb );
                    ExecutionResult result = engine.execute( cypherQuery );
                    // message = result.toString().substring( result.toString().lastIndexOf( "+" ) + 1 ).trim();
                    columns = result.columns();
                    iterator = result.iterator();
                }
                else if ( currentAlias.getConnectionMode() == ConnectionMode.REMOTE )
                {
                    Iterable<Map<String, Object>> execute = new RestCypherQueryEngine(( (RestGraphDatabase) graphDb ).getRestAPI()).query(cypherQuery,
                            new HashMap<String, Object>() );
View Full Code Here

  private T deserialize( @Nonnull AbstractNeo4jSerializer<T> serializer, @Nonnull String serialized ) throws IOException {
    GraphDatabaseService db = neo4jRule.createDb();

    //Fill the db initially
    try ( Transaction tx = db.beginTx() ) {
      ExecutionResult result = new ExecutionEngine( db ).execute( serialized );
      tx.success();
    }

    try ( Transaction tx = db.beginTx() ) {
      return serializer.deserialize( db.getNodeById( 0 ) );
View Full Code Here

TOP

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

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.