fixes missing orElse() calls

Tue, 19 May 2020 16:50:05 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 19 May 2020 16:50:05 +0200
changeset 65
9861a68a4612
parent 64
0f1746c6abfb
child 66
635ae67e73b5

fixes missing orElse() calls

src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java file | annotate | diff | comparison | revisions
--- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Mon May 18 21:08:14 2020 +0200
+++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java	Tue May 19 16:50:05 2020 +0200
@@ -98,7 +98,8 @@
     public ResponseType edit(HttpServletRequest req, DataAccessObjects dao) throws SQLException {
         final var projectDao = dao.getProjectDao();
 
-        req.setAttribute("project", findByParameter(req, Integer.class, "id", projectDao::find));
+        req.setAttribute("project", findByParameter(req, Integer.class, "id",
+                projectDao::find).orElse(new Project(-1)));
         setDynamicFragment(req, "project-form");
 
         return ResponseType.HTML;
@@ -155,7 +156,8 @@
             return ResponseType.NONE;
         }
 
-        req.setAttribute("version", findByParameter(req, Integer.class, "id", dao.getVersionDao()::find));
+        req.setAttribute("version", findByParameter(req, Integer.class, "id",
+                dao.getVersionDao()::find).orElse(new Version(-1, selectedProject)));
         req.setAttribute("versionStatusEnum", VersionStatus.values());
 
         setDynamicFragment(req, "version-form");
@@ -217,7 +219,8 @@
             return ResponseType.NONE;
         }
 
-        req.setAttribute("issue", findByParameter(req, Integer.class, "id", dao.getIssueDao()::find));
+        req.setAttribute("issue", findByParameter(req, Integer.class, "id",
+                dao.getIssueDao()::find).orElse(new Issue(-1, selectedProject)));
         req.setAttribute("issueStatusEnum", IssueStatus.values());
         req.setAttribute("issueCategoryEnum", IssueCategory.values());
 

mercurial