# HG changeset patch # User Mike Becker # Date 1609770359 -3600 # Node ID 1e6f2aace6663bebf58a369e94d0686deb115fc1 # Parent 690a9aad3f164646f9cdd4a95010c3ea3256a473 adds project ordering - fixes #34 diff -r 690a9aad3f16 -r 1e6f2aace666 setup/postgres/psql_create_tables.sql --- a/setup/postgres/psql_create_tables.sql Mon Jan 04 15:14:26 2021 +0100 +++ b/setup/postgres/psql_create_tables.sql Mon Jan 04 15:25:59 2021 +0100 @@ -13,6 +13,7 @@ projectid serial primary key, name varchar(20) not null unique, node varchar(20) not null unique, + ordinal integer not null default 0, description varchar(200), repoUrl varchar(50), owner integer references lpit_user(userid) diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Mon Jan 04 15:14:26 2021 +0100 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Mon Jan 04 15:25:59 2021 +0100 @@ -187,6 +187,7 @@ final var node = getParameter(req, String.class, "node").orElse(null); project.setNode(sanitizeNode(node, project.getName())); + getParameter(req, Integer.class, "ordinal").ifPresent(project::setOrdinal); getParameter(req, String.class, "description").ifPresent(project::setDescription); getParameter(req, String.class, "repoUrl").ifPresent(project::setRepoUrl); diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/kotlin/de/uapcore/lightpit/dao/PostgresDataAccessObject.kt --- 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 { diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/kotlin/de/uapcore/lightpit/entities/Project.kt --- a/src/main/kotlin/de/uapcore/lightpit/entities/Project.kt Mon Jan 04 15:14:26 2021 +0100 +++ b/src/main/kotlin/de/uapcore/lightpit/entities/Project.kt Mon Jan 04 15:25:59 2021 +0100 @@ -28,6 +28,7 @@ data class Project(override val id: Int) : Entity { var name: String = "" var node: String = name + var ordinal = 0 var description: String? = null var repoUrl: String? = null var owner: User? = null diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/resources/localization/projects.properties --- a/src/main/resources/localization/projects.properties Mon Jan 04 15:14:26 2021 +0100 +++ b/src/main/resources/localization/projects.properties Mon Jan 04 15:25:59 2021 +0100 @@ -43,6 +43,7 @@ name=Name node=Node +ordinal=Ordering node.tooltip=Name of the path node that will be used in URL construction. description=Description repoUrl=Repository diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/resources/localization/projects_de.properties --- a/src/main/resources/localization/projects_de.properties Mon Jan 04 15:14:26 2021 +0100 +++ b/src/main/resources/localization/projects_de.properties Mon Jan 04 15:25:59 2021 +0100 @@ -43,6 +43,7 @@ name=Name node=Pfadname +ordinal=Sequenznummer node.tooltip=Name, der zur Konstruktion der URL genutzt werden soll. description=Beschreibung repoUrl=Repository diff -r 690a9aad3f16 -r 1e6f2aace666 src/main/webapp/WEB-INF/jsp/project-form.jsp --- a/src/main/webapp/WEB-INF/jsp/project-form.jsp Mon Jan 04 15:14:26 2021 +0100 +++ b/src/main/webapp/WEB-INF/jsp/project-form.jsp Mon Jan 04 15:25:59 2021 +0100 @@ -67,6 +67,12 @@ + "> + + + + +