fix specs, add tags domain

integration-tests
Josha von Gizycki 5 years ago
parent bac79cd60c
commit 59755dc041

@ -3,7 +3,8 @@
[wanijo.specs :as specs]
[wanijo.framework.neo4j :as neo4j]
[wanijo.schema.domain :as domain-schema]
[wanijo.attribute.domain :as domain-attr]))
[wanijo.attribute.domain :as domain-attr]
[wanijo.tag.domain :as domain-tag]))
(spec/def ::instance
(spec/keys :req-un [::neo4j/uuid
@ -33,10 +34,9 @@
::source
::domain-schema/schema])))
(spec/def ::tags
(spec/coll-of
(spec/keys :req-un [::neo4j/uuid
::specs/name
::specs/created_at])))
(spec/coll-of ::domain-tag/tag))
(spec/def ::contains-schema
(spec/keys :req-un [::domain-schema/schema]))
(neo4j/defquery findy-by-schema
"MATCH (i:instance)-[:of]->(s:schema)
@ -89,9 +89,7 @@
prop-tuples))))
(spec/def ::instance-with-schema
(spec/and ::instance
(spec/keys :req-un
[::domain-schema/schema])))
(spec/merge ::instance ::contains-schema))
(neo4j/defquery find-by-uuid
"MATCH (i:instance {uuid:{uuid}})
-[:of]->(s:schema)
@ -235,25 +233,14 @@
(neo4j/exec-query! delete-link
{:uuid uuid}))
(neo4j/defquery tags
"MATCH (i:instance {uuid:{uuid}})-[:has]->(t:tag)
RETURN t
ORDER BY t.name")
(defn tags! [uuid]
{:post [(spec/assert ::tags %)]}
(neo4j/exec-query! tags
{:uuid uuid}))
(spec/def ::contains-full-information
(spec/keys :req-un [::properties
::links-out
::links-in
::tags]))
(spec/def ::full-instance
(spec/and ::instance-with-schema
(spec/keys ::req-un [::neo4j/uuid
::specs/created-at
::specs/updated-at
::specs/name
::properties
::links-out
::links-in
::tags])))
(spec/merge ::instance-with-schema
::contains-full-information))
(defn full-instance-by-uuid! [uuid]
{:post [(spec/assert ::full-instance %)]}
(assoc (find-by-uuid! uuid)
@ -264,7 +251,7 @@
:links-in
(incoming-links! uuid)
:tags
(tags! uuid)))
(domain-tag/tags-by-instance! uuid)))
(neo4j/defquery is-starred
"MATCH (u:user {uuid:{user_uuid}}),

@ -12,3 +12,4 @@
(spec/def ::instance_uuid ::neo4j/uuid)
(spec/def ::attribute_uuid ::neo4j/uuid)
(spec/def ::now ::neo4j/date-str)
(spec/def ::uuid ::neo4j/uuid)

@ -0,0 +1,19 @@
(ns wanijo.tag.domain
(:require [clojure.spec.alpha :as spec]
[wanijo.specs :as specs]
[wanijo.framework.neo4j :as neo4j]))
(spec/def ::name ::specs/req-name)
(spec/def ::tag
(spec/keys :req-un [::specs/uuid
::specs/created_at
::name]))
(neo4j/defquery tags-by-instance
"MATCH (i:instance {uuid:{uuid}})-[:has]->(t:tag)
RETURN t
ORDER BY t.name")
(defn tags-by-instance! [instance-uuid]
{:post [(spec/assert (spec/coll-of ::tag) %)]}
(neo4j/exec-query! tags-by-instance
{:uuid instance-uuid}))
Loading…
Cancel
Save