src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java

Tue, 05 Jan 2021 19:19:31 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 05 Jan 2021 19:19:31 +0100
changeset 179
623c340058f3
parent 178
88207b860cba
child 180
009700915269
permissions
-rw-r--r--

migrates the utility classes for the AbstractServlet

41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Copyright 2018 Mike Becker. All rights reserved.
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 *
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 */
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 package de.uapcore.lightpit.modules;
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 import de.uapcore.lightpit.*;
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
33 import de.uapcore.lightpit.dao.DataAccessObject;
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
34 import de.uapcore.lightpit.entities.*;
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
35 import de.uapcore.lightpit.filter.AllFilter;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
36 import de.uapcore.lightpit.filter.IssueFilter;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
37 import de.uapcore.lightpit.filter.NoneFilter;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
38 import de.uapcore.lightpit.filter.SpecificFilter;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
39 import de.uapcore.lightpit.types.IssueCategory;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
40 import de.uapcore.lightpit.types.IssueStatus;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
41 import de.uapcore.lightpit.types.VersionStatus;
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
42 import de.uapcore.lightpit.types.WebColor;
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
43 import de.uapcore.lightpit.viewmodel.*;
121
428dca747d6b adds application level issue sorting (fixes #19)
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
44 import de.uapcore.lightpit.viewmodel.util.IssueSorter;
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
45 import org.slf4j.Logger;
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
46 import org.slf4j.LoggerFactory;
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
48 import javax.servlet.ServletException;
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 import javax.servlet.annotation.WebServlet;
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 import javax.servlet.http.HttpServletRequest;
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
51 import javax.servlet.http.HttpServletResponse;
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
52 import java.io.IOException;
75
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
53 import java.sql.Date;
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
54 import java.sql.SQLException;
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
55 import java.util.NoSuchElementException;
136
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
56 import java.util.Optional;
83
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
57 import java.util.stream.Collectors;
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
58 import java.util.stream.Stream;
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 @WebServlet(
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 name = "ProjectsModule",
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 urlPatterns = "/projects/*"
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 )
179
623c340058f3 migrates the utility classes for the AbstractServlet
Mike Becker <universe@uap-core.de>
parents: 178
diff changeset
64 public final class ProjectsModule extends AbstractServlet {
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
66 private static final Logger LOG = LoggerFactory.getLogger(ProjectsModule.class);
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
67
78
bb4c52bf3439 bloat removal 2/3 - moduleInfo
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
68 @Override
bb4c52bf3439 bloat removal 2/3 - moduleInfo
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
69 protected String getResourceBundleName() {
bb4c52bf3439 bloat removal 2/3 - moduleInfo
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
70 return "localization.projects";
bb4c52bf3439 bloat removal 2/3 - moduleInfo
Mike Becker <universe@uap-core.de>
parents: 76
diff changeset
71 }
71
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
72
158
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
73 private static int parseIntOrZero(String str) {
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
74 try {
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
75 return Integer.parseInt(str);
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
76 } catch (NumberFormatException ex) {
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
77 return 0;
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
78 }
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
79 }
4f912cd42876 migrates constants and removes global functions
Mike Becker <universe@uap-core.de>
parents: 157
diff changeset
80
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
81 private void populate(ProjectView viewModel, PathParameters pathParameters, DataAccessObject dao) {
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
82 dao.listProjects().stream().map(ProjectInfo::new).forEach(viewModel.getProjectList()::add);
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
83
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
84 if (pathParameters == null)
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
85 return;
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
86
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
87 // Select Project
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
88 final var project = dao.findProjectByNode(pathParameters.get("project"));
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
89 if (project == null)
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
90 return;
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
91
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
92 final var info = new ProjectInfo(project);
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
93 info.setVersions(dao.listVersions(project));
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
94 info.setComponents(dao.listComponents(project));
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
95 info.setIssueSummary(dao.collectIssueSummary(project));
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
96 viewModel.setProjectInfo(info);
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
97
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
98 // Select Version
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
99 final var versionNode = pathParameters.get("version");
161
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
100 if (versionNode != null) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
101 if ("no-version".equals(versionNode)) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
102 viewModel.setVersionFilter(ProjectView.NO_VERSION);
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
103 } else if ("all-versions".equals(versionNode)) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
104 viewModel.setVersionFilter(ProjectView.ALL_VERSIONS);
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
105 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
106 viewModel.setVersionFilter(dao.findVersionByNode(project, versionNode));
161
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
107 }
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
108 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
109
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
110 // Select Component
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
111 final var componentNode = pathParameters.get("component");
161
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
112 if (componentNode != null) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
113 if ("no-component".equals(componentNode)) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
114 viewModel.setComponentFilter(ProjectView.NO_COMPONENT);
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
115 } else if ("all-components".equals(componentNode)) {
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
116 viewModel.setComponentFilter(ProjectView.ALL_COMPONENTS);
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
117 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
118 viewModel.setComponentFilter(dao.findComponentByNode(project, componentNode));
161
3d9218457b62 temporarily fixes version and component filter settings
Mike Becker <universe@uap-core.de>
parents: 159
diff changeset
119 }
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
120 }
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
121 }
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
122
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
123 private static String sanitizeNode(String node, String defaultValue) {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
124 String result = node == null || node.isBlank() ? defaultValue : node;
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
125 result = result.replace('/', '-');
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
126 if (result.equals(".") || result.equals("..")) {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
127 return "_"+result;
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
128 } else {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
129 return result;
129
a09d5c59351a add components to navmenu
Mike Becker <universe@uap-core.de>
parents: 128
diff changeset
130 }
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
131 }
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
132
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
133 private void forwardView(HttpServletRequest req, HttpServletResponse resp, ProjectView viewModel, String name) throws ServletException, IOException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
134 setViewModel(req, viewModel);
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
135 setContentPage(req, name);
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
136 setStylesheet(req, "projects");
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
137 setNavigationMenu(req, "project-navmenu");
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
138 renderSite(req, resp);
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
139 }
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
140
61
3e287f361c7a moves project index to separate sub path
Mike Becker <universe@uap-core.de>
parents: 59
diff changeset
141 @RequestMapping(method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
142 public void index(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws ServletException, IOException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
143 final var viewModel = new ProjectView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
144 populate(viewModel, null, dao);
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
145
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
146 for (var info : viewModel.getProjectList()) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
147 info.setVersions(dao.listVersions(info.getProject()));
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
148 info.setIssueSummary(dao.collectIssueSummary(info.getProject()));
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
149 }
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
150
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
151 forwardView(req, resp, viewModel, "projects");
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
152 }
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
153
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
154 private void configureProjectEditor(ProjectEditView viewModel, Project project, DataAccessObject dao) {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
155 viewModel.setProject(project);
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
156 viewModel.setUsers(dao.listUsers());
71
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
157 }
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
158
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
159 @RequestMapping(requestPath = "$project/edit", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
160 public void edit(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParams, DataAccessObject dao) throws IOException, SQLException, ServletException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
161 final var viewModel = new ProjectEditView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
162 populate(viewModel, pathParams, dao);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
163
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
164 if (!viewModel.isProjectInfoPresent()) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
165 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
166 return;
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
167 }
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
168
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
169 configureProjectEditor(viewModel, viewModel.getProjectInfo().getProject(), dao);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
170 forwardView(req, resp, viewModel, "project-form");
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
171 }
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 43
diff changeset
172
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
173 @RequestMapping(requestPath = "create", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
174 public void create(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws SQLException, ServletException, IOException {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
175 final var viewModel = new ProjectEditView();
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
176 populate(viewModel, null, dao);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
177 configureProjectEditor(viewModel, new Project(-1), dao);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
178 forwardView(req, resp, viewModel, "project-form");
45
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 43
diff changeset
179 }
cc7f082c5ef3 simplifies menu generation, adds submenus and removes VersionsModule (versions will be part of the ProjectsModule)
Mike Becker <universe@uap-core.de>
parents: 43
diff changeset
180
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
181 @RequestMapping(requestPath = "commit", method = HttpMethod.POST)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
182 public void commit(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws IOException, ServletException {
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
183
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
184 try {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
185 final var project = new Project(getParameter(req, Integer.class, "pid").orElseThrow());
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
186 project.setName(getParameter(req, String.class, "name").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
187
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
188 final var node = getParameter(req, String.class, "node").orElse(null);
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
189 project.setNode(sanitizeNode(node, project.getName()));
175
1e6f2aace666 adds project ordering - fixes #34
Mike Becker <universe@uap-core.de>
parents: 168
diff changeset
190 getParameter(req, Integer.class, "ordinal").ifPresent(project::setOrdinal);
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
191
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
192 getParameter(req, String.class, "description").ifPresent(project::setDescription);
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
193 getParameter(req, String.class, "repoUrl").ifPresent(project::setRepoUrl);
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
194 getParameter(req, Integer.class, "owner").map(
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
195 ownerId -> ownerId >= 0 ? new User(ownerId) : null
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
196 ).ifPresent(project::setOwner);
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
197
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
198 if (project.getId() > 0) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
199 dao.updateProject(project);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
200 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
201 dao.insertProject(project);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
202 }
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
203
118
d3583959c875 adding a new project redirects to the projects overview (because we do not retrieve the ID of the inserted project yet)
Mike Becker <universe@uap-core.de>
parents: 110
diff changeset
204 setRedirectLocation(req, "./projects/");
74
91d1fc2a3a14 removes that dynamic_fragment bullshit
Mike Becker <universe@uap-core.de>
parents: 71
diff changeset
205 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
206 LOG.debug("Successfully updated project {}", project.getName());
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
207
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
208 renderSite(req, resp);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
209 } catch (NoSuchElementException | IllegalArgumentException ex) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
210 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
211 // TODO: implement - fix issue #21
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
212 }
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
213 }
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
214
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
215 @RequestMapping(requestPath = "$project/$component/$version/issues/", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
216 public void issues(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParams, DataAccessObject dao) throws SQLException, IOException, ServletException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
217 final var viewModel = new ProjectDetailsView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
218 populate(viewModel, pathParams, dao);
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
219
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
220 if (!viewModel.isEveryFilterValid()) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
221 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
222 return;
80
27a25f32048e adds project overview page
Mike Becker <universe@uap-core.de>
parents: 79
diff changeset
223 }
47
57cfb94ab99f projects can now be added and updated
Mike Becker <universe@uap-core.de>
parents: 45
diff changeset
224
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
225 final var project = viewModel.getProjectInfo().getProject();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
226 final var version = viewModel.getVersionFilter();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
227 final var component = viewModel.getComponentFilter();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
228
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
229 // TODO: use new IssueFilter class for the ViewModel
70
821c4950b619 removes the sub menu and removes the home module
Mike Becker <universe@uap-core.de>
parents: 68
diff changeset
230
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
231 final var projectFilter = new SpecificFilter<>(project);
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
232 final IssueFilter filter;
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
233 if (version.equals(ProjectView.NO_VERSION)) {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
234 if (component.equals(ProjectView.ALL_COMPONENTS)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
235 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
236 new NoneFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
237 new AllFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
238 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
239 } else if (component.equals(ProjectView.NO_COMPONENT)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
240 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
241 new NoneFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
242 new NoneFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
243 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
244 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
245 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
246 new NoneFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
247 new SpecificFilter<>(component)
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
248 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
249 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
250 } else if (version.equals(ProjectView.ALL_VERSIONS)) {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
251 if (component.equals(ProjectView.ALL_COMPONENTS)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
252 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
253 new AllFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
254 new AllFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
255 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
256 } else if (component.equals(ProjectView.NO_COMPONENT)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
257 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
258 new AllFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
259 new NoneFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
260 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
261 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
262 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
263 new AllFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
264 new SpecificFilter<>(component)
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
265 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
266 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
267 } else {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
268 if (component.equals(ProjectView.ALL_COMPONENTS)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
269 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
270 new SpecificFilter<>(version),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
271 new AllFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
272 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
273 } else if (component.equals(ProjectView.NO_COMPONENT)) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
274 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
275 new SpecificFilter<>(version),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
276 new NoneFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
277 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
278 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
279 filter = new IssueFilter(projectFilter,
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
280 new SpecificFilter<>(version),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
281 new SpecificFilter<>(component)
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
282 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
283 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
284 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
285
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
286 final var issues = dao.listIssues(filter);
121
428dca747d6b adds application level issue sorting (fixes #19)
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
287 issues.sort(new IssueSorter(
141
8160dfc4dbc3 renames sort criteria PHASE to DONE, because phase 0 and 1 are combined
Mike Becker <universe@uap-core.de>
parents: 138
diff changeset
288 new IssueSorter.Criteria(IssueSorter.Field.DONE, true),
121
428dca747d6b adds application level issue sorting (fixes #19)
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
289 new IssueSorter.Criteria(IssueSorter.Field.ETA, true),
428dca747d6b adds application level issue sorting (fixes #19)
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
290 new IssueSorter.Criteria(IssueSorter.Field.UPDATED, false)
428dca747d6b adds application level issue sorting (fixes #19)
Mike Becker <universe@uap-core.de>
parents: 118
diff changeset
291 ));
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
292
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
293
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
294 viewModel.getProjectDetails().updateDetails(issues);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
295 if (version.getId() > 0)
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
296 viewModel.getProjectDetails().updateVersionInfo(version);
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
297
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
298 forwardView(req, resp, viewModel, "project-details");
71
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
299 }
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
300
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
301 @RequestMapping(requestPath = "$project/versions/", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
302 public void versions(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, SQLException, ServletException {
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
303 final var viewModel = new VersionsView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
304 populate(viewModel, pathParameters, dao);
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
305
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
306 final var projectInfo = viewModel.getProjectInfo();
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
307 if (projectInfo == null) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
308 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
309 return;
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
310 }
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
311
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
312 final var issues = dao.listIssues(
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
313 new IssueFilter(
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
314 new SpecificFilter<>(projectInfo.getProject()),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
315 new AllFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
316 new AllFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
317 )
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
318 );
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
319 viewModel.update(projectInfo.getVersions(), issues);
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
320
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
321 forwardView(req, resp, viewModel, "versions");
109
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
322 }
2e0669e814ff adds versions overview
Mike Becker <universe@uap-core.de>
parents: 107
diff changeset
323
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
324 @RequestMapping(requestPath = "$project/versions/$version/edit", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
325 public void editVersion(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
326 final var viewModel = new VersionEditView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
327 populate(viewModel, pathParameters, dao);
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
328
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
329 if (viewModel.getProjectInfo() == null || viewModel.getVersionFilter() == null) {
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
330 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
331 return;
110
9d0be0b1580f adds indicators for version status
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
332 }
9d0be0b1580f adds indicators for version status
Mike Becker <universe@uap-core.de>
parents: 109
diff changeset
333
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
334 viewModel.setVersion(viewModel.getVersionFilter());
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
335
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
336 forwardView(req, resp, viewModel, "version-form");
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
337 }
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
338
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
339 @RequestMapping(requestPath = "$project/create-version", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
340 public void createVersion(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
341 final var viewModel = new VersionEditView();
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
342 populate(viewModel, pathParameters, dao);
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
343
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
344 if (viewModel.getProjectInfo() == null) {
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
345 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
346 return;
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
347 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
348
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
349 viewModel.setVersion(new Version(-1, viewModel.getProjectInfo().getProject().getId()));
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
350
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
351 forwardView(req, resp, viewModel, "version-form");
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
352 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
353
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
354 @RequestMapping(requestPath = "commit-version", method = HttpMethod.POST)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
355 public void commitVersion(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws IOException, ServletException {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
356
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
357 try {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
358 final var project = dao.findProject(getParameter(req, Integer.class, "pid").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
359 if (project == null) {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
360 // TODO: improve error handling, because not found is not correct for this POST request
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
361 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
362 return;
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
363 }
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
364 final var version = new Version(getParameter(req, Integer.class, "id").orElseThrow(), project.getId());
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
365 version.setName(getParameter(req, String.class, "name").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
366
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
367 final var node = getParameter(req, String.class, "node").orElse(null);
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
368 version.setNode(sanitizeNode(node, version.getName()));
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
369
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
370 getParameter(req, Integer.class, "ordinal").ifPresent(version::setOrdinal);
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
371 version.setStatus(VersionStatus.valueOf(getParameter(req, String.class, "status").orElseThrow()));
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
372
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
373 if (version.getId() > 0) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
374 dao.updateVersion(version);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
375 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
376 dao.insertVersion(version);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
377 }
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
378
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
379 setRedirectLocation(req, "./projects/" + project.getNode() + "/versions/");
74
91d1fc2a3a14 removes that dynamic_fragment bullshit
Mike Becker <universe@uap-core.de>
parents: 71
diff changeset
380 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
381
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
382 renderSite(req, resp);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
383 } catch (NoSuchElementException | IllegalArgumentException ex) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
384 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
385 // TODO: implement - fix issue #21
59
c759c60507a2 adds version management
Mike Becker <universe@uap-core.de>
parents: 52
diff changeset
386 }
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
387 }
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
388
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
389 @RequestMapping(requestPath = "$project/components/", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
390 public void components(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, SQLException, ServletException {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
391 final var viewModel = new ComponentsView();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
392 populate(viewModel, pathParameters, dao);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
393
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
394 final var projectInfo = viewModel.getProjectInfo();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
395 if (projectInfo == null) {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
396 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
397 return;
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
398 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
399
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
400 final var issues = dao.listIssues(
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
401 new IssueFilter(
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
402 new SpecificFilter<>(projectInfo.getProject()),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
403 new AllFilter<>(),
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
404 new AllFilter<>()
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
405 )
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
406 );
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
407 viewModel.update(projectInfo.getComponents(), issues);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
408
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
409 forwardView(req, resp, viewModel, "components");
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
410 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
411
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
412 @RequestMapping(requestPath = "$project/components/$component/edit", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
413 public void editComponent(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
414 final var viewModel = new ComponentEditView();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
415 populate(viewModel, pathParameters, dao);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
416
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
417 if (viewModel.getProjectInfo() == null || viewModel.getComponentFilter() == null) {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
418 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
419 return;
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
420 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
421
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
422 viewModel.setComponent(viewModel.getComponentFilter());
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
423 viewModel.setUsers(dao.listUsers());
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
424
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
425 forwardView(req, resp, viewModel, "component-form");
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
426 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
427
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
428 @RequestMapping(requestPath = "$project/create-component", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
429 public void createComponent(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
430 final var viewModel = new ComponentEditView();
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
431 populate(viewModel, pathParameters, dao);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
432
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
433 if (viewModel.getProjectInfo() == null) {
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
434 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
435 return;
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
436 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
437
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
438 viewModel.setComponent(new Component(-1, viewModel.getProjectInfo().getProject().getId()));
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
439 viewModel.setUsers(dao.listUsers());
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
440
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
441 forwardView(req, resp, viewModel, "component-form");
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
442 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
443
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
444 @RequestMapping(requestPath = "commit-component", method = HttpMethod.POST)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
445 public void commitComponent(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws IOException, ServletException {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
446
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
447 try {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
448 final var project = dao.findProject(getParameter(req, Integer.class, "pid").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
449 if (project == null) {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
450 // TODO: improve error handling, because not found is not correct for this POST request
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
451 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
452 return;
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
453 }
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
454 final var component = new Component(getParameter(req, Integer.class, "id").orElseThrow(), project.getId());
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
455 component.setName(getParameter(req, String.class, "name").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
456
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
457 final var node = getParameter(req, String.class, "node").orElse(null);
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
458 component.setNode(sanitizeNode(node, component.getName()));
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
459
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
460 component.setColor(getParameter(req, WebColor.class, "color").orElseThrow());
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
461 getParameter(req, Integer.class, "ordinal").ifPresent(component::setOrdinal);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
462 getParameter(req, Integer.class, "lead").map(
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
463 userid -> userid >= 0 ? new User(userid) : null
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
464 ).ifPresent(component::setLead);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
465 getParameter(req, String.class, "description").ifPresent(component::setDescription);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
466
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
467 if (component.getId() > 0) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
468 dao.updateComponent(component);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
469 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
470 dao.insertComponent(component);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
471 }
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
472
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
473 setRedirectLocation(req, "./projects/" + project.getNode() + "/components/");
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
474 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
475
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
476 renderSite(req, resp);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
477 } catch (NoSuchElementException | IllegalArgumentException ex) {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
478 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
479 // TODO: implement - fix issue #21
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
480 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
481 }
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
482
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
483 private void configureIssueEditor(IssueEditView viewModel, Issue issue, DataAccessObject dao) {
134
f47e82cd6077 completes feature: project components
Mike Becker <universe@uap-core.de>
parents: 133
diff changeset
484 final var project = viewModel.getProjectInfo().getProject();
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
485 issue.setProject(project); // automatically set current project for new issues
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
486 viewModel.setIssue(issue);
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
487 viewModel.configureVersionSelectors(viewModel.getProjectInfo().getVersions());
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
488 viewModel.setUsers(dao.listUsers());
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
489 viewModel.setComponents(dao.listComponents(project));
71
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
490 }
dca186d3911f adds breadcrumb menu
Mike Becker <universe@uap-core.de>
parents: 70
diff changeset
491
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
492 @RequestMapping(requestPath = "$project/issues/$issue/view", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
493 public void viewIssue(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
494 final var viewModel = new IssueDetailView();
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
495 populate(viewModel, pathParameters, dao);
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
496
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
497 final var projectInfo = viewModel.getProjectInfo();
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
498 if (projectInfo == null) {
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
499 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
500 return;
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
501 }
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
502
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
503 final var issue = dao.findIssue(parseIntOrZero(pathParameters.get("issue")));
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
504 if (issue == null) {
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
505 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
506 return;
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
507 }
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
508
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
509 viewModel.setIssue(issue);
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
510 viewModel.setComments(dao.listComments(issue));
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
511
162
2adc8623dd89 enables markdown support in issue descriptions and comments - fixes #10
Mike Becker <universe@uap-core.de>
parents: 161
diff changeset
512 viewModel.processMarkdown();
2adc8623dd89 enables markdown support in issue descriptions and comments - fixes #10
Mike Becker <universe@uap-core.de>
parents: 161
diff changeset
513
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
514 forwardView(req, resp, viewModel, "issue-view");
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
515 }
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
516
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
517 // TODO: why should the issue editor be child of $project?
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
518 @RequestMapping(requestPath = "$project/issues/$issue/edit", method = HttpMethod.GET)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
519 public void editIssue(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, SQLException, ServletException {
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
520 final var viewModel = new IssueEditView();
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
521 populate(viewModel, pathParameters, dao);
99
a369fb1b3aa2 cleanup ProjectsModule
Mike Becker <universe@uap-core.de>
parents: 97
diff changeset
522
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
523 final var projectInfo = viewModel.getProjectInfo();
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
524 if (projectInfo == null) {
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
525 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
526 return;
86
0a658e53177c improves issue overview and adds progress information
Mike Becker <universe@uap-core.de>
parents: 83
diff changeset
527 }
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
528
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
529 final var issue = dao.findIssue(parseIntOrZero(pathParameters.get("issue")));
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
530 if (issue == null) {
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
531 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
532 return;
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
533 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
534
133
ef075cd7ce55 fixes wrong method name for configureIssueEditor()
Mike Becker <universe@uap-core.de>
parents: 131
diff changeset
535 configureIssueEditor(viewModel, issue, dao);
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
536
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
537 forwardView(req, resp, viewModel, "issue-form");
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
538 }
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
539
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
540 @RequestMapping(requestPath = "$project/create-issue", method = HttpMethod.GET)
168
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
541 public void createIssue(HttpServletRequest req, HttpServletResponse resp, PathParameters pathParameters, DataAccessObject dao) throws IOException, ServletException {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
542 final var viewModel = new IssueEditView();
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
543 populate(viewModel, pathParameters, dao);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
544
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
545 final var projectInfo = viewModel.getProjectInfo();
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
546 if (projectInfo == null) {
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
547 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
548 return;
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
549 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
550
168
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
551 setAttributeFromParameter(req, "more");
178
88207b860cba automatically select version/component when creating new issues under active filters
Mike Becker <universe@uap-core.de>
parents: 175
diff changeset
552 setAttributeFromParameter(req, "cid");
88207b860cba automatically select version/component when creating new issues under active filters
Mike Becker <universe@uap-core.de>
parents: 175
diff changeset
553 setAttributeFromParameter(req, "vid");
168
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
554
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
555 final var issue = new Issue(-1, projectInfo.getProject(), null);
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
556 issue.setProject(projectInfo.getProject());
133
ef075cd7ce55 fixes wrong method name for configureIssueEditor()
Mike Becker <universe@uap-core.de>
parents: 131
diff changeset
557 configureIssueEditor(viewModel, issue, dao);
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
558
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
559 forwardView(req, resp, viewModel, "issue-form");
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
560 }
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
561
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
562 @RequestMapping(requestPath = "commit-issue", method = HttpMethod.POST)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
563 public void commitIssue(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws IOException, ServletException {
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
564 try {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
565 final var project = dao.findProject(getParameter(req, Integer.class, "pid").orElseThrow());
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
566 if (project == null) {
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
567 // TODO: improve error handling, because not found is not correct for this POST request
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
568 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
569 return;
138
e2aa673dd473 adds custom node names - fixes #27
Mike Becker <universe@uap-core.de>
parents: 137
diff changeset
570 }
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
571 final var componentId = getParameter(req, Integer.class, "component");
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
572 final Component component;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
573 if (componentId.isPresent()) {
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
574 component = dao.findComponent(componentId.get());
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
575 } else {
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
576 component = null;
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
577 }
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
578 final var issue = new Issue(getParameter(req, Integer.class, "id").orElseThrow(), project, component);
75
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
579 getParameter(req, String.class, "category").map(IssueCategory::valueOf).ifPresent(issue::setCategory);
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
580 getParameter(req, String.class, "status").map(IssueStatus::valueOf).ifPresent(issue::setStatus);
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
581 issue.setSubject(getParameter(req, String.class, "subject").orElseThrow());
136
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
582 getParameter(req, Integer.class, "assignee").map(userid -> {
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
583 if (userid >= 0) {
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
584 return new User(userid);
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
585 } else if (userid == -2) {
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
586 return Optional.ofNullable(component).map(Component::getLead).orElse(null);
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
587 } else {
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
588 return null;
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
589 }
7281bdf43c60 automatic assignment of component lead (if available) - fixes #28
Mike Becker <universe@uap-core.de>
parents: 134
diff changeset
590 }
75
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
591 ).ifPresent(issue::setAssignee);
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
592 getParameter(req, String.class, "description").ifPresent(issue::setDescription);
33b6843fdf8a adds the ability to create and edit issues
Mike Becker <universe@uap-core.de>
parents: 74
diff changeset
593 getParameter(req, Date.class, "eta").ifPresent(issue::setEta);
83
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
594
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
595 getParameter(req, Integer[].class, "affected")
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
596 .map(Stream::of)
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
597 .map(stream ->
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
598 stream.map(id -> new Version(id, project.getId()))
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
599 .collect(Collectors.toList())
83
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
600 ).ifPresent(issue::setAffectedVersions);
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
601 getParameter(req, Integer[].class, "resolved")
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
602 .map(Stream::of)
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
603 .map(stream ->
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
604 stream.map(id -> new Version(id, project.getId()))
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
605 .collect(Collectors.toList())
83
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
606 ).ifPresent(issue::setResolvedVersions);
24a3596b8f98 adds version selection in issue editor
Mike Becker <universe@uap-core.de>
parents: 81
diff changeset
607
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
608 if (issue.getId() > 0) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
609 dao.updateIssue(issue);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
610 } else {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
611 dao.insertIssue(issue);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
612 }
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
613
168
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
614 if (getParameter(req, Boolean.class, "create-another").orElse(false)) {
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
615 // TODO: fix #38 - automatically select component (and version)
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
616 setRedirectLocation(req, "./projects/" + issue.getProject().getNode() + "/create-issue?more=true");
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
617 } else{
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
618 setRedirectLocation(req, "./projects/" + issue.getProject().getNode() + "/issues/" + issue.getId() + "/view");
1c3694ae224c adds "Create another" checkbox to issue form - fixes #110
Mike Becker <universe@uap-core.de>
parents: 167
diff changeset
619 }
74
91d1fc2a3a14 removes that dynamic_fragment bullshit
Mike Becker <universe@uap-core.de>
parents: 71
diff changeset
620 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
621
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
622 renderSite(req, resp);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
623 } catch (NoSuchElementException | IllegalArgumentException ex) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
624 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
625 // TODO: implement - fix issue #21
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
626 }
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
627 }
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
628
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
629 @RequestMapping(requestPath = "commit-issue-comment", method = HttpMethod.POST)
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
630 public void commentIssue(HttpServletRequest req, HttpServletResponse resp, DataAccessObject dao) throws IOException, ServletException {
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
631 final var issueIdParam = getParameter(req, Integer.class, "issueid");
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
632 if (issueIdParam.isEmpty()) {
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
633 resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Detected manipulated form.");
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
634 return;
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
635 }
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
636 final var issue = dao.findIssue(issueIdParam.get());
137
a7e543ab0c5f fixes creation of redirect link when commenting an issue
Mike Becker <universe@uap-core.de>
parents: 136
diff changeset
637 if (issue == null) {
a7e543ab0c5f fixes creation of redirect link when commenting an issue
Mike Becker <universe@uap-core.de>
parents: 136
diff changeset
638 resp.sendError(HttpServletResponse.SC_NOT_FOUND);
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
639 return;
137
a7e543ab0c5f fixes creation of redirect link when commenting an issue
Mike Becker <universe@uap-core.de>
parents: 136
diff changeset
640 }
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
641 try {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
642 final var issueComment = new IssueComment(getParameter(req, Integer.class, "commentid").orElse(-1), issue.getId());
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
643 issueComment.setComment(getParameter(req, String.class, "comment").orElse(""));
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
644
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
645 if (issueComment.getComment().isBlank()) {
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
646 throw new IllegalArgumentException("comment.null");
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
647 }
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
648
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
649 LOG.debug("User {} is commenting on issue #{}", req.getRemoteUser(), issue.getId());
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
650 if (req.getRemoteUser() != null) {
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
651 Optional.ofNullable(dao.findUserByName(req.getRemoteUser())).ifPresent(issueComment::setAuthor);
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
652 }
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
653
167
3f30adba1c63 major refactoring of DAO architecture - also fixes #114
Mike Becker <universe@uap-core.de>
parents: 162
diff changeset
654 dao.insertComment(issueComment);
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
655
146
b0e83cab0bde adds issue detail view - fixes #24
Mike Becker <universe@uap-core.de>
parents: 141
diff changeset
656 setRedirectLocation(req, "./projects/" + issue.getProject().getNode()+"/issues/"+issue.getId()+"/view");
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
657 setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL);
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
658
157
1e6f16fad3a5 removes ResponseType enum
Mike Becker <universe@uap-core.de>
parents: 152
diff changeset
659 renderSite(req, resp);
159
86b5d8a1662f migrates DAO classes
mike@uapl01.localdomain
parents: 158
diff changeset
660 } catch (NoSuchElementException | IllegalArgumentException ex) {
131
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
661 resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
67df332e3146 changes request mapping to contain project and version ID as path parameters (this removes the session storage)
Mike Becker <universe@uap-core.de>
parents: 129
diff changeset
662 // TODO: implement - fix issue #21
124
ed2e7aef2a3e adds issue comments
Mike Becker <universe@uap-core.de>
parents: 121
diff changeset
663 }
64
0f1746c6abfb adds backend methods for issues (TODO: implement commitIssue())
Mike Becker <universe@uap-core.de>
parents: 61
diff changeset
664 }
41
4f1c026a8aab adds files for ProjectsModule
Mike Becker <universe@uap-core.de>
parents:
diff changeset
665 }

mercurial