當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。