From b43b04e37e2289677a094a8dcb329ac406df27c5 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Wed, 24 Apr 2019 23:19:17 +0200 Subject: [PATCH] Sonar fixes --- .../vaadinclubhelper/data/Person.java | 31 +++++++++++------ .../ui/navigation/HeadView.java | 33 +++++++++++-------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java index af6bdf9..3fb2aa0 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java @@ -35,6 +35,7 @@ public class Person extends BaseEntity implements Serializable { public static final String SESSION_LOGIN = "SESSION_LOGIN_USER"; public static final String QUERY_FINDALL = "Person.findAll"; + public static final String QUERY_FINDLOGIN = "Person.findLogin"; private static final long serialVersionUID = -8361264400619997123L; @@ -42,9 +43,11 @@ public class Person extends BaseEntity implements Serializable { private LocalDate birth; private String prename; + private String surname; private String username; + private String password; private Integer gender; @@ -131,7 +134,8 @@ public class Person extends BaseEntity implements Serializable { public void setGender(Gender gender) { if (gender == null) { this.gender = null; - } else { + } + else { this.gender = gender.getId(); } } @@ -252,7 +256,8 @@ public class Person extends BaseEntity implements Serializable { public void setPersongroups(Collection persongroups) { if (persongroups instanceof Set) { this.groups = (Set) persongroups; - } else { + } + else { this.groups = new HashSet<>(persongroups); } } @@ -265,7 +270,7 @@ public class Person extends BaseEntity implements Serializable { } public void removePersongroup(GroupDef persongroup) { - if (this.groups == null) { + if (this.groups != null) { this.groups.remove(persongroup); } } @@ -362,42 +367,48 @@ public class Person extends BaseEntity implements Serializable { if (other.birth != null) { return false; } - } else if (!birth.equals(other.birth)) { + } + else if (!birth.equals(other.birth)) { return false; } if (groups == null) { if (other.groups != null) { return false; } - } else if (!groups.equals(other.groups)) { + } + else if (!groups.equals(other.groups)) { return false; } if (password == null) { if (other.password != null) { return false; } - } else if (!password.equals(other.password)) { + } + else if (!password.equals(other.password)) { return false; } if (prename == null) { if (other.prename != null) { return false; } - } else if (!prename.equals(other.prename)) { + } + else if (!prename.equals(other.prename)) { return false; } if (surname == null) { if (other.surname != null) { return false; } - } else if (!surname.equals(other.surname)) { + } + else if (!surname.equals(other.surname)) { return false; } if (username == null) { if (other.username != null) { return false; } - } else if (!username.equals(other.username)) { + } + else if (!username.equals(other.username)) { return false; } return true; @@ -408,4 +419,4 @@ public class Person extends BaseEntity implements Serializable { return "Person [id=" + getId() + ", prename=" + prename + ", surname=" + surname + "]"; } -} \ No newline at end of file +} diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java index 5c05760..54c66ea 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.java @@ -233,7 +233,7 @@ public class HeadView extends HorizontalLayout { private AbstractComponent createEmbedded(String title, JasperPrint print) throws IOException { - PipedInputStream in = new PipedInputStream(); + final PipedInputStream in = new PipedInputStream(); final PipedOutputStream out = new PipedOutputStream(in); final StreamResource resource = new StreamResource(() -> in, title); @@ -243,23 +243,28 @@ public class HeadView extends HorizontalLayout { c.setSizeFull(); ExecutorService exec = Executors.newSingleThreadExecutor(); - exec.execute(() -> { - try { - JasperExportManager.exportReportToPdfStream(print, out); - } - catch (JRException e) { - log.error("Error on Export to Pdf.", e); - throw new RuntimeException(e); - } - finally { + try { + exec.execute(() -> { try { - out.close(); + JasperExportManager.exportReportToPdfStream(print, out); + } + catch (JRException e) { + throw new RuntimeException("Error on Export to Pdf.", e); } - catch (IOException e) { - log.warn("Error closing Jasper output stream.", e); + finally { } + }); + } + finally { + try { + out.close(); + in.close(); + } + catch (IOException e) { + log.warn("Error closing Jasper output stream.", e); } - }); + + } exec.shutdown(); return c; }