From 7cf942c227619db61b382871daf0e2d0b1d299ba Mon Sep 17 00:00:00 2001
From: Jan-Niclas Struewer <j.n.struewer@gmail.com>
Date: Mon, 30 Oct 2023 09:17:51 +0100
Subject: [PATCH] Removed test call to ORT API with hardcoded project id

---
 .../toolRun/service/ToolRunService.kt         | 24 +++++++++----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt
index 96f1f17a..b72cf8ba 100644
--- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt
+++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/toolRun/service/ToolRunService.kt
@@ -43,21 +43,21 @@ class ToolRunService(
      * Lastly, we update the tool run with all tools, which provided results for the given repository,
      * and store this to the DB.
      */
-    suspend fun createToolRunForRepository(repoId: Long) = defaultScope.launch {
+    suspend fun createToolRunForRepository(projectId: Long) = defaultScope.launch {
         /**
          * Create initial db models.
          * If this fails we want the whole method to fail as we can't continue
          * without the db models.
          *
          */
-        logger.info("Starting tool run creation for repo $repoId")
+        logger.info("Starting tool run creation for repo $projectId")
         val toolRun = async(ioScope.coroutineContext) {
-            val repoDto = repositoryService.getRepositoryInfo(repoId)
+            val repoDto = repositoryService.getRepositoryInfo(projectId)
             val repo = repositoryService.getOrCreate(repoDto)
             val tr = createToolRunForRepository(repo)
             tr
         }.await()
-        logger.info("Finished tool run creation for repo $repoId $toolRun")
+        logger.info("Finished tool run creation for repo $projectId $toolRun")
 
         /**
          * For all tools, we in parallel query the tool results API.
@@ -68,11 +68,11 @@ class ToolRunService(
          * Lastly, we update the tool run object with all tools,
          * which returned results for this repository.
          */
-        logger.info("Starting batch API query for repo $repoId")
+        logger.info("Starting batch API query for repo $projectId")
         val apiJobs = listOf(
             async {
                 val vulnerabilityDtos =
-                    ortService.getOrtResults(106) // in the dev setup we get results for repo id 106
+                    ortService.getOrtResults(projectId) // in the dev setup we get results for repo id 106
                 if (vulnerabilityDtos.isNotEmpty()) {
                     toolRun.toolEntities.add(ortService.toolEntity)
                 }
@@ -80,13 +80,13 @@ class ToolRunService(
             },
 
             async {
-                val repoDetailsDto = repositoryDetailsService.getRepositoryDetails(repoId)
+                val repoDetailsDto = repositoryDetailsService.getRepositoryDetails(projectId)
                 toolRun.toolEntities.add(repositoryDetailsService.toolEntity)
                 kpiService.calculateRepositoryDetailsKpis(repoDetailsDto)
             },
 
             async {
-                val rawOccmdResults = occmdService.runOccmd(repoId, toolRun.repository.url)
+                val rawOccmdResults = occmdService.runOccmd(projectId, toolRun.repository.url)
                 if (rawOccmdResults.isNotEmpty()) {
                     toolRun.toolEntities.add(occmdService.toolEntity)
                 }
@@ -108,16 +108,16 @@ class ToolRunService(
             }
         }.flatten()
 
-        logger.info("All API queries finished for repo $repoId. Calculated ${kpis.size} raw KPIs.")
+        logger.info("All API queries finished for repo $projectId. Calculated ${kpis.size} raw KPIs.")
 
         if (kpis.isNotEmpty()) {
-            logger.info("Purging and storing new KPIs for repo $repoId")
+            logger.info("Purging and storing new KPIs for repo $projectId")
             val kpiEntities = kpiService.saveRawKpis(toolRun, kpis)
             toolRun.kpiEntities.addAll(kpiEntities)
             saveToolRunEntity(toolRun)
         }
 
-        logger.info("Finished processing repository changed request for repository $repoId")
+        logger.info("Finished processing repository changed request for repository $projectId")
     }
 
     fun createToolRunForRepository(repo: RepositoryEntity): ToolRunEntity {
@@ -150,7 +150,7 @@ class ToolRunService(
                     apiJobs.add(
                         defaultScope.async {
                             // TODO: this will be replaced by an API call
-                            val rawOrtResult = ortService.getOrtResults(106)
+                            val rawOrtResult = ortService.getOrtResults(repoId = repo.projectId)
                             val findings = ortService.getFindings(rawOrtResult)
                             tool.toolType.toViewModel(findings = findings)
                         }
-- 
GitLab