PackageDescription: Neo4jHttpDemo


Neo 4j Http Demo

Last published: June 29, 2023 by 'dwallen'

Defines 2 Classes
Extends 2 Classes


This package implements a tiny HTTP interface for connecting with Neo4j, the graph database.
Besides the http interface, it has a simple robot model to demonstrate navigation using the graph database. By default, the robot's world is a 2D house with four rooms, and doorways in each interior wall. The default number of grid locations is 20 x 20, but this can be changed in method RobotCleaner (class) gridSize.

To create your robot data:
RobotCleaner createRobotData.

To see the projected path, decide on start and finish locations, eg.:
RobotCleaner displayShortestPathFrom: 1@1 to: 20@20

To remove all the robot data:
RobotCleaner deleteRobotData.


The Neo4jSession class provides a simple wrapper for your own Cypher (the Neo4j query language) queries. A Cypher query is sent via http, and the results arrive in JSON format.

Here is a raw version of what the Neo4jSession class does behind the curtain. The JSON results are decoded into Dictionary form. Ignore the following unless you're interested in the nitty gritty, or need to fix something.

aPost := 'http://localhost:7474/db/neo4j/tx/commit'.
aClient := HttpClient new.
aRequest := HttpRequest post: aPost.
aRequest authorization: 'bmVvNGo6bmVvNGo='.
aRequest contentType: 'application/json'.
aRequest accept: 'application/JSON'.
aRequest contents: query.
response := aClient executeRequest: aRequest.
json := response value source stream contents asStringEncoding: 'utf-8'
^Xtreams.JSON decode: json