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

@ -12,3 +12,4 @@
(spec/def ::instance_uuid ::neo4j/uuid) (spec/def ::instance_uuid ::neo4j/uuid)
(spec/def ::attribute_uuid ::neo4j/uuid) (spec/def ::attribute_uuid ::neo4j/uuid)
(spec/def ::now ::neo4j/date-str) (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