Sonar fixes

master
Markus Kreth 7 years ago
parent 99cc213ef1
commit b43b04e37e
  1. 29
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Person.java
  2. 13
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/navigation/HeadView.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 SESSION_LOGIN = "SESSION_LOGIN_USER";
public static final String QUERY_FINDALL = "Person.findAll"; public static final String QUERY_FINDALL = "Person.findAll";
public static final String QUERY_FINDLOGIN = "Person.findLogin"; public static final String QUERY_FINDLOGIN = "Person.findLogin";
private static final long serialVersionUID = -8361264400619997123L; private static final long serialVersionUID = -8361264400619997123L;
@ -42,9 +43,11 @@ public class Person extends BaseEntity implements Serializable {
private LocalDate birth; private LocalDate birth;
private String prename; private String prename;
private String surname; private String surname;
private String username; private String username;
private String password; private String password;
private Integer gender; private Integer gender;
@ -131,7 +134,8 @@ public class Person extends BaseEntity implements Serializable {
public void setGender(Gender gender) { public void setGender(Gender gender) {
if (gender == null) { if (gender == null) {
this.gender = null; this.gender = null;
} else { }
else {
this.gender = gender.getId(); this.gender = gender.getId();
} }
} }
@ -252,7 +256,8 @@ public class Person extends BaseEntity implements Serializable {
public void setPersongroups(Collection<GroupDef> persongroups) { public void setPersongroups(Collection<GroupDef> persongroups) {
if (persongroups instanceof Set) { if (persongroups instanceof Set) {
this.groups = (Set<GroupDef>) persongroups; this.groups = (Set<GroupDef>) persongroups;
} else { }
else {
this.groups = new HashSet<>(persongroups); this.groups = new HashSet<>(persongroups);
} }
} }
@ -265,7 +270,7 @@ public class Person extends BaseEntity implements Serializable {
} }
public void removePersongroup(GroupDef persongroup) { public void removePersongroup(GroupDef persongroup) {
if (this.groups == null) { if (this.groups != null) {
this.groups.remove(persongroup); this.groups.remove(persongroup);
} }
} }
@ -362,42 +367,48 @@ public class Person extends BaseEntity implements Serializable {
if (other.birth != null) { if (other.birth != null) {
return false; return false;
} }
} else if (!birth.equals(other.birth)) { }
else if (!birth.equals(other.birth)) {
return false; return false;
} }
if (groups == null) { if (groups == null) {
if (other.groups != null) { if (other.groups != null) {
return false; return false;
} }
} else if (!groups.equals(other.groups)) { }
else if (!groups.equals(other.groups)) {
return false; return false;
} }
if (password == null) { if (password == null) {
if (other.password != null) { if (other.password != null) {
return false; return false;
} }
} else if (!password.equals(other.password)) { }
else if (!password.equals(other.password)) {
return false; return false;
} }
if (prename == null) { if (prename == null) {
if (other.prename != null) { if (other.prename != null) {
return false; return false;
} }
} else if (!prename.equals(other.prename)) { }
else if (!prename.equals(other.prename)) {
return false; return false;
} }
if (surname == null) { if (surname == null) {
if (other.surname != null) { if (other.surname != null) {
return false; return false;
} }
} else if (!surname.equals(other.surname)) { }
else if (!surname.equals(other.surname)) {
return false; return false;
} }
if (username == null) { if (username == null) {
if (other.username != null) { if (other.username != null) {
return false; return false;
} }
} else if (!username.equals(other.username)) { }
else if (!username.equals(other.username)) {
return false; return false;
} }
return true; return true;

@ -233,7 +233,7 @@ public class HeadView extends HorizontalLayout {
private AbstractComponent createEmbedded(String title, JasperPrint print) throws IOException { 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 PipedOutputStream out = new PipedOutputStream(in);
final StreamResource resource = new StreamResource(() -> in, title); final StreamResource resource = new StreamResource(() -> in, title);
@ -243,23 +243,28 @@ public class HeadView extends HorizontalLayout {
c.setSizeFull(); c.setSizeFull();
ExecutorService exec = Executors.newSingleThreadExecutor(); ExecutorService exec = Executors.newSingleThreadExecutor();
try {
exec.execute(() -> { exec.execute(() -> {
try { try {
JasperExportManager.exportReportToPdfStream(print, out); JasperExportManager.exportReportToPdfStream(print, out);
} }
catch (JRException e) { catch (JRException e) {
log.error("Error on Export to Pdf.", e); throw new RuntimeException("Error on Export to Pdf.", e);
throw new RuntimeException(e); }
finally {
}
});
} }
finally { finally {
try { try {
out.close(); out.close();
in.close();
} }
catch (IOException e) { catch (IOException e) {
log.warn("Error closing Jasper output stream.", e); log.warn("Error closing Jasper output stream.", e);
} }
} }
});
exec.shutdown(); exec.shutdown();
return c; return c;
} }

Loading…
Cancel
Save