Newer
Older
GitBucket / src / main / scala / gitbucket / core / model / Profile.scala
@takezoe takezoe on 2 Mar 2015 1 KB Temporary fix instantiation error
package gitbucket.core.model

trait Profile {
  // TODO Is it possible to fix instance at the sub-trait?
  val profile: slick.driver.JdbcProfile = slick.driver.H2Driver
  import profile.simple._

  // java.util.Date Mapped Column Types
  implicit val dateColumnType = MappedColumnType.base[java.util.Date, java.sql.Timestamp](
      d => new java.sql.Timestamp(d.getTime),
      t => new java.util.Date(t.getTime)
  )

  implicit class RichColumn(c1: Column[Boolean]){
    def &&(c2: => Column[Boolean], guard: => Boolean): Column[Boolean] = if(guard) c1 && c2 else c1
  }

  /**
   * Returns system date.
   */
  def currentDate = new java.util.Date()

}

trait CoreProfile extends Profile
  with AccountComponent
  with ActivityComponent
  with CollaboratorComponent
  with CommitCommentComponent
  with GroupMemberComponent
  with IssueComponent
  with IssueCommentComponent
  with IssueLabelComponent
  with LabelComponent
  with MilestoneComponent
  with PullRequestComponent
  with RepositoryComponent
  with SshKeyComponent
  with WebHookComponent
  with PluginComponent

object Profile extends CoreProfile