mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
(refs #341) Migrate model package.
This commit is contained in:
@@ -38,7 +38,7 @@ object MyBuild extends Build {
|
|||||||
"org.apache.commons" % "commons-email" % "1.3.1",
|
"org.apache.commons" % "commons-email" % "1.3.1",
|
||||||
"org.apache.httpcomponents" % "httpclient" % "4.3",
|
"org.apache.httpcomponents" % "httpclient" % "4.3",
|
||||||
"org.apache.sshd" % "apache-sshd" % "0.11.0",
|
"org.apache.sshd" % "apache-sshd" % "0.11.0",
|
||||||
"com.typesafe.slick" %% "slick" % "1.0.1",
|
"com.typesafe.slick" %% "slick" % "2.0.2",
|
||||||
"com.novell.ldap" % "jldap" % "2009-10-07",
|
"com.novell.ldap" % "jldap" % "2009-10-07",
|
||||||
"com.h2database" % "h2" % "1.3.173",
|
"com.h2database" % "h2" % "1.3.173",
|
||||||
"ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
|
"ch.qos.logback" % "logback-classic" % "1.0.13" % "runtime",
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait AccountComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object Accounts extends Table[Account]("ACCOUNT") {
|
lazy val Accounts = TableQuery[Accounts]
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
|
||||||
def fullName = column[String]("FULL_NAME")
|
|
||||||
def mailAddress = column[String]("MAIL_ADDRESS")
|
|
||||||
def password = column[String]("PASSWORD")
|
|
||||||
def isAdmin = column[Boolean]("ADMINISTRATOR")
|
|
||||||
def url = column[String]("URL")
|
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
|
||||||
def lastLoginDate = column[java.util.Date]("LAST_LOGIN_DATE")
|
|
||||||
def image = column[String]("IMAGE")
|
|
||||||
def groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
|
||||||
def removed = column[Boolean]("REMOVED")
|
|
||||||
def * = userName ~ fullName ~ mailAddress ~ password ~ isAdmin ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? ~ image.? ~ groupAccount ~ removed <> (Account, Account.unapply _)
|
|
||||||
}
|
|
||||||
|
|
||||||
case class Account(
|
class Accounts(tag: Tag) extends Table[Account](tag, "ACCOUNT") {
|
||||||
|
val userName = column[String]("USER_NAME", O PrimaryKey)
|
||||||
|
val fullName = column[String]("FULL_NAME")
|
||||||
|
val mailAddress = column[String]("MAIL_ADDRESS")
|
||||||
|
val password = column[String]("PASSWORD")
|
||||||
|
val isAdmin = column[Boolean]("ADMINISTRATOR")
|
||||||
|
val url = column[String]("URL")
|
||||||
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
|
val lastLoginDate = column[java.util.Date]("LAST_LOGIN_DATE")
|
||||||
|
val image = column[String]("IMAGE")
|
||||||
|
val groupAccount = column[Boolean]("GROUP_ACCOUNT")
|
||||||
|
val removed = column[Boolean]("REMOVED")
|
||||||
|
def * = (userName, fullName, mailAddress, password, isAdmin, url.?, registeredDate, updatedDate, lastLoginDate.?, image.?, groupAccount, removed) <> (Account.tupled, Account.unapply)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Account(
|
||||||
userName: String,
|
userName: String,
|
||||||
fullName: String,
|
fullName: String,
|
||||||
mailAddress: String,
|
mailAddress: String,
|
||||||
@@ -31,4 +35,5 @@ case class Account(
|
|||||||
image: Option[String],
|
image: Option[String],
|
||||||
isGroupAccount: Boolean,
|
isGroupAccount: Boolean,
|
||||||
isRemoved: Boolean
|
isRemoved: Boolean
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait ActivityComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object Activities extends Table[Activity]("ACTIVITY") with BasicTemplate {
|
lazy val Activities = TableQuery[Activities]
|
||||||
def activityId = column[Int]("ACTIVITY_ID", O AutoInc)
|
|
||||||
def activityUserName = column[String]("ACTIVITY_USER_NAME")
|
class Activities(tag: Tag) extends Table[Activity](tag, "ACTIVITY") with BasicTemplate {
|
||||||
def activityType = column[String]("ACTIVITY_TYPE")
|
val activityId = column[Int]("ACTIVITY_ID", O AutoInc)
|
||||||
def message = column[String]("MESSAGE")
|
val activityUserName = column[String]("ACTIVITY_USER_NAME")
|
||||||
def additionalInfo = column[String]("ADDITIONAL_INFO")
|
val activityType = column[String]("ACTIVITY_TYPE")
|
||||||
def activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
val message = column[String]("MESSAGE")
|
||||||
def * = activityId ~ userName ~ repositoryName ~ activityUserName ~ activityType ~ message ~ additionalInfo.? ~ activityDate <> (Activity, Activity.unapply _)
|
val additionalInfo = column[String]("ADDITIONAL_INFO")
|
||||||
def autoInc = userName ~ repositoryName ~ activityUserName ~ activityType ~ message ~ additionalInfo.? ~ activityDate returning activityId
|
val activityDate = column[java.util.Date]("ACTIVITY_DATE")
|
||||||
|
def * = (activityId, userName, repositoryName, activityUserName, activityType, message, additionalInfo.?, activityDate) <> (Activity.tupled, Activity.unapply)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Activity(
|
||||||
|
activityId: Int,
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
activityUserName: String,
|
||||||
|
activityType: String,
|
||||||
|
message: String,
|
||||||
|
additionalInfo: Option[String],
|
||||||
|
activityDate: java.util.Date
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Activity(
|
|
||||||
activityId: Int,
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
activityUserName: String,
|
|
||||||
activityType: String,
|
|
||||||
message: String,
|
|
||||||
additionalInfo: Option[String],
|
|
||||||
activityDate: java.util.Date
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,44 +1,47 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
protected[model] trait TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
protected[model] trait BasicTemplate { self: Table[_] =>
|
trait BasicTemplate { self: Table[_] =>
|
||||||
def userName = column[String]("USER_NAME")
|
val userName = column[String]("USER_NAME")
|
||||||
def repositoryName = column[String]("REPOSITORY_NAME")
|
val repositoryName = column[String]("REPOSITORY_NAME")
|
||||||
|
|
||||||
def byRepository(owner: String, repository: String) =
|
def byRepository(owner: String, repository: String) =
|
||||||
(userName is owner.bind) && (repositoryName is repository.bind)
|
(userName is owner.bind) && (repositoryName is repository.bind)
|
||||||
|
|
||||||
|
def byRepository(userName: Column[String], repositoryName: Column[String]) =
|
||||||
|
(this.userName is userName) && (this.repositoryName is repositoryName)
|
||||||
|
}
|
||||||
|
|
||||||
|
trait IssueTemplate extends BasicTemplate { self: Table[_] =>
|
||||||
|
val issueId = column[Int]("ISSUE_ID")
|
||||||
|
|
||||||
|
def byIssue(owner: String, repository: String, issueId: Int) =
|
||||||
|
byRepository(owner, repository) && (this.issueId is issueId.bind)
|
||||||
|
|
||||||
|
def byIssue(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) =
|
||||||
|
byRepository(userName, repositoryName) && (this.issueId is issueId)
|
||||||
|
}
|
||||||
|
|
||||||
|
trait LabelTemplate extends BasicTemplate { self: Table[_] =>
|
||||||
|
val labelId = column[Int]("LABEL_ID")
|
||||||
|
|
||||||
|
def byLabel(owner: String, repository: String, labelId: Int) =
|
||||||
|
byRepository(owner, repository) && (this.labelId is labelId.bind)
|
||||||
|
|
||||||
|
def byLabel(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) =
|
||||||
|
byRepository(userName, repositoryName) && (this.labelId is labelId)
|
||||||
|
}
|
||||||
|
|
||||||
|
trait MilestoneTemplate extends BasicTemplate { self: Table[_] =>
|
||||||
|
val milestoneId = column[Int]("MILESTONE_ID")
|
||||||
|
|
||||||
|
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
||||||
|
byRepository(owner, repository) && (this.milestoneId is milestoneId.bind)
|
||||||
|
|
||||||
|
def byMilestone(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) =
|
||||||
|
byRepository(userName, repositoryName) && (this.milestoneId is milestoneId)
|
||||||
|
}
|
||||||
|
|
||||||
def byRepository(userName: Column[String], repositoryName: Column[String]) =
|
|
||||||
(this.userName is userName) && (this.repositoryName is repositoryName)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected[model] trait IssueTemplate extends BasicTemplate { self: Table[_] =>
|
|
||||||
def issueId = column[Int]("ISSUE_ID")
|
|
||||||
|
|
||||||
def byIssue(owner: String, repository: String, issueId: Int) =
|
|
||||||
byRepository(owner, repository) && (this.issueId is issueId.bind)
|
|
||||||
|
|
||||||
def byIssue(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) =
|
|
||||||
byRepository(userName, repositoryName) && (this.issueId is issueId)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected[model] trait LabelTemplate extends BasicTemplate { self: Table[_] =>
|
|
||||||
def labelId = column[Int]("LABEL_ID")
|
|
||||||
|
|
||||||
def byLabel(owner: String, repository: String, labelId: Int) =
|
|
||||||
byRepository(owner, repository) && (this.labelId is labelId.bind)
|
|
||||||
|
|
||||||
def byLabel(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) =
|
|
||||||
byRepository(userName, repositoryName) && (this.labelId is labelId)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected[model] trait MilestoneTemplate extends BasicTemplate { self: Table[_] =>
|
|
||||||
def milestoneId = column[Int]("MILESTONE_ID")
|
|
||||||
|
|
||||||
def byMilestone(owner: String, repository: String, milestoneId: Int) =
|
|
||||||
byRepository(owner, repository) && (this.milestoneId is milestoneId.bind)
|
|
||||||
|
|
||||||
def byMilestone(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) =
|
|
||||||
byRepository(userName, repositoryName) && (this.milestoneId is milestoneId)
|
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,21 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait CollaboratorComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object Collaborators extends Table[Collaborator]("COLLABORATOR") with BasicTemplate {
|
lazy val Collaborators = TableQuery[Collaborators]
|
||||||
def collaboratorName = column[String]("COLLABORATOR_NAME")
|
|
||||||
def * = userName ~ repositoryName ~ collaboratorName <> (Collaborator, Collaborator.unapply _)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
class Collaborators(tag: Tag) extends Table[Collaborator](tag, "COLLABORATOR") with BasicTemplate {
|
||||||
byRepository(owner, repository) && (collaboratorName is collaborator.bind)
|
val collaboratorName = column[String]("COLLABORATOR_NAME")
|
||||||
|
def * = (userName, repositoryName, collaboratorName) <> (Collaborator.tupled, Collaborator.unapply)
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String, collaborator: String) =
|
||||||
|
byRepository(owner, repository) && (collaboratorName is collaborator.bind)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Collaborator(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
collaboratorName: String
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Collaborator(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
collaboratorName: String
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait GroupMemberComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object GroupMembers extends Table[GroupMember]("GROUP_MEMBER") {
|
lazy val GroupMembers = TableQuery[GroupMembers]
|
||||||
def groupName = column[String]("GROUP_NAME", O PrimaryKey)
|
|
||||||
def userName = column[String]("USER_NAME", O PrimaryKey)
|
class GroupMembers(tag: Tag) extends Table[GroupMember](tag, "GROUP_MEMBER") {
|
||||||
def isManager = column[Boolean]("MANAGER")
|
val groupName = column[String]("GROUP_NAME", O PrimaryKey)
|
||||||
def * = groupName ~ userName ~ isManager <> (GroupMember, GroupMember.unapply _)
|
val userName = column[String]("USER_NAME", O PrimaryKey)
|
||||||
|
val isManager = column[Boolean]("MANAGER")
|
||||||
|
def * = (groupName, userName, isManager) <> (GroupMember.tupled, GroupMember.unapply)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class GroupMember(
|
||||||
|
groupName: String,
|
||||||
|
userName: String,
|
||||||
|
isManager: Boolean
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class GroupMember(
|
|
||||||
groupName: String,
|
|
||||||
userName: String,
|
|
||||||
isManager: Boolean
|
|
||||||
)
|
|
||||||
@@ -1,32 +1,38 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait IssueComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object IssueId extends Table[(String, String, Int)]("ISSUE_ID") with IssueTemplate {
|
lazy val IssueId = TableQuery[IssueId]
|
||||||
def * = userName ~ repositoryName ~ issueId
|
lazy val IssueOutline = TableQuery[IssueOutline]
|
||||||
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
lazy val Issues = TableQuery[Issues]
|
||||||
}
|
|
||||||
|
|
||||||
object IssueOutline extends Table[(String, String, Int, Int)]("ISSUE_OUTLINE_VIEW") with IssueTemplate {
|
class IssueId(tag: Tag) extends Table[(String, String, Int)](tag, "ISSUE_ID") with IssueTemplate {
|
||||||
def commentCount = column[Int]("COMMENT_COUNT")
|
def * = (userName, repositoryName, issueId)
|
||||||
def * = userName ~ repositoryName ~ issueId ~ commentCount
|
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Issues extends Table[Issue]("ISSUE") with IssueTemplate with MilestoneTemplate {
|
class IssueOutline(tag: Tag) extends Table[(String, String, Int, Int)](tag, "ISSUE_OUTLINE_VIEW") with IssueTemplate {
|
||||||
def openedUserName = column[String]("OPENED_USER_NAME")
|
val commentCount = column[Int]("COMMENT_COUNT")
|
||||||
def assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
def * = (userName, repositoryName, issueId, commentCount)
|
||||||
def title = column[String]("TITLE")
|
}
|
||||||
def content = column[String]("CONTENT")
|
|
||||||
def closed = column[Boolean]("CLOSED")
|
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
|
||||||
def pullRequest = column[Boolean]("PULL_REQUEST")
|
|
||||||
def * = userName ~ repositoryName ~ issueId ~ openedUserName ~ milestoneId.? ~ assignedUserName.? ~ title ~ content.? ~ closed ~ registeredDate ~ updatedDate ~ pullRequest <> (Issue, Issue.unapply _)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
class Issues(tag: Tag) extends Table[Issue](tag, "ISSUE") with IssueTemplate with MilestoneTemplate {
|
||||||
}
|
val openedUserName = column[String]("OPENED_USER_NAME")
|
||||||
|
val assignedUserName = column[String]("ASSIGNED_USER_NAME")
|
||||||
|
val title = column[String]("TITLE")
|
||||||
|
val content = column[String]("CONTENT")
|
||||||
|
val closed = column[Boolean]("CLOSED")
|
||||||
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
|
val pullRequest = column[Boolean]("PULL_REQUEST")
|
||||||
|
def * = (userName, repositoryName, issueId, openedUserName, milestoneId.?, assignedUserName.?, title, content.?, closed, registeredDate, updatedDate, pullRequest) <> (Issue.tupled, Issue.unapply)
|
||||||
|
|
||||||
case class Issue(
|
def byPrimaryKey(owner: String, repository: String, issueId: Int) = byIssue(owner, repository, issueId)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Issue(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
@@ -39,3 +45,4 @@ case class Issue(
|
|||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date,
|
updatedDate: java.util.Date,
|
||||||
isPullRequest: Boolean)
|
isPullRequest: Boolean)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait IssueCommentComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object IssueComments extends Table[IssueComment]("ISSUE_COMMENT") with IssueTemplate {
|
lazy val IssueComments = new TableQuery(tag => new IssueComments(tag)){
|
||||||
def commentId = column[Int]("COMMENT_ID", O AutoInc)
|
def autoInc = this returning this.map(_.commentId)
|
||||||
def action = column[String]("ACTION")
|
}
|
||||||
def commentedUserName = column[String]("COMMENTED_USER_NAME")
|
|
||||||
def content = column[String]("CONTENT")
|
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
|
||||||
def * = userName ~ repositoryName ~ issueId ~ commentId ~ action ~ commentedUserName ~ content ~ registeredDate ~ updatedDate <> (IssueComment, IssueComment.unapply _)
|
|
||||||
|
|
||||||
def autoInc = userName ~ repositoryName ~ issueId ~ action ~ commentedUserName ~ content ~ registeredDate ~ updatedDate returning commentId
|
class IssueComments(tag: Tag) extends Table[IssueComment](tag, "ISSUE_COMMENT") with IssueTemplate {
|
||||||
def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind
|
val commentId = column[Int]("COMMENT_ID", O AutoInc)
|
||||||
}
|
val action = column[String]("ACTION")
|
||||||
|
val commentedUserName = column[String]("COMMENTED_USER_NAME")
|
||||||
|
val content = column[String]("CONTENT")
|
||||||
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
|
def * = (userName, repositoryName, issueId, commentId, action, commentedUserName, content, registeredDate, updatedDate) <> (IssueComment.tupled, IssueComment.unapply)
|
||||||
|
|
||||||
case class IssueComment(
|
def byPrimaryKey(commentId: Int) = this.commentId is commentId.bind
|
||||||
|
}
|
||||||
|
|
||||||
|
case class IssueComment(
|
||||||
userName: String,
|
userName: String,
|
||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
issueId: Int,
|
issueId: Int,
|
||||||
@@ -25,4 +30,5 @@ case class IssueComment(
|
|||||||
content: String,
|
content: String,
|
||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date
|
updatedDate: java.util.Date
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait IssueLabelComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object IssueLabels extends Table[IssueLabel]("ISSUE_LABEL") with IssueTemplate with LabelTemplate {
|
lazy val IssueLabels = TableQuery[IssueLabels]
|
||||||
def * = userName ~ repositoryName ~ issueId ~ labelId <> (IssueLabel, IssueLabel.unapply _)
|
|
||||||
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
class IssueLabels(tag: Tag) extends Table[IssueLabel](tag, "ISSUE_LABEL") with IssueTemplate with LabelTemplate {
|
||||||
byIssue(owner, repository, issueId) && (this.labelId is labelId.bind)
|
def * = (userName, repositoryName, issueId, labelId) <> (IssueLabel.tupled, IssueLabel.unapply)
|
||||||
|
def byPrimaryKey(owner: String, repository: String, issueId: Int, labelId: Int) =
|
||||||
|
byIssue(owner, repository, issueId) && (this.labelId is labelId.bind)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class IssueLabel(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
issueId: Int,
|
||||||
|
labelId: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class IssueLabel(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
issueId: Int,
|
|
||||||
labelId: Int)
|
|
||||||
@@ -1,34 +1,37 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait LabelComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object Labels extends Table[Label]("LABEL") with LabelTemplate {
|
lazy val Labels = TableQuery[Labels]
|
||||||
def labelName = column[String]("LABEL_NAME")
|
|
||||||
def color = column[String]("COLOR")
|
|
||||||
def * = userName ~ repositoryName ~ labelId ~ labelName ~ color <> (Label, Label.unapply _)
|
|
||||||
|
|
||||||
def ins = userName ~ repositoryName ~ labelName ~ color
|
class Labels(tag: Tag) extends Table[Label](tag, "LABEL") with LabelTemplate {
|
||||||
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
override val labelId = column[Int]("LABEL_ID", O AutoInc)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) = byLabel(userName, repositoryName, labelId)
|
val labelName = column[String]("LABEL_NAME")
|
||||||
}
|
val color = column[String]("COLOR")
|
||||||
|
def * = (userName, repositoryName, labelId, labelName, color) <> (Label.tupled, Label.unapply)
|
||||||
|
|
||||||
case class Label(
|
def byPrimaryKey(owner: String, repository: String, labelId: Int) = byLabel(owner, repository, labelId)
|
||||||
userName: String,
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], labelId: Column[Int]) = byLabel(userName, repositoryName, labelId)
|
||||||
repositoryName: String,
|
|
||||||
labelId: Int,
|
|
||||||
labelName: String,
|
|
||||||
color: String){
|
|
||||||
|
|
||||||
val fontColor = {
|
|
||||||
val r = color.substring(0, 2)
|
|
||||||
val g = color.substring(2, 4)
|
|
||||||
val b = color.substring(4, 6)
|
|
||||||
|
|
||||||
if(Integer.parseInt(r, 16) + Integer.parseInt(g, 16) + Integer.parseInt(b, 16) > 408){
|
|
||||||
"000000"
|
|
||||||
} else {
|
|
||||||
"FFFFFF"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case class Label(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
labelId: Int,
|
||||||
|
labelName: String,
|
||||||
|
color: String){
|
||||||
|
|
||||||
|
val fontColor = {
|
||||||
|
val r = color.substring(0, 2)
|
||||||
|
val g = color.substring(2, 4)
|
||||||
|
val b = color.substring(4, 6)
|
||||||
|
|
||||||
|
if(Integer.parseInt(r, 16) + Integer.parseInt(g, 16) + Integer.parseInt(b, 16) > 408){
|
||||||
|
"000000"
|
||||||
|
} else {
|
||||||
|
"FFFFFF"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,29 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait MilestoneComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object Milestones extends Table[Milestone]("MILESTONE") with MilestoneTemplate {
|
lazy val Milestones = TableQuery[Milestones]
|
||||||
def title = column[String]("TITLE")
|
|
||||||
def description = column[String]("DESCRIPTION")
|
|
||||||
def dueDate = column[java.util.Date]("DUE_DATE")
|
|
||||||
def closedDate = column[java.util.Date]("CLOSED_DATE")
|
|
||||||
def * = userName ~ repositoryName ~ milestoneId ~ title ~ description.? ~ dueDate.? ~ closedDate.? <> (Milestone, Milestone.unapply _)
|
|
||||||
|
|
||||||
def ins = userName ~ repositoryName ~ title ~ description.? ~ dueDate.? ~ closedDate.?
|
class Milestones(tag: Tag) extends Table[Milestone](tag, "MILESTONE") with MilestoneTemplate {
|
||||||
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
override val milestoneId = column[Int]("MILESTONE_ID", O AutoInc)
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
val title = column[String]("TITLE")
|
||||||
|
val description = column[String]("DESCRIPTION")
|
||||||
|
val dueDate = column[java.util.Date]("DUE_DATE")
|
||||||
|
val closedDate = column[java.util.Date]("CLOSED_DATE")
|
||||||
|
def * = (userName, repositoryName, milestoneId, title, description.?, dueDate.?, closedDate.?) <> (Milestone.tupled, Milestone.unapply)
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String, milestoneId: Int) = byMilestone(owner, repository, milestoneId)
|
||||||
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], milestoneId: Column[Int]) = byMilestone(userName, repositoryName, milestoneId)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Milestone(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
milestoneId: Int,
|
||||||
|
title: String,
|
||||||
|
description: Option[String],
|
||||||
|
dueDate: Option[java.util.Date],
|
||||||
|
closedDate: Option[java.util.Date])
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Milestone(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
milestoneId: Int,
|
|
||||||
title: String,
|
|
||||||
description: Option[String],
|
|
||||||
dueDate: Option[java.util.Date],
|
|
||||||
closedDate: Option[java.util.Date])
|
|
||||||
|
|||||||
20
src/main/scala/model/Profile.scala
Normal file
20
src/main/scala/model/Profile.scala
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import slick.driver.JdbcProfile
|
||||||
|
|
||||||
|
//private[model]
|
||||||
|
trait Profile {
|
||||||
|
val profile: JdbcProfile
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,28 +1,32 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait PullRequestComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object PullRequests extends Table[PullRequest]("PULL_REQUEST") with IssueTemplate {
|
lazy val PullRequests = TableQuery[PullRequests]
|
||||||
def branch = column[String]("BRANCH")
|
|
||||||
def requestUserName = column[String]("REQUEST_USER_NAME")
|
|
||||||
def requestRepositoryName = column[String]("REQUEST_REPOSITORY_NAME")
|
|
||||||
def requestBranch = column[String]("REQUEST_BRANCH")
|
|
||||||
def commitIdFrom = column[String]("COMMIT_ID_FROM")
|
|
||||||
def commitIdTo = column[String]("COMMIT_ID_TO")
|
|
||||||
def * = userName ~ repositoryName ~ issueId ~ branch ~ requestUserName ~ requestRepositoryName ~ requestBranch ~ commitIdFrom ~ commitIdTo <> (PullRequest, PullRequest.unapply _)
|
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
class PullRequests(tag: Tag) extends Table[PullRequest](tag, "PULL_REQUEST") with IssueTemplate {
|
||||||
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) = byIssue(userName, repositoryName, issueId)
|
val branch = column[String]("BRANCH")
|
||||||
|
val requestUserName = column[String]("REQUEST_USER_NAME")
|
||||||
|
val requestRepositoryName = column[String]("REQUEST_REPOSITORY_NAME")
|
||||||
|
val requestBranch = column[String]("REQUEST_BRANCH")
|
||||||
|
val commitIdFrom = column[String]("COMMIT_ID_FROM")
|
||||||
|
val commitIdTo = column[String]("COMMIT_ID_TO")
|
||||||
|
def * = (userName, repositoryName, issueId, branch, requestUserName, requestRepositoryName, requestBranch, commitIdFrom, commitIdTo) <> (PullRequest.tupled, PullRequest.unapply)
|
||||||
|
|
||||||
|
def byPrimaryKey(userName: String, repositoryName: String, issueId: Int) = byIssue(userName, repositoryName, issueId)
|
||||||
|
def byPrimaryKey(userName: Column[String], repositoryName: Column[String], issueId: Column[Int]) = byIssue(userName, repositoryName, issueId)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class PullRequest(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
issueId: Int,
|
||||||
|
branch: String,
|
||||||
|
requestUserName: String,
|
||||||
|
requestRepositoryName: String,
|
||||||
|
requestBranch: String,
|
||||||
|
commitIdFrom: String,
|
||||||
|
commitIdTo: String
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class PullRequest(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
issueId: Int,
|
|
||||||
branch: String,
|
|
||||||
requestUserName: String,
|
|
||||||
requestRepositoryName: String,
|
|
||||||
requestBranch: String,
|
|
||||||
commitIdFrom: String,
|
|
||||||
commitIdTo: String
|
|
||||||
)
|
|
||||||
@@ -1,34 +1,39 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
import self._
|
||||||
|
|
||||||
object Repositories extends Table[Repository]("REPOSITORY") with BasicTemplate {
|
lazy val Repositories = TableQuery[Repositories]
|
||||||
def isPrivate = column[Boolean]("PRIVATE")
|
|
||||||
def description = column[String]("DESCRIPTION")
|
|
||||||
def defaultBranch = column[String]("DEFAULT_BRANCH")
|
|
||||||
def registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
|
||||||
def updatedDate = column[java.util.Date]("UPDATED_DATE")
|
|
||||||
def lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
|
||||||
def originUserName = column[String]("ORIGIN_USER_NAME")
|
|
||||||
def originRepositoryName = column[String]("ORIGIN_REPOSITORY_NAME")
|
|
||||||
def parentUserName = column[String]("PARENT_USER_NAME")
|
|
||||||
def parentRepositoryName = column[String]("PARENT_REPOSITORY_NAME")
|
|
||||||
def * = userName ~ repositoryName ~ isPrivate ~ description.? ~ defaultBranch ~ registeredDate ~ updatedDate ~ lastActivityDate ~ originUserName.? ~ originRepositoryName.? ~ parentUserName.? ~ parentRepositoryName.? <> (Repository, Repository.unapply _)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
class Repositories(tag: Tag) extends Table[Repository](tag, "REPOSITORY") with BasicTemplate {
|
||||||
|
val isPrivate = column[Boolean]("PRIVATE")
|
||||||
|
val description = column[String]("DESCRIPTION")
|
||||||
|
val defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||||
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
|
val lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
||||||
|
val originUserName = column[String]("ORIGIN_USER_NAME")
|
||||||
|
val originRepositoryName = column[String]("ORIGIN_REPOSITORY_NAME")
|
||||||
|
val parentUserName = column[String]("PARENT_USER_NAME")
|
||||||
|
val parentRepositoryName = column[String]("PARENT_REPOSITORY_NAME")
|
||||||
|
def * = (userName, repositoryName, isPrivate, description.?, defaultBranch, registeredDate, updatedDate, lastActivityDate, originUserName.?, originRepositoryName.?, parentUserName.?, parentRepositoryName.?) <> (Repository.tupled, Repository.unapply)
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String) = byRepository(owner, repository)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class Repository(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
isPrivate: Boolean,
|
||||||
|
description: Option[String],
|
||||||
|
defaultBranch: String,
|
||||||
|
registeredDate: java.util.Date,
|
||||||
|
updatedDate: java.util.Date,
|
||||||
|
lastActivityDate: java.util.Date,
|
||||||
|
originUserName: Option[String],
|
||||||
|
originRepositoryName: Option[String],
|
||||||
|
parentUserName: Option[String],
|
||||||
|
parentRepositoryName: Option[String]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class Repository(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
isPrivate: Boolean,
|
|
||||||
description: Option[String],
|
|
||||||
defaultBranch: String,
|
|
||||||
registeredDate: java.util.Date,
|
|
||||||
updatedDate: java.util.Date,
|
|
||||||
lastActivityDate: java.util.Date,
|
|
||||||
originUserName: Option[String],
|
|
||||||
originRepositoryName: Option[String],
|
|
||||||
parentUserName: Option[String],
|
|
||||||
parentRepositoryName: Option[String]
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,22 +1,24 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait SshKeyComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object SshKeys extends Table[SshKey]("SSH_KEY") {
|
lazy val SshKeys = TableQuery[SshKeys]
|
||||||
def userName = column[String]("USER_NAME")
|
|
||||||
def sshKeyId = column[Int]("SSH_KEY_ID", O AutoInc)
|
|
||||||
def title = column[String]("TITLE")
|
|
||||||
def publicKey = column[String]("PUBLIC_KEY")
|
|
||||||
|
|
||||||
def ins = userName ~ title ~ publicKey returning sshKeyId
|
class SshKeys(tag: Tag) extends Table[SshKey](tag, "SSH_KEY") {
|
||||||
def * = userName ~ sshKeyId ~ title ~ publicKey <> (SshKey, SshKey.unapply _)
|
val userName = column[String]("USER_NAME")
|
||||||
|
val sshKeyId = column[Int]("SSH_KEY_ID", O AutoInc)
|
||||||
|
val title = column[String]("TITLE")
|
||||||
|
val publicKey = column[String]("PUBLIC_KEY")
|
||||||
|
def * = (userName, sshKeyId, title, publicKey) <> (SshKey.tupled, SshKey.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(userName: String, sshKeyId: Int) = (this.userName is userName.bind) && (this.sshKeyId is sshKeyId.bind)
|
def byPrimaryKey(userName: String, sshKeyId: Int) = (this.userName is userName.bind) && (this.sshKeyId is sshKeyId.bind)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class SshKey(
|
||||||
|
userName: String,
|
||||||
|
sshKeyId: Int,
|
||||||
|
title: String,
|
||||||
|
publicKey: String
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class SshKey(
|
|
||||||
userName: String,
|
|
||||||
sshKeyId: Int,
|
|
||||||
title: String,
|
|
||||||
publicKey: String
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,16 +1,20 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import scala.slick.driver.H2Driver.simple._
|
trait WebHookComponent extends TemplateComponent { self: Profile =>
|
||||||
|
import profile.simple._
|
||||||
|
|
||||||
object WebHooks extends Table[WebHook]("WEB_HOOK") with BasicTemplate {
|
lazy val WebHooks = TableQuery[WebHooks]
|
||||||
def url = column[String]("URL")
|
|
||||||
def * = userName ~ repositoryName ~ url <> (WebHook, WebHook.unapply _)
|
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url is url.bind)
|
class WebHooks(tag: Tag) extends Table[WebHook](tag, "WEB_HOOK") with BasicTemplate {
|
||||||
|
val url = column[String]("URL")
|
||||||
|
def * = (userName, repositoryName, url) <> (WebHook.tupled, WebHook.unapply)
|
||||||
|
|
||||||
|
def byPrimaryKey(owner: String, repository: String, url: String) = byRepository(owner, repository) && (this.url is url.bind)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class WebHook(
|
||||||
|
userName: String,
|
||||||
|
repositoryName: String,
|
||||||
|
url: String
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case class WebHook(
|
|
||||||
userName: String,
|
|
||||||
repositoryName: String,
|
|
||||||
url: String
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
package object model {
|
package object model extends {
|
||||||
import scala.slick.driver.BasicDriver.Implicit._
|
// TODO
|
||||||
import scala.slick.lifted.{Column, MappedTypeMapper}
|
val profile = slick.driver.H2Driver
|
||||||
|
|
||||||
// java.util.Date TypeMapper
|
|
||||||
implicit val dateTypeMapper = MappedTypeMapper.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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} with AccountComponent
|
||||||
|
with ActivityComponent
|
||||||
|
with CollaboratorComponent
|
||||||
|
with GroupMemberComponent
|
||||||
|
with IssueComponent
|
||||||
|
with IssueCommentComponent
|
||||||
|
with IssueLabelComponent
|
||||||
|
with LabelComponent
|
||||||
|
with MilestoneComponent
|
||||||
|
with PullRequestComponent
|
||||||
|
with RepositoryComponent
|
||||||
|
with SshKeyComponent
|
||||||
|
with WebHookComponent with Profile {
|
||||||
/**
|
/**
|
||||||
* Returns system date.
|
* Returns system date.
|
||||||
*/
|
*/
|
||||||
def currentDate = new java.util.Date()
|
def currentDate = new java.util.Date()
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user