Commit 2d604261 authored by Peter van 't Hof's avatar Peter van 't Hof

Moved schema's into 1 object

parent e062f718
......@@ -2,7 +2,6 @@ package nl.lumc.sasc.biopet.tools
import java.io.File
import nl.lumc.sasc.biopet.utils.summary.db.{Libraries, Samples}
import slick.driver.H2Driver.api._
import scala.concurrent.ExecutionContext.Implicits.global
......@@ -40,18 +39,20 @@ object SummaryToSqlite extends ToolCommand {
val jsonMap = ConfigUtils.fileToConfigMap(cmdArgs.inputJson)
if (cmdArgs.outputSqlite.exists()) {
if (cmdArgs.force) cmdArgs.outputSqlite.delete()
else throw new IllegalArgumentException(s"Db already exist: ${cmdArgs.outputSqlite}")
if (cmdArgs.force) {
logger.warn("Deleting old database")
cmdArgs.outputSqlite.delete()
} else throw new IllegalArgumentException(s"Db already exist: ${cmdArgs.outputSqlite}")
}
val db = Database.forURL(s"jdbc:sqlite:${cmdArgs.outputSqlite.getAbsolutePath}", driver = "org.sqlite.JDBC")
try {
val samples = TableQuery[Samples]
val libraries = TableQuery[Libraries]
import nl.lumc.sasc.biopet.utils.summary.db.Schema._
val setup = DBIO.seq(
(samples.schema ++ libraries.schema).create
(samples.schema ++ libraries.schema)
.create
)
val setupFuture = db.run(setup)
Await.result(setupFuture, Duration.Inf)
......
package nl.lumc.sasc.biopet.utils.summary.db
import java.sql.Blob
import slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 26-1-17.
*/
class Libraries(tag: Tag) extends Table[(Int, String, Int, Blob)](tag, "Libraries") {
def libraryId = column[Int]("libraryId", O.PrimaryKey) // This is the primary key column
def libraryName = column[String]("libraryName")
def sampleId = column[Int]("sampleId")
def tags = column[Blob]("tags")
// Every table needs a * projection with the same type as the table's type parameter
def * = (libraryId, libraryName, sampleId, tags)
}
\ No newline at end of file
package nl.lumc.sasc.biopet.utils.summary.db
import slick.driver.H2Driver.api._
/**
* Created by pjvanthof on 27/01/2017.
*/
class Pipelines(tag: Tag) extends Table[(Int, String)](tag, "Pipelines") {
def pipelineId = column[Int]("runId", O.PrimaryKey) // This is the primary key column
def pipelineName = column[String]("sampleName")
// Every table needs a * projection with the same type as the table's type parameter
def * = (pipelineId, pipelineName)
}
\ No newline at end of file
package nl.lumc.sasc.biopet.utils.summary.db
import slick.driver.H2Driver.api._
/**
* Created by pjvanthof on 27/01/2017.
*/
class Runs(tag: Tag) extends Table[(Int, String)](tag, "Runs") {
def runId = column[Int]("runId", O.PrimaryKey) // This is the primary key column
def runName = column[String]("sampleName")
// Every table needs a * projection with the same type as the table's type parameter
def * = (runId, runName)
}
\ No newline at end of file
package nl.lumc.sasc.biopet.utils.summary.db
import java.sql.Blob
import slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 26-1-17.
*/
class Samples(tag: Tag) extends Table[(Int, String, Blob)](tag, "Samples") {
def sampleId = column[Int]("sampleId", O.PrimaryKey) // This is the primary key column
def sampleName = column[String]("sampleName")
def tags = column[Blob]("tags")
// Every table needs a * projection with the same type as the table's type parameter
def * = (sampleId, sampleName, tags)
}
\ No newline at end of file
package nl.lumc.sasc.biopet.utils.summary.db
import java.sql.Blob
import slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 27-1-17.
*/
object Schema {
class Runs(tag: Tag) extends Table[(Int, String)](tag, "Runs") {
def runId = column[Int]("runId", O.PrimaryKey)
def runName = column[String]("sampleName")
def * = (runId, runName)
}
val runs = TableQuery[Runs]
class Samples(tag: Tag) extends Table[(Int, String, Int, Blob)](tag, "Samples") {
def sampleId = column[Int]("sampleId", O.PrimaryKey)
def sampleName = column[String]("sampleName")
def runId = column[Int]("runId")
def tags = column[Blob]("tags")
def * = (sampleId, sampleName, runId, tags)
}
val samples = TableQuery[Samples]
class Libraries(tag: Tag) extends Table[(Int, String, Int, Blob)](tag, "Libraries") {
def libraryId = column[Int]("libraryId", O.PrimaryKey)
def libraryName = column[String]("libraryName")
def sampleId = column[Int]("sampleId")
def tags = column[Blob]("tags")
def * = (libraryId, libraryName, sampleId, tags)
}
val libraries = TableQuery[Libraries]
class Pipelines(tag: Tag) extends Table[(Int, String)](tag, "Pipelines") {
def pipelineId = column[Int]("runId", O.PrimaryKey)
def pipelineName = column[String]("sampleName")
def * = (pipelineId, pipelineName)
}
val pipelines = TableQuery[Pipelines]
}
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