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


Java ExecutionEngine类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:ISA-tools,项目名称:Automacron,代码行数:18,代码来源:GraphFunctions.java

示例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();
    }
}
 
开发者ID:sifrproject,项目名称:viewpoints_io,代码行数:68,代码来源:N4jImportModule.java

示例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);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:22,代码来源:Neo4JExecutorTest.java

示例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());
}
 
开发者ID:ISA-tools,项目名称:Automacron,代码行数:11,代码来源:BenchMarks.java

示例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);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:9,代码来源:Neo4JExecutor.java


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