diff -r 6105ee2cceaf -r 947d0f6a6a83 src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java --- a/src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java Thu Oct 15 12:27:05 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/dao/postgres/PGIssueDao.java Thu Oct 15 13:31:52 2020 +0200 @@ -120,20 +120,6 @@ ); } - private User obtainUser(ResultSet result) throws SQLException { - final int id = result.getInt("userid"); - if (id != 0) { - final var user = new User(id); - user.setUsername(result.getString("username")); - user.setGivenname(result.getString("givenname")); - user.setLastname(result.getString("lastname")); - user.setMail(result.getString("mail")); - return user; - } else { - return null; - } - } - private Issue mapColumns(ResultSet result) throws SQLException { final var project = new Project(result.getInt("project")); project.setName(result.getString("projectname")); @@ -143,7 +129,7 @@ issue.setCategory(IssueCategory.valueOf(result.getString("category"))); issue.setSubject(result.getString("subject")); issue.setDescription(result.getString("description")); - issue.setAssignee(obtainUser(result)); + issue.setAssignee(PGUserDao.mapColumns(result)); issue.setCreated(result.getTimestamp("created")); issue.setUpdated(result.getTimestamp("updated")); issue.setEta(result.getDate("eta")); @@ -176,9 +162,9 @@ } @Override - public void save(Issue instance) throws SQLException { + public void save(Issue instance, Project project) throws SQLException { Objects.requireNonNull(instance.getSubject()); - Objects.requireNonNull(instance.getProject()); + instance.setProject(project); insert.setInt(1, instance.getProject().getId()); insert.setString(2, instance.getStatus().name()); insert.setString(3, instance.getCategory().name()); @@ -275,7 +261,7 @@ comment.setUpdated(result.getTimestamp("updated")); comment.setUpdateCount(result.getInt("updatecount")); comment.setComment(result.getString("comment")); - comment.setAuthor(obtainUser(result)); + comment.setAuthor(PGUserDao.mapColumns(result)); comments.add(comment); } }