Created
November 1, 2011 19:30
-
-
Save FaKod/1331645 to your computer and use it in GitHub Desktop.
Creating and deleting Nodes with Neo4j Server and sjersey-client for Scala
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
rest { | |
implicit s => | |
// defining note names and profession | |
val nodes = ("Mr. Andersson", "Hacker") :: | |
("Morpheus", "Hacker") :: | |
("Trinity", "Hacker") :: | |
("Cypher", "Hacker") :: | |
("Agent Smith", "Program") :: | |
("The Architect", "Whatever") :: Nil | |
// for all notes | |
val locations = | |
for (node <- nodes; | |
// create node | |
cr = "node".POST[ClientResponse] <= MatrixNodeProperties(name = node._1, profession = node._2) | |
// if creation was successful use yield | |
if (cr.getStatus == ClientResponse.Status.CREATED.getStatusCode) | |
// yield all created locations | |
) yield cr.getLocation | |
// print them to the console | |
locations.foreach(s => println("created nodes: " + s.getPath)) | |
// and remove them | |
for (location <- locations) { | |
val cr = (location.toString).DELETE[ClientResponse] <=() | |
// no exception and No Content means successful | |
cr.getStatus must beEqualTo(ClientResponse.Status.NO_CONTENT.getStatusCode) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment