Skip to content

Commit dd2a5c1

Browse files
authored
Merge pull request #102 from JohT/feature/java-rest-endpoints
Add reports containing JavaEE and Spring REST resources
2 parents 07fde6d + 716f4fa commit dd2a5c1

File tree

6 files changed

+147
-2
lines changed

6 files changed

+147
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Jakarta Enterprise Edition JAX-RS REST Annotations
2+
//
3+
// --- Method Http Annotation ---
4+
MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type)
5+
WHERE ((httpMethodAnnotation.fqn STARTS WITH 'jakarta.ws.rs.'
6+
OR httpMethodAnnotation.fqn STARTS WITH 'javax.ws.rs.')
7+
AND httpMethodAnnotation.name IN ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'])
8+
// --- Method Path Annotation ---
9+
OPTIONAL MATCH (method)-[:ANNOTATED_BY]->(pathMethodLink:Annotation)-[:OF_TYPE]->(pathMethodAnnotation:Type)
10+
WHERE pathMethodAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
11+
OPTIONAL MATCH (pathMethodLink)-[:HAS]->(pathMethodValue:Value{name: 'value'})
12+
// --- Method Parameter Annotation ---
13+
OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type)
14+
WHERE ((methodParamAnnotation.fqn STARTS WITH 'jakarta.ws.rs.'
15+
OR methodParamAnnotation.fqn STARTS WITH 'javax.ws.rs.')
16+
AND methodParamAnnotation.name ENDS WITH 'Param'
17+
AND methodParamAnnotation.name <> 'PathParam')
18+
OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamValue:Value{name: 'value'})
19+
// --- Type Path Annotation ---
20+
OPTIONAL MATCH (method)<-[:DECLARES]-(pathType:Type)
21+
OPTIONAL MATCH (pathType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type)
22+
WHERE pathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
23+
OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeValue:Value{name: 'value'})
24+
// --- SubType Path Annotation ---
25+
OPTIONAL MATCH (pathType:Type)<-[:EXTENDS*1..3]-(subPathType:Type)-[:ANNOTATED_BY]->(subPathTypeLink:Annotation)-[:OF_TYPE]->(subPathTypeAnnotation:Type)
26+
WHERE subPathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
27+
OPTIONAL MATCH (subPathTypeLink)-[:HAS]->(subPathTypeValue:Value{name: 'value'})
28+
// --- Application Path Annotation ---
29+
OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(pathType)
30+
OPTIONAL MATCH (artifact)-[:CONTAINS]->(applicationPathType:Type)-[:ANNOTATED_BY]->(applicationPathLink:Annotation)-[:OF_TYPE]->(applicationPathAnnotation:Type)
31+
WHERE applicationPathAnnotation.fqn in ['jakarta.ws.rs.ApplicationPath', 'javax.ws.rs.ApplicationPath']
32+
OPTIONAL MATCH (applicationPathLink)-[:HAS]->(applicationPathValue:Value{name: 'value'})
33+
// --- Return Results ---
34+
RETURN replace(
35+
coalesce(applicationPathValue.value, '') + '/' +
36+
coalesce(subPathTypeValue.value, pathTypeValue.value, '') + '/' +
37+
coalesce(pathMethodValue.value, '')
38+
, '//', '/') AS path
39+
,httpMethodAnnotation.name AS httpMethod
40+
,replace(last(split(artifact.fileName, '/')), '.jar', '') AS resourceArtifact
41+
,coalesce(subPathType.fqn, pathType.fqn) AS resourceType
42+
,method.name AS resourceMethod
43+
,collect(methodParamAnnotation.name + ': ' +
44+
methodParamValue.value
45+
) AS methodParameters
46+
ORDER BY path, httpMethod, resourceType, resourceMethod
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Jakarta Enterprise Edition JAX-RS REST Annotations Nodes
2+
//
3+
// --- Method Http Annotation ---
4+
MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type)
5+
WHERE ((httpMethodAnnotation.fqn STARTS WITH 'jakarta.ws.rs.'
6+
OR httpMethodAnnotation.fqn STARTS WITH 'javax.ws.rs.')
7+
AND httpMethodAnnotation.name IN ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'])
8+
// --- Method Path Annotation ---
9+
OPTIONAL MATCH (method)-[:ANNOTATED_BY]->(pathMethodLink:Annotation)-[:OF_TYPE]->(pathMethodAnnotation:Type)
10+
WHERE pathMethodAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
11+
OPTIONAL MATCH (pathMethodLink)-[:HAS]->(pathMethodValue:Value{name: 'value'})
12+
// --- Method Parameter Annotation ---
13+
OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type)
14+
WHERE ((methodParamAnnotation.fqn STARTS WITH 'jakarta.ws.rs.'
15+
OR methodParamAnnotation.fqn STARTS WITH 'javax.ws.rs.')
16+
AND methodParamAnnotation.name ENDS WITH 'Param'
17+
AND methodParamAnnotation.name <> 'PathParam')
18+
OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamValue:Value{name: 'value'})
19+
// --- Type Path Annotation ---
20+
OPTIONAL MATCH (method)<-[:DECLARES]-(pathType:Type)
21+
OPTIONAL MATCH (pathType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type)
22+
WHERE pathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
23+
OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeValue:Value{name: 'value'})
24+
// --- SubType Path Annotation ---
25+
OPTIONAL MATCH (pathType:Type)<-[:EXTENDS*1..3]-(subPathType:Type)-[:ANNOTATED_BY]->(subPathTypeLink:Annotation)-[:OF_TYPE]->(subPathTypeAnnotation:Type)
26+
WHERE subPathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path']
27+
OPTIONAL MATCH (subPathTypeLink)-[:HAS]->(subPathTypeValue:Value{name: 'value'})
28+
// --- Application Path Annotation ---
29+
OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(pathType)
30+
OPTIONAL MATCH (artifact)-[:CONTAINS]->(applicationPathType:Type)-[:ANNOTATED_BY]->(applicationPathLink:Annotation)-[:OF_TYPE]->(applicationPathAnnotation:Type)
31+
WHERE applicationPathAnnotation.fqn in ['jakarta.ws.rs.ApplicationPath', 'javax.ws.rs.ApplicationPath']
32+
OPTIONAL MATCH (applicationPathLink)-[:HAS]->(applicationPathValue:Value{name: 'value'})
33+
// --- Return Results ---
34+
RETURN method
35+
,httpMethodLink, httpMethodAnnotation
36+
,methodParam, methodParamLink, methodParamAnnotation, methodParamValue
37+
,pathMethodLink, pathMethodAnnotation, pathMethodValue
38+
,pathType, pathTypeLink, pathTypeAnnotation, pathTypeValue
39+
,subPathType, subPathTypeLink, subPathTypeAnnotation, subPathTypeValue
40+
,artifact, applicationPathType, applicationPathLink, applicationPathAnnotation, applicationPathValue
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Spring Web Request Annotations
2+
//
3+
// --- Method HTTP Annotation ---
4+
MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type)
5+
WHERE httpMethodAnnotation.fqn STARTS WITH 'org.springframework.web.bind.annotation.'
6+
AND httpMethodAnnotation.name IN ['RequestMapping', 'GetMapping', 'PostMapping', 'PutMapping', 'DeleteMapping', 'PatchMapping']
7+
// --- Method HTTP Annotation Path Value ---
8+
OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpPathAnnotationProperty:Value)-[:CONTAINS]->(httpPathAnnotationValue:Value)
9+
WHERE httpPathAnnotationProperty.name IN ['value', 'path']
10+
// --- Method HTTP Annotation Path Value ---
11+
OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpMethodAnnotationProperty:Value)-[:CONTAINS]->(httpMethodAnnotationValue:Value)
12+
WHERE httpMethodAnnotationProperty.name = 'method'
13+
// --- Method HTTP Annotation Other Values ---
14+
OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpAnnotationAdditionalProperty:Value)-[:CONTAINS]->(httpAnnotationAdditionalValue:Value)
15+
WHERE NOT httpAnnotationAdditionalProperty.name IN ['value', 'path', 'method']
16+
// --- Method Parameter Annotation ---
17+
OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type)
18+
WHERE methodParamAnnotation.fqn STARTS WITH 'org.springframework.web.bind.annotation.'
19+
OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamAnnotationValue:Value)
20+
// --- Type Path Annotation ---
21+
OPTIONAL MATCH (method)<-[:DECLARES]-(resourceType:Type)
22+
OPTIONAL MATCH (resourceType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type)
23+
WHERE pathTypeAnnotation.fqn = 'org.springframework.web.bind.annotation.RequestMapping'
24+
OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeAnnotationProperty:Value)-[:CONTAINS]->(pathTypeAnnotationValue:Value)
25+
WHERE pathTypeAnnotationProperty.name IN ['value', 'path']
26+
// --- SubType Path Annotation ---
27+
OPTIONAL MATCH (resourceType:Type)<-[:EXTENDS*1..5]-(subResourceType:Type)-[:ANNOTATED_BY]->(subResourceTypeLink:Annotation)-[:OF_TYPE]->(subResourceTypeAnnotation:Type)
28+
WHERE subResourceTypeAnnotation.fqn = 'org.springframework.web.bind.annotation.RequestMapping'
29+
OPTIONAL MATCH (subResourceTypeLink)-[:HAS]->(subResourceTypeAnnotationProperty:Value)-[:CONTAINS]->(subResourceTypeAnnotationValue:Value)
30+
WHERE subResourceTypeAnnotationProperty.name IN ['value', 'path']
31+
// --- Artifact ---
32+
OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(resourceType)
33+
// --- Return Results ---
34+
RETURN replace(
35+
coalesce(subResourceTypeAnnotationValue.value, pathTypeAnnotationValue.value, '') +
36+
'/' +
37+
coalesce(httpPathAnnotationValue.value, '')
38+
, '//', '/') AS path
39+
,coalesce(
40+
httpMethodAnnotationValue.value,
41+
toUpper(
42+
replace(replace(httpMethodAnnotation.name, 'Mapping', ''), 'Request', 'All')
43+
)
44+
) AS httpMethod
45+
,replace(last(split(artifact.fileName, '/')), '.jar', '') AS resourceArtifact
46+
,coalesce(subResourceType.fqn, resourceType.fqn) AS resourceType
47+
,method.name AS resourceMethod
48+
,collect(
49+
httpAnnotationAdditionalProperty.name + ': ' +
50+
httpAnnotationAdditionalValue.value
51+
) AS additionalHttpProperties
52+
,collect(methodParamAnnotation.name +
53+
replace('.' + methodParamAnnotationValue.name, '.value', '') +
54+
': ' +
55+
methodParamAnnotationValue.value) AS methodParameters
56+
ORDER BY path, httpMethod, resourceType, resourceType

scripts/reports/JavaCsv.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ execute_cypher "${JAVA_CYPHER_DIR}/Java_deprecated_element_usage_detailed.cypher
4646
execute_cypher "${JAVA_CYPHER_DIR}/Annotated_code_elements.cypher" > "${FULL_REPORT_DIRECTORY}/AnnotatedCodeElements.csv"
4747
execute_cypher "${JAVA_CYPHER_DIR}/Annotated_code_elements_per_artifact.cypher" > "${FULL_REPORT_DIRECTORY}/AnnotatedCodeElementsPerArtifact.csv"
4848

49+
execute_cypher "${JAVA_CYPHER_DIR}/JakartaEE_REST_Annotations.cypher" > "${FULL_REPORT_DIRECTORY}/JakartaEE_REST_Annotations.csv"
50+
execute_cypher "${JAVA_CYPHER_DIR}/Spring_Web_Request_Annotations.cypher" > "${FULL_REPORT_DIRECTORY}/Spring_Web_Request_Annotations.csv"
51+
4952
echo "JavaCsv: $(date +'%Y-%m-%dT%H:%M:%S%z') Successfully finished"

scripts/reports/compilations/JupyterReports.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# It only consideres scripts in the "reports" directory (overridable with REPORTS_SCRIPT_DIR) one directory above this one.
55
# These require phython, conda (e.g. miniconda) as well as several packages.
66
# For PDF generation chromium is required additionally.
7-
# Therefore these reports will take longer and require more ressources than just plain database queries/procedures.
7+
# Therefore these reports will take longer and require more resources than just plain database queries/procedures.
88

99
# Requires reports/*.sh
1010

scripts/reports/compilations/VisualizationReports.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Runs all Visualization reports.
44
# It only consideres scripts in the "reports" directory (overridable with REPORTS_SCRIPT_DIR) one directory above this one.
55
# These require node.js.
6-
# Therefore these reports will take longer and require more ressources than just plain database queries/procedures.
6+
# Therefore these reports will take longer and require more resources than just plain database queries/procedures.
77

88
# Requires reports/*.sh
99
# Needs to run after reports/TopologySortCsv.sh that provides the property "topologicalSortIndex" to be queried.

0 commit comments

Comments
 (0)