Skip to content

Instantly share code, notes, and snippets.

@FaKod
Created November 1, 2011 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FaKod/1331645 to your computer and use it in GitHub Desktop.
Save FaKod/1331645 to your computer and use it in GitHub Desktop.
Creating and deleting Nodes with Neo4j Server and sjersey-client for Scala
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