diff --git a/.classpath b/.classpath
index 5772ac7..522ef49 100644
--- a/.classpath
+++ b/.classpath
@@ -30,13 +30,6 @@
-
-
-
-
-
-
-
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
index 6d88dab..f004f42 100644
--- a/.settings/org.eclipse.core.resources.prefs
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -5,5 +5,4 @@ encoding//src/main/resources/jasper/calendar_month.jrxml=UTF-8
encoding//src/main/resources/jasper/calendar_year.jrxml=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
-encoding//target/generated-resources/gwt=UTF-8
encoding/=UTF-8
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index c34e8ca..4524558 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,74 +1,81 @@
-
+
+
-
-
+
+
+
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
+ uses
+
+
-
-
-
+
+
-
+
+
-
+
+
diff --git a/pom.xml b/pom.xml
index 8b4ede2..d47fc04 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,9 +29,6 @@
11
8.6.2
3.141.59
- 1.23.0
- v4-rev488-1.23.0
- v3-rev271-1.23.0
de.kreth.vaadin.clubhelper.vaadinclubhelper.VaadinClubhelperApplication
7af449877bbf41d707e8ae7d322b1d6e9b15a89d
@@ -229,6 +226,11 @@
jasperreports-functions
6.7.0
+
+ de.kreth.googleconnect
+ GoogleConnectors
+ 0.0.2-SNAPSHOT
+
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java
index e28b4c6..7ec225c 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java
@@ -1,11 +1,17 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
+import de.kreth.googleconnectors.calendar.CalendarAdapter;
+
@SpringBootApplication(scanBasePackages = { "de.kreth.vaadin.clubhelper", "de.kreth.clubhelperbackend" })
@EnableScheduling
public class VaadinClubhelperApplication extends SpringBootServletInitializer {
@@ -18,4 +24,10 @@ public class VaadinClubhelperApplication extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(VaadinClubhelperApplication.class);
}
+
+ @Bean
+ public CalendarAdapter calendarAdapter() throws GeneralSecurityException, IOException {
+ return new CalendarAdapter();
+ }
+
}
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 477d96b..d753592 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
@@ -90,4 +90,9 @@ public class EventBusiness {
public void storeEventType() {
clubEventDao.updateEventType(current);
}
+
+ public void delete(ClubEvent bean) {
+ clubEventDao.delete(bean);
+ current = null;
+ }
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDao.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDao.java
index 6502b94..584cf46 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDao.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDao.java
@@ -17,4 +17,6 @@ public interface ClubEventDao extends IDao {
void addPersons(ClubEvent event, Collection persons);
void updateEventType(ClubEvent obj);
+
+ void delete(ClubEvent obj);
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java
index 7d669c7..5e59d4b 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java
@@ -16,7 +16,6 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@Repository
-@Transactional
public class ClubEventDaoImpl extends AbstractDaoImpl implements ClubEventDao {
private static final long serialVersionUID = 7648111697282525347L;
@@ -26,6 +25,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl implements Club
}
@Override
+ @Transactional
public void save(ClubEvent obj) {
CompetitionType competitionType = obj.getCompetitionType();
if (competitionType != null) {
@@ -62,6 +62,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl implements Club
current.removeAll(removed);
}
+ @Transactional
public void executeQueries(ClubEvent event, List added, List removed) {
if (!added.isEmpty()) {
Query insertQuery = entityManager.createNativeQuery(
@@ -84,6 +85,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl implements Club
}
@Override
+ @Transactional
public void updateEventType(ClubEvent obj) {
CompetitionType type = obj.getCompetitionType();
if (type != null) {
@@ -103,4 +105,10 @@ public class ClubEventDaoImpl extends AbstractDaoImpl implements Club
}
}
+ @Override
+ @Transactional
+ public void delete(ClubEvent entity) {
+ entityManager.remove(entityManager.contains(entity) ? entity : entityManager.merge(entity));
+ }
+
}
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 cfd1575..6a1f1ea 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
@@ -8,12 +8,12 @@ import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme;
import com.vaadin.navigator.Navigator;
-import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.UI;
+import de.kreth.googleconnectors.calendar.CalendarAdapter;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
@@ -45,6 +45,9 @@ public class MainUi extends UI {
@Autowired
SecurityVerifier securityGroupVerifier;
+ @Autowired
+ CalendarAdapter calendarAdapter;
+
@Override
protected void init(VaadinRequest request) {
@@ -58,7 +61,8 @@ public class MainUi extends UI {
navigator.addView(MainView.VIEW_NAME, new MainView(personDao, groupDao, eventBusiness, securityGroupVerifier));
navigator.addView(LoginUI.VIEW_NAME, new LoginUI(personDao, securityGroupVerifier));
navigator.addView(PersonEditView.VIEW_NAME, new PersonEditView(groupDao, personDao));
- navigator.addView(EventDetails.VIEW_NAME, new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao));
+ navigator.addView(EventDetails.VIEW_NAME,
+ new EventDetails(personDao, groupDao, eventBusiness, pflichtenDao, calendarAdapter));
navigator.navigateTo(MainView.VIEW_NAME);
}
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainView.java
index 4bf0b7d..b14c4cb 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainView.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainView.java
@@ -25,8 +25,8 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent;
-import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.CalendarComponent.ClubEventProvider;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.EventDetails;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.PersonGrid;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView;
@@ -74,6 +74,8 @@ public class MainView extends VerticalLayout implements NamedView {
openPersonViewForEvent(current);
if (current != null) {
calendar.setToday(current.getStart());
+ } else {
+ reloadEvents();
}
head.updateLoggedinPerson();
} else {
@@ -137,6 +139,10 @@ public class MainView extends VerticalLayout implements NamedView {
setExpandRatio(mainLayout, 1f);
setSizeFull();
+ reloadEvents();
+ }
+
+ public void reloadEvents() {
ExecutorService exec = Executors.newSingleThreadExecutor();
exec.execute(() -> {
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 dcdce7c..8482d75 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
@@ -11,6 +11,7 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
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.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
@@ -33,14 +34,16 @@ public class EventDetails extends GridLayout implements NamedView {
private SingleEventView eventView;
private PersonGrid personGrid;
private EventAltersgruppen eventAltersgruppen;
+ private CalendarAdapter calendarAdapter;
- public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness,
- PflichtenDao pflichtenDao) {
+ public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness, PflichtenDao pflichtenDao,
+ CalendarAdapter calendarAdapter) {
super(3, 5);
this.eventBusiness = eventBusiness;
this.personDao = personDao;
this.groupDao = groupDao;
this.pflichtenDao = pflichtenDao;
+ this.calendarAdapter = calendarAdapter;
}
@Override
@@ -52,6 +55,10 @@ public class EventDetails extends GridLayout implements NamedView {
Navigator navigator = event.getNavigator();
eventView = new SingleEventView(true);
+ eventView.setCalendarAdapter(calendarAdapter);
+ eventView.setEventBusiness(eventBusiness);
+ eventView.setDeletedHandler(() -> navigator.navigateTo(((NamedView) event.getOldView()).getViewName()));
+
eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType());
eventAltersgruppen = new EventAltersgruppen(pflichtenDao, eventBusiness);
diff --git a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java
index 50004ae..4c7690d 100644
--- a/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java
+++ b/src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java
@@ -1,5 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
+import java.io.IOException;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
@@ -14,6 +15,8 @@ import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField;
+import de.kreth.googleconnectors.calendar.CalendarAdapter;
+import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type;
@@ -35,7 +38,12 @@ public class SingleEventView extends CustomComponent {
private Binder binder;
private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler();
- private Button deleteEvent;
+ private Button deleteButton;
+
+ private CalendarAdapter calendarAdapter;
+
+ private EventBusiness eventBusiness;
+ private Runnable deletedHandler;
public SingleEventView(boolean showCompetitionType) {
setCaption("Gewählte Veranstaltung");
@@ -84,22 +92,46 @@ public class SingleEventView extends CustomComponent {
layout = new GridLayout(2, 2);
}
- deleteEvent = new Button("Löschen");
+ deleteButton = new Button("Löschen");
layout.setMargin(true);
layout.setSpacing(true);
layout.addComponents(textTitle, startDate, textLocation, endDate);
if (showCompetitionType) {
layout.addComponent(competitionType);
- deleteEvent = new Button("Löschen");
- deleteEvent.addClickListener(ev -> deleteEvent());
- layout.addComponent(deleteEvent);
+ deleteButton = new Button("Löschen");
+ deleteButton.addClickListener(ev -> deleteEvent());
+ layout.addComponent(deleteButton);
}
setCompositionRoot(layout);
}
private void deleteEvent() {
- Notification.show("Termin löschen?", "Soll " + binder.getBean() + " wirklich gelöscht werden?",
- Notification.Type.HUMANIZED_MESSAGE);
+ ClubEvent bean = binder.getBean();
+
+ ConfirmDialog dlg = ConfirmDialog.builder().setCaption("Löschen bestätigen!").setMessage("Wollen Sie Termin \""
+ + bean.getCaption() + "\" vom " + bean.getStart() + "\" bis " + bean.getEnd()
+ + " wirklich löschen? Dieser Vorgang kann nicht rückgängig gemacht werden und betrifft auch den Online Google Calendar.")
+ .setResultHandler(btn -> {
+ if (btn == ConfirmDialog.Buttons.YES) {
+ try {
+ String host = getUI().getPage().getLocation().getHost();
+ if (calendarAdapter.deleteEvent(host, bean.getOrganizerDisplayName(), bean.getId())) {
+ eventBusiness.delete(bean);
+ if (deletedHandler != null) {
+ deletedHandler.run();
+ }
+ } else {
+ Notification.show("Fehler beim Löschen von " + bean, "Bitte erneut versuchen.",
+ Notification.Type.ERROR_MESSAGE);
+ }
+ } catch (IOException e) {
+ Notification.show("Fehler beim Löschen von " + bean, e.toString(),
+ Notification.Type.ERROR_MESSAGE);
+ }
+ }
+ }).yesCancel().build();
+ getUI().addWindow(dlg);
+
}
void endDateVisibleCheck(ValueChangeEvent event) {
@@ -122,6 +154,10 @@ public class SingleEventView extends CustomComponent {
return updateHandler.remove(o);
}
+ public void setDeletedHandler(Runnable deletedHandler) {
+ this.deletedHandler = deletedHandler;
+ }
+
void setTitle(String value) {
if (value == null) {
value = "";
@@ -141,13 +177,21 @@ public class SingleEventView extends CustomComponent {
binder.setBean(ev);
if (ev != null) {
- deleteEvent.setEnabled(true);
+ deleteButton.setEnabled(true);
} else {
setTitle("");
setLocation("");
endDate.setVisible(false);
- deleteEvent.setEnabled(false);
+ deleteButton.setEnabled(false);
}
}
+ public void setCalendarAdapter(CalendarAdapter calendarAdapter) {
+ this.calendarAdapter = calendarAdapter;
+ }
+
+ public void setEventBusiness(EventBusiness eventBusiness) {
+ this.eventBusiness = eventBusiness;
+ }
+
}