Reputation: 2311
i m new in neo4j and unmanaged extension.
i just write HelloWorld example in neo4j and the code is the following
//START SNIPPET: HelloWorldResource
@Path( "/helloworld" )
public class HelloWorldResource
{
private final GraphDatabaseService database;
public HelloWorldResource( @Context GraphDatabaseService database )
{
this.database = database;
}
@GET
@Produces( MediaType.TEXT_PLAIN )
@Path( "/{nodeId}" )
public Response hello( @PathParam( "nodeId" ) long nodeId )
{
// Do stuff with the database
return Response.status( Status.OK ).entity(
("Hello World2, nodeId=" + nodeId + ", ADDRESSNO = " + "").getBytes( Charset.forName("UTF-8") ) ).build();
}
}
how can i access to the node its id is nodeId
how can i access its address property
Upvotes: 0
Views: 76
Reputation: 39925
inside the hello
method:
try (Transaction tx = database.beginTx()) {
Node n = database.getNodeById(nodeId);
String address = (String)n.getProperty("address", null);
tx.success();
}
Upvotes: 1