move form neocons to neo4j-clj, update dependencies

integration-tests
Josha von Gizycki 6 years ago
parent d7947c431a
commit 2b09913ca4

@ -3,10 +3,9 @@
:url "http://example.com/FIXME" :url "http://example.com/FIXME"
:min-lein-version "2.0.0" :min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.9.0"] :dependencies [[org.clojure/clojure "1.9.0"]
[compojure "1.5.1"] [compojure "1.6.1"]
[ring/ring-defaults "0.2.1"] [ring/ring-defaults "0.3.2"]
[clojurewerkz/neocons "3.2.0" [gorillalabs/neo4j-clj "1.1.0"]
:exclusions [commons-codec]]
[hiccup "1.0.5"] [hiccup "1.0.5"]
[buddy/buddy-hashers "1.3.0" [buddy/buddy-hashers "1.3.0"
:exclusions [commons-codec]]] :exclusions [commons-codec]]]
@ -14,7 +13,7 @@
:ring {:handler wanijo.handler/app} :ring {:handler wanijo.handler/app}
:profiles {:dev {:dependencies :profiles {:dev {:dependencies
[[javax.servlet/servlet-api "2.5"] [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.0"]] [ring/ring-mock "0.3.2"]]
:plugins [[lein-less "1.7.5"]]}} :plugins [[lein-less "1.7.5"]]}}
:less {:source-paths ["resources/app/stylesheets"] :less {:source-paths ["resources/app/stylesheets"]
:target-path "resources/public/css"} :target-path "resources/public/css"}

@ -11,27 +11,34 @@
:str (spec/and string? :str (spec/and string?
#(re-matches #"\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}" %)))) #(re-matches #"\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}" %))))
(defn all-created-by! [user-uuid] (neo4j/defquery
(neo4j/query-rawdata! all-created-by
:query
"MATCH (s:schema)-[:created_by]->(u:user) "MATCH (s:schema)-[:created_by]->(u:user)
WHERE u.uuid = {uuid} WHERE u.uuid = {uuid}
RETURN s RETURN s
ORDER BY s.name" ORDER BY s.name")
:params {:uuid user-uuid}
:alias "s")) (defn all-created-by! [user-uuid]
(map :s
(neo4j/exec-query
all-created-by
{:uuid user-uuid})))
(defn create-new! [name user-uid] (neo4j/defquery
(:uuid create-new
(neo4j/query-rawdata!
:query
"MATCH (u:user) "MATCH (u:user)
WHERE u.uuid = {u_uuid} WHERE u.uuid = {u_uuid}
CREATE (s:schema)-[:created_by]->(u) CREATE (s:schema)-[:created_by]->(u)
SET s.name = {name} SET s.name = {name}
SET s.uuid = {s_uuid} SET s.uuid = {s_uuid}
RETURN s" RETURN s")
:params {:u_uuid user-uid
(defn create-new! [name user-uuid]
(->>
(neo4j/exec-query
create-new
{:u_uuid user-uuid
:name name :name name
:s_uuid (neo4j/uuid)} :s_uuid (neo4j/uuid)})
:alias "s"))) first
:uuid))

@ -1,12 +1,16 @@
(ns wanijo.domain.user (ns wanijo.domain.user
(:require [wanijo.neo4j :as neo4j])) (:require [wanijo.neo4j :as neo4j]))
(defn find! [ident] (neo4j/defquery
(first find-user
(neo4j/query-rawdata!
:query
"MATCH (n:user) "MATCH (n:user)
WHERE n.ident = {ident} WHERE n.ident = {ident}
RETURN n" RETURN n")
:alias "n"
:params {:ident ident}))) (defn find! [ident]
(->>
(neo4j/exec-query
find-user
{:ident ident})
first
:n))

@ -1,34 +1,31 @@
(ns wanijo.neo4j (ns wanijo.neo4j
(:require [clojurewerkz.neocons.rest :as nr] (:require [neo4j-clj.core :as db]
[clojurewerkz.neocons.rest.nodes :as nrn]
[clojurewerkz.neocons.rest.cypher :as cypher]
[wanijo.devmode :as devmode])) [wanijo.devmode :as devmode]))
(def conn (def conn
(delay (nr/connect "http://neo4j:b@localhost:7474/db/data"))) (delay (db/connect
"bolt://localhost:7687"
"neo4j"
"b")))
(defn conn! [] (defmacro defquery [& args] `(db/defquery ~@args))
@conn)
(defn uuid [] (defn uuid []
(str (java.util.UUID/randomUUID))) (str (java.util.UUID/randomUUID)))
(defn butiful-query [qry] (defn butiful-query [qry]
(->> qry (->> qry
str
clojure.string/trim-newline clojure.string/trim-newline
clojure.string/split-lines clojure.string/split-lines
(map clojure.string/trim) (map clojure.string/trim)
(filter #(> (count %) 0)) (filter #(> (count %) 0))
(clojure.string/join \newline))) (clojure.string/join \newline)))
(defn query-rawdata! (defn exec-query [qry params]
[& {:keys [query alias params] (with-open [session (db/get-session @conn)]
:or {params {}}}]
(devmode/send-to-bar (devmode/send-to-bar
(str (butiful-query query) (str (butiful-query qry)
"<br>---Params---<br>" "<br>---Params---<br>"
params)) params))
(->> (qry session params)))
(cypher/tquery (conn!) query params)
(map #(get % alias))
(map :data)))

@ -1,17 +1,18 @@
(ns wanijo.repl (ns wanijo.repl
(:require [clojurewerkz.neocons.rest.nodes :as nodes] (:require [buddy.hashers :as hashers]
[clojurewerkz.neocons.rest.labels :as labels] [neo4j-clj.core :as db]
[clojurewerkz.neocons.rest.cypher :as cypher]
[buddy.hashers :as hashers]
[wanijo.neo4j :as neo4j])) [wanijo.neo4j :as neo4j]))
(defn create-user! [ident pw] (db/defquery
(cypher/tquery create-user
(neo4j/conn!)
"CREATE (n:user) "CREATE (n:user)
SET n.ident = {ident} SET n.ident = {ident}
SET n.pw = {pw} SET n.pw = {pw}
SET n.uuid = {uuid}" SET n.uuid = {uuid}")
(defn create-user! [ident pw]
(neo4j/exec-query
create-user
{:ident ident {:ident ident
:pw (hashers/derive pw) :pw (hashers/derive pw)
:uuid (neo4j/uuid)})) :uuid (neo4j/uuid)}))

Loading…
Cancel
Save