|
|
@ -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}}),
|
|
|
|