Created
April 8, 2010 16:39
-
-
Save akollegger/360258 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/src/main/java/com/example/models/Predicates.java b/src/main/java/com/example/models/Predicates.java | |
index e9e9d35..06ad491 100644 | |
--- a/src/main/java/com/example/models/Predicates.java | |
+++ b/src/main/java/com/example/models/Predicates.java | |
@@ -1,6 +1,6 @@ | |
package com.example.models; | |
-import org.neo4j.api.core.RelationshipType; | |
+import org.neo4j.graphdb.RelationshipType; | |
// Scala can't produce Java-compatible enums, so they will have to be | |
// defined in Java for now. | |
diff --git a/src/main/scala/com/example/InitServlet.scala b/src/main/scala/com/example/InitServlet.scala | |
index 4ca99d2..52793d1 100644 | |
--- a/src/main/scala/com/example/InitServlet.scala | |
+++ b/src/main/scala/com/example/InitServlet.scala | |
@@ -1,13 +1,13 @@ | |
package com.example | |
import javax.servlet.http.HttpServlet | |
-import com.eptcomputing.neo4j.NeoServer | |
+import com.eptcomputing.neo4j.Neo4jServer | |
/** | |
* This servlet is automatically initialized when the web app is started. | |
* Here we set up the Neo4j server for the rest of the application to use. | |
*/ | |
class InitServlet extends HttpServlet { | |
- override def init = NeoServer.startup(getServletContext) | |
- override def destroy = NeoServer.shutdown | |
+ override def init = Neo4jServer.startup(getServletContext) | |
+ override def destroy = Neo4jServer.shutdown | |
} | |
diff --git a/src/main/scala/com/example/models/Moo.scala b/src/main/scala/com/example/models/Moo.scala | |
index ffe0eb1..f234630 100644 | |
--- a/src/main/scala/com/example/models/Moo.scala | |
+++ b/src/main/scala/com/example/models/Moo.scala | |
@@ -3,7 +3,7 @@ package com.example.models | |
import javax.xml.bind.annotation.XmlRootElement | |
import javax.xml.bind.annotation.XmlRegistry | |
-import org.neo4j.api.core.NeoService | |
+import org.neo4j.graphdb.GraphDatabaseService | |
/** | |
* Example of using a model object which can be automatically serialized/unserialized | |
@@ -18,11 +18,11 @@ import org.neo4j.api.core.NeoService | |
class Moo(var colourOfSpots: java.lang.String) { | |
/** Constructor which loads the colourOfSpots property from the Neo reference node */ | |
- def this(neo: NeoService) = | |
+ def this(neo: GraphDatabaseService) = | |
this(neo.getReferenceNode.getProperty("cowColour", "brown").asInstanceOf[String]) | |
/** Save this model object to Neo */ | |
- def save(neo: NeoService) = neo.getReferenceNode.setProperty("cowColour", colourOfSpots) | |
+ def save(neo: GraphDatabaseService) = neo.getReferenceNode.setProperty("cowColour", colourOfSpots) | |
/** Zero-argument constructor is required */ | |
private [models] def this() = this(null.asInstanceOf[String]) | |
diff --git a/src/main/scala/com/example/models/Stats.scala b/src/main/scala/com/example/models/Stats.scala | |
index d905918..9f44c86 100644 | |
--- a/src/main/scala/com/example/models/Stats.scala | |
+++ b/src/main/scala/com/example/models/Stats.scala | |
@@ -2,7 +2,7 @@ package com.example.models | |
import java.util.logging.Logger | |
import org.codehaus.jettison.json.JSONObject | |
-import org.neo4j.api.core._ | |
+import org.neo4j.graphdb._ | |
import com.eptcomputing.neo4j.IteratorConverters | |
/** | |
diff --git a/src/main/scala/com/example/restapi/ManualResource.scala b/src/main/scala/com/example/restapi/ManualResource.scala | |
index d0f0ca0..10cb56a 100644 | |
--- a/src/main/scala/com/example/restapi/ManualResource.scala | |
+++ b/src/main/scala/com/example/restapi/ManualResource.scala | |
@@ -3,7 +3,7 @@ package com.example.restapi | |
import java.util.logging.Logger | |
import javax.ws.rs._ | |
-import com.eptcomputing.neo4j.NeoServer | |
+import com.eptcomputing.neo4j.Neo4jServer | |
import com.eptcomputing.neo4j.rest.RequiredParam | |
import com.example.models.Predicates | |
@@ -24,7 +24,7 @@ class ManualResource extends RequiredParam { | |
@POST @Produces(Array("text/plain")) | |
def helloWorld: String = { | |
// Execute the following inside a Neo4j transaction | |
- NeoServer.exec(neo => { | |
+ Neo4jServer.exec(neo => { | |
val firstNode = neo.createNode | |
val secondNode = neo.createNode | |
val relationship = firstNode.createRelationshipTo(secondNode, Predicates.KNOWS) | |
diff --git a/src/main/scala/com/example/restapi/MooResource.scala b/src/main/scala/com/example/restapi/MooResource.scala | |
index f3477be..04ba921 100644 | |
--- a/src/main/scala/com/example/restapi/MooResource.scala | |
+++ b/src/main/scala/com/example/restapi/MooResource.scala | |
@@ -3,7 +3,7 @@ package com.example.restapi | |
import javax.ws.rs._ | |
import javax.ws.rs.core._ | |
-import com.eptcomputing.neo4j.NeoServer | |
+import com.eptcomputing.neo4j.Neo4jServer | |
import com.example.models.Moo | |
/** | |
@@ -24,7 +24,7 @@ class MooResource { | |
@Consumes(Array(MediaType.APPLICATION_JSON)) | |
@Produces(Array(MediaType.APPLICATION_JSON)) | |
def setMostRecentlySeenCow(cow: Moo) = { | |
- NeoServer.exec { neo => cow.save(neo) } | |
+ Neo4jServer.exec { neo => cow.save(neo) } | |
cow | |
} | |
@@ -34,6 +34,6 @@ class MooResource { | |
*/ | |
@GET | |
@Produces(Array(MediaType.APPLICATION_JSON)) | |
- def getCow = NeoServer.exec { neo => new Moo(neo) } | |
+ def getCow = Neo4jServer.exec { neo => new Moo(neo) } | |
} | |
diff --git a/src/main/scala/com/example/restapi/NeoResource.scala b/src/main/scala/com/example/restapi/NeoResource.scala | |
index 7957638..20da0b5 100644 | |
--- a/src/main/scala/com/example/restapi/NeoResource.scala | |
+++ b/src/main/scala/com/example/restapi/NeoResource.scala | |
@@ -1,7 +1,7 @@ | |
package com.example.restapi | |
import javax.ws.rs.Path | |
-import com.eptcomputing.neo4j.rest.SimpleNeoResource | |
+import com.eptcomputing.neo4j.rest.SimpleNeo4jResource | |
@Path("/neo_resource") | |
-class NeoResource extends SimpleNeoResource | |
+class NeoResource extends SimpleNeo4jResource | |
diff --git a/src/main/scala/com/example/restapi/StatsResource.scala b/src/main/scala/com/example/restapi/StatsResource.scala | |
index 5039ad0..25e8e10 100644 | |
--- a/src/main/scala/com/example/restapi/StatsResource.scala | |
+++ b/src/main/scala/com/example/restapi/StatsResource.scala | |
@@ -2,7 +2,7 @@ package com.example.restapi | |
import javax.ws.rs.Path | |
import org.codehaus.jettison.json.JSONObject | |
-import org.neo4j.api.core.{NeoService, Node} | |
+import org.neo4j.graphdb.{GraphDatabaseService, Node} | |
import com.example.models.Stats | |
@@ -12,13 +12,13 @@ import com.example.models.Stats | |
* class implements the actual query. | |
*/ | |
@Path("/stats") | |
-class StatsResource extends com.eptcomputing.neo4j.rest.NeoResource { | |
+class StatsResource extends com.eptcomputing.neo4j.rest.Neo4jResource { | |
- def read(neo: NeoService, node: Node) = new Stats(node).toJSON | |
+ def read(neo: GraphDatabaseService, node: Node) = new Stats(node).toJSON | |
- def create(neo: NeoService, json: JSONObject) = throw new Exception("not allowed") | |
+ def create(neo: GraphDatabaseService, json: JSONObject) = throw new Exception("not allowed") | |
- def update(neo: NeoService, existing: Node, newValue: JSONObject) = throw new Exception("not allowed") | |
+ def update(neo: GraphDatabaseService, existing: Node, newValue: JSONObject) = throw new Exception("not allowed") | |
- def delete(neo: NeoService, node: Node) = throw new Exception("not allowed") | |
+ def delete(neo: GraphDatabaseService, node: Node) = throw new Exception("not allowed") | |
} | |
diff --git a/src/test/scala/com/example/models/StatsSpec.scala b/src/test/scala/com/example/models/StatsSpec.scala | |
index e66302e..a77ff9d 100644 | |
--- a/src/test/scala/com/example/models/StatsSpec.scala | |
+++ b/src/test/scala/com/example/models/StatsSpec.scala | |
@@ -6,9 +6,9 @@ import org.junit.runner.RunWith | |
import com.jteigen.scalatest.JUnit4Runner | |
import org.codehaus.jettison.json.JSONObject | |
-import org.neo4j.api.core._ | |
+import org.neo4j.graphdb._ | |
-import com.eptcomputing.neo4j.{NeoConverters, NeoServer} | |
+import com.eptcomputing.neo4j.{Neo4jConverters, Neo4jServer} | |
/** | |
* This is an example of how you can write good and expressive tests/specs using | |
@@ -17,21 +17,21 @@ import com.eptcomputing.neo4j.{NeoConverters, NeoServer} | |
* API request/response cycles, see <tt>NeoResourceTest</tt>. | |
*/ | |
@RunWith(classOf[JUnit4Runner]) | |
-class StatsSpec extends Spec with ShouldMatchers with NeoConverters { | |
+class StatsSpec extends Spec with ShouldMatchers with Neo4jConverters { | |
import Predicates._ | |
describe("Stats model") { | |
it("should return an empty object if the node has no relationships") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val node = neo.createNode | |
new Stats(node).toJSON.length should equal(0) | |
} | |
} | |
it("should return the number of neighbours") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val node = neo.createNode | |
(1 to 3) foreach { _ => node --> KNOWS --> neo.createNode } | |
new Stats(node).toJSON.getInt("depth_1") should equal(3) | |
@@ -39,7 +39,7 @@ class StatsSpec extends Spec with ShouldMatchers with NeoConverters { | |
} | |
it("should not count a node twice") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val start = neo.createNode | |
val end = neo.createNode | |
start --> "KNOWS" --> neo.createNode --> "KNOWS" --> end | |
@@ -51,7 +51,7 @@ class StatsSpec extends Spec with ShouldMatchers with NeoConverters { | |
} | |
it("should not follow inbound relationships") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val node = neo.createNode | |
neo.createNode --> KNOWS --> node --> KNOWS --> neo.createNode | |
new Stats(node).toJSON.getInt("depth_1") should equal(1) | |
@@ -59,7 +59,7 @@ class StatsSpec extends Spec with ShouldMatchers with NeoConverters { | |
} | |
it("should not follow relationships of a different type") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val node = neo.createNode | |
node --> "KNOWS" --> neo.createNode | |
node --> "LIKES" --> neo.createNode | |
@@ -68,7 +68,7 @@ class StatsSpec extends Spec with ShouldMatchers with NeoConverters { | |
} | |
it("should count only the shortest path to each reachable node") { | |
- NeoServer.exec { neo => | |
+ Neo4jServer.exec { neo => | |
val start = neo.createNode | |
val reachByTwoPaths = neo.createNode | |
start --> KNOWS --> neo.createNode --> KNOWS --> reachByTwoPaths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment