本文整理汇总了Java中org.neo4j.driver.v1.StatementResult.next方法的典型用法代码示例。如果您正苦于以下问题:Java StatementResult.next方法的具体用法?Java StatementResult.next怎么用?Java StatementResult.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.driver.v1.StatementResult
的用法示例。
在下文中一共展示了StatementResult.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
示例3: 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;
}
示例4: 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";
}
示例5: getLabels
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public Map<String, String> getLabels(boolean refresh) {
if (labels == null || refresh) {
Map<String, String> old = labels == null ?
new LinkedHashMap<String, String>() : new LinkedHashMap<>(labels);
labels = new LinkedHashMap<>();
StatementResult result = this.neo4jConnectionManager.execute("CALL db.labels()");
Set<String> colors = new HashSet<>();
while (result.hasNext()) {
Record record = result.next();
String label = record.get("label").asString();
String color = old.get(label);
while (color == null || colors.contains(color)) {
color = Neo4jConversionUtils.getRandomLabelColor();
}
colors.add(color);
labels.put(label, color);
}
}
return labels;
}
示例6: executeOperation
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
@Override
public void executeOperation(OperationType operation, CypherDriverConnectionStore<QueryStore> state,
ResultReporter resultReporter) throws DbException {
Session session = state.getSession();
OperationResult tuple = null;
int resultCount = 0;
final String queryString = getQueryString(state, operation);
state.logQuery(operation.getClass().getSimpleName(), queryString);
final StatementResult result = session.run(queryString);
if (result.hasNext()) {
final Record record = result.next();
resultCount++;
tuple = convertSingleResult(record);
if (state.isPrintResults()) {
System.out.println(tuple.toString());
}
}
session.close();
resultReporter.report(resultCount, tuple, operation);
}
示例7: writeEquivalences
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
@Test
public void writeEquivalences() throws Exception {
equivalenceWriter.writeEquivalences(
contentRefA,
ImmutableSet.of(contentRefB),
ImmutableSet.of(Publisher.METABROADCAST, Publisher.BBC),
session
);
StatementResult result = session.run(
"MATCH (a { id: {idA} })-[:IS_EQUIVALENT]->(b { id: {idB} })"
+ "RETURN a.id AS idA, b.id AS idB",
ImmutableMap.of(
"idA", contentRefA.getId().longValue(),
"idB", contentRefB.getId().longValue()
)
);
assertThat(result.hasNext(), is(true));
Record record = result.next();
assertThat(record.get("idA").asLong(), is(contentRefA.getId().longValue()));
assertThat(record.get("idB").asLong(), is(contentRefB.getId().longValue()));
}
示例8: getWrittenRecord
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
private Record getWrittenRecord(Content content, String... customFields) {
String customFieldsReturn = "";
if (customFields.length > 0) {
customFieldsReturn += ", ";
customFieldsReturn += Arrays.stream(customFields)
.map(field -> "n." + field + " AS " + field)
.collect(Collectors.joining(", "));
}
StatementResult result = session.run(
"MATCH (n:Content { id: {id} }) "
+ "RETURN n.id as id, n.source AS source, n.type AS type"
+ customFieldsReturn,
ImmutableMap.of("id", content.getId().longValue())
);
assertThat(result.hasNext(), is(true));
Record record = result.next();
assertThat(record.get("id").asLong(), is(content.getId().longValue()));
assertThat(record.get("source").asString(), is(content.getSource().key()));
assertThat(record.get("type").asString(),
is(ContentType.fromContent(content).get().getKey()));
return record;
}
示例9: checkParent
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
private void checkParent(Content child, Brand expectedParent) {
StatementResult result = session.run(
"MATCH (parent:Content)<-[:HAS_BRAND]-(child:Content { id: {id} }) "
+ "WHERE parent.type={type} "
+ "RETURN parent.id AS id",
ImmutableMap.of(
"id", child.getId().longValue(),
"type", ContentType.fromContent(expectedParent).get().getKey()
)
);
assertThat("No parent found", result.hasNext(), is(true));
Record record = result.next();
assertThat("Found child with multiple parents", result.hasNext(), is(false));
assertThat(record.get("id").asLong(), is(expectedParent.getId().longValue()));
}
示例10: addPerson
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public String addPerson() {
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();
}
}
示例11: addPersonClassInstanceInjection
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public String addPersonClassInstanceInjection() {
Session session = injectedDriver.session();
try {
session.run("CREATE (a:Person {name:'CDI', title:'King'})");
StatementResult result = session.run("MATCH (a:Person) WHERE a.name = 'CDI' 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();
}
}
示例12: getPerson
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
@TransactionAttribute(REQUIRES_NEW)
public String getPerson(String name) {
Session session = injectedDriver.session();
try {
StatementResult result = session.run("MATCH (a:Person) WHERE a.name = '" + name + "' RETURN a.name AS name, a.title AS title");
if (result.hasNext()) {
Record record = result.next();
return record.toString();
}
return name + " not found";
}
finally {
session.close();
}
}
示例13: get
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public static Neo4jNode get(long id, SnowGraphContext context){
Neo4jNode node=null;
Session session = context.getNeo4jBoltDriver().session();
String stat = "match (n) where id(n)=" + id + " return id(n), labels(n)[0], n";
StatementResult rs = session.run(stat);
while (rs.hasNext()) {
Record item=rs.next();
node=new Neo4jNode(item.get("id(n)").asLong(),item.get("labels(n)[0]").asString());
node.properties.putAll(item.get("n").asMap());
node.properties.put("id",node.id);
node.properties.put("label",node.label);
}
session.close();
return node;
}
示例14: getNeo4jRelationList
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public static List<Neo4jRelation> getNeo4jRelationList(long nodeId, SnowGraphContext context){
List<Neo4jRelation> list=new ArrayList<>();
Session session = context.getNeo4jBoltDriver().session();
String stat = "match p=(n)-[r]-(x) where id(n)=" + nodeId + " return id(r), id(startNode(r)), id(endNode(r)), type(r)";
StatementResult rs = session.run(stat);
while (rs.hasNext()) {
Record item=rs.next();
list.add(new Neo4jRelation(item.get("id(startNode(r))").asLong(),item.get("id(endNode(r))").asLong(),item.get("id(r)").asLong(),item.get("type(r)").asString()));
}
session.close();
return list;
}
示例15: get
import org.neo4j.driver.v1.StatementResult; //导入方法依赖的package包/类
public static Neo4jRelation get(long rId, SnowGraphContext context){
Neo4jRelation r=null;
Session session = context.getNeo4jBoltDriver().session();
String stat = "match p=(n)-[r]-(x) where id(r)=" + rId + " return id(r), id(startNode(r)), id(endNode(r)), type(r)";
StatementResult rs = session.run(stat);
while (rs.hasNext()) {
Record item=rs.next();
r=new Neo4jRelation(item.get("id(startNode(r))").asLong(),item.get("id(endNode(r))").asLong(),item.get("id(r)").asLong(),item.get("type(r)").asString());
}
session.close();
return r;
}