|
|
@ -23,16 +23,6 @@
|
|
|
|
::name]))
|
|
|
|
::name]))
|
|
|
|
(spec/def ::target ::instance)
|
|
|
|
(spec/def ::target ::instance)
|
|
|
|
(spec/def ::source ::instance)
|
|
|
|
(spec/def ::source ::instance)
|
|
|
|
(spec/def ::links-out
|
|
|
|
|
|
|
|
(spec/coll-of
|
|
|
|
|
|
|
|
(spec/keys :req-un [::link
|
|
|
|
|
|
|
|
::target
|
|
|
|
|
|
|
|
::domain-schema/schema])))
|
|
|
|
|
|
|
|
(spec/def ::links-in
|
|
|
|
|
|
|
|
(spec/coll-of
|
|
|
|
|
|
|
|
(spec/keys :req-un [::link
|
|
|
|
|
|
|
|
::source
|
|
|
|
|
|
|
|
::domain-schema/schema])))
|
|
|
|
|
|
|
|
(spec/def ::tags
|
|
|
|
(spec/def ::tags
|
|
|
|
(spec/coll-of ::domain-tag/tag))
|
|
|
|
(spec/coll-of ::domain-tag/tag))
|
|
|
|
(spec/def ::contains-schema
|
|
|
|
(spec/def ::contains-schema
|
|
|
@ -212,37 +202,57 @@
|
|
|
|
(:to link))]
|
|
|
|
(:to link))]
|
|
|
|
(apply neo4j/exec-queries! tuples)))
|
|
|
|
(apply neo4j/exec-queries! tuples)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defn grouped-links-by-tag [uuid query direction]
|
|
|
|
|
|
|
|
(->> (neo4j/exec-query! query
|
|
|
|
|
|
|
|
{:uuid uuid})
|
|
|
|
|
|
|
|
(group-by
|
|
|
|
|
|
|
|
(fn [{:keys [link schema] :as row}]
|
|
|
|
|
|
|
|
{:link link
|
|
|
|
|
|
|
|
direction (direction row)
|
|
|
|
|
|
|
|
:schema schema}))
|
|
|
|
|
|
|
|
(map (fn [[link tags]]
|
|
|
|
|
|
|
|
(assoc link
|
|
|
|
|
|
|
|
:tags
|
|
|
|
|
|
|
|
(filter some?
|
|
|
|
|
|
|
|
(map :tag tags)))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(spec/def ::links-out
|
|
|
|
|
|
|
|
(spec/coll-of
|
|
|
|
|
|
|
|
(spec/keys :req-un [::link
|
|
|
|
|
|
|
|
::target
|
|
|
|
|
|
|
|
::domain-schema/schema
|
|
|
|
|
|
|
|
::tags])))
|
|
|
|
(neo4j/defquery outgoing-links
|
|
|
|
(neo4j/defquery outgoing-links
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
(i)<-[:link_from]-(l:link),
|
|
|
|
(inst)<-[:link_from]-(link:link),
|
|
|
|
(l)-[:link_to]->(t:instance),
|
|
|
|
(link)-[:link_to]->(target:instance),
|
|
|
|
(t)-[:of]->(s:schema)
|
|
|
|
(target)-[:of]->(schema:schema)
|
|
|
|
RETURN i, l, t, s
|
|
|
|
OPTIONAL MATCH
|
|
|
|
ORDER BY s.name, t.name, t.created_at")
|
|
|
|
(target)-[:tagged_with]->(tag:tag)
|
|
|
|
|
|
|
|
RETURN link, target, schema, tag
|
|
|
|
|
|
|
|
ORDER BY schema.name, target.name, target.created_at")
|
|
|
|
(defn outgoing-links! [uuid]
|
|
|
|
(defn outgoing-links! [uuid]
|
|
|
|
{:post [(spec/assert ::links-out %)]}
|
|
|
|
{:post [(spec/assert ::links-out %)]}
|
|
|
|
(map (fn [row]
|
|
|
|
(grouped-links-by-tag uuid outgoing-links :target))
|
|
|
|
{:link (:l row)
|
|
|
|
|
|
|
|
:target (:t row)
|
|
|
|
|
|
|
|
:schema (:s row)})
|
|
|
|
|
|
|
|
(neo4j/exec-query! outgoing-links
|
|
|
|
|
|
|
|
{:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(spec/def ::links-in
|
|
|
|
|
|
|
|
(spec/coll-of
|
|
|
|
|
|
|
|
(spec/keys :req-un [::link
|
|
|
|
|
|
|
|
::source
|
|
|
|
|
|
|
|
::domain-schema/schema
|
|
|
|
|
|
|
|
::tags])))
|
|
|
|
(neo4j/defquery incoming-links
|
|
|
|
(neo4j/defquery incoming-links
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
(i)<-[:link_to]-(l:link),
|
|
|
|
(inst)<-[:link_to]-(link:link),
|
|
|
|
(l)-[:link_from]->(source:instance),
|
|
|
|
(link)-[:link_from]->(source:instance),
|
|
|
|
(source)-[:of]->(schema:schema)
|
|
|
|
(source)-[:of]->(schema:schema)
|
|
|
|
RETURN i, l, source, schema
|
|
|
|
OPTIONAL MATCH
|
|
|
|
|
|
|
|
(source)-[:tagged_with]->(tag:tag)
|
|
|
|
|
|
|
|
RETURN link, source, schema, tag
|
|
|
|
ORDER BY schema.name, source.name, source.created_at")
|
|
|
|
ORDER BY schema.name, source.name, source.created_at")
|
|
|
|
(defn incoming-links! [uuid]
|
|
|
|
(defn incoming-links! [uuid]
|
|
|
|
{:post [(spec/assert ::links-in %)]}
|
|
|
|
{:post [(spec/assert ::links-in %)]}
|
|
|
|
(map (fn [row]
|
|
|
|
(grouped-links-by-tag uuid incoming-links :source))
|
|
|
|
{:link (:l row)
|
|
|
|
|
|
|
|
:source (:source row)
|
|
|
|
|
|
|
|
:schema (:schema row)})
|
|
|
|
|
|
|
|
(neo4j/exec-query! incoming-links
|
|
|
|
|
|
|
|
{:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery delete-link
|
|
|
|
(neo4j/defquery delete-link
|
|
|
|
"MATCH (l:link {uuid:{uuid}}),
|
|
|
|
"MATCH (l:link {uuid:{uuid}}),
|
|
|
|