Commit 0724a458 authored by Peter van 't Hof's avatar Peter van 't Hof

WIP

parent 355126e2
...@@ -210,12 +210,10 @@ trait ReportBuilder extends ToolCommand { ...@@ -210,12 +210,10 @@ trait ReportBuilder extends ToolCommand {
done = 0 done = 0
logger.info("Generate pages") logger.info("Generate pages")
val jobs = generatePage(summary, rootPage, cmdArgs.outputDir, val jobsFutures = generatePage(summary, rootPage, cmdArgs.outputDir,
args = pageArgs ++ cmdArgs.pageArgs.toMap ++ args = pageArgs ++ cmdArgs.pageArgs.toMap ++
Map("summary" -> summary, "reportName" -> reportName, "indexPage" -> rootPage, "runId" -> cmdArgs.runId)) Map("summary" -> summary, "reportName" -> reportName, "indexPage" -> rootPage, "runId" -> cmdArgs.runId))
val jobsFutures = Await.result(jobs, Duration.Inf)
total = jobsFutures.size total = jobsFutures.size
logger.info(total + " pages to be generated") logger.info(total + " pages to be generated")
...@@ -259,12 +257,12 @@ trait ReportBuilder extends ToolCommand { ...@@ -259,12 +257,12 @@ trait ReportBuilder extends ToolCommand {
pageFuture: Future[ReportPage], pageFuture: Future[ReportPage],
outputDir: File, outputDir: File,
path: List[String] = Nil, path: List[String] = Nil,
args: Map[String, Any] = Map()): Future[List[Future[_]]] = { args: Map[String, Any] = Map()): List[Future[_]] = {
pageFuture.map { page => val pageOutputDir = new File(outputDir, path.mkString(File.separator))
val pageOutputDir = new File(outputDir, path.mkString(File.separator))
pageOutputDir.mkdirs() def pageArgs(page: ReportPage) = {
val rootPath = "./" + Array.fill(path.size)("../").mkString val rootPath = "./" + Array.fill(path.size)("../").mkString
val pageArgs = args ++ page.args ++ args ++ page.args ++
Map("page" -> page, Map("page" -> page,
"path" -> path, "path" -> path,
"outputDir" -> pageOutputDir, "outputDir" -> pageOutputDir,
...@@ -274,29 +272,32 @@ trait ReportBuilder extends ToolCommand { ...@@ -274,29 +272,32 @@ trait ReportBuilder extends ToolCommand {
"allSamples" -> samples, "allSamples" -> samples,
"allLibraries" -> libraries "allLibraries" -> libraries
) )
}
val subPageJobs = pageFuture.map { page =>
// Generating subpages // Generating subpages
val jobs = page.subPages.flatMap { page.subPages.flatMap {
case (name, subPage) => generatePage(summary, subPage, outputDir, path ::: name :: Nil, pageArgs) case (name, subPage) => generatePage(summary, subPage, outputDir, path ::: name :: Nil, pageArgs(page))
} }
}
val renderFuture = pageFuture.map { page =>
pageOutputDir.mkdirs()
val renderFuture = Future {
val file = new File(pageOutputDir, "index.html") val file = new File(pageOutputDir, "index.html")
logger.info(s"Start rendering: $file") logger.info(s"Start rendering: $file")
val output = ReportBuilder.renderTemplate("/nl/lumc/sasc/biopet/core/report/main.ssp", val output = ReportBuilder.renderTemplate("/nl/lumc/sasc/biopet/core/report/main.ssp",
pageArgs ++ Map("args" -> pageArgs)) pageArgs(page) ++ Map("args" -> pageArgs(page)))
val writer = new PrintWriter(file) val writer = new PrintWriter(file)
writer.println(output) writer.println(output)
writer.close() writer.close()
logger.info(s"Done rendering: $file") logger.info(s"Done rendering: $file")
}
renderFuture :: jobs
} }
renderFuture :: Await.result(subPageJobs, Duration.Inf)
} }
def pipelineName: String def pipelineName: String
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment