|
|
|
@ -38,16 +38,25 @@
|
|
|
|
|
(spec/def ::contains-schema
|
|
|
|
|
(spec/keys :req-un [::domain-schema/schema]))
|
|
|
|
|
|
|
|
|
|
(spec/def ::instances-with-tags
|
|
|
|
|
(spec/coll-of (spec/merge ::instance
|
|
|
|
|
(spec/keys :req-un [::tags]))))
|
|
|
|
|
(neo4j/defquery findy-by-schema
|
|
|
|
|
"MATCH (i:instance)-[:of]->(s:schema)
|
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
|
RETURN i
|
|
|
|
|
OPTIONAL MATCH
|
|
|
|
|
(i)-[:tagged_with]->(t:tag)
|
|
|
|
|
RETURN i, t
|
|
|
|
|
ORDER BY i.name")
|
|
|
|
|
(defn find-by-schema! [schema-uuid]
|
|
|
|
|
(map :i
|
|
|
|
|
(neo4j/exec-query!
|
|
|
|
|
findy-by-schema
|
|
|
|
|
{:uuid schema-uuid})))
|
|
|
|
|
{:post [(spec/assert ::instances-with-tags %)]}
|
|
|
|
|
(->> (neo4j/exec-query! findy-by-schema
|
|
|
|
|
{:uuid schema-uuid})
|
|
|
|
|
(group-by :i)
|
|
|
|
|
(map #(assoc (key %)
|
|
|
|
|
:tags (->> (val %)
|
|
|
|
|
(map :t)
|
|
|
|
|
(filter some?))))))
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery create-instance
|
|
|
|
|
"MATCH (s:schema {uuid:{schema_uuid}}),
|
|
|
|
@ -91,8 +100,7 @@
|
|
|
|
|
(spec/def ::instance-with-schema
|
|
|
|
|
(spec/merge ::instance ::contains-schema))
|
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})
|
|
|
|
|
-[:of]->(s:schema)
|
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
|
|
|
|
|
RETURN i, s")
|
|
|
|
|
(defn find-by-uuid! [uuid]
|
|
|
|
|
{:post [(spec/assert ::instance-with-schema %)]}
|
|
|
|
|