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


Java ExecutionResult类代码示例

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


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

示例1: runQueryMultipleResult

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public List<Object> runQueryMultipleResult(NeoProfiler parent, String query, String columnReturn) {
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	List<Object> retvals = new ArrayList<Object>();
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		ResourceIterator<Object> rit = result.columnAs(columnReturn);
				
		while(rit.hasNext()) {				
			retvals.add(rit.next());
		}					
	}
	
	return retvals;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:17,代码来源:QueryRunner.java

示例2: findConnectedNodesUsingCypher

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
/**
 * demo usage of traversal API, see http://docs.neo4j.org/chunked/stable/tutorial-traversal.html
 */
@GET
@Produces("application/json")
@Path("/cypher/{label}/{key}/{value}/{relType}/{depth}")
public People findConnectedNodesUsingCypher(
        @PathParam("label") String label,
        @PathParam("key") String key,
        @PathParam("value") String value,
        @PathParam("relType") String relType,
        @PathParam("depth") int depth) {

    StringBuilder cypher = new StringBuilder();
    cypher.append("MATCH (:").append(label).append("{").append(key).append(":{value}})-[:").append(relType).append("*").append(depth).append("..").append(depth).append("]->(f) RETURN f.name as name");

    // System.out.println(cypher);

    // NB: executionEngine opens a transaction on its own unless it's managed explicitly
    ExecutionResult result = cypherExecutor.getExecutionEngine().execute(cypher.toString(), Collections.<String, Object>singletonMap("value", value));

    Iterator<String> names = result.columnAs("name");

    return new People(names);
}
 
开发者ID:sarmbruster,项目名称:unmanaged-extension,代码行数:26,代码来源:UnmanagedExtension.java

示例3: getAllFriends

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public List<String> getAllFriends(String userId){
	
	ExecutionResult result0 = engine
			.execute("start node=node:nodes(userId = '" + userId + "') "
					+ "match node-[:FRIEND_OF]->deg0 " + "return deg0");

	List<String> deg0Nodes = new ArrayList<String>();
	Iterator<Node> n_column = result0.columnAs("deg0");
	
		for (Node node : IteratorUtil.asIterable(n_column)) {
			String nodeResult = null;
			try ( Transaction tx = graphDb.beginTx() ){
				nodeResult = node.getProperty(USER_ID).toString();
				tx.success();
			}
			deg0Nodes.add(nodeResult);
		}
	return deg0Nodes;
}
 
开发者ID:karth707,项目名称:iBase,代码行数:20,代码来源:FriendGraph.java

示例4: isConnected

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private  boolean isConnected(Node node1, Node node2) {
	String node1Key = null;
	String node2Key = null;
	try ( Transaction tx = graphDb.beginTx() ){
		node1Key = node1.getProperty(USER_ID).toString();
		node2Key = node2.getProperty(USER_ID).toString();
		tx.success();
	}
	
	String query = "start node1=node:nodes(userId = '" + node1Key + "'), "
			+ "node2=node:nodes(userId = '" + node2Key + "') "
			+ "match node1-[r:FRIEND_OF]->node2 " + "return r";

	ExecutionResult result = engine.execute(query);

	Iterator<Node> rcolumn = result.columnAs("r");
	if (rcolumn.hasNext()) {
		// edge exists!
		return true;
	} else {
		return false;
	}
}
 
开发者ID:karth707,项目名称:iBase,代码行数:24,代码来源:FriendGraph.java

示例5: isConnected

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private boolean isConnected(Node node1, Node node2) {

		String node1Key = node1.getProperty("message").toString();
		String node2Key = node2.getProperty("message").toString();

		String query = "start node1=node:nodes(message = '" + node1Key + "'), "
				+ "node2=node:nodes(message = '" + node2Key + "') "
				+ "match node1-[r:KNOWS]->node2 " + "return r";

		ExecutionEngine engine = new ExecutionEngine(graphDb);
		ExecutionResult result = engine.execute(query);

		Iterator<Node> rcolumn = result.columnAs("r");
		if (rcolumn.hasNext()) {
			// edge exists!
			return true;
		} else {
			return false;
		}
	}
 
开发者ID:karth707,项目名称:iBase,代码行数:21,代码来源:GraphInstanceTest.java

示例6: getAllFriends

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public List<String> getAllFriends(String userId) {

		ExecutionEngine engine = new ExecutionEngine(graphDb);
		ExecutionResult result0 = engine
				.execute("start node=node:nodes(message = '" + userId + "') "
						+ "match node-[:KNOWS]->deg0 " + "return deg0");

		List<String> deg0Nodes = new ArrayList<String>();
		Iterator<Node> n_column = result0.columnAs("deg0");
		for (Node node : IteratorUtil.asIterable(n_column)) {
			String nodeResult = node.getProperty("message").toString();
			deg0Nodes.add(nodeResult);
		}
		return deg0Nodes;

	}
 
开发者ID:karth707,项目名称:iBase,代码行数:17,代码来源:GraphInstanceTest.java

示例7: createData

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private Node createData()
{
    ExecutionEngine engine = new ExecutionEngine( db );
    String query = "CREATE (joe {name: 'Joe'}), (sara {name: 'Sara'}), "
       + "(lisa {name: 'Lisa'}), (peter {name: 'PETER'}), (dirk {name: 'Dirk'}), "
                   + "(lars {name: 'Lars'}), (ed {name: 'Ed'}),"
       + "(joe)-[:KNOWS]->(sara), (lisa)-[:LIKES]->(joe), "
       + "(peter)-[:KNOWS]->(sara), (dirk)-[:KNOWS]->(peter), "
       + "(lars)-[:KNOWS]->(drk), (ed)-[:KNOWS]->(lars), " 
       + "(lisa)-[:KNOWS]->(lars) " 
       + "RETURN joe";
    ExecutionResult result = engine.execute( query );
    Object joe = result.columnAs( "joe" ).next();
    if ( joe instanceof Node )
    {
        return (Node) joe;
    }
    else
    {
        throw new RuntimeException( "Joe isn't a node!" );
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:23,代码来源:DbManager.java

示例8: runQueryComplexResult

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public Map<String,List<Object>> runQueryComplexResult(NeoProfiler parent, String query, String...columns) {
	HashMap<String,List<Object>> all = new HashMap<String,List<Object>>();
	
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	List<Object> retvals = new ArrayList<Object>();
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		
		ResourceIterator<Map<String,Object>> rows = result.iterator();
		
		while(rows.hasNext()) {
			Map<String,Object> row = rows.next();
			
			for(String col : columns) { 
				if(!all.containsKey(col)) all.put(col, new ArrayList<Object>());
				all.get(col).add(row.get(col));
			}
		}
		
		rows.close();
	} // End try
	
	return all;
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:27,代码来源:QueryRunner.java

示例9: runQuerySingleResult

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public Object runQuerySingleResult(NeoProfiler parent, String query, String columnReturn) {		
	ExecutionEngine engine = new ExecutionEngine(parent.getDB());
	
	try ( Transaction tx = parent.getDB().beginTx() ) {
		// log.info(query);
		ExecutionResult result = engine.execute(query);
		ResourceIterator<Object> vals = result.columnAs(columnReturn);
					
		if(vals.hasNext()) {
			Object retval = vals.next();
			vals.close();
			return retval;
		} 
		
		return null;
	}		
}
 
开发者ID:moxious,项目名称:neoprofiler,代码行数:18,代码来源:QueryRunner.java

示例10: execute

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@Override
public void execute(String query, JsonObject params, Handler<JsonObject> handler) {
	ExecutionResult result;
	try (Transaction tx = gdb.beginTx()) {
		if (params != null){
			result = engine.execute(query, params.toMap());
		} else {
			result = engine.execute(query);
		}
		JsonObject json = new JsonObject().putArray("result",toJson(result));
		tx.success();
		handler.handle(json);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		handler.handle(ExceptionUtils.exceptionToJson(e));
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:18,代码来源:Neo4jEmbedded.java

示例11: executeBatch

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@Override
public void executeBatch(JsonArray queries, Handler<JsonObject> handler) {
	ExecutionResult result;
	try (Transaction tx = gdb.beginTx()) {
		JsonArray results = new JsonArray();
		int i = 0;
		for (Object q: queries) {
			JsonObject qr = (JsonObject) q;
			String query = qr.getString("query");
			JsonObject params = qr.getObject("params");
			if (params != null){
				result = engine.execute(query, params.toMap());
			} else {
				result = engine.execute(query);
			}
			results.addObject(new JsonObject().putArray("result", toJson(result))
					.putNumber("idx", i++));
		}
		JsonObject json = new JsonObject().putArray("results", results);
		tx.success();
		handler.handle(json);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		handler.handle(ExceptionUtils.exceptionToJson(e));
	}
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:27,代码来源:Neo4jEmbedded.java

示例12: info

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
@GET
@Path("/csvtree")
@Produces("application/json")
public Response info(@QueryParam(value = "debug") Boolean debug,
		@Context GraphDatabaseService db) {
	try {
		logger.info("Processing 'loadcsvtree_version' request");
		if (debug == null) debug = false;
		HashMap<String, Object> response = new HashMap<String, Object>();
		response.put("version", "0.0.4");
		ExecutionEngine engine = new ExecutionEngine(db);
		ExecutionResult result = engine.execute("MATCH (g:DeviceGroup)-->(d:Device) RETURN g.name as Group, count(d) as Devices");
		for (Map<String, Object> record : result) {
			response.put(record.get("Group").toString(), record.get("Devices"));
		}
		return Response.ok().entity(new ObjectMapper().writeValueAsString(response)).build();
	} catch (IOException e) {
		logger.severe("Error processing 'loadcsvtree_version' request: " + e.getMessage());
		return Response.status(404).entity(e.getMessage()).build();
	}
}
 
开发者ID:craigtaverner,项目名称:csvtreeloader,代码行数:22,代码来源:CSVTreeLoaderService.java

示例13: executeCypher

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
/**
 * Executes the cypher
 * @param cypher
 * @return
 */
String executeCypher(String cypher){
    final GraphDatabaseService graphDb = getGraphDb();
    Transaction tx = graphDb.beginTx();
    ExecutionResult result = null;
    try {
        ExecutionEngine engine = new ExecutionEngine( graphDb );
        result = engine.execute( cypher );
        tx.success();
    } catch(Exception e){
        throw new RuntimeException("Error executing cypher: ", e);
    } finally {
        tx.finish();
    }
    return result.dumpToString();
}
 
开发者ID:fizalihsan,项目名称:Fig,代码行数:21,代码来源:Neo4jHelper.java

示例14: ExecutionResultIterator

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
public ExecutionResultIterator(ExecutionResult results, GraphDatabaseService graphdb) {
	//this.results = results;
	//System.out.println("In iterator constructor");
	this.delegate = results.iterator();
	this.graphdb = graphdb;
	//this.transaction = tx;
	
	//System.out.println(delegate.hasNext());
	//System.out.println("constructor next:"+delegate.next());
	//System.out.println(results.dumpToString());
	
	//System.out.println(delegate.next().size());
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:14,代码来源:ExecutionResultIterator.java

示例15: deleteEdge

import org.neo4j.cypher.javacompat.ExecutionResult; //导入依赖的package包/类
private void deleteEdge(Node node1, Node node2) {
	String node1Key = node1.getProperty(USER_ID).toString();
	String node2Key = node2.getProperty(USER_ID).toString();
	
	String query = "start node1=node:nodes(userId = '" + node1Key + "'), "
			+ "node2=node:nodes(userId = '" + node2Key + "') "
			+ "match node1-[r:FRIEND_OF]->node2 " + "delete r";
	
	ExecutionResult result = engine.execute(query);
	logger.info("deleted edge between: "+ node1Key
			+ " and " + node2Key + "; result: "+ result.toString());
}
 
开发者ID:karth707,项目名称:iBase,代码行数:13,代码来源:FriendGraph.java


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