|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
(ns wanijo.schema.db
|
|
|
|
|
(:require [wanijo.infrastructure.neo4j :as neo4j]
|
|
|
|
|
[wanijo.schema.domain :as domain]))
|
|
|
|
|
[wanijo.schema.domain :as domain]
|
|
|
|
|
[clojure.spec.alpha :as spec]))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery all-created-by
|
|
|
|
|
"MATCH (s:schema)-[:created_by]->(u:user)
|
|
|
|
@ -43,14 +44,20 @@
|
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
|
"MATCH (s:schema)
|
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
|
RETURN s")
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
|
(s)<-[:of]-(a:attribute)
|
|
|
|
|
WHERE a.required = 1
|
|
|
|
|
RETURN s, a
|
|
|
|
|
ORDER BY a.name")
|
|
|
|
|
(defn find-by-uuid! [uuid]
|
|
|
|
|
(->>
|
|
|
|
|
(neo4j/exec-query!
|
|
|
|
|
find-by-uuid
|
|
|
|
|
{:uuid uuid})
|
|
|
|
|
first
|
|
|
|
|
:s))
|
|
|
|
|
{:post [(spec/assert ::domain/schema-with-req-attrs %)]}
|
|
|
|
|
(let [result (neo4j/exec-query!
|
|
|
|
|
find-by-uuid
|
|
|
|
|
{:uuid uuid})
|
|
|
|
|
schema (:s (first result))]
|
|
|
|
|
(when schema
|
|
|
|
|
(assoc schema
|
|
|
|
|
:req-attrs (map :a result)))))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery schema-permissions
|
|
|
|
|
"MATCH (s:schema {uuid:{schema_uuid}})
|
|
|
|
|