diff --git a/.classpath b/.classpath
index a25dc2c..1c125a8 100644
--- a/.classpath
+++ b/.classpath
@@ -1,42 +1,42 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.settings/com.vaadin.integration.eclipse.prefs b/.settings/com.vaadin.integration.eclipse.prefs
index 2bf7134..ea671d4 100644
--- a/.settings/com.vaadin.integration.eclipse.prefs
+++ b/.settings/com.vaadin.integration.eclipse.prefs
@@ -1,4 +1,4 @@
-com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.8.3"]
+com.vaadin.integration.eclipse.mavenLatestVersionsUpgrade=["8.6.4","8.8.6"]
com.vaadin.integration.eclipse.previousCompileAction=both
com.vaadin.integration.eclipse.useLatestNightly=false
com.vaadin.integration.eclipse.widgetsetDirty=true
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 1ae503a..5d2cc4e 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,5 +1,8 @@
-
+
+
+
+
@@ -11,7 +14,7 @@
-
+
@@ -22,20 +25,17 @@
-
-
-
+
+
-
-
@@ -43,11 +43,11 @@
+
+
-
-
@@ -59,11 +59,15 @@
-
-
+
+
+
-
+
+
+
+
@@ -75,7 +79,10 @@
-
+
+
+
+
@@ -87,7 +94,10 @@
-
+
+
+
+
@@ -99,7 +109,10 @@
-
+
+
+
+
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
deleted file mode 100644
index 8d301e9..0000000
--- a/src/main/java/Main.java
+++ /dev/null
@@ -1,21 +0,0 @@
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-
-import com.mysql.cj.jdbc.MysqlDataSource;
-
-public class Main {
-
- public static void main(String[] args) throws SQLException {
- MysqlDataSource dataSource = new MysqlDataSource();
- dataSource.setUrl(
- "jdbc:mysql://localhost:3306/clubhelper?useSSL=FALSE&useUnicode=yes&characterEncoding=utf8&serverTimezone=UTC");
- dataSource.setUser("root");
- dataSource.setPassword("07!73");
- try (Connection conn = dataSource.getConnection()) {
- DatabaseMetaData meta = conn.getMetaData();
- System.out.println(meta);
- }
- }
-
-}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
index a5fbecb..e4ad929 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
@@ -87,6 +87,7 @@ public class EventBusiness {
public void storeAltersgruppe(Altersgruppe edited) {
altersgruppeDao.save(edited);
clubEventDao.save(current);
+ log.info("Stored {}", edited);
}
public EventMeldung createMeldung() {
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/PersonBusiness.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/PersonBusiness.java
new file mode 100644
index 0000000..39b5490
--- /dev/null
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/PersonBusiness.java
@@ -0,0 +1,60 @@
+package de.kreth.vaadin.clubhelper.vaadinclubhelper.business;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Adress;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Contact;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Relation;
+
+@Component
+public class PersonBusiness {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private PersonDao dao;
+
+ public void save(Person edited) {
+ dao.save(edited);
+ log.info("Saved {}", edited);
+ }
+
+ public void delete(Contact c) {
+ dao.delete(c);
+ log.info("Deleted {}", c);
+ }
+
+ public Collection extends Relation> findRelationsFor(Person person) {
+ log.info("Loading relations of {}", person);
+ return dao.findRelationsFor(person);
+ }
+
+ public void delete(Adress a) {
+ dao.delete(a);
+ log.info("Deleted {}", a);
+ }
+
+ public List listAll() {
+ log.info("Loading all Persons");
+ return dao.listAll();
+ }
+
+ public void delete(Person c) {
+ dao.delete(c);
+ log.info("Deleted {}", c);
+ }
+
+ public Person findLoginUser(String username, String password) {
+ log.info("Identifiing Login for user {}", username);
+ return dao.findLoginUser(username, password);
+ }
+
+}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDao.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDao.java
index 7a0929a..234256b 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDao.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDao.java
@@ -28,4 +28,5 @@ public interface PersonDao extends IDao {
void delete(Person p);
void delete(Adress a);
+
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java
index a689947..bb0e730 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/PersonDaoImpl.java
@@ -133,4 +133,5 @@ public class PersonDaoImpl extends AbstractDaoImpl implements PersonDao
Person person = a.getPerson();
person.getAdresses().remove(a);
}
+
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/AbstractDataGrid.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/AbstractDataGrid.java
index ea17f3f..5aeb7a2 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/AbstractDataGrid.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/AbstractDataGrid.java
@@ -30,17 +30,24 @@ public abstract class AbstractDataGrid extends VerticalLayout {
private static final long serialVersionUID = -3404971410481135696L;
private final Grid grid;
+
private final List source;
+
private final ListDataProvider dataProvider;
+
private boolean hasChanges;
+
private Column deleteButtonColumn;
+
private Consumer deleteConsumer;
+
private final List> successConsumers;
private final HorizontalLayout buttonLayout;
+
private final Button addButton;
- public AbstractDataGrid() {
+ protected AbstractDataGrid() {
this.grid = new Grid<>();
this.source = new ArrayList<>();
successConsumers = new ArrayList<>();
@@ -110,7 +117,8 @@ public abstract class AbstractDataGrid extends VerticalLayout {
this.deleteConsumer = deleteConsumer;
if (deleteConsumer != null) {
deleteButtonColumn.setHidden(false);
- } else {
+ }
+ else {
deleteButtonColumn.setHidden(true);
}
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ContactGrid.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ContactGrid.java
index bd5c61d..fa75e8b 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ContactGrid.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/ContactGrid.java
@@ -24,6 +24,7 @@ public class ContactGrid extends AbstractDataGrid {
*
*/
private static final long serialVersionUID = -2573761302198992085L;
+
private static final PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
@Override
@@ -40,17 +41,21 @@ public class ContactGrid extends AbstractDataGrid {
protected ValidationResult validate(Contact obj, ValueContext context) {
if (obj.getType().equalsIgnoreCase("email")) {
return new EmailValidator("Emailformat nicht gültig!").apply(obj.getValue(), context);
- } else if (obj.getType().equalsIgnoreCase("Telefon") || obj.getType().equalsIgnoreCase("Mobile")) {
+ }
+ else if (obj.getType().equalsIgnoreCase("Telefon") || obj.getType().equalsIgnoreCase("Mobile")) {
try {
PhoneNumber phone = phoneUtil.parse(obj.getValue(), "DE");
+
if (phoneUtil.isValidNumber(phone)) {
obj.setValue(phoneUtil.format(phone,
com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL));
return ValidationResult.ok();
- } else {
- return ValidationResult.error("Fehler beim Validieren von Telefonnummer: " + obj.getValue());
}
- } catch (NumberParseException e) {
+ else {
+ return ValidationResult.error("Ungültige Telefonnummer: " + obj.getValue());
+ }
+ }
+ catch (NumberParseException e) {
return ValidationResult.error("Fehler beim Validieren von Telefonnummer: " + obj.getValue());
}
}
@@ -74,4 +79,4 @@ public class ContactGrid extends AbstractDataGrid {
return new Contact();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
index dddb32d..7b8af18 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
@@ -13,9 +13,9 @@ import com.vaadin.ui.Window;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
-import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PflichtenDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.navigation.ClubhelperNavigation.ClubNavigator;
@@ -25,17 +25,25 @@ public class EventDetails extends GridLayout implements View {
private static final long serialVersionUID = 8290150079638390995L;
private final EventBusiness eventBusiness;
- private final PersonDao personDao;
+
+ private final PersonBusiness personDao;
+
private final GroupDao groupDao;
+
private final PflichtenDao pflichtenDao;
private ClubEvent currentEvent;
+
private SingleEventView eventView;
+
private PersonGrid personGrid;
+
private EventAltersgruppen eventAltersgruppen;
+
private CalendarAdapter calendarAdapter;
- public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness, PflichtenDao pflichtenDao,
+ public EventDetails(PersonBusiness personDao, GroupDao groupDao, EventBusiness eventBusiness,
+ PflichtenDao pflichtenDao,
CalendarAdapter calendarAdapter) {
super(3, 5);
this.eventBusiness = eventBusiness;
@@ -81,7 +89,8 @@ public class EventDetails extends GridLayout implements View {
addComponent(personGrid, 2, 0);
addComponent(buttonLayout, 0, 4, 2, 4);
setSizeFull();
- } else {
+ }
+ else {
eventAltersgruppen.updateData();
}
eventView.setEvent(currentEvent);
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDetails.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDetails.java
index f23d2a8..61eb169 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDetails.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/PersonEditDetails.java
@@ -1,12 +1,18 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import java.util.List;
+import java.util.Set;
import java.util.function.Consumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.vaadin.teemu.switchui.Switch;
import com.vaadin.data.Binder;
+import com.vaadin.data.Binder.BindingBuilder;
import com.vaadin.data.BinderValidationStatus;
+import com.vaadin.data.HasValue.ValueChangeEvent;
+import com.vaadin.data.HasValue.ValueChangeListener;
import com.vaadin.data.ValidationResult;
import com.vaadin.ui.Button;
import com.vaadin.ui.ComboBox;
@@ -18,7 +24,7 @@ import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
-import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.PersonBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Gender;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.GroupDef;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@@ -34,10 +40,12 @@ public class PersonEditDetails extends HorizontalLayout {
private final DateField birthday;
- private final PersonDao dao;
+ private final PersonBusiness dao;
private final Binder binder;
+ private final Binder> binderGroups;
+
private Consumer personChangeHandler;
private Button okButton;
@@ -48,11 +56,11 @@ public class PersonEditDetails extends HorizontalLayout {
private AdressComponent adressLayout;
- public PersonEditDetails(List groups, PersonDao dao) {
+ public PersonEditDetails(List groups, PersonBusiness dao) {
this(groups, dao, true);
}
- public PersonEditDetails(List groups, PersonDao dao, boolean showCloseButton) {
+ public PersonEditDetails(List groups, PersonBusiness dao, boolean showCloseButton) {
this.dao = dao;
@@ -122,6 +130,7 @@ public class PersonEditDetails extends HorizontalLayout {
VerticalLayout layout = new VerticalLayout(textPrename, textSureName, birthday, genderBox, textStartPass, close,
okButton);
+ binderGroups = new Binder>();
Component groupLayout = createGroupPanel(groups);
contactLayout = new ContactGrid();
contactLayout.setDeleteConsumer(c -> {
@@ -175,18 +184,46 @@ public class PersonEditDetails extends HorizontalLayout {
for (GroupDef g : groups) {
Switch sw = new Switch(g.getName());
+ sw.setId("Group_" + g.getName());
sw.setData(g);
layout.addComponent(sw);
- binder.forField(sw).bind(p -> p.getGroups().contains(g), (bean, fieldvalue) -> {
+ BindingBuilder, Boolean> forField = binderGroups.forField(sw);
+ forField.bind(p -> p.contains(g), (bean, fieldvalue) -> {
if (fieldvalue) {
- bean.getGroups().add(g);
+ bean.add(g);
}
else {
- bean.getGroups().remove(g);
+ bean.remove(g);
}
});
}
+ binder.addValueChangeListener(new ValueChangeListener