|
|
@ -24,11 +24,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery create-new
|
|
|
|
(neo4j/defquery create-new
|
|
|
|
"MATCH (u:user)
|
|
|
|
"MATCH (u:user)
|
|
|
|
WHERE u.uuid = {u_uuid}
|
|
|
|
WHERE u.uuid = $u_uuid
|
|
|
|
CREATE (s:schema)-[:created_by]->(u)
|
|
|
|
CREATE (s:schema)-[:created_by]->(u)
|
|
|
|
SET s.name = {name}
|
|
|
|
SET s.name = $name
|
|
|
|
SET s.uuid = {s_uuid}
|
|
|
|
SET s.uuid = $s_uuid
|
|
|
|
SET s.created_at = {created_at}
|
|
|
|
SET s.created_at = $created_at
|
|
|
|
RETURN s")
|
|
|
|
RETURN s")
|
|
|
|
(defn create-new! [schema-name user-uuid]
|
|
|
|
(defn create-new! [schema-name user-uuid]
|
|
|
|
(->>
|
|
|
|
(->>
|
|
|
@ -43,7 +43,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
(neo4j/defquery find-by-uuid
|
|
|
|
"MATCH (s:schema)
|
|
|
|
"MATCH (s:schema)
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
OPTIONAL MATCH
|
|
|
|
OPTIONAL MATCH
|
|
|
|
(s)<-[:of]-(a:attribute)
|
|
|
|
(s)<-[:of]-(a:attribute)
|
|
|
|
WHERE a.required = 1
|
|
|
|
WHERE a.required = 1
|
|
|
@ -60,13 +60,13 @@
|
|
|
|
:req-attrs (map :a result)))))
|
|
|
|
:req-attrs (map :a result)))))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery schema-permissions
|
|
|
|
(neo4j/defquery schema-permissions
|
|
|
|
"MATCH (s:schema {uuid:{schema_uuid}})
|
|
|
|
"MATCH (s:schema {uuid: $schema_uuid})
|
|
|
|
RETURN
|
|
|
|
RETURN
|
|
|
|
EXISTS((:user {uuid:{user_uuid}})
|
|
|
|
EXISTS((:user {uuid: $user_uuid})
|
|
|
|
-[:permission {type:{type}}]-
|
|
|
|
-[:permission {type: $type}]-
|
|
|
|
(s)) AS user_has_permission,
|
|
|
|
(s)) AS user_has_permission,
|
|
|
|
NOT EXISTS((:user)
|
|
|
|
NOT EXISTS((:user)
|
|
|
|
-[:permission {type:{type}}]-
|
|
|
|
-[:permission {type: $type}]-
|
|
|
|
(s)) AS is_public")
|
|
|
|
(s)) AS is_public")
|
|
|
|
(defn has-user-permission? [perm-type schema-uuid user-uuid]
|
|
|
|
(defn has-user-permission? [perm-type schema-uuid user-uuid]
|
|
|
|
(let [perms (first
|
|
|
|
(let [perms (first
|
|
|
@ -82,7 +82,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery accessible-schemas
|
|
|
|
(neo4j/defquery accessible-schemas
|
|
|
|
"MATCH (s:schema),
|
|
|
|
"MATCH (s:schema),
|
|
|
|
(u:user {uuid:{user_uuid}})
|
|
|
|
(u:user {uuid: $user_uuid})
|
|
|
|
WHERE EXISTS((u)-[:permission {type:'read'}]->(s))
|
|
|
|
WHERE EXISTS((u)-[:permission {type:'read'}]->(s))
|
|
|
|
OR NOT EXISTS((:user)-[:permission {type:'read'}]->(s))
|
|
|
|
OR NOT EXISTS((:user)-[:permission {type:'read'}]->(s))
|
|
|
|
WITH s
|
|
|
|
WITH s
|
|
|
@ -100,7 +100,7 @@
|
|
|
|
{:user_uuid user-uuid})))
|
|
|
|
{:user_uuid user-uuid})))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery delete
|
|
|
|
(neo4j/defquery delete
|
|
|
|
"MATCH (s:schema {uuid:{uuid}})
|
|
|
|
"MATCH (s:schema {uuid: $uuid})
|
|
|
|
WITH s
|
|
|
|
WITH s
|
|
|
|
OPTIONAL MATCH (s)--(a:attribute)-[cb:created_by]-(:user)
|
|
|
|
OPTIONAL MATCH (s)--(a:attribute)-[cb:created_by]-(:user)
|
|
|
|
DELETE cb, a
|
|
|
|
DELETE cb, a
|
|
|
@ -114,8 +114,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery edit
|
|
|
|
(neo4j/defquery edit
|
|
|
|
"MATCH (s:schema)
|
|
|
|
"MATCH (s:schema)
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
SET s.name = {name}")
|
|
|
|
SET s.name = $name")
|
|
|
|
(defn edit! [schema]
|
|
|
|
(defn edit! [schema]
|
|
|
|
(neo4j/exec-query!
|
|
|
|
(neo4j/exec-query!
|
|
|
|
edit
|
|
|
|
edit
|
|
|
@ -123,7 +123,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery assigned-users
|
|
|
|
(neo4j/defquery assigned-users
|
|
|
|
"MATCH (s:schema)-[p:permission]-(u:user)
|
|
|
|
"MATCH (s:schema)-[p:permission]-(u:user)
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
RETURN u, p
|
|
|
|
RETURN u, p
|
|
|
|
ORDER BY u.ident")
|
|
|
|
ORDER BY u.ident")
|
|
|
|
(defn assigned-users! [uuid]
|
|
|
|
(defn assigned-users! [uuid]
|
|
|
@ -133,7 +133,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery assigned-schemas
|
|
|
|
(neo4j/defquery assigned-schemas
|
|
|
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
|
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
|
|
WHERE s1.uuid = {uuid}
|
|
|
|
WHERE s1.uuid = $uuid
|
|
|
|
RETURN s2
|
|
|
|
RETURN s2
|
|
|
|
ORDER BY s2.name")
|
|
|
|
ORDER BY s2.name")
|
|
|
|
(defn assigned-schemas! [uuid]
|
|
|
|
(defn assigned-schemas! [uuid]
|
|
|
@ -157,14 +157,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery remove-assignments
|
|
|
|
(neo4j/defquery remove-assignments
|
|
|
|
"MATCH (s:schema)-[c:permission]-(:user)
|
|
|
|
"MATCH (s:schema)-[c:permission]-(:user)
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
AND c.type = {permtype}
|
|
|
|
AND c.type = $permtype
|
|
|
|
DELETE c")
|
|
|
|
DELETE c")
|
|
|
|
(neo4j/defquery create-assignments
|
|
|
|
(neo4j/defquery create-assignments
|
|
|
|
"MATCH (s:schema), (u:user)
|
|
|
|
"MATCH (s:schema), (u:user)
|
|
|
|
WHERE s.uuid = {uuid}
|
|
|
|
WHERE s.uuid = $uuid
|
|
|
|
AND u.uuid IN {users}
|
|
|
|
AND u.uuid IN $users
|
|
|
|
CREATE (s)<-[:permission{type:{permtype}}]-(u)")
|
|
|
|
CREATE (s)<-[:permission{type: $permtype}]-(u)")
|
|
|
|
(defn assign-users! [uuid users permission]
|
|
|
|
(defn assign-users! [uuid users permission]
|
|
|
|
(neo4j/exec-queries!
|
|
|
|
(neo4j/exec-queries!
|
|
|
|
[remove-assignments
|
|
|
|
[remove-assignments
|
|
|
@ -177,12 +177,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery remove-schema-assignments
|
|
|
|
(neo4j/defquery remove-schema-assignments
|
|
|
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
|
|
"MATCH (s1:schema)-[p:permission]-(s2:schema)
|
|
|
|
WHERE s1.uuid = {uuid}
|
|
|
|
WHERE s1.uuid = $uuid
|
|
|
|
DELETE p")
|
|
|
|
DELETE p")
|
|
|
|
(neo4j/defquery create-schema-assignments
|
|
|
|
(neo4j/defquery create-schema-assignments
|
|
|
|
"MATCH (s1:schema), (s2:schema)
|
|
|
|
"MATCH (s1:schema), (s2:schema)
|
|
|
|
WHERE s1.uuid = {uuid}
|
|
|
|
WHERE s1.uuid = $uuid
|
|
|
|
AND s2.uuid IN {schemas}
|
|
|
|
AND s2.uuid IN $schemas
|
|
|
|
CREATE (s1)-[:permission]->(s2)")
|
|
|
|
CREATE (s1)-[:permission]->(s2)")
|
|
|
|
(defn assign-schemas! [uuid schemas]
|
|
|
|
(defn assign-schemas! [uuid schemas]
|
|
|
|
(neo4j/exec-queries!
|
|
|
|
(neo4j/exec-queries!
|
|
|
@ -192,7 +192,7 @@
|
|
|
|
{:uuid uuid :schemas schemas}]))
|
|
|
|
{:uuid uuid :schemas schemas}]))
|
|
|
|
|
|
|
|
|
|
|
|
(neo4j/defquery find-by-instance
|
|
|
|
(neo4j/defquery find-by-instance
|
|
|
|
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
|
|
|
|
"MATCH (i:instance {uuid: $uuid})-[:of]->(s:schema)
|
|
|
|
RETURN s")
|
|
|
|
RETURN s")
|
|
|
|
(defn find-by-instance! [uuid]
|
|
|
|
(defn find-by-instance! [uuid]
|
|
|
|
(-> find-by-instance
|
|
|
|
(-> find-by-instance
|
|
|
|