8000 Changes to create new wrapper around new Neo4J HTTP API by rvedam · Pull Request #6 · kraison/cl-neo4j · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Changes to create new wrapper around new Neo4J HTTP API #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cl-neo4j.asd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(:file "query" :depends-on ("utilities"))
(:file "requests" :depends-on ("conditions" "query"))
(:file "restapi" :depends-on ("requests"))
(:file "transaction" :depends-on ("requests"))
(:file "wrapper" :depends-on ("restapi"))))))

(defsystem cl-neo4j.tests
Expand Down
4 changes: 2 additions & 2 deletions src/conditions.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; Conditions that low-level REST api throw in default unexpected situations.

(in-package #:cl-neo4j)
(in-package #:cl-neo4j.utils)

(define-condition unknown-return-type-error (error)
((uri :accessor uri :initarg :uri)
Expand Down Expand Up @@ -58,4 +58,4 @@
(define-condition path-not-found-error (error)
((uri :accessor uri :initarg :uri))
(:report (lambda (condition stream)
(format stream "No path found with current algorithm at ~A" (uri condition)))))
(format stream "No path found with current algorithm at ~A" (uri condition)))))
3 changes: 2 additions & 1 deletion src/globals.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(in-package #:cl-neo4j)
(in-package #:cl-neo4j.utils)

(defvar *neo4j-host* "localhost")
(defvar *neo4j-port* 7474)
(defvar *neo4j-user* "neo4j")
(defvar *neo4j-pass* "neo4j")
(defvar *neo4j-database* "data")
133 changes: 84 additions & 49 deletions src/package.lisp
Original file line number Diff line number Diff line change
@@ -1,57 +1,79 @@
(in-package #:cl-user)

(defpackage #:cl-neo4j
(defpackage #:cl-neo4j.utils
(:use #:cl
#:alexandria
#:anaphora
#:json
#:json-rpc
#:drakma)
(:export #:get-node
#:create-node
#:delete-node
#:set-node-properties
#:get-node-properties
#:del-node-properties
#:set-node-property
#:get-node-property
#:del-node-property
#:get-relationship
#:create-relationship
#:set-relationship-properties
#:get-relationship-properties
#:del-relationship-properties
#:set-relationship-property
#:get-relationship-property
#:del-relationship-property
#:delete-relationship
#:get-node-relationships
#:get-relationships-types
#:create-index
#:delete-index
#:add-to-index
#:remove-from-index
#:lookup-index
#:query-index
#:traverse
#:get-path
#:get-paths
;; Conditions
#:unknown-return-type-error
#:invalid-data-sent-error
#:node-not-found-error
#:property-not-found-error
#:unable-to-delete-node-error
#:relationship-not-found-error
#:index-not-found-error
#:index-entry-not-found-error
#:path-not-found-error
;; Vars
#:*neo4j-host*
#:*neo4j-port*
#:*neo4j-user*
#:*neo4j-pass*
))
#:json
#:json-rpc
#:drakma)
(:export
;; Conditions
#:unknown-return-type-error
#:invalid-data-sent-error
#:node-not-found-error
#:property-not-found-error
#:unable-to-delete-node-error
#:relationship-not-found-error
#:index-not-found-error
#:index-entry-not-found-error
#:path-not-found-error
;; Macros
#:def-neo4j-fun
;; query data structures
#:cypher-query
#:cypher-transaction
;; Vars
#:*neo4j-host*
#:*neo4j-port*
#:*neo4j-user*
#:*neo4j-pass*
#:*neo4j-database*))

(defpackage #:cl-neo4j.deprecated
(:use #:cl
#:alexandria
#:cl-neo4j.utils))

(defpackage #:cl-neo4j
(:use
#:cl
#:cl-neo4j.utils
#:alexandria
#:anaphora
#:json
#:json-rpc
#:drakma)
(:export
#:get-node
#:create-node
#:delete-node
#:set-node-properties
#:get-node-properties
#:del-node-properties
#:set-node-property
#:get-node-property
#:del-node-property
#:get-relationship
#:create-relationship
#:set-relationship-properties
#:get-relationship-properties
#:del-relationship-properties
#:set-relationship-property
#:get-relationship-property
#:del-relationship-property
#:delete-relationship
#:get-node-relationships
#:get-relationships-types
#:create-index
#:delete-index
#:add-to-index
#:remove-from-index
#:lookup-index
#:query-index
#:traverse
#:get-path
#:get-paths))

(defpackage #:cl-neo4j-wrapper
(:use #:cl
Expand Down Expand Up @@ -91,3 +113,16 @@
;: Vars
#:*default-node-constructor*
#:*default-relationship-constructor*))

(defpackage #:cl-neo4j.transaction
(:use #:cl
#:alexandria
#:anaphora)
(:export
;; transaction
#:tx-create-node
#:tx-get-node
#:tx-delete-node
#:tx-relationship-create
#:tx-relationship-get-by-id
#:tx-relationship-delete))
5 changes: 4 additions & 1 deletion src/query.lisp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
(in-package #:cl-neo4j)
(in-package #:cl-neo4j.utils)

(defclass cypher-transaction ()
((statements :initarg :statements :accessor statements :initform '())))

(defclass cypher-query ()
((statement :accessor statement :initform "" :initarg :statement)
Expand Down
14 changes: 9 additions & 5 deletions src/requests.lisp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; Neo4j requests and request handlers for them. Also database stuff is handled here.

(in-package :cl-neo4j)
(in-package :cl-neo4j.utils)

(defmacro with-neo4j-database ((host port user pass) &rest body)
`(let ((*neo4j-host* ,host)
Expand Down Expand Up @@ -58,24 +58,28 @@
((host :initarg :host :accessor handler-host)
(port :initarg :port :accessor handler-port)
(user :initarg :user :accessor handler-user)
(pass :initarg :pass :accessor handler-pass))
(pass :initarg :pass :accessor handler-pass)
(database :initarg :db-name :accessor handler-db))
(:documentation "Basic handler that just sends request to the database."))

(defun basic-handler (&key (host *neo4j-host*) (port *neo4j-port*)
(user *neo4j-user*) (pass *neo4j-pass*))
(user *neo4j-user*) (pass *neo4j-pass*)
(db *neo4j-database*))
(make-instance 'basic-handler
:host host
:port port
:user user
:pass pass))
:pass pass
:db-name db))

(defmethod send-request ((handler basic-handler) request)
(with-accessors ((method request-method) (uri request-uri) (payload request-payload))
request
(multiple-value-bind (body status)
(http-request (format-neo4j-query (handler-host handler)
(handler-port handler)
uri)
uri
:db-postfix (format nil "db/~A/" (handler-db handler)))
:method method
:basic-authorization (list (handler-user handler)
(handler-pass handler))
Expand Down
Loading
0