-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS2Script.cql
54 lines (41 loc) · 1.58 KB
/
S2Script.cql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Run this first against an empty Neo4j instance
CREATE (p1:Person {name:'John'})
CREATE (p2:Person {name:'Rose'})
CREATE (p3:Person {name:'Linda'})
CREATE (p4:Person {name:'Frank'})
CREATE (p5:Person {name:'Susan'})
CREATE (c1:Course {name:'SAFe Agilist 5'})
CREATE (c2:Course {name:'SecOps 2021'})
CREATE (r1:Role {name:'Product Owner'})
CREATE (r2:Role {name:'Scrum Master'})
CREATE (r3:Role {name:'Developer'})
MERGE (p1)-[:PERFORMS]->(r1)
MERGE (p2)-[:PERFORMS]->(r1)
MERGE (p3)-[:PERFORMS]->(r1)
MERGE (p4)-[:PERFORMS]->(r2)
MERGE (p5)-[:PERFORMS]->(r3)
MERGE (p1)-[:RECOMMENDS {role:r1.name}]->(c1)
MERGE (p2)-[:RECOMMENDS {role:r1.name}]->(c1)
MERGE (p3)-[:RECOMMENDS {role:r1.name}]->(c1)
MERGE (p4)-[:RECOMMENDS {role:r2.name}]->(c1)
MERGE (p5)-[:RECOMMENDS {role:r3.name}]->(c1)
MERGE (p1)-[:RECOMMENDS {role:r1.name}]->(c2)
MERGE (p2)-[:RECOMMENDS {role:r1.name}]->(c2)
MERGE (p5)-[:RECOMMENDS {role:r3.name}]->(c2)
---
// Get all recommended courses for the role Product Owner
MATCH (c:Course)<-[rec:RECOMMENDS]-(p:Person)
WHERE rec.role ='Product Owner'
RETURN c.name, count (rec) as numberOfRecs
// Now move one of the existing Product Owners to a new role
MATCH (p:Person {name:'Linda'})-[r]-(:Role)
DELETE r
WITH p
MATCH (r:Role {name:'Developer'})
MERGE (p)-[:PERFORMS]->(r)
// The recommendations made when Linda was a Product Owner remain in place
// Option add a recommendation date and include this within the query
// Retun the query - result set remains the same.
MATCH (c:Course)<-[rec:RECOMMENDS]-(p:Person)
WHERE rec.role ='Product Owner'
RETURN c.name, count (rec) as numberOfRecs