Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrade to 2.0-RC1 reference node removal
- Loading branch information
Showing
10 changed files
with
61 additions
and
37 deletions.
There are no files selected for viewing
73 changes: 47 additions & 26 deletions
73
src/main/java/org/neo4j/collections/graphdb/ReferenceNodes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,59 @@ | ||
/** | ||
* Copyright (c) 2002-2013 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** | ||
' * Copyright (c) 2002-2011 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.collections.graphdb; | ||
|
||
import org.neo4j.cypher.javacompat.ExecutionEngine; | ||
import org.neo4j.cypher.javacompat.ExecutionResult; | ||
import org.neo4j.graphdb.GraphDatabaseService; | ||
import org.neo4j.graphdb.Node; | ||
import org.neo4j.helpers.collection.IteratorUtil; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: peter | ||
* Date: 07/12/13 | ||
* Time: 17:36 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public class ReferenceNodes { | ||
private static ReferenceNodes instance; | ||
private final ExecutionEngine engine; | ||
private GraphDatabaseService db; | ||
private Node referenceNode; | ||
|
||
public ReferenceNodes(GraphDatabaseService db) { | ||
this.db = db; | ||
engine = new ExecutionEngine(db); | ||
} | ||
import static org.neo4j.helpers.collection.MapUtil.map; | ||
|
||
public static ReferenceNodes getOrCreateInstance(GraphDatabaseService db) { | ||
if (instance == null) { | ||
instance = new ReferenceNodes(db); | ||
} | ||
return instance; | ||
public class ReferenceNodes { | ||
public static Node getReferenceNode(GraphDatabaseService db) { | ||
return getReferenceNode(db, "rtree"); | ||
} | ||
|
||
public Node getReferenceNode() { | ||
String ref = "ref"; | ||
ExecutionResult result = engine.execute("MERGE (" + ref + ":ReferenceNodes{name:'referenceNode'}) RETURN "+ref); | ||
return (Node)result.iterator().next().get(ref); | ||
public static Node getReferenceNode(GraphDatabaseService db, String name) { | ||
ExecutionEngine engine = new ExecutionEngine(db); | ||
ExecutionResult result = engine.execute("MERGE (ref:ReferenceNode {name:{name}}) RETURN ref",map("name", name)); | ||
return IteratorUtil.single(result.<Node>columnAs("ref")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters