diff --git a/cypher/Java/JakartaEE_REST_Annotations.cypher b/cypher/Java/JakartaEE_REST_Annotations.cypher new file mode 100644 index 000000000..a9ba68657 --- /dev/null +++ b/cypher/Java/JakartaEE_REST_Annotations.cypher @@ -0,0 +1,46 @@ +// Jakarta Enterprise Edition JAX-RS REST Annotations +// +// --- Method Http Annotation --- +MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type) +WHERE ((httpMethodAnnotation.fqn STARTS WITH 'jakarta.ws.rs.' + OR httpMethodAnnotation.fqn STARTS WITH 'javax.ws.rs.') + AND httpMethodAnnotation.name IN ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']) +// --- Method Path Annotation --- +OPTIONAL MATCH (method)-[:ANNOTATED_BY]->(pathMethodLink:Annotation)-[:OF_TYPE]->(pathMethodAnnotation:Type) +WHERE pathMethodAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (pathMethodLink)-[:HAS]->(pathMethodValue:Value{name: 'value'}) +// --- Method Parameter Annotation --- +OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type) +WHERE ((methodParamAnnotation.fqn STARTS WITH 'jakarta.ws.rs.' + OR methodParamAnnotation.fqn STARTS WITH 'javax.ws.rs.') + AND methodParamAnnotation.name ENDS WITH 'Param' + AND methodParamAnnotation.name <> 'PathParam') +OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamValue:Value{name: 'value'}) +// --- Type Path Annotation --- +OPTIONAL MATCH (method)<-[:DECLARES]-(pathType:Type) +OPTIONAL MATCH (pathType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type) +WHERE pathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeValue:Value{name: 'value'}) +// --- SubType Path Annotation --- +OPTIONAL MATCH (pathType:Type)<-[:EXTENDS*1..3]-(subPathType:Type)-[:ANNOTATED_BY]->(subPathTypeLink:Annotation)-[:OF_TYPE]->(subPathTypeAnnotation:Type) +WHERE subPathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (subPathTypeLink)-[:HAS]->(subPathTypeValue:Value{name: 'value'}) +// --- Application Path Annotation --- +OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(pathType) +OPTIONAL MATCH (artifact)-[:CONTAINS]->(applicationPathType:Type)-[:ANNOTATED_BY]->(applicationPathLink:Annotation)-[:OF_TYPE]->(applicationPathAnnotation:Type) +WHERE applicationPathAnnotation.fqn in ['jakarta.ws.rs.ApplicationPath', 'javax.ws.rs.ApplicationPath'] +OPTIONAL MATCH (applicationPathLink)-[:HAS]->(applicationPathValue:Value{name: 'value'}) +// --- Return Results --- +RETURN replace( + coalesce(applicationPathValue.value, '') + '/' + + coalesce(subPathTypeValue.value, pathTypeValue.value, '') + '/' + + coalesce(pathMethodValue.value, '') + , '//', '/') AS path + ,httpMethodAnnotation.name AS httpMethod + ,replace(last(split(artifact.fileName, '/')), '.jar', '') AS resourceArtifact + ,coalesce(subPathType.fqn, pathType.fqn) AS resourceType + ,method.name AS resourceMethod + ,collect(methodParamAnnotation.name + ': ' + + methodParamValue.value + ) AS methodParameters +ORDER BY path, httpMethod, resourceType, resourceMethod \ No newline at end of file diff --git a/cypher/Java/JakartaEE_REST_Annotations_Nodes.cypher b/cypher/Java/JakartaEE_REST_Annotations_Nodes.cypher new file mode 100644 index 000000000..80285c37c --- /dev/null +++ b/cypher/Java/JakartaEE_REST_Annotations_Nodes.cypher @@ -0,0 +1,40 @@ +// Jakarta Enterprise Edition JAX-RS REST Annotations Nodes +// +// --- Method Http Annotation --- +MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type) +WHERE ((httpMethodAnnotation.fqn STARTS WITH 'jakarta.ws.rs.' + OR httpMethodAnnotation.fqn STARTS WITH 'javax.ws.rs.') + AND httpMethodAnnotation.name IN ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']) +// --- Method Path Annotation --- +OPTIONAL MATCH (method)-[:ANNOTATED_BY]->(pathMethodLink:Annotation)-[:OF_TYPE]->(pathMethodAnnotation:Type) +WHERE pathMethodAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (pathMethodLink)-[:HAS]->(pathMethodValue:Value{name: 'value'}) +// --- Method Parameter Annotation --- +OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type) +WHERE ((methodParamAnnotation.fqn STARTS WITH 'jakarta.ws.rs.' + OR methodParamAnnotation.fqn STARTS WITH 'javax.ws.rs.') + AND methodParamAnnotation.name ENDS WITH 'Param' + AND methodParamAnnotation.name <> 'PathParam') +OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamValue:Value{name: 'value'}) +// --- Type Path Annotation --- +OPTIONAL MATCH (method)<-[:DECLARES]-(pathType:Type) +OPTIONAL MATCH (pathType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type) +WHERE pathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeValue:Value{name: 'value'}) +// --- SubType Path Annotation --- +OPTIONAL MATCH (pathType:Type)<-[:EXTENDS*1..3]-(subPathType:Type)-[:ANNOTATED_BY]->(subPathTypeLink:Annotation)-[:OF_TYPE]->(subPathTypeAnnotation:Type) +WHERE subPathTypeAnnotation.fqn in ['jakarta.ws.rs.Path', 'javax.ws.rs.Path'] +OPTIONAL MATCH (subPathTypeLink)-[:HAS]->(subPathTypeValue:Value{name: 'value'}) +// --- Application Path Annotation --- +OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(pathType) +OPTIONAL MATCH (artifact)-[:CONTAINS]->(applicationPathType:Type)-[:ANNOTATED_BY]->(applicationPathLink:Annotation)-[:OF_TYPE]->(applicationPathAnnotation:Type) +WHERE applicationPathAnnotation.fqn in ['jakarta.ws.rs.ApplicationPath', 'javax.ws.rs.ApplicationPath'] +OPTIONAL MATCH (applicationPathLink)-[:HAS]->(applicationPathValue:Value{name: 'value'}) +// --- Return Results --- +RETURN method + ,httpMethodLink, httpMethodAnnotation + ,methodParam, methodParamLink, methodParamAnnotation, methodParamValue + ,pathMethodLink, pathMethodAnnotation, pathMethodValue + ,pathType, pathTypeLink, pathTypeAnnotation, pathTypeValue + ,subPathType, subPathTypeLink, subPathTypeAnnotation, subPathTypeValue + ,artifact, applicationPathType, applicationPathLink, applicationPathAnnotation, applicationPathValue \ No newline at end of file diff --git a/cypher/Java/Spring_Web_Request_Annotations.cypher b/cypher/Java/Spring_Web_Request_Annotations.cypher new file mode 100644 index 000000000..57a4d6cb4 --- /dev/null +++ b/cypher/Java/Spring_Web_Request_Annotations.cypher @@ -0,0 +1,56 @@ +// Spring Web Request Annotations +// +// --- Method HTTP Annotation --- +MATCH (method:Method)-[:ANNOTATED_BY]->(httpMethodLink:Annotation)-[:OF_TYPE]->(httpMethodAnnotation:Type) +WHERE httpMethodAnnotation.fqn STARTS WITH 'org.springframework.web.bind.annotation.' + AND httpMethodAnnotation.name IN ['RequestMapping', 'GetMapping', 'PostMapping', 'PutMapping', 'DeleteMapping', 'PatchMapping'] +// --- Method HTTP Annotation Path Value --- +OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpPathAnnotationProperty:Value)-[:CONTAINS]->(httpPathAnnotationValue:Value) +WHERE httpPathAnnotationProperty.name IN ['value', 'path'] +// --- Method HTTP Annotation Path Value --- +OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpMethodAnnotationProperty:Value)-[:CONTAINS]->(httpMethodAnnotationValue:Value) +WHERE httpMethodAnnotationProperty.name = 'method' +// --- Method HTTP Annotation Other Values --- +OPTIONAL MATCH (httpMethodLink)-[:HAS]->(httpAnnotationAdditionalProperty:Value)-[:CONTAINS]->(httpAnnotationAdditionalValue:Value) +WHERE NOT httpAnnotationAdditionalProperty.name IN ['value', 'path', 'method'] +// --- Method Parameter Annotation --- +OPTIONAL MATCH (method)-[:HAS]->(methodParam:Parameter)-[:ANNOTATED_BY]->(methodParamLink:Annotation)-[:OF_TYPE]->(methodParamAnnotation:Type) +WHERE methodParamAnnotation.fqn STARTS WITH 'org.springframework.web.bind.annotation.' +OPTIONAL MATCH (methodParamLink)-[:HAS]->(methodParamAnnotationValue:Value) +// --- Type Path Annotation --- +OPTIONAL MATCH (method)<-[:DECLARES]-(resourceType:Type) +OPTIONAL MATCH (resourceType)-[:ANNOTATED_BY]->(pathTypeLink:Annotation)-[:OF_TYPE]->(pathTypeAnnotation:Type) +WHERE pathTypeAnnotation.fqn = 'org.springframework.web.bind.annotation.RequestMapping' +OPTIONAL MATCH (pathTypeLink)-[:HAS]->(pathTypeAnnotationProperty:Value)-[:CONTAINS]->(pathTypeAnnotationValue:Value) +WHERE pathTypeAnnotationProperty.name IN ['value', 'path'] +// --- SubType Path Annotation --- +OPTIONAL MATCH (resourceType:Type)<-[:EXTENDS*1..5]-(subResourceType:Type)-[:ANNOTATED_BY]->(subResourceTypeLink:Annotation)-[:OF_TYPE]->(subResourceTypeAnnotation:Type) +WHERE subResourceTypeAnnotation.fqn = 'org.springframework.web.bind.annotation.RequestMapping' +OPTIONAL MATCH (subResourceTypeLink)-[:HAS]->(subResourceTypeAnnotationProperty:Value)-[:CONTAINS]->(subResourceTypeAnnotationValue:Value) +WHERE subResourceTypeAnnotationProperty.name IN ['value', 'path'] +// --- Artifact --- +OPTIONAL MATCH (artifact:Artifact)-[:CONTAINS]->(resourceType) +// --- Return Results --- +RETURN replace( + coalesce(subResourceTypeAnnotationValue.value, pathTypeAnnotationValue.value, '') + + '/' + + coalesce(httpPathAnnotationValue.value, '') + , '//', '/') AS path + ,coalesce( + httpMethodAnnotationValue.value, + toUpper( + replace(replace(httpMethodAnnotation.name, 'Mapping', ''), 'Request', 'All') + ) + ) AS httpMethod + ,replace(last(split(artifact.fileName, '/')), '.jar', '') AS resourceArtifact + ,coalesce(subResourceType.fqn, resourceType.fqn) AS resourceType + ,method.name AS resourceMethod + ,collect( + httpAnnotationAdditionalProperty.name + ': ' + + httpAnnotationAdditionalValue.value + ) AS additionalHttpProperties + ,collect(methodParamAnnotation.name + + replace('.' + methodParamAnnotationValue.name, '.value', '') + + ': ' + + methodParamAnnotationValue.value) AS methodParameters +ORDER BY path, httpMethod, resourceType, resourceType \ No newline at end of file diff --git a/scripts/reports/JavaCsv.sh b/scripts/reports/JavaCsv.sh index 34f3225d9..3410f3ccf 100755 --- a/scripts/reports/JavaCsv.sh +++ b/scripts/reports/JavaCsv.sh @@ -46,4 +46,7 @@ execute_cypher "${JAVA_CYPHER_DIR}/Java_deprecated_element_usage_detailed.cypher execute_cypher "${JAVA_CYPHER_DIR}/Annotated_code_elements.cypher" > "${FULL_REPORT_DIRECTORY}/AnnotatedCodeElements.csv" execute_cypher "${JAVA_CYPHER_DIR}/Annotated_code_elements_per_artifact.cypher" > "${FULL_REPORT_DIRECTORY}/AnnotatedCodeElementsPerArtifact.csv" +execute_cypher "${JAVA_CYPHER_DIR}/JakartaEE_REST_Annotations.cypher" > "${FULL_REPORT_DIRECTORY}/JakartaEE_REST_Annotations.csv" +execute_cypher "${JAVA_CYPHER_DIR}/Spring_Web_Request_Annotations.cypher" > "${FULL_REPORT_DIRECTORY}/Spring_Web_Request_Annotations.csv" + echo "JavaCsv: $(date +'%Y-%m-%dT%H:%M:%S%z') Successfully finished" \ No newline at end of file diff --git a/scripts/reports/compilations/JupyterReports.sh b/scripts/reports/compilations/JupyterReports.sh index f60f8e3d8..a30a2c35b 100755 --- a/scripts/reports/compilations/JupyterReports.sh +++ b/scripts/reports/compilations/JupyterReports.sh @@ -4,7 +4,7 @@ # It only consideres scripts in the "reports" directory (overridable with REPORTS_SCRIPT_DIR) one directory above this one. # These require phython, conda (e.g. miniconda) as well as several packages. # For PDF generation chromium is required additionally. -# Therefore these reports will take longer and require more ressources than just plain database queries/procedures. +# Therefore these reports will take longer and require more resources than just plain database queries/procedures. # Requires reports/*.sh diff --git a/scripts/reports/compilations/VisualizationReports.sh b/scripts/reports/compilations/VisualizationReports.sh index 691b2eee5..10500ed9f 100755 --- a/scripts/reports/compilations/VisualizationReports.sh +++ b/scripts/reports/compilations/VisualizationReports.sh @@ -3,7 +3,7 @@ # Runs all Visualization reports. # It only consideres scripts in the "reports" directory (overridable with REPORTS_SCRIPT_DIR) one directory above this one. # These require node.js. -# Therefore these reports will take longer and require more ressources than just plain database queries/procedures. +# Therefore these reports will take longer and require more resources than just plain database queries/procedures. # Requires reports/*.sh # Needs to run after reports/TopologySortCsv.sh that provides the property "topologicalSortIndex" to be queried.