Commit a32ce842 authored by Peter van 't Hof's avatar Peter van 't Hof

Added executables

parent eb3a77c1
......@@ -129,8 +129,6 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
Await.result(createFile(db, qscript.summaryRunId, pipelineId, Some(moduleId), sampleId, libId, key, file, outputDir), Duration.Inf)
}
//TODO: Add executables
qscript match {
case tag: SampleLibraryTag =>
val sampleId = tag.sampleId.flatMap(name => Await.result(db.getSampleId(qscript.summaryRunId, name), Duration.Inf))
......@@ -165,6 +163,21 @@ class WriteSummary(val parent: SummaryQScript) extends InProcessFunction with Co
db.createOrUpdateSetting(qscript.summaryRunId, pipelineId, None, None, None, ConfigUtils.mapToJson(q.summarySettings).nospaces)
}
for ((name, f) <- qscript.functions.flatMap(_ match {
case c:Configurable with Version => Some(c)
case _ => None
}).groupBy(_.configNamespace)) yield {
f match {
case f: BiopetJavaCommandLineFunction with Version =>
db.createOrUpdateExecutable(qscript.summaryRunId, name, f.getVersion, f.getJavaVersion, javaMd5 = BiopetCommandLineFunction.executableMd5Cache.get(f.executable), jarPath = Some(f.jarFile.getAbsolutePath))
case f: BiopetCommandLineFunction with Version =>
db.createOrUpdateExecutable(qscript.summaryRunId, name, f.getVersion, Option(f.executable))
case f: Configurable with Version =>
db.createOrUpdateExecutable(qscript.summaryRunId, name, f.getVersion)
case _ => None
}
}
db.close()
......
......@@ -272,6 +272,31 @@ class SummaryDb(db: Database) extends Closeable {
if (r == 0) createFile(runId, pipelineId, moduleId, sampleId, libId, key, path, md5, link, size)
else db.run(filter.update(File(runId, pipelineId, moduleId, sampleId, libId, key, path, md5, link, size)))
}
def executablesFilter(runId: Option[Int], toolName: Option[String]) = {
val l: List[Option[Query[Executables, Executables#TableElementType, Seq] => Query[Executables, Executables#TableElementType, Seq]]] = List(
runId.map(x => y => y.filter(_.runId === x)),
toolName.map(x => y => y.filter(_.toolName === x))
)
l.flatten.foldLeft(executables.subquery)((a, b) => b(a))
}
def getFiles(runId: Option[Int], toolName: Option[String]) = {
db.run(executablesFilter(runId, toolName).result)
}
def createExecutable(runId: Int, toolName: String, version: Option[String] = None, path: Option[String] = None,
javaVersion: Option[String] = None, exeMd5: Option[String] = None, javaMd5: Option[String] = None, jarPath: Option[String] = None) = {
db.run(executables.forceInsert(Executable(runId, toolName, version, path, javaVersion, exeMd5, javaMd5, jarPath)))
}
def createOrUpdateExecutable(runId: Int, toolName: String, version: Option[String] = None, path: Option[String] = None,
javaVersion: Option[String] = None, exeMd5: Option[String] = None, javaMd5: Option[String] = None, jarPath: Option[String] = None) = {
val filter = executablesFilter(Some(runId), Some(toolName))
val r = Await.result(db.run(filter.size.result), Duration.Inf)
if (r == 0) createExecutable(runId, toolName, version, javaVersion, exeMd5, javaMd5)
else db.run(filter.update(Executable(runId, toolName, version, path, javaVersion, exeMd5, javaMd5, jarPath)))
}
}
object SummaryDb {
......
......@@ -118,16 +118,18 @@ object Schema {
}
val files = TableQuery[Files]
case class Executable(runId: Int, toolName: String, version: Option[String], javaVersion: Option[String], exeMd5: Option[String], javaMd5: Option[String])
case class Executable(runId: Int, toolName: String, version: Option[String], path = Option[String], javaVersion: Option[String], exeMd5: Option[String], javaMd5: Option[String], jarPath: Option[String])
class Executables(tag: Tag) extends Table[Executable](tag, "Executables") {
def runId = column[Int]("runId")
def toolName = column[String]("toolName")
def version = column[Option[String]]("version")
def path = column[Option[String]]("path")
def javaVersion = column[Option[String]]("javaVersion")
def exeMd5 = column[Option[String]]("exeMd5")
def javaMd5 = column[Option[String]]("javaMd5")
def jarPath = column[Option[String]]("jarPath")
def * = (runId, toolName, version, javaVersion, exeMd5, javaMd5) <> (Executable.tupled, Executable.unapply)
def * = (runId, toolName, version, path, javaVersion, exeMd5, javaMd5, jarPath) <> (Executable.tupled, Executable.unapply)
def idx = index("idx_executables", (runId, toolName), unique = true)
}
......
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