本文整理汇总了Java中org.neo4j.cypher.ExecutionEngine类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionEngine类的具体用法?Java ExecutionEngine怎么用?Java ExecutionEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionEngine类属于org.neo4j.cypher包,在下文中一共展示了ExecutionEngine类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteExperiment
import org.neo4j.cypher.ExecutionEngine; //导入依赖的package包/类
public static boolean deleteExperiment(GraphDatabaseService graphDB, DBGraph experiment) {
Transaction tx = graphDB.beginTx();
try {
ExecutionEngine engine = new ExecutionEngine( graphDB );
ExecutionResult result = engine.execute( "START n=node(" + experiment.getCorrespondingNodeInDB().getId() +")\n" +
"MATCH n-[r?]-()\n" +
"WHERE ID(n) <> 0\n" +
"DELETE n,r" );
System.out.println(result.toString());
tx.success();
return true;
} catch (Exception e) {
return false;
} finally {
tx.finish();
}
}
示例2: importFromN4j
import org.neo4j.cypher.ExecutionEngine; //导入依赖的package包/类
/**
*
* @param dbService
* @param KG
*/
public static void importFromN4j(GraphDatabaseService dbService, KnowledgeGraph KG) {
ExecutionResult result;
ExecutionEngine engine = new ExecutionEngine(dbService, StringLogger.SYSTEM);
try(Transaction importDb = dbService.beginTx()) {
result = engine.execute("start n=node(*) return n");
scala.collection.immutable.Vector<Object> results = result.columnAs("n").toVector();
for(int i = 0; i < results.length(); i++) {
org.neo4j.graphdb.Node node = (org.neo4j.graphdb.Node) results.getElem(i, 0);
switch((String) node.getProperty("type")) {
case "HumanAgent":
Agent a = new HumanAgent((String) node.getProperty("name"));
a.setId((int) node.getProperty("id"));
KG.addResource(a);
break;
case "ArtificialAgent":
Agent aa = new ArtificialAgent((String) node.getProperty("name"));
aa.setId((int) node.getProperty("id"));
KG.addResource(aa);
break;
case "Topic":
Topic t = new Topic((String) node.getProperty("name"));
t.setId((int) node.getProperty("id"));
KG.addResource(t);
break;
case "Document":
Document d = new Document((String) node.getProperty("name"));
d.setId((int) node.getProperty("id"));
KG.addResource(d);
break;
}
if(((String) node.getProperty("type")).contains("Viewpoint")) {
ConnectedViewpoint v;
Agent emitter = null;
ArrayList<Resource> o = new ArrayList<>();
Iterable<Relationship> expressesRels = node.getRelationships(N4jEdgeType.EXPRESSES_VIEWPOINT);
for(Relationship expressesRel : expressesRels)
emitter = (Agent) KG.getNamedObject((String) expressesRel.getOtherNode(node).getProperty("name"));
Iterable<Relationship> connectorRels = node.getRelationships(N4jEdgeType.VIEWPOINT_CONNECTOR);
for(Relationship connectorRel : connectorRels)
o.add(KG.getNamedObject((String) connectorRel.getOtherNode(node).getProperty("name")));
v = ViewpointFactory.newInstance(emitter, o.get(0), o.get(1), (String) node.getProperty("type"), ViewpointPolarity.POSITIVE);
emitter.getPerspective().addViewpoint(v);
v.setCorrespondingNode(node);
KG.addViewpoint(v);
break;
}
}
importDb.success();
}
}
示例3: givenNewIdentifierExecutor
import org.neo4j.cypher.ExecutionEngine; //导入依赖的package包/类
private void givenNewIdentifierExecutor(GraphType type) {
cypher = Mockito.mock(ExecutionEngine.class);
@SuppressWarnings("unchecked")
Iterator<Object> nodes = Mockito.mock(Iterator.class);
Mockito.when(nodes.hasNext()).thenReturn(true);
Mockito.when(nodes.next()).thenReturn(2L);
ExecutionResult result = Mockito.mock(ExecutionResult.class);
Mockito.when(result.columnAs("result")).thenReturn(nodes);
if (GraphType.IDENTIFIER == type) {
buildIdentifierQuerieAtCurrent();
Mockito.when(cypher.execute(query)).thenReturn(result);
}
executor = new Neo4JExecutor(cypher);
}
示例4: printGraphInfo
import org.neo4j.cypher.ExecutionEngine; //导入依赖的package包/类
private void printGraphInfo(Neo4JConnector connector, PrintStream ps) {
ExecutionEngine engine = new ExecutionEngine(connector.getGraphDB());
ExecutionResult result = engine.execute("start n=node(*) return count(*)");
ps.println("Vertices: " + result.dumpToString());
result = engine.execute("start r=rel(*) return count(*)");
ps.println("Edges: " + result.dumpToString());
}
示例5: Neo4JExecutor
import org.neo4j.cypher.ExecutionEngine; //导入依赖的package包/类
/**
* Creates a new Executor wich queries the given database.
*
* @param db
*/
public Neo4JExecutor(Neo4JConnection db) {
cypher = new ExecutionEngine(db.getConnection(), StringLogger.DEV_NULL);
}