Skip to content

Instantly share code, notes, and snippets.

@brianhsu
Created January 9, 2010 04:32
Show Gist options
  • Save brianhsu/272727 to your computer and use it in GitHub Desktop.
Save brianhsu/272727 to your computer and use it in GitHub Desktop.
package bootstrap.liftweb
import _root_.net.liftweb.common._
import _root_.net.liftweb.util._
import _root_.net.liftweb.http._
import _root_.net.liftweb.sitemap._
import _root_.net.liftweb.sitemap.Loc._
import _root_.net.liftweb.mapper._
import _root_.java.sql._
import org.maidroid.model.User
import Helpers._
/**
* A class that's instantiated early and run. It allows the application
* to modify lift's environment
*/
object SQLiteDriver extends DriverType("SQLite")
{
def binaryColumnType = "BLOB"
def clobColumnType = "TEXT"
def booleanColumnType = "BOOLEAN"
def dateTimeColumnType = "DATETIME"
def dateColumnType = "DATE"
def timeColumnType = "TIME"
def integerColumnType = "INTEGER"
def integerIndexColumnType = "INTEGER PRIMARY KEY AUTOINCREMENT"
def enumColumnType = "BIGINT"
def longForeignKeyColumnType = "UNSIGNED BIGINT"
def longIndexColumnType = "INTEGER PRIMARY KEY AUTOINCREMENT"
def enumListColumnType = "BIGINT"
def longColumnType = "BIGINT"
def doubleColumnType = "DOUBLE"
override def primaryKeySetup (tableName : String, columnName : String) = Nil
}
class Boot
{
def initDB () {
object DBVendor extends ConnectionManager
{
// http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC
Class.forName ("org.sqlite.JDBC")
def newConnection (name: ConnectionIdentifier) = {
Full (DriverManager.getConnection ("jdbc:sqlite:test.db"))
}
def releaseConnection (connection: Connection) {
connection.close ()
}
}
DriverType.calcDriver = conn => { SQLiteDriver }
DB.defineConnectionManager (DefaultConnectionIdentifier, DBVendor)
Schemifier.schemify(true, Log.infoF _, User)
}
def boot {
// where to search snippet
LiftRules.addToPackages("org.maidroid")
// Build SiteMap
val entries = Menu(Loc("Home", List("index"), "Home")) :: User.sitemap
initDB()
LiftRules.setSiteMap(SiteMap(entries:_*))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment