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


Java GraphDatabaseService.getNodeById方法代码示例

本文整理汇总了Java中org.neo4j.graphdb.GraphDatabaseService.getNodeById方法的典型用法代码示例。如果您正苦于以下问题:Java GraphDatabaseService.getNodeById方法的具体用法?Java GraphDatabaseService.getNodeById怎么用?Java GraphDatabaseService.getNodeById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.neo4j.graphdb.GraphDatabaseService的用法示例。


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

示例1: createRelationship

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
/**
 * 
 * @param properties
 * @param labels
 * @return
 */
public static long createRelationship(long startNodeId, long endNodeId, RelationshipType relationshipType, Map<String, Object> properties)
{
  GraphDatabaseService graphDatabaseService = getGraphDatabaseService();

  Node startNode = graphDatabaseService.getNodeById(startNodeId);
  Node endNode = graphDatabaseService.getNodeById(endNodeId);

  Relationship relationship = startNode.createRelationshipTo(endNode, relationshipType);

  for (String key : properties.keySet())
  {
    relationship.setProperty(key, properties.get(key));
  }

  return relationship.getId();
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:23,代码来源:Neo4ArtGraphDatabaseServiceSingleton.java

示例2: remove

import org.neo4j.graphdb.GraphDatabaseService; //导入方法依赖的package包/类
@Override
public void remove(String key, Object value, IGraphNode n) {

	if (index != null) {
		GraphDatabaseService g = graph.getGraph();
		long l = (long) n.getId();
		Node node = null;
		try {
			node = g.getNodeById(l);
		} catch (Exception e) {
			System.err.println("tried to remove node: " + l + " from index " + name + " but it does not exist");
		}

		if (node != null) {

			if (key == null && value == null) {
				index.remove(node);
			} else if (key == null) {
				throw new UnsupportedOperationException("Removing key * does not work");
			} else if (value == null) {
				index.remove(node, key);
			} else {
				index.remove(node, key, value);
			}

		} else {
			System.err.println("tried to remove node: " + l + " from index " + name + " but it does not exist");
		}
	} else {
		System.err.println("invoked remove on a batchindex, this is not supported");
	}

}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:34,代码来源:Neo4JNodeIndex.java


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