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

changeset 175
1e6f2aace666
parent 167
3f30adba1c63
child 176
4da5b783aa2d
--- a/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Mon Jan 04 15:14:26 2021 +0100
+++ b/src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt	Mon Jan 04 15:25:59 2021 +0100
@@ -338,6 +338,7 @@
                 yield(Project(rs.getInt("projectid")).apply {
                     name = rs.getString("name")
                     node = rs.getString("node")
+                    ordinal = rs.getInt("ordinal")
                     description = rs.getString("description")
                     repoUrl = rs.getString("repourl")
                     owner = selectUserInfo(rs)
@@ -350,17 +351,18 @@
         with(obj) {
             stmt.setStringSafe(1, name)
             stmt.setStringSafe(2, node)
-            stmt.setStringOrNull(3, description)
-            stmt.setStringOrNull(4, repoUrl)
-            stmt.setIntOrNull(5, owner?.id)
+            stmt.setInt(3, ordinal)
+            stmt.setStringOrNull(4, description)
+            stmt.setStringOrNull(5, repoUrl)
+            stmt.setIntOrNull(6, owner?.id)
         }
-        return 6
+        return 7
     }
 
     //language=SQL
     private val projectQuery =
         """
-        select projectid, name, node, description, repourl,
+        select projectid, name, node, ordinal, description, repourl,
             userid, username, lastname, givenname, mail
         from lpit_project
         left join lpit_user owner on lpit_project.owner = owner.userid
@@ -369,7 +371,7 @@
     private val stmtProjects by lazy {
         connection.prepareStatement(
             """${projectQuery}
-            order by lower(name)
+            order by ordinal, lower(name)
             """
         )
     }
@@ -389,12 +391,12 @@
     }
     private val stmtInsertProject by lazy {
         connection.prepareStatement(
-            "insert into lpit_project (name, node, description, repourl, owner) values (?, ?, ?, ?, ?)"
+            "insert into lpit_project (name, node, ordinal, description, repourl, owner) values (?, ?, ?, ?, ?, ?)"
         )
     }
     private val stmtUpdateProject by lazy {
         connection.prepareStatement(
-            "update lpit_project set name = ?, node = ?, description = ?, repourl = ?, owner = ? where projectid = ?"
+            "update lpit_project set name = ?, node = ?, ordinal = ?, description = ?, repourl = ?, owner = ? where projectid = ?"
         )
     }
     private val stmtIssueSummary by lazy {

mercurial