From 49008df2b72fa540d54db3050c86c4175eef0748 Mon Sep 17 00:00:00 2001 From: Varsha Mahuli Date: Wed, 27 Mar 2024 13:39:08 +0530 Subject: [PATCH] Added KCM report to the zip report --- .../org/ekstep/analytics/dashboard/TestUtil.scala | 1 + .../zipreports/ZipReportsWithSecurityModel.scala | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/batch-models/src/main/scala/org/ekstep/analytics/dashboard/TestUtil.scala b/batch-models/src/main/scala/org/ekstep/analytics/dashboard/TestUtil.scala index 38e8506b..d7c86655 100644 --- a/batch-models/src/main/scala/org/ekstep/analytics/dashboard/TestUtil.scala +++ b/batch-models/src/main/scala/org/ekstep/analytics/dashboard/TestUtil.scala @@ -150,6 +150,7 @@ object TestUtil extends Serializable { "prefixDirectoryPath" -> "standalone-reports", "destinationDirectoryPath" -> "standalone-reports/merged", + "localReportDir" -> "/mount/data/analytics/reports", "directoriesToSelect" -> "blended-program-report-mdo,cbp-report-mdo-summary,course-report,cba-report,cbp-report-mdo-enrolment,user-report,user-enrollment-report,kcm-report", "password" -> "123456", diff --git a/batch-models/src/main/scala/org/ekstep/analytics/dashboard/report/zipreports/ZipReportsWithSecurityModel.scala b/batch-models/src/main/scala/org/ekstep/analytics/dashboard/report/zipreports/ZipReportsWithSecurityModel.scala index aa5ce9fc..1e6953ca 100644 --- a/batch-models/src/main/scala/org/ekstep/analytics/dashboard/report/zipreports/ZipReportsWithSecurityModel.scala +++ b/batch-models/src/main/scala/org/ekstep/analytics/dashboard/report/zipreports/ZipReportsWithSecurityModel.scala @@ -35,6 +35,7 @@ object ZipReportsWithSecurityModel extends AbsDashboardModel { val destinationPath = s"${conf.localReportDir}${conf.destinationDirectoryPath}" val directoriesToSelect = conf.directoriesToSelect.split(",").toSet val specificDate = getDate() + val kcmFolderPath = s"${conf.localReportDir}${conf.kcmReportPath}/${specificDate}/ContentCompetencyMapping" // Method to traverse all the report folders within the source folder and check for specific date folder def traverseDirectory(directory: File): Unit = { @@ -65,6 +66,8 @@ object ZipReportsWithSecurityModel extends AbsDashboardModel { for (mdoidFolder <- files if mdoidFolder.isDirectory) { // Inside each mdoid folder, copy all CSV files to the destination directory copyFiles(mdoidFolder, destinationPath) + // Copy the competencyMapping file from kcm-report folder to the destination mdoid folder + copyKCMFile(mdoidFolder) } } } @@ -87,6 +90,16 @@ object ZipReportsWithSecurityModel extends AbsDashboardModel { } } + // Method to copy the desired file from kcm-report folder to the destination mdoid folder + def copyKCMFile(mdoidFolder: File): Unit = { + val kcmFile = new File(kcmFolderPath, "ContentCompetencyMapping.csv") + val destinationDirectory = Paths.get(destinationPath, mdoidFolder.getName) + if (kcmFile.exists() && destinationDirectory.toFile.exists()) { + val destinationFile = Paths.get(destinationDirectory.toString, kcmFile.getName) + Files.copy(kcmFile.toPath, destinationFile, StandardCopyOption.REPLACE_EXISTING) + } + } + // Start traversing the source directory traverseDirectory(new File(prefixDirectoryPath))