33 import de.uapcore.lightpit.entities.* |
33 import de.uapcore.lightpit.entities.* |
34 import de.uapcore.lightpit.types.IssueCategory |
34 import de.uapcore.lightpit.types.IssueCategory |
35 import de.uapcore.lightpit.types.IssueStatus |
35 import de.uapcore.lightpit.types.IssueStatus |
36 import de.uapcore.lightpit.types.VersionStatus |
36 import de.uapcore.lightpit.types.VersionStatus |
37 import de.uapcore.lightpit.types.WebColor |
37 import de.uapcore.lightpit.types.WebColor |
38 import de.uapcore.lightpit.util.IssueSorter.Companion.DEFAULT_ISSUE_SORTER |
|
39 import de.uapcore.lightpit.viewmodel.* |
38 import de.uapcore.lightpit.viewmodel.* |
40 import java.sql.Date |
39 import java.sql.Date |
41 import javax.servlet.annotation.WebServlet |
40 import javax.servlet.annotation.WebServlet |
42 |
41 |
43 @WebServlet(urlPatterns = ["/projects/*"]) |
42 @WebServlet(urlPatterns = ["/projects/*"]) |
185 |
184 |
186 private fun project(http: HttpRequest, dao: DataAccessObject) { |
185 private fun project(http: HttpRequest, dao: DataAccessObject) { |
187 withPathInfo(http, dao)?.run { |
186 withPathInfo(http, dao)?.run { |
188 |
187 |
189 val issues = dao.listIssues(project, version, component) |
188 val issues = dao.listIssues(project, version, component) |
190 .sortedWith(DEFAULT_ISSUE_SORTER) |
189 .sortedWith( |
|
190 IssueSorter( |
|
191 IssueSorter.Criteria(IssueSorter.Field.DONE), |
|
192 IssueSorter.Criteria(IssueSorter.Field.ETA), |
|
193 IssueSorter.Criteria(IssueSorter.Field.UPDATED, false) |
|
194 ) |
|
195 ) |
191 |
196 |
192 with(http) { |
197 with(http) { |
193 pageTitle = project.name |
198 pageTitle = project.name |
194 view = ProjectDetails(projectInfo, issues, version, component) |
199 view = ProjectDetails(projectInfo, issues, version, component) |
195 feedPath = feedPath(project) |
200 feedPath = feedPath(project) |
302 styleSheets = listOf("projects") |
307 styleSheets = listOf("projects") |
303 render("version-form") |
308 render("version-form") |
304 } |
309 } |
305 } |
310 } |
306 |
311 |
307 private fun obtainIdAndProject(http: HttpRequest, dao:DataAccessObject): Pair<Int, Project>? { |
312 private fun obtainIdAndProject(http: HttpRequest, dao: DataAccessObject): Pair<Int, Project>? { |
308 val id = http.param("id")?.toIntOrNull() |
313 val id = http.param("id")?.toIntOrNull() |
309 val projectid = http.param("projectid")?.toIntOrNull() ?: -1 |
314 val projectid = http.param("projectid")?.toIntOrNull() ?: -1 |
310 val project = dao.findProject(projectid) |
315 val project = dao.findProject(projectid) |
311 return if (id == null || project == null) { |
316 return if (id == null || project == null) { |
312 http.response.sendError(400) |
317 http.response.sendError(400) |
324 name = http.param("name") ?: "" |
329 name = http.param("name") ?: "" |
325 node = http.param("node") ?: "" |
330 node = http.param("node") ?: "" |
326 ordinal = http.param("ordinal")?.toIntOrNull() ?: 0 |
331 ordinal = http.param("ordinal")?.toIntOrNull() ?: 0 |
327 status = http.param("status")?.let(VersionStatus::valueOf) ?: VersionStatus.Future |
332 status = http.param("status")?.let(VersionStatus::valueOf) ?: VersionStatus.Future |
328 // TODO: process error messages |
333 // TODO: process error messages |
329 eol = http.param("eol", ::dateOptValidator, null, mutableListOf()) |
334 eol = http.param("eol", ::dateOptValidator, null, mutableListOf()) |
330 release = http.param("release", ::dateOptValidator, null, mutableListOf()) |
335 release = http.param("release", ::dateOptValidator, null, mutableListOf()) |
331 // intentional defaults |
336 // intentional defaults |
332 if (node.isBlank()) node = name |
337 if (node.isBlank()) node = name |
333 // sanitizing |
338 // sanitizing |
334 node = sanitizeNode(node) |
339 node = sanitizeNode(node) |
335 } |
340 } |