本文整理汇总了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();
}
示例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");
}
}