|
|
@ -6,7 +6,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(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
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
|
(i)-[:tagged_with]->(t:tag)
|
|
|
|
(i)-[:tagged_with]->(t:tag)
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
@ -34,21 +34,21 @@
|
|
|
|
(sort-by :name)))
|
|
|
|
(sort-by :name)))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery create-instance
|
|
|
|
(neo4j/defquery create-instance
|
|
|
|
"MATCH (s:schema {uuid:{schema_uuid}}),
|
|
|
|
"MATCH (s:schema {uuid: $schema_uuid}),
|
|
|
|
(u:user {uuid:{user_uuid}})
|
|
|
|
(u:user {uuid: $user_uuid})
|
|
|
|
CREATE (i:instance {uuid:{uuid}})-[:of]->(s),
|
|
|
|
CREATE (i:instance {uuid: $uuid})-[:of]->(s),
|
|
|
|
(i)-[:created_by]->(u)
|
|
|
|
(i)-[:created_by]->(u)
|
|
|
|
SET i.name = {name},
|
|
|
|
SET i.name = $name,
|
|
|
|
i.created_at = {created_at},
|
|
|
|
i.created_at = $created_at,
|
|
|
|
i.updated_at = {created_at}")
|
|
|
|
i.updated_at = $created_at")
|
|
|
|
(neo4j/defquery create-property
|
|
|
|
(neo4j/defquery create-property
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
(a:attribute {uuid:{attr_uuid}})
|
|
|
|
(a:attribute {uuid: $attr_uuid})
|
|
|
|
CREATE (p:property {uuid:{prop_uuid}})-[:of]->(i),
|
|
|
|
CREATE (p:property {uuid: $prop_uuid})-[:of]->(i),
|
|
|
|
(p)-[:of]->(a)
|
|
|
|
(p)-[:of]->(a)
|
|
|
|
SET p.value = {value},
|
|
|
|
SET p.value = $value,
|
|
|
|
p.created_at = {created_at},
|
|
|
|
p.created_at = $created_at,
|
|
|
|
p.updated_at = {updated_at}")
|
|
|
|
p.updated_at = $updated_at")
|
|
|
|
(defn create! [user-uuid
|
|
|
|
(defn create! [user-uuid
|
|
|
|
schema-uuid
|
|
|
|
schema-uuid
|
|
|
|
{:keys [name properties]}]
|
|
|
|
{:keys [name properties]}]
|
|
|
@ -73,7 +73,7 @@
|
|
|
|
prop-tuples))))
|
|
|
|
prop-tuples))))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
|
|
|
|
"MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema)
|
|
|
|
RETURN i, s")
|
|
|
|
RETURN i, s")
|
|
|
|
(defn find-by-uuid! [uuid]
|
|
|
|
(defn find-by-uuid! [uuid]
|
|
|
|
{:post [(spec/assert ::domain-instance/instance-with-schema %)]}
|
|
|
|
{:post [(spec/assert ::domain-instance/instance-with-schema %)]}
|
|
|
@ -85,7 +85,7 @@
|
|
|
|
first))
|
|
|
|
first))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-properties
|
|
|
|
(neo4j/defquery find-properties
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
(p:property)-[:of]->(i),
|
|
|
|
(p:property)-[:of]->(i),
|
|
|
|
(p)-[:of]->(a:attribute)
|
|
|
|
(p)-[:of]->(a:attribute)
|
|
|
|
RETURN p, a
|
|
|
|
RETURN p, a
|
|
|
@ -98,19 +98,19 @@
|
|
|
|
{:uuid uuid})))
|
|
|
|
{:uuid uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery edit-instance
|
|
|
|
(neo4j/defquery edit-instance
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})
|
|
|
|
"MATCH (i:instance {uuid: $uuid})
|
|
|
|
SET i.name = {name},
|
|
|
|
SET i.name = $name,
|
|
|
|
i.updated_at = {updated_at}")
|
|
|
|
i.updated_at = $updated_at")
|
|
|
|
(neo4j/defquery edit-property
|
|
|
|
(neo4j/defquery edit-property
|
|
|
|
"MATCH (i:instance {uuid:{instance_uuid}}),
|
|
|
|
"MATCH (i:instance {uuid: $instance_uuid}),
|
|
|
|
(a:attribute {uuid:{attribute_uuid}})
|
|
|
|
(a:attribute {uuid: $attribute_uuid})
|
|
|
|
MERGE (p:property {uuid:{uuid}})-[:of]->(i)
|
|
|
|
MERGE (p:property {uuid: $uuid})-[:of]->(i)
|
|
|
|
MERGE (p)-[:of]->(a)
|
|
|
|
MERGE (p)-[:of]->(a)
|
|
|
|
ON CREATE SET p.created_at = {now},
|
|
|
|
ON CREATE SET p.created_at = $now,
|
|
|
|
p.updated_at = {now},
|
|
|
|
p.updated_at = $now,
|
|
|
|
p.value = {value}
|
|
|
|
p.value = $value
|
|
|
|
ON MATCH SET p.updated_at = {now},
|
|
|
|
ON MATCH SET p.updated_at = $now,
|
|
|
|
p.value = {value}")
|
|
|
|
p.value = $value")
|
|
|
|
(defn instance->prop-tuples [instance]
|
|
|
|
(defn instance->prop-tuples [instance]
|
|
|
|
{:post [(spec/assert ::domain-instance/prop-tuple %)]}
|
|
|
|
{:post [(spec/assert ::domain-instance/prop-tuple %)]}
|
|
|
|
(map (fn [prop]
|
|
|
|
(map (fn [prop]
|
|
|
@ -135,7 +135,7 @@
|
|
|
|
prop-tuples))))
|
|
|
|
prop-tuples))))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery delete
|
|
|
|
(neo4j/defquery delete
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
(i)-[ic:of]->(s:schema),
|
|
|
|
(i)-[ic:of]->(s:schema),
|
|
|
|
(i)-[cb:created_by]->(:user)
|
|
|
|
(i)-[cb:created_by]->(:user)
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
@ -164,7 +164,7 @@
|
|
|
|
#(-> % direction :created_at)))))
|
|
|
|
#(-> % direction :created_at)))))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery outgoing-links
|
|
|
|
(neo4j/defquery outgoing-links
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (inst:instance {uuid: $uuid}),
|
|
|
|
(inst)-[link:link]->(target:instance),
|
|
|
|
(inst)-[link:link]->(target:instance),
|
|
|
|
(target)-[:of]->(schema:schema)
|
|
|
|
(target)-[:of]->(schema:schema)
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
@ -175,7 +175,7 @@
|
|
|
|
(group-by-link-and-assoc-tags uuid outgoing-links :target))
|
|
|
|
(group-by-link-and-assoc-tags uuid outgoing-links :target))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery incoming-links
|
|
|
|
(neo4j/defquery incoming-links
|
|
|
|
"MATCH (inst:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (inst:instance {uuid: $uuid}),
|
|
|
|
(inst)<-[link:link]-(source:instance),
|
|
|
|
(inst)<-[link:link]-(source:instance),
|
|
|
|
(source)-[:of]->(schema:schema)
|
|
|
|
(source)-[:of]->(schema:schema)
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
@ -199,8 +199,8 @@
|
|
|
|
(db-tag/tags-by-instance! uuid)))
|
|
|
|
(db-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}),
|
|
|
|
(i:instance {uuid:{uuid}})
|
|
|
|
(i:instance {uuid: $uuid})
|
|
|
|
RETURN EXISTS((i)-[:starred_by]->(u)) AS starred")
|
|
|
|
RETURN EXISTS((i)-[:starred_by]->(u)) AS starred")
|
|
|
|
(defn is-starred! [uuid user-uuid]
|
|
|
|
(defn is-starred! [uuid user-uuid]
|
|
|
|
(-> (neo4j/exec-query! is-starred
|
|
|
|
(-> (neo4j/exec-query! is-starred
|
|
|
@ -210,11 +210,11 @@
|
|
|
|
:starred))
|
|
|
|
:starred))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery mark-starred
|
|
|
|
(neo4j/defquery mark-starred
|
|
|
|
"MATCH (i:instance {uuid:{uuid}}),
|
|
|
|
"MATCH (i:instance {uuid: $uuid}),
|
|
|
|
(u:user {uuid:{user_uuid}})
|
|
|
|
(u:user {uuid: $user_uuid})
|
|
|
|
MERGE (i)-[s:starred_by]->(u)
|
|
|
|
MERGE (i)-[s:starred_by]->(u)
|
|
|
|
ON CREATE
|
|
|
|
ON CREATE
|
|
|
|
SET s.created_at = {now}")
|
|
|
|
SET s.created_at = $now")
|
|
|
|
(defn mark-starred! [uuid user-uuid]
|
|
|
|
(defn mark-starred! [uuid user-uuid]
|
|
|
|
(neo4j/exec-query! mark-starred
|
|
|
|
(neo4j/exec-query! mark-starred
|
|
|
|
{:uuid uuid
|
|
|
|
{:uuid uuid
|
|
|
@ -222,9 +222,9 @@
|
|
|
|
:now (neo4j/now-str)}))
|
|
|
|
:now (neo4j/now-str)}))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery remove-starred
|
|
|
|
(neo4j/defquery remove-starred
|
|
|
|
"MATCH (:instance {uuid:{uuid}})
|
|
|
|
"MATCH (:instance {uuid: $uuid})
|
|
|
|
-[s:starred_by]->
|
|
|
|
-[s:starred_by]->
|
|
|
|
(:user {uuid:{user_uuid}})
|
|
|
|
(:user {uuid: $user_uuid})
|
|
|
|
DELETE s")
|
|
|
|
DELETE s")
|
|
|
|
(defn remove-starred! [uuid user-uuid]
|
|
|
|
(defn remove-starred! [uuid user-uuid]
|
|
|
|
(neo4j/exec-query! remove-starred
|
|
|
|
(neo4j/exec-query! remove-starred
|
|
|
@ -232,7 +232,7 @@
|
|
|
|
:user_uuid user-uuid}))
|
|
|
|
:user_uuid user-uuid}))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery starred-by-user
|
|
|
|
(neo4j/defquery starred-by-user
|
|
|
|
"MATCH (u:user {uuid:{user_uuid}})
|
|
|
|
"MATCH (u:user {uuid: $user_uuid})
|
|
|
|
<-[s:starred_by]-
|
|
|
|
<-[s:starred_by]-
|
|
|
|
(i:instance)
|
|
|
|
(i:instance)
|
|
|
|
RETURN i, s
|
|
|
|
RETURN i, s
|
|
|
|