当前位置: 首页>>代码示例>>Java>>正文


Java StatementResult类代码示例

本文整理汇总了Java中org.neo4j.driver.v1.StatementResult的典型用法代码示例。如果您正苦于以下问题:Java StatementResult类的具体用法?Java StatementResult怎么用?Java StatementResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StatementResult类属于org.neo4j.driver.v1包,在下文中一共展示了StatementResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generates_executable_dump

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void generates_executable_dump() throws IOException {
    exporter.accept(dump, asList(
            exercise("foo", "MATCH (n:Foo) RETURN COUNT(n) AS foo_count"),
            exercise("bar", "MATCH (n:Bar) RETURN COUNT(n) AS bar_count"),
            exercise("baz", "MATCH (n:Baz) RETURN COUNT(n) AS baz_count", "CREATE (:Baz {name:'meh'})")));

    lines(dump.toPath(), UTF_8).forEachOrdered(line -> {
        try (Driver driver = GraphDatabase.driver(graphDb.boltURI(), config()); Session session = driver.session()) {
            session.run(line);
        }
    });

    try (Driver driver = GraphDatabase.driver(graphDb.boltURI(), config()); Session session = driver.session()) {
        StatementResult result = session.run(
                "MATCH p=(e1:Exercise)-[:NEXT*]->(e2:Exercise) WITH p ORDER BY LENGTH(p) DESC LIMIT 1 " +
                        "RETURN EXTRACT(exercise IN NODES(p) | exercise.instructions) AS instructions");
        assertThat(result.single().get("instructions").asList(Value::asString)).containsExactly("foo", "bar", "baz");
        result = session.run(
                "MATCH (e:Exercise) WHERE EXISTS(e.validationQuery) RETURN e.instructions AS instruction");
        assertThat(result.single().get("instruction").asString()).isEqualTo("baz");
    }
}
 
开发者ID:fbiville,项目名称:hands-on-neo4j-devoxx-fr-2017,代码行数:24,代码来源:ExerciseExporterTest.java

示例2: get

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@GET
@Produces({"text/plain"})
public String get() {
    Session session = driver.session();
    try {
        session.run("CREATE (a:Person {name:'Arthur', title:'King'})");
        StatementResult result = session.run("MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title");

        Record record = result.next();
        return record.toString();
    } finally {
        session.run("MATCH (a:Person) delete a");
        session.close();
    }

}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:17,代码来源:ClientResource.java

示例3: shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldAuthenticateAndAuthorizeKalleMoraeusAsAdmin() throws Exception
{
    Driver driver = GraphDatabase.driver( server.boltURI(), AuthTokens.basic( "moraeus", "suearom" ) );
    Session session = driver.session();

    session.run( "CREATE (a:Person {name:'Kalle Moraeus', title:'Riksspelman'})" );

    StatementResult result =
            session.run( "MATCH (a:Person) WHERE a.name = 'Kalle Moraeus' RETURN a.name AS name, a.title AS title" );
    assertTrue( result.hasNext() );
    while ( result.hasNext() )
    {
        Record record = result.next();
        assertThat( record.get( "name" ).asString(), equalTo( "Kalle Moraeus" ) );
        assertThat( record.get( "title" ).asString(), equalTo( "Riksspelman" ) );
        System.out.println( record.get( "title" ).asString() + " " + record.get( "name" ).asString() );
    }

    session.close();
    driver.close();
}
 
开发者ID:neo4j,项目名称:neo4j-example-auth-plugins,代码行数:23,代码来源:MyAuthPluginIT.java

示例4: run

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
public static SubGraph run(String query, SubGraph searchResult1, SubGraph linkedSearchResult1,  ApiLocatorContext context){
    SubGraph r = new SubGraph();
    r.getNodes().addAll(searchResult1.getNodes());
    r.cost = searchResult1.cost;
    List<LuceneSearchResult> luceneSearchResults=context.getLuceneSearcher().query(query);
    luceneSearchResults.sort((LuceneSearchResult a, LuceneSearchResult b)->{
        Double aDist=new Double(dist(a.nodeSet,searchResult1.getNodes(),context));
        Double bDist=new Double(dist(b.nodeSet,searchResult1.getNodes(),context));
        return aDist.compareTo(bDist);
    });
    for (int i=0;i<3&&i<luceneSearchResults.size();i++) {
        r.getNodes().add(luceneSearchResults.get(i).id);
        for (long node:linkedSearchResult1.getNodes()){
            Session session=context.connection.session();
            StatementResult rs=session.run("match (a)-[r]-(b) where id(a)="+node+" and id(b)="+luceneSearchResults.get(i).id+" return id(r)");
            while (rs.hasNext()){
                Record item=rs.next();
                r.getEdges().add(item.get("id(r)").asLong());
            }
            session.close();
        }
    }
    return r;
}
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:25,代码来源:ExpandFlossNodes.java

示例5: run

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
public String run(String branchId) {
    final DbServices dbServices = DbServicesManager.getDbServices(branchId);
    try (Transaction tx = dbServices.beginTx()) {
        final StatementResult result = dbServices.execute(GET_LAST_COMMIT_HASH);

        JSONObject response = new JSONObject();
        while (result.hasNext()) {
            Record next = result.next();

            Object commitHash = next.get("commitHash");
            response.put("commitHash", commitHash);
        }

        return response.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return "ERROR";
}
 
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:21,代码来源:GetLastCommitHash.java

示例6: shouldCreateComplexArray1

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldCreateComplexArray1(){
	String key = "shouldCreateComplexArray1";
	String json = "{\"id\": \"1\", "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"albums\": ["
			+ "             {"
			+ "               \"type\": \"album\","
			+ "               \"id\": \"10\","
			+ "               \"producer\": \"Jonathan King\","
			+ "               \"title\": \"From Genesis to Revelation\""
			+ "             }"
			+ "]"
			+ "}";
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (art {type: 'artist'}) - [r] -> (alb {type: 'album'}) RETURN art.name, alb.title,r");
	Record single = result.single();
	Assert.assertEquals("Wrong node","Genesis", single.get("art.name").asString());
	Assert.assertEquals("Wrong inner node","From Genesis to Revelation", single.get("alb.title").asString());
	Assert.assertEquals("Wrong inner node","shouldCreateComplexArray1", single.get("r").asRelationship().type());

}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:25,代码来源:JsonHelperCustomTest.java

示例7: shouldAddNestedNode

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldAddNestedNode() {
	String key = "shouldAddNestedNode";
	String json = "{\"id\": \"1\", "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"origin\": {"
			+ "              \"type\": \"origin\","
			+ "              \"id\": \"1483\","
			+ "              \"sovereign-state\": \"UK\","
			+ "              \"country\": \"England\","				
			+ "              \"region\": \"South East\""
			+ "            }"				
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (n {id: '1', type: 'artist'}) RETURN n.name");
	Assert.assertEquals("Wrong node","Genesis", result.single().get("n.name").asString());
	
	StatementResult result1 = session.run("MATCH (n {id: '1483', type: 'origin'}) RETURN n.country");
	Assert.assertEquals("Wrong inner node","England", result1.single().get("n.country").asString());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:24,代码来源:JsonHelperCustomTest.java

示例8: shouldCreateRelation

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldCreateRelation() {
	String key = "shouldCreateRelation";
	String json = "{\"id\": \"1\", "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"origin\": {"
			+ "              \"type\": \"origin\","
			+ "              \"id\": \"1483\","
			+ "              \"sovereign-state\": \"UK\","
			+ "              \"country\": \"England\","				
			+ "              \"region\": \"South East\""
			+ "            }"				
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (a {id: '1', type: 'artist'}) - [r] -> (o) RETURN a.name, o.country,r");
	Record single = result.single();
	Assert.assertEquals("Wrong node","Genesis", single.get("a.name").asString());
	Assert.assertEquals("Wrong inner node","England", single.get("o.country").asString());
	Assert.assertEquals("Wrong inner node","shouldCreateRelation", single.get("r").asRelationship().type());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:24,代码来源:JsonHelperCustomTest.java

示例9: shouldDeleteDocumentWihoutRelations

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldDeleteDocumentWihoutRelations() {
	String key = "shouldDeleteDocumentWihoutRelations";
	String json = "{\"id\": \"1\", "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\""
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	StatementResult result1 = session.run("MATCH (art {type: 'artist'}) RETURN art.name");
	Assert.assertEquals("Wrong node","Genesis", result1.single().get("art.name").asString());
	
	session.run(CALL_DELETE, Values.parameters( "key", key));
	StatementResult result = session.run("MATCH (n) RETURN n");
	Assert.assertEquals(1,result.list().size());//JSON_CONFIG
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:17,代码来源:JsonHelperCustomTest.java

示例10: shouldSetDocumentKey

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldSetDocumentKey() {
	String key = "shouldSetDocumentKey";
	String json = "{\"id\": \"1\", "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"albums\": ["
			+ "             {"
			+ "               \"type\": \"album\","
			+ "               \"id\": \"10\","
			+ "               \"producer\": \"Jonathan King\","
			+ "               \"title\": \"From Genesis to Revelation\","
			+ "               \"tracks\": [{"
			+ "                             \"type\": \"track\","
			+ "                             \"id\": \"100\","
			+ "                             \"title\": \"Where the Sour Turns to Sweet\""
			+ "                           }]"
			+ "             }"
			+ "]"
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	StatementResult result1 = session.run("MATCH (n {_root: 'shouldSetDocumentKey'}) RETURN n.type");
	Assert.assertEquals("Wrong _root","artist", result1.single().get("n.type").asString());

}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:27,代码来源:JsonHelperCustomTest.java

示例11: shouldCreateComplexArray1

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldCreateComplexArray1(){
	String key = "shouldCreateComplexArray1";
	String json = "{\"id\": 1, "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"albums\": ["
			+ "             {"
			+ "               \"type\": \"album\","
			+ "               \"id\": 1,"
			+ "               \"producer\": \"Jonathan King\","
			+ "               \"title\": \"From Genesis to Revelation\""
			+ "             }"
			+ "]"
			+ "}";
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (art {type: 'artist'}) - [r] -> (alb {type: 'album'}) RETURN art.name, alb.title,r");
	Record single = result.single();
	Assert.assertEquals("Wrong node","Genesis", single.get("art.name").asString());
	Assert.assertEquals("Wrong inner node","From Genesis to Revelation", single.get("alb.title").asString());
	Assert.assertEquals("Wrong inner node","HAS_ALBUM", single.get("r").asRelationship().type());

}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:25,代码来源:JsonHelperDefaultTest.java

示例12: shouldAddNestedNode

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldAddNestedNode() {
	String key = "shouldAddNestedNode";
	String json = "{\"id\": 1, "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"origin\": {"
			+ "              \"type\": \"origin\","
			+ "              \"id\": 1483,"
			+ "              \"sovereign-state\": \"UK\","
			+ "              \"country\": \"England\","				
			+ "              \"region\": \"South East\""
			+ "            }"				
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (n {id: 1, type: 'artist'}) RETURN n.name");
	Assert.assertEquals("Wrong node","Genesis", result.single().get("n.name").asString());
	
	StatementResult result1 = session.run("MATCH (n {id: 1483, type: 'origin'}) RETURN n.country");
	Assert.assertEquals("Wrong inner node","England", result1.single().get("n.country").asString());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:24,代码来源:JsonHelperDefaultTest.java

示例13: shouldCreateRelation

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldCreateRelation() {
	String key = "shouldCreateRelation";
	String json = "{\"id\": 1, "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"origin\": {"
			+ "              \"type\": \"origin\","
			+ "              \"id\": 1483,"
			+ "              \"sovereign-state\": \"UK\","
			+ "              \"country\": \"England\","				
			+ "              \"region\": \"South East\""
			+ "            }"				
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	
	StatementResult result = session.run("MATCH (a {id: 1, type: 'artist'}) - [r] -> (o) RETURN a.name, o.country,r");
	Record single = result.single();
	Assert.assertEquals("Wrong node","Genesis", single.get("a.name").asString());
	Assert.assertEquals("Wrong inner node","England", single.get("o.country").asString());
	Assert.assertEquals("Wrong inner node","HAS_ORIGIN", single.get("r").asRelationship().type());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:24,代码来源:JsonHelperDefaultTest.java

示例14: shouldDeleteDocumentWihoutRelations

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldDeleteDocumentWihoutRelations() {
	String key = "shouldDeleteDocumentWihoutRelations";
	String json = "{\"id\": 1, "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\""
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	StatementResult result1 = session.run("MATCH (art {type: 'artist'}) RETURN art.name");
	Assert.assertEquals("Wrong node","Genesis", result1.single().get("art.name").asString());
	
	session.run(CALL_DELETE, Values.parameters( "key", key));
	StatementResult result = session.run("MATCH (n) RETURN n");
	Assert.assertTrue(result.list().isEmpty());
}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:17,代码来源:JsonHelperDefaultTest.java

示例15: shouldSetDocumentKey

import org.neo4j.driver.v1.StatementResult; //导入依赖的package包/类
@Test
public void shouldSetDocumentKey() {
	String key = "shouldSetDocumentKey";
	String json = "{\"id\": 1, "
			+ "\"type\": \"artist\","
			+ "\"name\": \"Genesis\","
			+ "\"albums\": ["
			+ "             {"
			+ "               \"type\": \"album\","
			+ "               \"id\": 1,"
			+ "               \"producer\": \"Jonathan King\","
			+ "               \"title\": \"From Genesis to Revelation\","
			+ "               \"tracks\": [{"
			+ "                             \"type\": \"track\","
			+ "                             \"id\": 1,"
			+ "                             \"title\": \"Where the Sour Turns to Sweet\""
			+ "                           }]"
			+ "             }"
			+ "]"
			+ "}";
	
	session.run(CALL_UPSERT, Values.parameters( "key", key, "json", json ));
	StatementResult result1 = session.run("MATCH (n {_document_key: 'shouldSetDocumentKey'}) RETURN n.type");
	Assert.assertEquals("Wrong _document_key","artist", result1.single().get("n.type").asString());

}
 
开发者ID:larusba,项目名称:doc2graph,代码行数:27,代码来源:JsonHelperDefaultTest.java


注:本文中的org.neo4j.driver.v1.StatementResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。