specs restructuring

integration-tests
Josha von Gizycki 5 years ago
parent 527380e241
commit 0b76877028

@ -1,23 +1,17 @@
(ns wanijo.attribute.domain (ns wanijo.attribute.domain
(:require [clojure.spec.alpha :as spec] (:require [clojure.spec.alpha :as spec]
[wanijo.specs :as specs]
[wanijo.framework.neo4j :as neo4j])) [wanijo.framework.neo4j :as neo4j]))
(spec/def ::name
(spec/and string? not-empty))
(def types (def types
#{"string" "markdown"}) #{"string" "markdown"})
(spec/def ::type types)
(spec/def ::type (spec/def ::name
(spec/and string? types)) (spec/and ::specs/name (complement empty?)))
(spec/def ::created-at
(spec/and string? ::neo4j/date-str))
(spec/def ::attribute (spec/def ::attribute
(spec/keys ::req-un [::name (spec/keys ::req-un [::name
::type ::type
::created-at])) ::specs/created-at]))
(neo4j/defquery (neo4j/defquery
findy-by-schema findy-by-schema
@ -25,7 +19,6 @@
WHERE s.uuid = {uuid} WHERE s.uuid = {uuid}
RETURN a RETURN a
ORDER BY a.name") ORDER BY a.name")
(defn find-by-schema! [schema-uuid] (defn find-by-schema! [schema-uuid]
(map :a (map :a
(neo4j/exec-query! (neo4j/exec-query!
@ -43,7 +36,6 @@
SET a.uuid = {attribute_uuid} SET a.uuid = {attribute_uuid}
SET a.required = {required} SET a.required = {required}
SET a.created_at = {created_at}") SET a.created_at = {created_at}")
(defn create-new! [attr schema-uuid user-uuid] (defn create-new! [attr schema-uuid user-uuid]
(neo4j/exec-query! (neo4j/exec-query!
create-new create-new
@ -59,7 +51,6 @@
SET a.type = {type} SET a.type = {type}
SET a.name = {name} SET a.name = {name}
SET a.required = {required}") SET a.required = {required}")
(defn edit! [attr] (defn edit! [attr]
(neo4j/exec-query! (neo4j/exec-query!
edit edit
@ -69,7 +60,6 @@
"MATCH (a:attribute)-[c]-() "MATCH (a:attribute)-[c]-()
WHERE a.uuid = {uuid} WHERE a.uuid = {uuid}
DELETE c, a") DELETE c, a")
(defn delete-by-uuid! [uuid] (defn delete-by-uuid! [uuid]
(neo4j/exec-query! (neo4j/exec-query!
delete-by-uuid delete-by-uuid
@ -80,7 +70,6 @@
WHERE a.required = 1 WHERE a.required = 1
RETURN a RETURN a
ORDER BY a.name") ORDER BY a.name")
(defn required! [schema-uuid] (defn required! [schema-uuid]
(map :a (map :a
(neo4j/exec-query! required (neo4j/exec-query! required
@ -89,7 +78,6 @@
(neo4j/defquery schema-of (neo4j/defquery schema-of
"MATCH (a:attribute {uuid:{uuid}})-[:of]->(s:schema) "MATCH (a:attribute {uuid:{uuid}})-[:of]->(s:schema)
RETURN s") RETURN s")
(defn schema-of! [uuid] (defn schema-of! [uuid]
(->> (neo4j/exec-query! schema-of (->> (neo4j/exec-query! schema-of
{:uuid uuid}) {:uuid uuid})
@ -102,7 +90,6 @@
(a:attribute)-[:of]->(s) (a:attribute)-[:of]->(s)
RETURN a RETURN a
ORDER BY a.name") ORDER BY a.name")
(defn find-by-instance! [instance-uuid] (defn find-by-instance! [instance-uuid]
(map :a (map :a
(neo4j/exec-query! find-by-instance (neo4j/exec-query! find-by-instance

Loading…
Cancel
Save