本文整理匯總了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");
}
}