-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet_Outgoing_Java_Package_Dependencies_Including_Subpackages.cypher
40 lines (39 loc) · 2.16 KB
/
Set_Outgoing_Java_Package_Dependencies_Including_Subpackages.cypher
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
// Set Outgoing Package Dependencies including sub-packages. Requires "Add_file_name and_extension.cypher".
MATCH (p:Java:Package)
WITH *
,EXISTS{
MATCH (p)<-[:CONTAINS]-(ancestor:Package)-[:CONTAINS]->(sibling:Package)
WHERE sibling <> p
} AS hasSiblingPackages
,EXISTS{(p)-[:CONTAINS]->(:Type)} AS containsTypes
WHERE hasSiblingPackages OR containsTypes
MATCH (artifact:Artifact)-[:CONTAINS]->(p)
OPTIONAL MATCH (p)-[:CONTAINS*0..]->(sp:Package)-[:CONTAINS]->(st:Java:Type)-[r:DEPENDS_ON]->(et:Java:Type)<-[:CONTAINS]-(ep:Package)<-[:CONTAINS]-(ea:Artifact)
WHERE NOT ep.fqn starts with p.fqn + '.'
AND ep.fqn <> p.fqn
// AND p.outgoingDependenciesIncludingSubpackages IS NULL // comment out to recalculate
OPTIONAL MATCH (st)<-[:DEPENDS_ON]-(ei:Java:Type:Interface)
WITH artifact.name AS artifactName
,p
,COUNT(et) AS outgoingDependencies
,SUM(r.weight) AS outgoingDependenciesWeight
,COUNT(DISTINCT et) AS outgoingDependentTypes
,COUNT(DISTINCT ei) AS outgoingDependentInterfaces // also included in dependent types
,COUNT(DISTINCT ep) AS outgoingDependentPackages
,COUNT(DISTINCT ea) - 1 AS outgoingDependentArtifacts
ORDER BY outgoingDependencies DESC, p.fqn ASC // package with most incoming dependencies first
SET p.outgoingDependenciesIncludingSubpackages = outgoingDependencies
,p.outgoingDependenciesWeightIncludingSubpackages = outgoingDependenciesWeight
,p.outgoingDependentTypesIncludingSubpackages = outgoingDependentTypes
,p.outgoingDependentInterfacesIncludingSubpackages = outgoingDependentInterfaces
,p.outgoingDependentPackagesIncludingSubpackages = outgoingDependentPackages
,p.outgoingDependentArtifactsIncludingSubpackages = outgoingDependentArtifacts
RETURN artifactName
,p.fqn AS fullQualifiedPackageName
,p.name AS packageName
,outgoingDependencies
,outgoingDependenciesWeight
,outgoingDependentTypes
,outgoingDependentInterfaces
,outgoingDependentPackages
,outgoingDependentArtifacts