From 3943e3a2281e89e296e62785070c2435500ecc39 Mon Sep 17 00:00:00 2001 From: Markus Kreth Date: Mon, 3 Sep 2018 23:47:32 +0200 Subject: [PATCH] PersonEditDialog with birtday --- pom.xml | 390 +++++----- src/main/java/META-INF/persistence.xml | 50 +- .../vaadinclubhelper/data/GroupDef.java | 302 ++++---- .../vaadinclubhelper/data/Person.java | 728 +++++++++--------- .../vaadinclubhelper/data/Persongroup.java | 260 +++---- .../vaadinclubhelper/data/Relative.java | 330 ++++---- .../vaadinclubhelper/data/Startpaesse.java | 322 ++++---- .../vaadinclubhelper/ui/MainUi.java | 250 +++--- .../ui/components/PersonEditDialog.java | 13 +- .../ui/components/PersonGrid.java | 438 +++++------ src/main/resources/hibernate.cfg.xml | 44 +- src/main/resources/schema/ClubEvent.hbm.xml | 72 +- .../dao/ClubEventDataTest.java | 338 ++++---- 13 files changed, 1773 insertions(+), 1764 deletions(-) diff --git a/pom.xml b/pom.xml index 08323dc..943e87b 100644 --- a/pom.xml +++ b/pom.xml @@ -1,195 +1,195 @@ - - - 4.0.0 - - de.kreth.vaadin.clubhelper - vaadin-clubhelper - 0.0.1-SNAPSHOT - war - - vaadin-clubhelper - Demo project for Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 2.0.3.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - 8.4.4 - 1.23.0 - v4-rev488-1.23.0 - v3-rev271-1.23.0 - - - - - org.springframework.boot - spring-boot-starter-jdbc - - - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - - - com.vaadin - vaadin-spring-boot-starter - - - com.vaadin - vaadin-push - - - org.vaadin.teemu - switch - 3.0.0 - - - org.hibernate - hibernate-core - - - mysql - mysql-connector-java - - - - org.vaadin.blackbluegl - calendar-component - 2.0-BETA4 - - - - com.google.apis - google-api-services-calendar - ${google-api-calendar-version} - - - com.google.api-client - google-api-client-appengine - ${google-api-version} - - - com.google.api-client - google-api-client-gson - ${google-api-version} - - - com.google.oauth-client - google-oauth-client-java6 - ${google-api-version} - - - com.google.oauth-client - google-oauth-client-jetty - ${google-api-version} - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - - - com.h2database - h2 - test - - - commons-io - commons-io - 2.6 - - - org.hibernate - hibernate-testing - test - - - org.hibernate - hibernate-entitymanager - test - - - org.slf4j - slf4j-simple - - - - - - - com.vaadin - vaadin-bom - ${vaadin.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - com.vaadin - vaadin-maven-plugin - ${vaadin.version} - - - - update-theme - update-widgetset - compile - - compile-theme - - - - - true - - - - - - - - vaadin-addons - http://maven.vaadin.com/vaadin-addons - - - - + + + 4.0.0 + + de.kreth.vaadin.clubhelper + vaadin-clubhelper + 0.0.1-SNAPSHOT + war + + vaadin-clubhelper + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.3.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 8.4.4 + 1.23.0 + v4-rev488-1.23.0 + v3-rev271-1.23.0 + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + com.vaadin + vaadin-spring-boot-starter + + + com.vaadin + vaadin-push + + + org.vaadin.teemu + switch + 3.0.0 + + + org.vaadin.blackbluegl + calendar-component + 2.0-BETA4 + + + + org.hibernate + hibernate-core + + + mysql + mysql-connector-java + + + + com.google.apis + google-api-services-calendar + ${google-api-calendar-version} + + + com.google.api-client + google-api-client-appengine + ${google-api-version} + + + com.google.api-client + google-api-client-gson + ${google-api-version} + + + com.google.oauth-client + google-oauth-client-java6 + ${google-api-version} + + + com.google.oauth-client + google-oauth-client-jetty + ${google-api-version} + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + com.h2database + h2 + test + + + commons-io + commons-io + 2.6 + + + org.hibernate + hibernate-testing + test + + + org.hibernate + hibernate-entitymanager + test + + + org.slf4j + slf4j-simple + + + + + + + com.vaadin + vaadin-bom + ${vaadin.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + com.vaadin + vaadin-maven-plugin + ${vaadin.version} + + + + update-theme + update-widgetset + compile + + compile-theme + + + + + true + + + + + + + + vaadin-addons + http://maven.vaadin.com/vaadin-addons + + + + diff --git a/src/main/java/META-INF/persistence.xml b/src/main/java/META-INF/persistence.xml index 0c77216..a5e3420 100644 --- a/src/main/java/META-INF/persistence.xml +++ b/src/main/java/META-INF/persistence.xml @@ -1,25 +1,25 @@ - - - - org.hibernate.ejb.HibernatePersistence - schema/ClubEvent.hbm.xml - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte - de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version - - - - - - - - - + + + + org.hibernate.ejb.HibernatePersistence + schema/ClubEvent.hbm.xml + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Attendance + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.DeletedEntry + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Persongroup + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relative + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Startpaesse + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.StartpassStartrechte + de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Version + + + + + + + + + diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/GroupDef.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/GroupDef.java index 4c227ce..bddfbdf 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/GroupDef.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/GroupDef.java @@ -1,152 +1,152 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -/** - * The persistent class for the groupDef database table. - * - */ -@Entity(name = "groupDef") -@Table(name = "groupDef") -@NamedQuery(name = GroupDef.QUERY_FINDALL, query = "SELECT g FROM groupDef g") -public class GroupDef implements Serializable { - - public final static String QUERY_FINDALL = "GroupDef.findAll"; - - private static final long serialVersionUID = -2827542956463449518L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private int id; - - @Temporal(TemporalType.TIMESTAMP) - private Date changed; - - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @Temporal(TemporalType.TIMESTAMP) - private Date deleted; - - private String name; - - @ManyToMany(fetch=FetchType.LAZY) - @JoinTable (name = "persongroup", - joinColumns = { @JoinColumn(name = "group_id") }, - inverseJoinColumns = { @JoinColumn(name = "person_id") }) - private List persongroups; - - public GroupDef() { - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public Date getChanged() { - return this.changed; - } - - public void setChanged(Date changed) { - this.changed = changed; - } - - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public Date getDeleted() { - return this.deleted; - } - - public void setDeleted(Date deleted) { - this.deleted = deleted; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public List getPersongroups() { - return this.persongroups; - } - - public void setPersongroups(List persongroups) { - this.persongroups = persongroups; - } - - public Persongroup addPersongroup(Persongroup persongroup) { - getPersongroups().add(persongroup); - persongroup.setGroupDef(this); - - return persongroup; - } - - public Persongroup removePersongroup(Persongroup persongroup) { - getPersongroups().remove(persongroup); - persongroup.setGroupDef(null); - - return persongroup; - } - - @Override - public String toString() { - return "GroupDef [id=" + id + ", name=" + name + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - GroupDef other = (GroupDef) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/** + * The persistent class for the groupDef database table. + * + */ +@Entity(name = "groupDef") +@Table(name = "groupDef") +@NamedQuery(name = GroupDef.QUERY_FINDALL, query = "SELECT g FROM groupDef g") +public class GroupDef implements Serializable { + + public final static String QUERY_FINDALL = "GroupDef.findAll"; + + private static final long serialVersionUID = -2827542956463449518L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Temporal(TemporalType.TIMESTAMP) + private Date changed; + + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleted; + + private String name; + + @ManyToMany(fetch=FetchType.LAZY) + @JoinTable (name = "persongroup", + joinColumns = { @JoinColumn(name = "group_id") }, + inverseJoinColumns = { @JoinColumn(name = "person_id") }) + private List persongroups; + + public GroupDef() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getChanged() { + return this.changed; + } + + public void setChanged(Date changed) { + this.changed = changed; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getDeleted() { + return this.deleted; + } + + public void setDeleted(Date deleted) { + this.deleted = deleted; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public List getPersongroups() { + return this.persongroups; + } + + public void setPersongroups(List persongroups) { + this.persongroups = persongroups; + } + + public Persongroup addPersongroup(Persongroup persongroup) { + getPersongroups().add(persongroup); + persongroup.setGroupDef(this); + + return persongroup; + } + + public Persongroup removePersongroup(Persongroup persongroup) { + getPersongroups().remove(persongroup); + persongroup.setGroupDef(null); + + return persongroup; + } + + @Override + public String toString() { + return "GroupDef [id=" + id + ", name=" + name + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + GroupDef other = (GroupDef) obj; + if (id != other.id) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + } \ No newline at end of file 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 d045eae..36ab5e8 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 @@ -1,365 +1,365 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; -import java.util.Set; - -import javax.persistence.*; - -/** - * The persistent class for the person database table. - * - */ -@Entity -@Table(name = "person") -@NamedQuery(name = Person.QUERY_FINDALL, query = "SELECT p FROM Person p") -public class Person implements Serializable { - - public final static String QUERY_FINDALL = "Person.findAll"; - - private static final long serialVersionUID = -8361264400619997123L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private int id; - - @Temporal(TemporalType.TIMESTAMP) - private Date birth; - - @Temporal(TemporalType.TIMESTAMP) - private Date changed; - - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @Temporal(TemporalType.TIMESTAMP) - private Date deleted; - - private String password; - - private String prename; - - private String surname; - - private String username; - - // bi-directional many-to-one association to Adress - @OneToMany(mappedBy = "person") - private List adresses; - - // bi-directional many-to-one association to Attendance - @OneToMany(mappedBy = "person") - private List attendances; - - // bi-directional many-to-one association to Contact - @OneToMany(mappedBy = "person") - private List contacts; - - // bi-directional many-to-many association to Persongroup - @ManyToMany(fetch=FetchType.EAGER) - @JoinTable (name = "persongroup", - joinColumns = { @JoinColumn(name = "person_id") }, - inverseJoinColumns = { @JoinColumn(name = "group_id") }) - private List groups; - - // bi-directional many-to-one association to Relative - @OneToMany(mappedBy = "person1Bean") - private List relatives1; - - // bi-directional many-to-one association to Relative - @OneToMany(mappedBy = "person2Bean") - private List relatives2; - - // bi-directional many-to-one association to Startpaesse - @OneToMany(mappedBy = "person") - private List startpaesses; - - @ManyToMany(cascade = { CascadeType.MERGE, CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.DETACH }, fetch = FetchType.LAZY) - @JoinTable( - name = "clubevent_has_person", - joinColumns = { @JoinColumn(name = "person_id") }, - inverseJoinColumns = { @JoinColumn(name = "clubevent_id") } - ) - private Set events; - - public Person() { - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public Date getBirth() { - return this.birth; - } - - public void setBirth(Date birth) { - this.birth = birth; - } - - public Date getChanged() { - return this.changed; - } - - public void setChanged(Date changed) { - this.changed = changed; - } - - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public Date getDeleted() { - return this.deleted; - } - - public void setDeleted(Date deleted) { - this.deleted = deleted; - } - - public String getPassword() { - return this.password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getPrename() { - return this.prename; - } - - public void setPrename(String prename) { - this.prename = prename; - } - - public String getSurname() { - return this.surname; - } - - public void setSurname(String surname) { - this.surname = surname; - } - - public String getUsername() { - return this.username; - } - - public void setUsername(String username) { - this.username = username; - } - - public List getAdresses() { - return this.adresses; - } - - public void setAdresses(List adresses) { - this.adresses = adresses; - } - - public Adress addAdress(Adress adress) { - getAdresses().add(adress); - adress.setPerson(this); - - return adress; - } - - public Adress removeAdress(Adress adress) { - getAdresses().remove(adress); - adress.setPerson(null); - - return adress; - } - - public List getAttendances() { - return this.attendances; - } - - public void setAttendances(List attendances) { - this.attendances = attendances; - } - - public Attendance addAttendance(Attendance attendance) { - getAttendances().add(attendance); - attendance.setPerson(this); - - return attendance; - } - - public Attendance removeAttendance(Attendance attendance) { - getAttendances().remove(attendance); - attendance.setPerson(null); - - return attendance; - } - - public List getContacts() { - return this.contacts; - } - - public void setContacts(List contacts) { - this.contacts = contacts; - } - - public Contact addContact(Contact contact) { - getContacts().add(contact); - contact.setPerson(this); - - return contact; - } - - public Contact removeContact(Contact contact) { - getContacts().remove(contact); - contact.setPerson(null); - - return contact; - } - - public List getPersongroups() { - return this.groups; - } - - public void setPersongroups(List persongroups) { - this.groups = persongroups; - } - - public void addPersongroup(GroupDef persongroup) { - getPersongroups().add(persongroup); - } - - public void removePersongroup(GroupDef persongroup) { - getPersongroups().remove(persongroup); - } - - public List getRelatives1() { - return this.relatives1; - } - - public void setRelatives1(List relatives1) { - this.relatives1 = relatives1; - } - - public Relative addRelatives1(Relative relatives1) { - getRelatives1().add(relatives1); - relatives1.setPerson1Bean(this); - - return relatives1; - } - - public Relative removeRelatives1(Relative relatives1) { - getRelatives1().remove(relatives1); - relatives1.setPerson1Bean(null); - - return relatives1; - } - - public List getRelatives2() { - return this.relatives2; - } - - public void setRelatives2(List relatives2) { - this.relatives2 = relatives2; - } - - public Relative addRelatives2(Relative relatives2) { - getRelatives2().add(relatives2); - relatives2.setPerson2Bean(this); - - return relatives2; - } - - public Relative removeRelatives2(Relative relatives2) { - getRelatives2().remove(relatives2); - relatives2.setPerson2Bean(null); - - return relatives2; - } - - public List getStartpaesses() { - return this.startpaesses; - } - - public void setStartpaesses(List startpaesses) { - this.startpaesses = startpaesses; - } - - public Startpaesse addStartpaess(Startpaesse startpaess) { - getStartpaesses().add(startpaess); - startpaess.setPerson(this); - - return startpaess; - } - - public Startpaesse removeStartpaess(Startpaesse startpaess) { - getStartpaesses().remove(startpaess); - startpaess.setPerson(null); - return startpaess; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); - result = prime * result + id; - result = prime * result + ((prename == null) ? 0 : prename.hashCode()); - result = prime * result + ((surname == null) ? 0 : surname.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Person other = (Person) obj; - if (created == null) { - if (other.created != null) - return false; - } else if (!created.equals(other.created)) - return false; - if (deleted == null) { - if (other.deleted != null) - return false; - } else if (!deleted.equals(other.deleted)) - return false; - if (id != other.id) - return false; - if (prename == null) { - if (other.prename != null) - return false; - } else if (!prename.equals(other.prename)) - return false; - if (surname == null) { - if (other.surname != null) - return false; - } else if (!surname.equals(other.surname)) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; - } - - @Override - public String toString() { - return "Person [id=" + id + ", prename=" + prename + ", surname=" + surname + "]"; - } - +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import javax.persistence.*; + +/** + * The persistent class for the person database table. + * + */ +@Entity +@Table(name = "person") +@NamedQuery(name = Person.QUERY_FINDALL, query = "SELECT p FROM Person p") +public class Person implements Serializable { + + public final static String QUERY_FINDALL = "Person.findAll"; + + private static final long serialVersionUID = -8361264400619997123L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + @Temporal(TemporalType.TIMESTAMP) + private Date birth; + + @Temporal(TemporalType.TIMESTAMP) + private Date changed; + + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleted; + + private String password; + + private String prename; + + private String surname; + + private String username; + + // bi-directional many-to-one association to Adress + @OneToMany(mappedBy = "person") + private List adresses; + + // bi-directional many-to-one association to Attendance + @OneToMany(mappedBy = "person") + private List attendances; + + // bi-directional many-to-one association to Contact + @OneToMany(mappedBy = "person") + private List contacts; + + // bi-directional many-to-many association to Persongroup + @ManyToMany(fetch=FetchType.EAGER) + @JoinTable (name = "persongroup", + joinColumns = { @JoinColumn(name = "person_id") }, + inverseJoinColumns = { @JoinColumn(name = "group_id") }) + private List groups; + + // bi-directional many-to-one association to Relative + @OneToMany(mappedBy = "person1Bean") + private List relatives1; + + // bi-directional many-to-one association to Relative + @OneToMany(mappedBy = "person2Bean") + private List relatives2; + + // bi-directional many-to-one association to Startpaesse + @OneToMany(mappedBy = "person") + private List startpaesses; + + @ManyToMany(cascade = { CascadeType.MERGE, CascadeType.REFRESH, CascadeType.REMOVE, CascadeType.DETACH }, fetch = FetchType.LAZY) + @JoinTable( + name = "clubevent_has_person", + joinColumns = { @JoinColumn(name = "person_id") }, + inverseJoinColumns = { @JoinColumn(name = "clubevent_id") } + ) + private Set events; + + public Person() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getBirth() { + return this.birth; + } + + public void setBirth(Date birth) { + this.birth = birth; + } + + public Date getChanged() { + return this.changed; + } + + public void setChanged(Date changed) { + this.changed = changed; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getDeleted() { + return this.deleted; + } + + public void setDeleted(Date deleted) { + this.deleted = deleted; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPrename() { + return this.prename; + } + + public void setPrename(String prename) { + this.prename = prename; + } + + public String getSurname() { + return this.surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public List getAdresses() { + return this.adresses; + } + + public void setAdresses(List adresses) { + this.adresses = adresses; + } + + public Adress addAdress(Adress adress) { + getAdresses().add(adress); + adress.setPerson(this); + + return adress; + } + + public Adress removeAdress(Adress adress) { + getAdresses().remove(adress); + adress.setPerson(null); + + return adress; + } + + public List getAttendances() { + return this.attendances; + } + + public void setAttendances(List attendances) { + this.attendances = attendances; + } + + public Attendance addAttendance(Attendance attendance) { + getAttendances().add(attendance); + attendance.setPerson(this); + + return attendance; + } + + public Attendance removeAttendance(Attendance attendance) { + getAttendances().remove(attendance); + attendance.setPerson(null); + + return attendance; + } + + public List getContacts() { + return this.contacts; + } + + public void setContacts(List contacts) { + this.contacts = contacts; + } + + public Contact addContact(Contact contact) { + getContacts().add(contact); + contact.setPerson(this); + + return contact; + } + + public Contact removeContact(Contact contact) { + getContacts().remove(contact); + contact.setPerson(null); + + return contact; + } + + public List getPersongroups() { + return this.groups; + } + + public void setPersongroups(List persongroups) { + this.groups = persongroups; + } + + public void addPersongroup(GroupDef persongroup) { + getPersongroups().add(persongroup); + } + + public void removePersongroup(GroupDef persongroup) { + getPersongroups().remove(persongroup); + } + + public List getRelatives1() { + return this.relatives1; + } + + public void setRelatives1(List relatives1) { + this.relatives1 = relatives1; + } + + public Relative addRelatives1(Relative relatives1) { + getRelatives1().add(relatives1); + relatives1.setPerson1Bean(this); + + return relatives1; + } + + public Relative removeRelatives1(Relative relatives1) { + getRelatives1().remove(relatives1); + relatives1.setPerson1Bean(null); + + return relatives1; + } + + public List getRelatives2() { + return this.relatives2; + } + + public void setRelatives2(List relatives2) { + this.relatives2 = relatives2; + } + + public Relative addRelatives2(Relative relatives2) { + getRelatives2().add(relatives2); + relatives2.setPerson2Bean(this); + + return relatives2; + } + + public Relative removeRelatives2(Relative relatives2) { + getRelatives2().remove(relatives2); + relatives2.setPerson2Bean(null); + + return relatives2; + } + + public List getStartpaesses() { + return this.startpaesses; + } + + public void setStartpaesses(List startpaesses) { + this.startpaesses = startpaesses; + } + + public Startpaesse addStartpaess(Startpaesse startpaess) { + getStartpaesses().add(startpaess); + startpaess.setPerson(this); + + return startpaess; + } + + public Startpaesse removeStartpaess(Startpaesse startpaess) { + getStartpaesses().remove(startpaess); + startpaess.setPerson(null); + return startpaess; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((created == null) ? 0 : created.hashCode()); + result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); + result = prime * result + id; + result = prime * result + ((prename == null) ? 0 : prename.hashCode()); + result = prime * result + ((surname == null) ? 0 : surname.hashCode()); + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Person other = (Person) obj; + if (created == null) { + if (other.created != null) + return false; + } else if (!created.equals(other.created)) + return false; + if (deleted == null) { + if (other.deleted != null) + return false; + } else if (!deleted.equals(other.deleted)) + return false; + if (id != other.id) + return false; + if (prename == null) { + if (other.prename != null) + return false; + } else if (!prename.equals(other.prename)) + return false; + if (surname == null) { + if (other.surname != null) + return false; + } else if (!surname.equals(other.surname)) + return false; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + + @Override + public String toString() { + return "Person [id=" + id + ", prename=" + prename + ", surname=" + surname + "]"; + } + } \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Persongroup.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Persongroup.java index 4466b8d..ca308cb 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Persongroup.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Persongroup.java @@ -1,131 +1,131 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; - -import java.io.Serializable; -import javax.persistence.*; -import java.util.Date; - - -/** - * The persistent class for the persongroup database table. - * - */ -@Entity -@Table(name="persongroup") -@NamedQuery(name="Persongroup.findAll", query="SELECT p FROM Persongroup p") -public class Persongroup implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private int id; - - @Temporal(TemporalType.TIMESTAMP) - private Date changed; - - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @Temporal(TemporalType.TIMESTAMP) - private Date deleted; - - //bi-directional many-to-one association to Person - @ManyToOne - private Person person; - - //bi-directional many-to-one association to GroupDef - @ManyToOne - @JoinColumn(name="group_id") - private GroupDef groupDef; - - public Persongroup() { - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public Date getChanged() { - return this.changed; - } - - public void setChanged(Date changed) { - this.changed = changed; - } - - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public Date getDeleted() { - return this.deleted; - } - - public void setDeleted(Date deleted) { - this.deleted = deleted; - } - - public Person getPerson() { - return this.person; - } - - public void setPerson(Person person) { - this.person = person; - } - - public GroupDef getGroupDef() { - return this.groupDef; - } - - public void setGroupDef(GroupDef groupDef) { - this.groupDef = groupDef; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); - result = prime * result + ((groupDef == null) ? 0 : groupDef.hashCode()); - result = prime * result + id; - result = prime * result + ((person == null) ? 0 : person.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Persongroup other = (Persongroup) obj; - if (deleted == null) { - if (other.deleted != null) - return false; - } else if (!deleted.equals(other.deleted)) - return false; - if (groupDef == null) { - if (other.groupDef != null) - return false; - } else if (!groupDef.equals(other.groupDef)) - return false; - if (id != other.id) - return false; - if (person == null) { - if (other.person != null) - return false; - } else if (!person.equals(other.person)) - return false; - return true; - } - +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import java.io.Serializable; +import javax.persistence.*; +import java.util.Date; + + +/** + * The persistent class for the persongroup database table. + * + */ +@Entity +@Table(name="persongroup") +@NamedQuery(name="Persongroup.findAll", query="SELECT p FROM Persongroup p") +public class Persongroup implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private int id; + + @Temporal(TemporalType.TIMESTAMP) + private Date changed; + + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleted; + + //bi-directional many-to-one association to Person + @ManyToOne + private Person person; + + //bi-directional many-to-one association to GroupDef + @ManyToOne + @JoinColumn(name="group_id") + private GroupDef groupDef; + + public Persongroup() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getChanged() { + return this.changed; + } + + public void setChanged(Date changed) { + this.changed = changed; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getDeleted() { + return this.deleted; + } + + public void setDeleted(Date deleted) { + this.deleted = deleted; + } + + public Person getPerson() { + return this.person; + } + + public void setPerson(Person person) { + this.person = person; + } + + public GroupDef getGroupDef() { + return this.groupDef; + } + + public void setGroupDef(GroupDef groupDef) { + this.groupDef = groupDef; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); + result = prime * result + ((groupDef == null) ? 0 : groupDef.hashCode()); + result = prime * result + id; + result = prime * result + ((person == null) ? 0 : person.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Persongroup other = (Persongroup) obj; + if (deleted == null) { + if (other.deleted != null) + return false; + } else if (!deleted.equals(other.deleted)) + return false; + if (groupDef == null) { + if (other.groupDef != null) + return false; + } else if (!groupDef.equals(other.groupDef)) + return false; + if (id != other.id) + return false; + if (person == null) { + if (other.person != null) + return false; + } else if (!person.equals(other.person)) + return false; + return true; + } + } \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Relative.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Relative.java index a241982..56e37f2 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Relative.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Relative.java @@ -1,166 +1,166 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; - -import java.io.Serializable; -import javax.persistence.*; -import java.util.Date; - - -/** - * The persistent class for the relative database table. - * - */ -@Entity -@Table(name="relative") -@NamedQuery(name="Relative.findAll", query="SELECT r FROM Relative r") -public class Relative implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private int id; - - @Temporal(TemporalType.TIMESTAMP) - private Date changed; - - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @Temporal(TemporalType.TIMESTAMP) - private Date deleted; - - @Column(name="TO_PERSON1_RELATION") - private String toPerson1Relation; - - @Column(name="TO_PERSON2_RELATION") - private String toPerson2Relation; - - //bi-directional many-to-one association to Person - @ManyToOne - @JoinColumn(name="person1") - private Person person1Bean; - - //bi-directional many-to-one association to Person - @ManyToOne - @JoinColumn(name="person2") - private Person person2Bean; - - public Relative() { - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public Date getChanged() { - return this.changed; - } - - public void setChanged(Date changed) { - this.changed = changed; - } - - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public Date getDeleted() { - return this.deleted; - } - - public void setDeleted(Date deleted) { - this.deleted = deleted; - } - - public String getToPerson1Relation() { - return this.toPerson1Relation; - } - - public void setToPerson1Relation(String toPerson1Relation) { - this.toPerson1Relation = toPerson1Relation; - } - - public String getToPerson2Relation() { - return this.toPerson2Relation; - } - - public void setToPerson2Relation(String toPerson2Relation) { - this.toPerson2Relation = toPerson2Relation; - } - - public Person getPerson1Bean() { - return this.person1Bean; - } - - public void setPerson1Bean(Person person1Bean) { - this.person1Bean = person1Bean; - } - - public Person getPerson2Bean() { - return this.person2Bean; - } - - public void setPerson2Bean(Person person2Bean) { - this.person2Bean = person2Bean; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); - result = prime * result + id; - result = prime * result + ((person1Bean == null) ? 0 : person1Bean.hashCode()); - result = prime * result + ((person2Bean == null) ? 0 : person2Bean.hashCode()); - result = prime * result + ((toPerson1Relation == null) ? 0 : toPerson1Relation.hashCode()); - result = prime * result + ((toPerson2Relation == null) ? 0 : toPerson2Relation.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Relative other = (Relative) obj; - if (deleted == null) { - if (other.deleted != null) - return false; - } else if (!deleted.equals(other.deleted)) - return false; - if (id != other.id) - return false; - if (person1Bean == null) { - if (other.person1Bean != null) - return false; - } else if (!person1Bean.equals(other.person1Bean)) - return false; - if (person2Bean == null) { - if (other.person2Bean != null) - return false; - } else if (!person2Bean.equals(other.person2Bean)) - return false; - if (toPerson1Relation == null) { - if (other.toPerson1Relation != null) - return false; - } else if (!toPerson1Relation.equals(other.toPerson1Relation)) - return false; - if (toPerson2Relation == null) { - if (other.toPerson2Relation != null) - return false; - } else if (!toPerson2Relation.equals(other.toPerson2Relation)) - return false; - return true; - } - +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import java.io.Serializable; +import javax.persistence.*; +import java.util.Date; + + +/** + * The persistent class for the relative database table. + * + */ +@Entity +@Table(name="relative") +@NamedQuery(name="Relative.findAll", query="SELECT r FROM Relative r") +public class Relative implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private int id; + + @Temporal(TemporalType.TIMESTAMP) + private Date changed; + + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleted; + + @Column(name="TO_PERSON1_RELATION") + private String toPerson1Relation; + + @Column(name="TO_PERSON2_RELATION") + private String toPerson2Relation; + + //bi-directional many-to-one association to Person + @ManyToOne + @JoinColumn(name="person1") + private Person person1Bean; + + //bi-directional many-to-one association to Person + @ManyToOne + @JoinColumn(name="person2") + private Person person2Bean; + + public Relative() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getChanged() { + return this.changed; + } + + public void setChanged(Date changed) { + this.changed = changed; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getDeleted() { + return this.deleted; + } + + public void setDeleted(Date deleted) { + this.deleted = deleted; + } + + public String getToPerson1Relation() { + return this.toPerson1Relation; + } + + public void setToPerson1Relation(String toPerson1Relation) { + this.toPerson1Relation = toPerson1Relation; + } + + public String getToPerson2Relation() { + return this.toPerson2Relation; + } + + public void setToPerson2Relation(String toPerson2Relation) { + this.toPerson2Relation = toPerson2Relation; + } + + public Person getPerson1Bean() { + return this.person1Bean; + } + + public void setPerson1Bean(Person person1Bean) { + this.person1Bean = person1Bean; + } + + public Person getPerson2Bean() { + return this.person2Bean; + } + + public void setPerson2Bean(Person person2Bean) { + this.person2Bean = person2Bean; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); + result = prime * result + id; + result = prime * result + ((person1Bean == null) ? 0 : person1Bean.hashCode()); + result = prime * result + ((person2Bean == null) ? 0 : person2Bean.hashCode()); + result = prime * result + ((toPerson1Relation == null) ? 0 : toPerson1Relation.hashCode()); + result = prime * result + ((toPerson2Relation == null) ? 0 : toPerson2Relation.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Relative other = (Relative) obj; + if (deleted == null) { + if (other.deleted != null) + return false; + } else if (!deleted.equals(other.deleted)) + return false; + if (id != other.id) + return false; + if (person1Bean == null) { + if (other.person1Bean != null) + return false; + } else if (!person1Bean.equals(other.person1Bean)) + return false; + if (person2Bean == null) { + if (other.person2Bean != null) + return false; + } else if (!person2Bean.equals(other.person2Bean)) + return false; + if (toPerson1Relation == null) { + if (other.toPerson1Relation != null) + return false; + } else if (!toPerson1Relation.equals(other.toPerson1Relation)) + return false; + if (toPerson2Relation == null) { + if (other.toPerson2Relation != null) + return false; + } else if (!toPerson2Relation.equals(other.toPerson2Relation)) + return false; + return true; + } + } \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Startpaesse.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Startpaesse.java index 1be213c..9efad54 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Startpaesse.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/data/Startpaesse.java @@ -1,162 +1,162 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; - -import java.io.Serializable; -import javax.persistence.*; -import java.util.Date; -import java.util.List; - - -/** - * The persistent class for the startpaesse database table. - * - */ -@Entity -@Table(name="startpaesse") -@NamedQuery(name="Startpaesse.findAll", query="SELECT s FROM Startpaesse s") -public class Startpaesse implements Serializable { - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy=GenerationType.IDENTITY) - private int id; - - @Temporal(TemporalType.TIMESTAMP) - private Date changed; - - @Temporal(TemporalType.TIMESTAMP) - private Date created; - - @Temporal(TemporalType.TIMESTAMP) - private Date deleted; - - @Column(name="startpass_nr") - private String startpassNr; - - //bi-directional many-to-one association to Person - @ManyToOne - private Person person; - - //bi-directional many-to-one association to StartpassStartrechte - @OneToMany(mappedBy="startpaesse") - private List startpassStartrechtes; - - public Startpaesse() { - } - - public int getId() { - return this.id; - } - - public void setId(int id) { - this.id = id; - } - - public Date getChanged() { - return this.changed; - } - - public void setChanged(Date changed) { - this.changed = changed; - } - - public Date getCreated() { - return this.created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public Date getDeleted() { - return this.deleted; - } - - public void setDeleted(Date deleted) { - this.deleted = deleted; - } - - public String getStartpassNr() { - return this.startpassNr; - } - - public void setStartpassNr(String startpassNr) { - this.startpassNr = startpassNr; - } - - public Person getPerson() { - return this.person; - } - - public void setPerson(Person person) { - this.person = person; - } - - public List getStartpassStartrechtes() { - return this.startpassStartrechtes; - } - - public void setStartpassStartrechtes(List startpassStartrechtes) { - this.startpassStartrechtes = startpassStartrechtes; - } - - public StartpassStartrechte addStartpassStartrechte(StartpassStartrechte startpassStartrechte) { - getStartpassStartrechtes().add(startpassStartrechte); - startpassStartrechte.setStartpaesse(this); - - return startpassStartrechte; - } - - public StartpassStartrechte removeStartpassStartrechte(StartpassStartrechte startpassStartrechte) { - getStartpassStartrechtes().remove(startpassStartrechte); - startpassStartrechte.setStartpaesse(null); - - return startpassStartrechte; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); - result = prime * result + id; - result = prime * result + ((person == null) ? 0 : person.hashCode()); - result = prime * result + ((startpassNr == null) ? 0 : startpassNr.hashCode()); - result = prime * result + ((startpassStartrechtes == null) ? 0 : startpassStartrechtes.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Startpaesse other = (Startpaesse) obj; - if (deleted == null) { - if (other.deleted != null) - return false; - } else if (!deleted.equals(other.deleted)) - return false; - if (id != other.id) - return false; - if (person == null) { - if (other.person != null) - return false; - } else if (!person.equals(other.person)) - return false; - if (startpassNr == null) { - if (other.startpassNr != null) - return false; - } else if (!startpassNr.equals(other.startpassNr)) - return false; - if (startpassStartrechtes == null) { - if (other.startpassStartrechtes != null) - return false; - } else if (!startpassStartrechtes.equals(other.startpassStartrechtes)) - return false; - return true; - } - +package de.kreth.vaadin.clubhelper.vaadinclubhelper.data; + +import java.io.Serializable; +import javax.persistence.*; +import java.util.Date; +import java.util.List; + + +/** + * The persistent class for the startpaesse database table. + * + */ +@Entity +@Table(name="startpaesse") +@NamedQuery(name="Startpaesse.findAll", query="SELECT s FROM Startpaesse s") +public class Startpaesse implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private int id; + + @Temporal(TemporalType.TIMESTAMP) + private Date changed; + + @Temporal(TemporalType.TIMESTAMP) + private Date created; + + @Temporal(TemporalType.TIMESTAMP) + private Date deleted; + + @Column(name="startpass_nr") + private String startpassNr; + + //bi-directional many-to-one association to Person + @ManyToOne + private Person person; + + //bi-directional many-to-one association to StartpassStartrechte + @OneToMany(mappedBy="startpaesse") + private List startpassStartrechtes; + + public Startpaesse() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getChanged() { + return this.changed; + } + + public void setChanged(Date changed) { + this.changed = changed; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getDeleted() { + return this.deleted; + } + + public void setDeleted(Date deleted) { + this.deleted = deleted; + } + + public String getStartpassNr() { + return this.startpassNr; + } + + public void setStartpassNr(String startpassNr) { + this.startpassNr = startpassNr; + } + + public Person getPerson() { + return this.person; + } + + public void setPerson(Person person) { + this.person = person; + } + + public List getStartpassStartrechtes() { + return this.startpassStartrechtes; + } + + public void setStartpassStartrechtes(List startpassStartrechtes) { + this.startpassStartrechtes = startpassStartrechtes; + } + + public StartpassStartrechte addStartpassStartrechte(StartpassStartrechte startpassStartrechte) { + getStartpassStartrechtes().add(startpassStartrechte); + startpassStartrechte.setStartpaesse(this); + + return startpassStartrechte; + } + + public StartpassStartrechte removeStartpassStartrechte(StartpassStartrechte startpassStartrechte) { + getStartpassStartrechtes().remove(startpassStartrechte); + startpassStartrechte.setStartpaesse(null); + + return startpassStartrechte; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((deleted == null) ? 0 : deleted.hashCode()); + result = prime * result + id; + result = prime * result + ((person == null) ? 0 : person.hashCode()); + result = prime * result + ((startpassNr == null) ? 0 : startpassNr.hashCode()); + result = prime * result + ((startpassStartrechtes == null) ? 0 : startpassStartrechtes.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Startpaesse other = (Startpaesse) obj; + if (deleted == null) { + if (other.deleted != null) + return false; + } else if (!deleted.equals(other.deleted)) + return false; + if (id != other.id) + return false; + if (person == null) { + if (other.person != null) + return false; + } else if (!person.equals(other.person)) + return false; + if (startpassNr == null) { + if (other.startpassNr != null) + return false; + } else if (!startpassNr.equals(other.startpassNr)) + return false; + if (startpassStartrechtes == null) { + if (other.startpassStartrechtes != null) + return false; + } else if (!startpassStartrechtes.equals(other.startpassStartrechtes)) + return false; + return true; + } + } \ No newline at end of file diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java index 72d1891..30ccf0e 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java @@ -1,125 +1,125 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.addon.calendar.ui.CalendarComponentEvents; - -import com.vaadin.annotations.Push; -import com.vaadin.annotations.Theme; -import com.vaadin.event.selection.SelectionEvent; -import com.vaadin.server.VaadinRequest; -import com.vaadin.shared.communication.PushMode; -import com.vaadin.spring.annotation.SpringUI; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.UI; - -import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDialog; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; - -@Theme("vaadin-clubhelpertheme") -@SpringUI -@Push(value=PushMode.MANUAL) -public class MainUi extends UI { - - private static final long serialVersionUID = 7581634188909841919L; - private static final Logger LOGGER = LoggerFactory.getLogger(MainUi.class); - - @Autowired - PersonDao personDao; - - @Autowired - GroupDao groupDao; - - @Autowired - EventBusiness eventBusiness; - - private PersonGrid personGrid; - - private CalendarComponent calendar; - - private HorizontalLayout contentLayout; - - @Override - protected void init(VaadinRequest request) { - - LOGGER.debug("Starting Vaadin UI with " + getClass().getName()); - - List persons = personDao.listAll(); - personGrid = new PersonGrid(groupDao); - personGrid.setItems(persons); - personGrid.setCaption("Personen"); - personGrid.onClosedFunction(() -> detailClosed()); - personGrid.onPersonSelect(ev -> personSelectionChange(ev)); - personGrid.onPersonEdit(p -> onPersonEdit(p)); - - this.calendar = new CalendarComponent(); - calendar.setHandler(this::onItemClick); - - contentLayout = new HorizontalLayout(); - contentLayout.setSizeFull(); - contentLayout.addComponents(calendar); - - setContent(contentLayout); - setSizeFull(); - - ExecutorService exec = Executors.newSingleThreadExecutor(); - exec.execute(() -> { - - final List events = eventBusiness.loadEvents(request); - LOGGER.info("Loaded events: {}", events); - final UI ui = calendar.getUI(); - ui.access(() -> { - calendar.setItems(events); - ui.push(); - }); - - }); - exec.shutdown(); - LOGGER.info("Loaded UI and started fetch of Events"); - } - - private void onPersonEdit(Person p) { - PersonEditDialog dlg = new PersonEditDialog(groupDao.listAll(), p, personDao); - getUI().addWindow(dlg); - } - - private void personSelectionChange(SelectionEvent ev) { - Set selected = ev.getAllSelectedItems(); - LOGGER.debug("Selection changed to: {}", selected); - eventBusiness.changePersons(selected); - } - - private void detailClosed() { - LOGGER.debug("Closing detail view."); - contentLayout.removeComponent(personGrid); - } - - private void onItemClick(CalendarComponentEvents.ItemClickEvent event) { - ClubEvent ev = (ClubEvent) event.getCalendarItem(); - LOGGER.debug("Opening detail view for {}", ev); - - contentLayout.removeComponent(personGrid); - contentLayout.addComponent(personGrid); - - personGrid.setCaption(ev.getCaption()); - personGrid.setTitle(ev.getCaption()); - personGrid.setEnabled(false); - personGrid.selectItems(ev.getPersons()); - personGrid.setVisible(true); - personGrid.setEnabled(true); - eventBusiness.setSelected(ev); - } - -} +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui; + +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.vaadin.addon.calendar.ui.CalendarComponentEvents; + +import com.vaadin.annotations.Push; +import com.vaadin.annotations.Theme; +import com.vaadin.event.selection.SelectionEvent; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.communication.PushMode; +import com.vaadin.spring.annotation.SpringUI; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.UI; + +import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonEditDialog; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid; + +@Theme("vaadin-clubhelpertheme") +@SpringUI +@Push(value=PushMode.MANUAL) +public class MainUi extends UI { + + private static final long serialVersionUID = 7581634188909841919L; + private static final Logger LOGGER = LoggerFactory.getLogger(MainUi.class); + + @Autowired + PersonDao personDao; + + @Autowired + GroupDao groupDao; + + @Autowired + EventBusiness eventBusiness; + + private PersonGrid personGrid; + + private CalendarComponent calendar; + + private HorizontalLayout contentLayout; + + @Override + protected void init(VaadinRequest request) { + + LOGGER.debug("Starting Vaadin UI with " + getClass().getName()); + + List persons = personDao.listAll(); + personGrid = new PersonGrid(groupDao); + personGrid.setItems(persons); + personGrid.setCaption("Personen"); + personGrid.onClosedFunction(() -> detailClosed()); + personGrid.onPersonSelect(ev -> personSelectionChange(ev)); + personGrid.onPersonEdit(p -> onPersonEdit(p)); + + this.calendar = new CalendarComponent(); + calendar.setHandler(this::onItemClick); + + contentLayout = new HorizontalLayout(); + contentLayout.setSizeFull(); + contentLayout.addComponents(calendar); + + setContent(contentLayout); + setSizeFull(); + + ExecutorService exec = Executors.newSingleThreadExecutor(); + exec.execute(() -> { + + final List events = eventBusiness.loadEvents(request); + LOGGER.info("Loaded events: {}", events); + final UI ui = calendar.getUI(); + ui.access(() -> { + calendar.setItems(events); + ui.push(); + }); + + }); + exec.shutdown(); + LOGGER.info("Loaded UI and started fetch of Events"); + } + + private void onPersonEdit(Person p) { + PersonEditDialog dlg = new PersonEditDialog(groupDao.listAll(), p, personDao); + getUI().addWindow(dlg); + } + + private void personSelectionChange(SelectionEvent ev) { + Set selected = ev.getAllSelectedItems(); + LOGGER.debug("Selection changed to: {}", selected); + eventBusiness.changePersons(selected); + } + + private void detailClosed() { + LOGGER.debug("Closing detail view."); + contentLayout.removeComponent(personGrid); + } + + private void onItemClick(CalendarComponentEvents.ItemClickEvent event) { + ClubEvent ev = (ClubEvent) event.getCalendarItem(); + LOGGER.debug("Opening detail view for {}", ev); + + contentLayout.removeComponent(personGrid); + contentLayout.addComponent(personGrid); + + personGrid.setCaption(ev.getCaption()); + personGrid.setTitle(ev.getCaption()); + personGrid.setEnabled(false); + personGrid.selectItems(ev.getPersons()); + personGrid.setVisible(true); + personGrid.setEnabled(true); + eventBusiness.setSelected(ev); + } + +} diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDialog.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDialog.java index b20fa5f..6632d17 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDialog.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDialog.java @@ -1,5 +1,6 @@ package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; +import java.time.ZoneId; import java.util.ArrayList; import java.util.List; @@ -7,7 +8,9 @@ import org.vaadin.teemu.switchui.Switch; import com.vaadin.data.Binder; import com.vaadin.data.HasValue.ValueChangeEvent; +import com.vaadin.data.converter.LocalDateToDateConverter; import com.vaadin.ui.Button; +import com.vaadin.ui.DateField; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -25,12 +28,16 @@ public class PersonEditDialog extends Window { private final Person person; private final Binder binder; + private DateField birthday; public PersonEditDialog(List groups, Person person, PersonDao dao) { this.person = person; textPrename = new TextField(); textSureName = new TextField(); + birthday = new DateField(); + birthday.setCaption("Geburtstag"); + Panel groupPanel = new Panel("Gruppen"); VerticalLayout glay = new VerticalLayout(); groupPanel.setContent(glay); @@ -49,6 +56,8 @@ public class PersonEditDialog extends Window { binder = new Binder<>(); binder.forField(textPrename).bind(Person::getPrename, Person::setPrename); binder.forField(textSureName).bind(Person::getSurname, Person::setSurname); + binder.forField(birthday).withConverter(new LocalDateToDateConverter(ZoneId.systemDefault())).bind(Person::getBirth, Person::setBirth); + binder.readBean(person); Button close = new Button("Schließen"); @@ -59,9 +68,9 @@ public class PersonEditDialog extends Window { dao.update(person); }); VerticalLayout layout = new VerticalLayout(); - layout.addComponents(textPrename, textSureName, groupPanel, close, ok); + layout.addComponents(textPrename, textSureName, birthday, groupPanel, close, ok); setContent(layout); - + center(); } private void groupChanged(ValueChangeEvent ev) { diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java index b96226f..eb2d445 100644 --- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java +++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonGrid.java @@ -1,219 +1,219 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; - -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Consumer; -import java.util.function.Predicate; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.vaadin.data.HasValue.ValueChangeEvent; -import com.vaadin.data.provider.ConfigurableFilterDataProvider; -import com.vaadin.data.provider.ListDataProvider; -import com.vaadin.event.selection.SelectionListener; -import com.vaadin.event.selection.SingleSelectionEvent; -import com.vaadin.icons.VaadinIcons; -import com.vaadin.server.SerializablePredicate; -import com.vaadin.ui.Button; -import com.vaadin.ui.CheckBox; -import com.vaadin.ui.ComboBox; -import com.vaadin.ui.CustomComponent; -import com.vaadin.ui.Grid; -import com.vaadin.ui.Grid.SelectionMode; -import com.vaadin.ui.HorizontalLayout; -import com.vaadin.ui.MultiSelect; -import com.vaadin.ui.TextField; -import com.vaadin.ui.VerticalLayout; -import com.vaadin.ui.themes.ValoTheme; - -import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; - -public class PersonGrid extends CustomComponent { - - private static final long serialVersionUID = -8148097982839343673L; - private final Logger log = LoggerFactory.getLogger(getClass()); - - private final DateFormat birthFormat = DateFormat - .getDateInstance(DateFormat.MEDIUM); - - private final Grid grid; - - private final CheckBox checkIncluded; - private final ComboBox comboGroups; - - private final TextField textTitle; - - private ClosedFunction closedFunction = null; - private ConfigurableFilterDataProvider> dataProvider; - private Boolean selectedOnlyFilter; - private Set groupMemberFilter; - private List allGroups; - private Consumer onPersonEdit; - - public PersonGrid(GroupDao groupDao) { - - textTitle = new TextField(); - textTitle.setStyleName("title_label"); - textTitle.setCaption("Veranstaltung"); - textTitle.setEnabled(false); - textTitle.setSizeFull(); - - checkIncluded = new CheckBox("Nur gemeldete"); - checkIncluded.addValueChangeListener(ev -> onSelectedOnly(ev)); - comboGroups = new ComboBox<>("Gruppenfilter"); - comboGroups.setEmptySelectionAllowed(true); - comboGroups.setEmptySelectionCaption("Alle"); - comboGroups.setItemCaptionGenerator(GroupDef::getName); - comboGroups.addSelectionListener(ev -> onGroupSelected(ev)); - allGroups = groupDao.listAll(); - comboGroups.setItems(allGroups); - log.info("Loaded Groups: {}", allGroups); - - HorizontalLayout filters = new HorizontalLayout(); - filters.addComponents(checkIncluded, comboGroups); - dataProvider = new ListDataProvider(new ArrayList<>()).withConfigurableFilter(); - grid = new Grid<>(); - grid.setDataProvider(dataProvider); - grid.addColumn(Person::getPrename).setCaption("Vorname"); - grid.addColumn(Person::getSurname).setCaption("Nachname"); - grid.addColumn(Person::getBirth, - b -> b != null ? birthFormat.format(b) : "") - .setCaption("Geburtstag"); - grid.addComponentColumn(this::buildDeleteButton); - grid.setSelectionMode(SelectionMode.MULTI); - - Button close = new Button("Schließen", ev -> { - PersonGrid.this.setVisible(false); - if (closedFunction != null) { - closedFunction.closed(); - } - }); - - VerticalLayout panel = new VerticalLayout(); - panel.addComponents(textTitle, filters, grid, close); - setCompositionRoot(panel); - } - - private Button buildDeleteButton(Person p) { - Button button = new Button(VaadinIcons.EDIT); - button.addStyleName(ValoTheme.BUTTON_SMALL); - button.addClickListener(e -> showPersonDetails(p)); - return button; - } - - private void showPersonDetails(Person p) { - if (onPersonEdit != null) { - onPersonEdit.accept(p); - } - } - - public void onClosedFunction(ClosedFunction closedFunction) { - this.closedFunction = closedFunction; - } - - private void onSelectedOnly(ValueChangeEvent ev) { - this.selectedOnlyFilter = ev.getValue(); - updateFilter(); - } - - private void updateFilter() { - Predicate filter = p -> true; - if (selectedOnlyFilter!= null && selectedOnlyFilter.equals(Boolean.TRUE)) { - Set selected = grid.getSelectedItems(); - filter = p -> selected.contains(p); - } - if (groupMemberFilter != null && groupMemberFilter.isEmpty() == false) { - final Set groupIds = new HashSet<>(); - groupMemberFilter.forEach(gm -> { - groupIds.add(gm.getId()); - }); - - filter = filter.and(p -> { - { - List personGroups = p.getPersongroups(); - for (GroupDef pg : personGroups) { - if (groupIds.contains(pg.getId())) { - return true; - } - } - return false; - } - }); - } - - setFilter(filter); - } - - public void setFilter(Predicate filter) { - dataProvider.setFilter(p -> filter.test(p)); - grid.getDataProvider().refreshAll(); - } - - public void onPersonSelect(SelectionListener listener) throws UnsupportedOperationException { - grid.addSelectionListener(listener); - } - - public void selectItems(Person... items) { - MultiSelect asMultiSelect = grid.asMultiSelect(); - asMultiSelect.deselectAll(); - asMultiSelect.select(items); - } - - public void deselectItems(Person... items) { - grid.asMultiSelect().deselect(items); - } - - public void select(Person item) { - grid.select(item); - } - - public void deselect(Person item) { - grid.deselect(item); - } - - public void deselectAll() { - grid.deselectAll(); - } - - private void onGroupSelected(SingleSelectionEvent ev) { - - groupMemberFilter = ev.getAllSelectedItems(); - updateFilter(); - } - - public void setTitle(String value) { - if (value == null) { - value = ""; - } - textTitle.setValue(value); - } - - public void setItems(Collection items) { - grid.setItems(items); - } - - public void setItems(Person... items) { - grid.setItems(items); - } - - public interface ClosedFunction { - void closed(); - } - - public void selectItems(Collection persons) { - log.debug("Selecting now: {}" + persons); - selectItems(persons.toArray(new Person[0])); - } - - public void onPersonEdit(Consumer function) { - this.onPersonEdit = function; - } - -} +package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import java.util.function.Predicate; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.vaadin.data.HasValue.ValueChangeEvent; +import com.vaadin.data.provider.ConfigurableFilterDataProvider; +import com.vaadin.data.provider.ListDataProvider; +import com.vaadin.event.selection.SelectionListener; +import com.vaadin.event.selection.SingleSelectionEvent; +import com.vaadin.icons.VaadinIcons; +import com.vaadin.server.SerializablePredicate; +import com.vaadin.ui.Button; +import com.vaadin.ui.CheckBox; +import com.vaadin.ui.ComboBox; +import com.vaadin.ui.CustomComponent; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.SelectionMode; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.MultiSelect; +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.themes.ValoTheme; + +import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; + +public class PersonGrid extends CustomComponent { + + private static final long serialVersionUID = -8148097982839343673L; + private final Logger log = LoggerFactory.getLogger(getClass()); + + private final DateFormat birthFormat = DateFormat + .getDateInstance(DateFormat.MEDIUM); + + private final Grid grid; + + private final CheckBox checkIncluded; + private final ComboBox comboGroups; + + private final TextField textTitle; + + private ClosedFunction closedFunction = null; + private ConfigurableFilterDataProvider> dataProvider; + private Boolean selectedOnlyFilter; + private Set groupMemberFilter; + private List allGroups; + private Consumer onPersonEdit; + + public PersonGrid(GroupDao groupDao) { + + textTitle = new TextField(); + textTitle.setStyleName("title_label"); + textTitle.setCaption("Veranstaltung"); + textTitle.setEnabled(false); + textTitle.setSizeFull(); + + checkIncluded = new CheckBox("Nur gemeldete"); + checkIncluded.addValueChangeListener(ev -> onSelectedOnly(ev)); + comboGroups = new ComboBox<>("Gruppenfilter"); + comboGroups.setEmptySelectionAllowed(true); + comboGroups.setEmptySelectionCaption("Alle"); + comboGroups.setItemCaptionGenerator(GroupDef::getName); + comboGroups.addSelectionListener(ev -> onGroupSelected(ev)); + allGroups = groupDao.listAll(); + comboGroups.setItems(allGroups); + log.info("Loaded Groups: {}", allGroups); + + HorizontalLayout filters = new HorizontalLayout(); + filters.addComponents(checkIncluded, comboGroups); + dataProvider = new ListDataProvider(new ArrayList<>()).withConfigurableFilter(); + grid = new Grid<>(); + grid.setDataProvider(dataProvider); + grid.addColumn(Person::getPrename).setCaption("Vorname"); + grid.addColumn(Person::getSurname).setCaption("Nachname"); + grid.addColumn(Person::getBirth, + b -> b != null ? birthFormat.format(b) : "") + .setCaption("Geburtstag"); + grid.addComponentColumn(this::buildDeleteButton); + grid.setSelectionMode(SelectionMode.MULTI); + + Button close = new Button("Schließen", ev -> { + PersonGrid.this.setVisible(false); + if (closedFunction != null) { + closedFunction.closed(); + } + }); + + VerticalLayout panel = new VerticalLayout(); + panel.addComponents(textTitle, filters, grid, close); + setCompositionRoot(panel); + } + + private Button buildDeleteButton(Person p) { + Button button = new Button(VaadinIcons.EDIT); + button.addStyleName(ValoTheme.BUTTON_SMALL); + button.addClickListener(e -> showPersonDetails(p)); + return button; + } + + private void showPersonDetails(Person p) { + if (onPersonEdit != null) { + onPersonEdit.accept(p); + } + } + + public void onClosedFunction(ClosedFunction closedFunction) { + this.closedFunction = closedFunction; + } + + private void onSelectedOnly(ValueChangeEvent ev) { + this.selectedOnlyFilter = ev.getValue(); + updateFilter(); + } + + private void updateFilter() { + Predicate filter = p -> true; + if (selectedOnlyFilter!= null && selectedOnlyFilter.equals(Boolean.TRUE)) { + Set selected = grid.getSelectedItems(); + filter = p -> selected.contains(p); + } + if (groupMemberFilter != null && groupMemberFilter.isEmpty() == false) { + final Set groupIds = new HashSet<>(); + groupMemberFilter.forEach(gm -> { + groupIds.add(gm.getId()); + }); + + filter = filter.and(p -> { + { + List personGroups = p.getPersongroups(); + for (GroupDef pg : personGroups) { + if (groupIds.contains(pg.getId())) { + return true; + } + } + return false; + } + }); + } + + setFilter(filter); + } + + public void setFilter(Predicate filter) { + dataProvider.setFilter(p -> filter.test(p)); + grid.getDataProvider().refreshAll(); + } + + public void onPersonSelect(SelectionListener listener) throws UnsupportedOperationException { + grid.addSelectionListener(listener); + } + + public void selectItems(Person... items) { + MultiSelect asMultiSelect = grid.asMultiSelect(); + asMultiSelect.deselectAll(); + asMultiSelect.select(items); + } + + public void deselectItems(Person... items) { + grid.asMultiSelect().deselect(items); + } + + public void select(Person item) { + grid.select(item); + } + + public void deselect(Person item) { + grid.deselect(item); + } + + public void deselectAll() { + grid.deselectAll(); + } + + private void onGroupSelected(SingleSelectionEvent ev) { + + groupMemberFilter = ev.getAllSelectedItems(); + updateFilter(); + } + + public void setTitle(String value) { + if (value == null) { + value = ""; + } + textTitle.setValue(value); + } + + public void setItems(Collection items) { + grid.setItems(items); + } + + public void setItems(Person... items) { + grid.setItems(items); + } + + public interface ClosedFunction { + void closed(); + } + + public void selectItems(Collection persons) { + log.debug("Selecting now: {}" + persons); + selectItems(persons.toArray(new Person[0])); + } + + public void onPersonEdit(Consumer function) { + this.onPersonEdit = function; + } + +} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 45363c8..7c0393c 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -1,22 +1,22 @@ - - - - - - - org.hibernate.dialect.MySQLDialect - - - com.mysql.jdbc.Driver - java:comp/env/jdbc/clubhelperbackend - org.hibernate.NoCacheProvider - true - - - org.hibernate.context.internal.ThreadLocalSessionContext - - - - + + + + + + + org.hibernate.dialect.MySQLDialect + + + com.mysql.jdbc.Driver + java:comp/env/jdbc/clubhelperbackend + org.hibernate.NoCacheProvider + true + + + org.hibernate.context.internal.ThreadLocalSessionContext + + + + diff --git a/src/main/resources/schema/ClubEvent.hbm.xml b/src/main/resources/schema/ClubEvent.hbm.xml index 4633e4b..fd65403 100644 --- a/src/main/resources/schema/ClubEvent.hbm.xml +++ b/src/main/resources/schema/ClubEvent.hbm.xml @@ -1,36 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java index 4547449..54c6eb8 100644 --- a/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java +++ b/src/test/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDataTest.java @@ -1,169 +1,169 @@ -package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.hibernate.IdentifierLoadAccess; -import org.hibernate.Transaction; -import org.hibernate.jdbc.Work; -import org.hibernate.query.Query; -import org.junit.Test; - -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; -import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; - -public class ClubEventDataTest extends AbstractDatabaseTest { - - public Person testInsertPerson() { - Person p = new Person(); - p.setPrename("prename"); - p.setSurname("surname"); - p.setBirth(new Date()); - Transaction tx = session.beginTransaction(); - session.save(p); - tx.commit(); - return p; - } - - @Test - public void testInsertEvent() { - ClubEvent ev = creteEvent(); - - Transaction tx = session.beginTransaction(); - session.save(ev); - tx.commit(); - } - - @Test - public void testSelectEvents() { - ClubEvent ev = creteEvent(); - - Transaction tx = session.beginTransaction(); - session.save(ev); - tx.commit(); - - Query query = session.createNamedQuery("ClubEvent.findAll", - ClubEvent.class); - List result = query.list(); - assertEquals(1, result.size()); - } - - @Test - public void testEventWithPerson() { - - ClubEvent ev = creteEvent(); - - Person person = testInsertPerson(); - Set persons = ev.getPersons(); - if (persons == null) { - persons = new HashSet<>(); - ev.setPersons(persons); - } - persons.add(person); - - Transaction tx = session.beginTransaction(); - session.save(ev); - tx.commit(); - - List loadEventPersons = loadEventPersons(); - assertFalse(loadEventPersons.isEmpty()); - ClubeventHasPerson link = loadEventPersons.get(0); - assertEquals(person.getId(), link.getPersonId()); - assertEquals(ev.getId(), link.getClubEventId()); - - } - - private List loadEventPersons() { - final AtomicBoolean finishedWork = new AtomicBoolean(false); - List link = new ArrayList<>(); - - session.doWork(new Work() { - - @Override - public void execute(Connection connection) throws SQLException { - Statement stm = connection.createStatement(); - ResultSet rs = stm.executeQuery("select * from clubevent_has_person"); - while (rs.next()) { - ClubeventHasPerson ep = new ClubeventHasPerson(); - - ep.setClubEventId(rs.getString("clubevent_id")); - ep.setPersonId(rs.getInt("person_id")); - link.add(ep); - } - - finishedWork.set(true); - } - }); - assertTrue(finishedWork.get()); - return link; - } - - @Test - public void changeEventsPersons() { - ClubEvent ev = creteEvent(); - - Transaction tx = session.beginTransaction(); - session.save(ev); - tx.commit(); - - Person person = testInsertPerson(); - - Person person2 = new Person(); - person2.setId(person.getId() + 1); - person2.setPrename(person.getPrename() + "_2"); - person2.setSurname(person.getSurname() + "_2"); - person2.setBirth(new Date()); - - tx = session.beginTransaction(); - session.save(person2); - tx.commit(); - - IdentifierLoadAccess idLoadAccess = session.byId(ClubEvent.class); - ClubEvent loaded = idLoadAccess.load(ev.getId()); - assertNotNull(loaded); - if (loaded.getPersons() == null) { - loaded.setPersons(new HashSet<>()); - } - - loaded.getPersons().add(person); - tx = session.beginTransaction(); - session.update(ev); - tx.commit(); - - loaded.getPersons().add(person2); - tx = session.beginTransaction(); - session.update(ev); - tx.commit(); - List entries = loadEventPersons(); - assertEquals(2, entries.size()); - } - - private ClubEvent creteEvent() { - ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true) - .withCaption("caption").withDescription("description") - .withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, - ZoneId.systemDefault())) - .withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, - ZoneId.systemDefault())) - .withiCalUID("iCalUID") - .withOrganizerDisplayName("organizerDisplayName").build(); - return ev; - } -} +package de.kreth.vaadin.clubhelper.vaadinclubhelper.dao; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.hibernate.IdentifierLoadAccess; +import org.hibernate.Transaction; +import org.hibernate.jdbc.Work; +import org.hibernate.query.Query; +import org.junit.Test; + +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEventBuilder; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubeventHasPerson; +import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; + +public class ClubEventDataTest extends AbstractDatabaseTest { + + public Person testInsertPerson() { + Person p = new Person(); + p.setPrename("prename"); + p.setSurname("surname"); + p.setBirth(new Date()); + Transaction tx = session.beginTransaction(); + session.save(p); + tx.commit(); + return p; + } + + @Test + public void testInsertEvent() { + ClubEvent ev = creteEvent(); + + Transaction tx = session.beginTransaction(); + session.save(ev); + tx.commit(); + } + + @Test + public void testSelectEvents() { + ClubEvent ev = creteEvent(); + + Transaction tx = session.beginTransaction(); + session.save(ev); + tx.commit(); + + Query query = session.createNamedQuery("ClubEvent.findAll", + ClubEvent.class); + List result = query.list(); + assertEquals(1, result.size()); + } + + @Test + public void testEventWithPerson() { + + ClubEvent ev = creteEvent(); + + Person person = testInsertPerson(); + Set persons = ev.getPersons(); + if (persons == null) { + persons = new HashSet<>(); + ev.setPersons(persons); + } + persons.add(person); + + Transaction tx = session.beginTransaction(); + session.save(ev); + tx.commit(); + + List loadEventPersons = loadEventPersons(); + assertFalse(loadEventPersons.isEmpty()); + ClubeventHasPerson link = loadEventPersons.get(0); + assertEquals(person.getId(), link.getPersonId()); + assertEquals(ev.getId(), link.getClubEventId()); + + } + + private List loadEventPersons() { + final AtomicBoolean finishedWork = new AtomicBoolean(false); + List link = new ArrayList<>(); + + session.doWork(new Work() { + + @Override + public void execute(Connection connection) throws SQLException { + Statement stm = connection.createStatement(); + ResultSet rs = stm.executeQuery("select * from clubevent_has_person"); + while (rs.next()) { + ClubeventHasPerson ep = new ClubeventHasPerson(); + + ep.setClubEventId(rs.getString("clubevent_id")); + ep.setPersonId(rs.getInt("person_id")); + link.add(ep); + } + + finishedWork.set(true); + } + }); + assertTrue(finishedWork.get()); + return link; + } + + @Test + public void changeEventsPersons() { + ClubEvent ev = creteEvent(); + + Transaction tx = session.beginTransaction(); + session.save(ev); + tx.commit(); + + Person person = testInsertPerson(); + + Person person2 = new Person(); + person2.setId(person.getId() + 1); + person2.setPrename(person.getPrename() + "_2"); + person2.setSurname(person.getSurname() + "_2"); + person2.setBirth(new Date()); + + tx = session.beginTransaction(); + session.save(person2); + tx.commit(); + + IdentifierLoadAccess idLoadAccess = session.byId(ClubEvent.class); + ClubEvent loaded = idLoadAccess.load(ev.getId()); + assertNotNull(loaded); + if (loaded.getPersons() == null) { + loaded.setPersons(new HashSet<>()); + } + + loaded.getPersons().add(person); + tx = session.beginTransaction(); + session.update(ev); + tx.commit(); + + loaded.getPersons().add(person2); + tx = session.beginTransaction(); + session.update(ev); + tx.commit(); + List entries = loadEventPersons(); + assertEquals(2, entries.size()); + } + + private ClubEvent creteEvent() { + ClubEvent ev = ClubEventBuilder.builder().withId("id").withAllDay(true) + .withCaption("caption").withDescription("description") + .withStart(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, + ZoneId.systemDefault())) + .withEnd(ZonedDateTime.of(2018, 8, 13, 0, 0, 0, 0, + ZoneId.systemDefault())) + .withiCalUID("iCalUID") + .withOrganizerDisplayName("organizerDisplayName").build(); + return ev; + } +}