src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt

changeset 242
b7f3e972b13c
parent 241
1ca4f27cefe8
child 244
28052f3b9cf9
     1.1 --- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 12:12:20 2021 +0100
     1.2 +++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Sat Nov 27 13:03:57 2021 +0100
     1.3 @@ -597,28 +597,27 @@
     1.4          val issueid = if (newId > 0) newId else issue.id
     1.5  
     1.6          val eventid =
     1.7 -            withStatement("insert into lpit_issue_history_event(issueid, type) values (?,?::issue_history_event) returning eventid") {
     1.8 +            withStatement("insert into lpit_issue_history_event(issueid, subject, type) values (?,?,?::issue_history_event) returning eventid") {
     1.9                  setInt(1, issueid)
    1.10 -                setEnum(2, type)
    1.11 +                setString(2, issue.subject)
    1.12 +                setEnum(3, type)
    1.13                  querySingle { it.getInt(1) }!!
    1.14              }
    1.15          withStatement(
    1.16              """
    1.17 -            insert into lpit_issue_history_data (component, status, category, subject, description, assignee, assignee_username, eta, affected, resolved, eventid)
    1.18 -            values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?, ?, ?)
    1.19 +            insert into lpit_issue_history_data (component, status, category, description, assignee, eta, affected, resolved, eventid)
    1.20 +            values (?, ?::issue_status, ?::issue_category, ?, ?, ?, ?, ?, ?)
    1.21              """.trimIndent()
    1.22          ) {
    1.23              setStringOrNull(1, issue.component?.name)
    1.24              setEnum(2, issue.status)
    1.25              setEnum(3, issue.category)
    1.26 -            setString(4, issue.subject)
    1.27 -            setStringOrNull(5, issue.description)
    1.28 -            setStringOrNull(6, issue.assignee?.shortDisplayname)
    1.29 -            setStringOrNull(7, issue.assignee?.username)
    1.30 -            setDateOrNull(8, issue.eta)
    1.31 -            setStringOrNull(9, issue.affected?.name)
    1.32 -            setStringOrNull(10, issue.resolved?.name)
    1.33 -            setInt(11, eventid)
    1.34 +            setStringOrNull(4, issue.description)
    1.35 +            setStringOrNull(5, issue.assignee?.shortDisplayname)
    1.36 +            setDateOrNull(6, issue.eta)
    1.37 +            setStringOrNull(7, issue.affected?.name)
    1.38 +            setStringOrNull(8, issue.resolved?.name)
    1.39 +            setInt(9, eventid)
    1.40              executeUpdate()
    1.41          }
    1.42      }
    1.43 @@ -678,17 +677,18 @@
    1.44      }
    1.45  
    1.46  
    1.47 -    override fun insertHistoryEvent(issueComment: IssueComment, newId: Int) {
    1.48 +    override fun insertHistoryEvent(issue: Issue, issueComment: IssueComment, newId: Int) {
    1.49          val type = if (newId > 0) IssueHistoryType.NewComment else IssueHistoryType.UpdateComment
    1.50          val commentid = if (newId > 0) newId else issueComment.id
    1.51  
    1.52          val eventid =
    1.53 -            withStatement("insert into lpit_issue_history_event(issueid, type) values (?,?::issue_history_event) returning eventid") {
    1.54 +            withStatement("insert into lpit_issue_history_event(issueid, subject, type) values (?,?,?::issue_history_event) returning eventid") {
    1.55                  setInt(1, issueComment.issueid)
    1.56 -                setEnum(2, type)
    1.57 +                setString(1, issue.subject)
    1.58 +                setEnum(3, type)
    1.59                  querySingle { it.getInt(1) }!!
    1.60              }
    1.61 -        withStatement("insert into lpit_issue_comment_history (commentid, eventid, comment) values (?,?,?)") {
    1.62 +        withStatement("insert into lpit_issue_comment_history (commentid, eventid, comment) values (?,?,?,?)") {
    1.63              setInt(1, commentid)
    1.64              setInt(2, eventid)
    1.65              setString(3, issueComment.comment)
    1.66 @@ -718,20 +718,19 @@
    1.67              queryAll { rs->
    1.68                  with(rs) {
    1.69                      IssueHistoryEntry(
    1.70 -                        getTimestamp("time"),
    1.71 -                        getEnum("type"),
    1.72 -                        getString("current_assignee"),
    1.73 -                        IssueHistoryData(getInt("issueid"),
    1.74 -                            component = getString("component") ?: "",
    1.75 -                            status = getEnum("status"),
    1.76 -                            category = getEnum("category"),
    1.77 -                            subject = getString("subject"),
    1.78 -                            description = getString("description") ?: "",
    1.79 -                            assignee = getString("assignee") ?: "",
    1.80 -                            eta = getDate("eta"),
    1.81 -                            affected = getString("affected") ?: "",
    1.82 -                            resolved = getString("resolved") ?: ""
    1.83 -                        )
    1.84 +                        subject = getString("subject"),
    1.85 +                        time = getTimestamp("time"),
    1.86 +                        type = getEnum("type"),
    1.87 +                        currentAssignee = getString("current_assignee"),
    1.88 +                        issueid = getInt("issueid"),
    1.89 +                        component = getString("component") ?: "",
    1.90 +                        status = getEnum("status"),
    1.91 +                        category = getEnum("category"),
    1.92 +                        description = getString("description") ?: "",
    1.93 +                        assignee = getString("assignee") ?: "",
    1.94 +                        eta = getDate("eta"),
    1.95 +                        affected = getString("affected") ?: "",
    1.96 +                        resolved = getString("resolved") ?: ""
    1.97                      )
    1.98                  }
    1.99              }
   1.100 @@ -755,13 +754,13 @@
   1.101              queryAll { rs->
   1.102                  with(rs) {
   1.103                      IssueCommentHistoryEntry(
   1.104 -                        getTimestamp("time"),
   1.105 -                        getEnum("type"),
   1.106 -                        getString("current_assignee"),
   1.107 -                        IssueCommentHistoryData(
   1.108 -                            getInt("commentid"),
   1.109 -                            getString("comment")
   1.110 -                        )
   1.111 +                        subject = getString("subject"),
   1.112 +                        time = getTimestamp("time"),
   1.113 +                        type = getEnum("type"),
   1.114 +                        currentAssignee = getString("current_assignee"),
   1.115 +                        issueid = getInt("issueid"),
   1.116 +                        commentid = getInt("commentid"),
   1.117 +                        comment = getString("comment")
   1.118                      )
   1.119                  }
   1.120              }

mercurial