Skip to content

Commit

Permalink
Added KCM report to the zip report
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamahuli97 committed Mar 27, 2024
1 parent be4b618 commit 49008df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)
}
}
}
Expand All @@ -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))

Expand Down

0 comments on commit 49008df

Please sign in to comment.