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