Package org.neo4j.cypher.javacompat

Examples of org.neo4j.cypher.javacompat.ExecutionEngine.execute()


  protected ExecutionResult executeCypherQuery(String query, Map<String, Object> parameters) throws Exception {
    SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) ( (OgmEntityManagerFactory) getFactory() ).getSessionFactory();
    Neo4jDatastoreProvider provider = (Neo4jDatastoreProvider) sessionFactory.getServiceRegistry().getService( DatastoreProvider.class );
    ExecutionEngine engine = new ExecutionEngine( provider.getDataBase() );
    ExecutionResult result = engine.execute( query, parameters );
    return result;
  }

  private Long executeQuery(String queryString) throws Exception {
    getTransactionManager().begin();
View Full Code Here


  private static final String ROOT_FOLDER = buildDirectory() + File.separator + "NEO4J";

  @Override
  public long getNumberOfEntities(SessionFactory sessionFactory) {
    ExecutionEngine engine = new ExecutionEngine( getProvider( sessionFactory ).getDataBase() );
    ExecutionResult result = engine.execute( ENTITY_COUNT_QUERY );
    ResourceIterator<Map<String, Object>> iterator = result.iterator();
    if ( iterator.hasNext() ) {
      Map<String, Object> next = iterator.next();
      return ( (Long) next.get( "COUNT(n)" ) ).longValue();
    }
View Full Code Here

  @Override
  public long getNumberOfAssociations(SessionFactory sessionFactory) {
    String query = "MATCH (n) - [r] -> () RETURN COUNT(DISTINCT type(r))";
    ExecutionEngine engine = new ExecutionEngine( getProvider( sessionFactory ).getDataBase() );
    ExecutionResult result = engine.execute( query.toString() );
    ResourceIterator<Long> columnAs = result.columnAs( "COUNT(DISTINCT type(r))" );
    Long next = columnAs.next();
    columnAs.close();
    return next.longValue();
  }
View Full Code Here

                assertEquals(2, a.properties("name").count().next().intValue());
                assertEquals(1, b.properties("name").count().next().intValue());
                assertEquals(1, b.properties("location").count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());

                assertEquals(4l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(2l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                assertEquals(2l, cypher.execute("MATCH (a)-[r]->() WHERE id(a) = " + a.id() + " RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                final AtomicInteger counter = new AtomicInteger(0);
                a.getBaseVertex().getRelationships(Direction.OUTGOING).forEach(relationship -> {
                    assertEquals(Neo4jVertexProperty.VERTEX_PROPERTY_PREFIX.concat("name"), relationship.getType().name());
View Full Code Here

                assertEquals(1, b.properties("name").count().next().intValue());
                assertEquals(1, b.properties("location").count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());

                assertEquals(4l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(2l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                assertEquals(2l, cypher.execute("MATCH (a)-[r]->() WHERE id(a) = " + a.id() + " RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                final AtomicInteger counter = new AtomicInteger(0);
                a.getBaseVertex().getRelationships(Direction.OUTGOING).forEach(relationship -> {
                    assertEquals(Neo4jVertexProperty.VERTEX_PROPERTY_PREFIX.concat("name"), relationship.getType().name());
                    counter.incrementAndGet();
View Full Code Here

                assertEquals(1, b.properties("location").count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());

                assertEquals(4l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(2l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                assertEquals(2l, cypher.execute("MATCH (a)-[r]->() WHERE id(a) = " + a.id() + " RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                final AtomicInteger counter = new AtomicInteger(0);
                a.getBaseVertex().getRelationships(Direction.OUTGOING).forEach(relationship -> {
                    assertEquals(Neo4jVertexProperty.VERTEX_PROPERTY_PREFIX.concat("name"), relationship.getType().name());
                    counter.incrementAndGet();
                });
View Full Code Here

                a.getBaseVertex().getRelationships(Direction.OUTGOING).forEach(relationship -> {
                    assertEquals(Neo4jVertexProperty.VERTEX_PROPERTY_PREFIX.concat("name"), relationship.getType().name());
                    counter.incrementAndGet();
                });
                assertEquals(2, counter.getAndSet(0));
                cypher.execute("MATCH (a)-[]->(m) WHERE id(a) = " + a.id() + " RETURN labels(m)").forEach(results -> {
                    assertEquals(VertexProperty.DEFAULT_LABEL, ((List<String>) results.get("labels(m)")).get(0));
                    counter.incrementAndGet();
                });
                assertEquals(2, counter.getAndSet(0));
                StreamFactory.stream(a.getBaseVertex().getRelationships(Direction.OUTGOING)).map(Relationship::getEndNode).forEach(node -> {
View Full Code Here

                assertEquals(1, a.properties().count().next().intValue());
                assertEquals(1, b.properties("name").count().next().intValue());
                assertEquals(1, b.properties("location").count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());

                assertEquals(2l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(0l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));

                assertEquals(1, StreamFactory.stream(a.getBaseVertex().getPropertyKeys()).count());
                assertEquals("the marko", a.getBaseVertex().getProperty("name"));
                assertEquals(2, StreamFactory.stream(b.getBaseVertex().getPropertyKeys()).count());
View Full Code Here

                assertEquals(1, b.properties("name").count().next().intValue());
                assertEquals(1, b.properties("location").count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());

                assertEquals(2l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(0l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));

                assertEquals(1, StreamFactory.stream(a.getBaseVertex().getPropertyKeys()).count());
                assertEquals("the marko", a.getBaseVertex().getProperty("name"));
                assertEquals(2, StreamFactory.stream(b.getBaseVertex().getPropertyKeys()).count());
                assertEquals("stephen", b.getBaseVertex().getProperty("name"));
View Full Code Here

            tryCommit(g, g -> {
                assertEquals(2, g.V().count().next().intValue());
                assertEquals(0, a.properties().count().next().intValue());
                assertEquals(2, b.properties().count().next().intValue());
                assertEquals(0, g.E().count().next().intValue());
                assertEquals(2l, cypher.execute("MATCH n RETURN COUNT(n)").iterator().next().get("COUNT(n)"));
                assertEquals(0l, cypher.execute("MATCH (n)-[r]->(m) RETURN COUNT(r)").iterator().next().get("COUNT(r)"));
                assertEquals(0, StreamFactory.stream(a.getBaseVertex().getPropertyKeys()).count());
                assertEquals(2, StreamFactory.stream(b.getBaseVertex().getPropertyKeys()).count());
            });
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.