This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Account | |
object Clob { | |
def unapply(clob: Clob): Option[String] = Some(clob.getSubString(1, clob.length.toInt)) | |
} | |
implicit val rowToPermission: Column[Permission] = { | |
Column.nonNull[Permission] { (value, meta) => | |
value match { | |
case Clob("Administrator") => Right(Administrator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Permission | |
case object Administrator extends Permission | |
case object NormalUser extends Permission |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def testMappedType { | |
sealed trait Bool | |
case object True extends Bool | |
case object False extends Bool | |
implicit val boolTypeMapper = MappedColumnType.base[Bool, Int]( | |
{ b => | |
assertNotNull(b) | |
if(b == True) 1 else 0 | |
}, { i => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit val permissionTypeMapper = MappedTypeMapper.base[Permission, String]( | |
p => p match { | |
case Administrator => "Administrator" | |
case NormalUser => "NormalUser" | |
}, | |
s => s match { | |
case "Administrator" => Administrator | |
case "NormalUser" => NormalUser | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index = MaybeAuthenticated { implicit userOrLogin => implicit request => | |
val frontpageItems = Item.frontpage | |
Ok(views.html.index("Your new application is ready.")(frontpageItems)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def saveList(list: List[Long]) = { | |
DB.withConnection { implicit connection => | |
val insertQuery = SQL("insert into UserActions(action) values ({action})") | |
val batchInsert = (insertQuery.asBatch /: list)( | |
(sql, elem) => sql.addBatchParams(elem) | |
) | |
batchInsert.execute() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pass in the role name of the service being tested | |
object BackendConfig extends MultiNodeConfig { | |
// register the named roles (nodes) of the test | |
val supervisor = role("supervisor") | |
val analytics = role("analytics") | |
val imap = role("imap") | |
val mailer = role("mailer") | |
val nodeConfig: Config = ConfigFactory.parseString(s""" | |
akka.actor.provider = "akka.cluster.ClusterActorRefProvider" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pass in the role name of the service being tested | |
object MultiSpecConfig extends MultiNodeConfig { | |
// register the named roles (nodes) of the test | |
val supervisor = role("supervisor") | |
val service1 = role("service1") | |
val service2 = role("service2") | |
val nodeConfig: Config = ConfigFactory.parseString(s""" | |
akka.actor.provider = "akka.cluster.ClusterActorRefProvider" | |
akka.remote.log-remote-lifecycle-events = off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import sbt.Keys._ | |
import PlayProject._ | |
import akka.sbt.AkkaKernelPlugin | |
import akka.sbt.AkkaKernelPlugin.{ Dist, outputDirectory, distJvmOptions, configSourceDirs, distMainClass } | |
import com.typesafe.sbt.SbtMultiJvm | |
import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys._ | |
import sbtassembly.Plugin._ | |
import AssemblyKeys._ | |
import twirl.sbt.TwirlPlugin._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Play controller | |
def source(flightIdent: String) = Action { | |
Async { | |
for { | |
flight <- Flight.findByIdent(flightIdent) | |
source <- (eventSource ? Track(flight)) | |
} yield source match { case Connected(stream) => | |
Ok.feed((stream &> EventSource[JsValue]()( |
OlderNewer