Implemented Delete

master
Markus Kreth 7 years ago
parent ad53664e14
commit 6904bc87e6
  1. 7
      .classpath
  2. 1
      .settings/org.eclipse.core.resources.prefs
  3. 19
      .settings/org.eclipse.wst.common.component
  4. 8
      pom.xml
  5. 12
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/VaadinClubhelperApplication.java
  6. 5
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/business/EventBusiness.java
  7. 2
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDao.java
  8. 10
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/dao/ClubEventDaoImpl.java
  9. 8
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainUi.java
  10. 8
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/MainView.java
  11. 11
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/EventDetails.java
  12. 62
      src/main/java/de/kreth/vaadin/clubhelper/vaadinclubhelper/ui/components/SingleEventView.java

@ -30,13 +30,6 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="target/generated-resources/gwt">
<attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

@ -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/main/resources/jasper/calendar_year.jrxml=UTF-8
encoding//src/test/java=UTF-8 encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8 encoding//src/test/resources=UTF-8
encoding//target/generated-resources/gwt=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8

@ -5,7 +5,9 @@
<wb-module deploy-name="vaadin-clubhelper-1.0.3">
<wb-module deploy-name="vaadin-clubhelper-1.0.6-SNAPSHOT">
@ -19,6 +21,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -26,27 +29,28 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<dependent-module archiveName="GoogleConnectors-0.0.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/GoogleConnectors/GoogleConnectors">
<dependency-type>uses</dependency-type>
</dependent-module>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-resources/gwt"/>
@ -60,6 +64,7 @@
<property name="java-output-path" value="/vaadin-clubhelper/target/classes"/> <property name="java-output-path" value="/vaadin-clubhelper/target/classes"/>
@ -67,6 +72,7 @@
</wb-module> </wb-module>
@ -74,4 +80,5 @@
</project-modules> </project-modules>

@ -29,9 +29,6 @@
<java.version>11</java.version> <java.version>11</java.version>
<vaadin.version>8.6.2</vaadin.version> <vaadin.version>8.6.2</vaadin.version>
<selenium.version>3.141.59</selenium.version> <selenium.version>3.141.59</selenium.version>
<google-api-version>1.23.0</google-api-version>
<google-api-sheets-version>v4-rev488-1.23.0</google-api-sheets-version>
<google-api-calendar-version>v3-rev271-1.23.0</google-api-calendar-version>
<start-class>de.kreth.vaadin.clubhelper.vaadinclubhelper.VaadinClubhelperApplication</start-class> <start-class>de.kreth.vaadin.clubhelper.vaadinclubhelper.VaadinClubhelperApplication</start-class>
<sonar.login>7af449877bbf41d707e8ae7d322b1d6e9b15a89d</sonar.login> <sonar.login>7af449877bbf41d707e8ae7d322b1d6e9b15a89d</sonar.login>
@ -229,6 +226,11 @@
<artifactId>jasperreports-functions</artifactId> <artifactId>jasperreports-functions</artifactId>
<version>6.7.0</version> <version>6.7.0</version>
</dependency> </dependency>
<dependency>
<groupId>de.kreth.googleconnect</groupId>
<artifactId>GoogleConnectors</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>

@ -1,11 +1,17 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper; package de.kreth.vaadin.clubhelper.vaadinclubhelper;
import java.io.IOException;
import java.security.GeneralSecurityException;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import de.kreth.googleconnectors.calendar.CalendarAdapter;
@SpringBootApplication(scanBasePackages = { "de.kreth.vaadin.clubhelper", "de.kreth.clubhelperbackend" }) @SpringBootApplication(scanBasePackages = { "de.kreth.vaadin.clubhelper", "de.kreth.clubhelperbackend" })
@EnableScheduling @EnableScheduling
public class VaadinClubhelperApplication extends SpringBootServletInitializer { public class VaadinClubhelperApplication extends SpringBootServletInitializer {
@ -18,4 +24,10 @@ public class VaadinClubhelperApplication extends SpringBootServletInitializer {
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(VaadinClubhelperApplication.class); return builder.sources(VaadinClubhelperApplication.class);
} }
@Bean
public CalendarAdapter calendarAdapter() throws GeneralSecurityException, IOException {
return new CalendarAdapter();
}
} }

@ -90,4 +90,9 @@ public class EventBusiness {
public void storeEventType() { public void storeEventType() {
clubEventDao.updateEventType(current); clubEventDao.updateEventType(current);
} }
public void delete(ClubEvent bean) {
clubEventDao.delete(bean);
current = null;
}
} }

@ -17,4 +17,6 @@ public interface ClubEventDao extends IDao<ClubEvent> {
void addPersons(ClubEvent event, Collection<Person> persons); void addPersons(ClubEvent event, Collection<Person> persons);
void updateEventType(ClubEvent obj); void updateEventType(ClubEvent obj);
void delete(ClubEvent obj);
} }

@ -16,7 +16,6 @@ import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.Person;
@Repository @Repository
@Transactional
public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements ClubEventDao { public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements ClubEventDao {
private static final long serialVersionUID = 7648111697282525347L; private static final long serialVersionUID = 7648111697282525347L;
@ -26,6 +25,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements Club
} }
@Override @Override
@Transactional
public void save(ClubEvent obj) { public void save(ClubEvent obj) {
CompetitionType competitionType = obj.getCompetitionType(); CompetitionType competitionType = obj.getCompetitionType();
if (competitionType != null) { if (competitionType != null) {
@ -62,6 +62,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements Club
current.removeAll(removed); current.removeAll(removed);
} }
@Transactional
public void executeQueries(ClubEvent event, List<Person> added, List<Person> removed) { public void executeQueries(ClubEvent event, List<Person> added, List<Person> removed) {
if (!added.isEmpty()) { if (!added.isEmpty()) {
Query insertQuery = entityManager.createNativeQuery( Query insertQuery = entityManager.createNativeQuery(
@ -84,6 +85,7 @@ public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements Club
} }
@Override @Override
@Transactional
public void updateEventType(ClubEvent obj) { public void updateEventType(ClubEvent obj) {
CompetitionType type = obj.getCompetitionType(); CompetitionType type = obj.getCompetitionType();
if (type != null) { if (type != null) {
@ -103,4 +105,10 @@ public class ClubEventDaoImpl extends AbstractDaoImpl<ClubEvent> implements Club
} }
} }
@Override
@Transactional
public void delete(ClubEvent entity) {
entityManager.remove(entityManager.contains(entity) ? entity : entityManager.merge(entity));
}
} }

@ -8,12 +8,12 @@ import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Push; import com.vaadin.annotations.Push;
import com.vaadin.annotations.Theme; import com.vaadin.annotations.Theme;
import com.vaadin.navigator.Navigator; import com.vaadin.navigator.Navigator;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.VaadinRequest; import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.communication.PushMode; import com.vaadin.shared.communication.PushMode;
import com.vaadin.spring.annotation.SpringUI; import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.ui.UI; 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.business.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.PersonDao;
@ -45,6 +45,9 @@ public class MainUi extends UI {
@Autowired @Autowired
SecurityVerifier securityGroupVerifier; SecurityVerifier securityGroupVerifier;
@Autowired
CalendarAdapter calendarAdapter;
@Override @Override
protected void init(VaadinRequest request) { 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(MainView.VIEW_NAME, new MainView(personDao, groupDao, eventBusiness, securityGroupVerifier));
navigator.addView(LoginUI.VIEW_NAME, new LoginUI(personDao, securityGroupVerifier)); navigator.addView(LoginUI.VIEW_NAME, new LoginUI(personDao, securityGroupVerifier));
navigator.addView(PersonEditView.VIEW_NAME, new PersonEditView(groupDao, personDao)); 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); navigator.navigateTo(MainView.VIEW_NAME);
} }

@ -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.data.Person;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.security.SecurityVerifier; 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.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.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.PersonGrid;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView; import de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components.SingleEventView;
@ -74,6 +74,8 @@ public class MainView extends VerticalLayout implements NamedView {
openPersonViewForEvent(current); openPersonViewForEvent(current);
if (current != null) { if (current != null) {
calendar.setToday(current.getStart()); calendar.setToday(current.getStart());
} else {
reloadEvents();
} }
head.updateLoggedinPerson(); head.updateLoggedinPerson();
} else { } else {
@ -137,6 +139,10 @@ public class MainView extends VerticalLayout implements NamedView {
setExpandRatio(mainLayout, 1f); setExpandRatio(mainLayout, 1f);
setSizeFull(); setSizeFull();
reloadEvents();
}
public void reloadEvents() {
ExecutorService exec = Executors.newSingleThreadExecutor(); ExecutorService exec = Executors.newSingleThreadExecutor();
exec.execute(() -> { exec.execute(() -> {

@ -11,6 +11,7 @@ import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; 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.EventBusiness;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung; import de.kreth.vaadin.clubhelper.vaadinclubhelper.business.meldung.EventMeldung;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao; import de.kreth.vaadin.clubhelper.vaadinclubhelper.dao.GroupDao;
@ -33,14 +34,16 @@ public class EventDetails extends GridLayout implements NamedView {
private SingleEventView eventView; private SingleEventView eventView;
private PersonGrid personGrid; private PersonGrid personGrid;
private EventAltersgruppen eventAltersgruppen; private EventAltersgruppen eventAltersgruppen;
private CalendarAdapter calendarAdapter;
public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness, public EventDetails(PersonDao personDao, GroupDao groupDao, EventBusiness eventBusiness, PflichtenDao pflichtenDao,
PflichtenDao pflichtenDao) { CalendarAdapter calendarAdapter) {
super(3, 5); super(3, 5);
this.eventBusiness = eventBusiness; this.eventBusiness = eventBusiness;
this.personDao = personDao; this.personDao = personDao;
this.groupDao = groupDao; this.groupDao = groupDao;
this.pflichtenDao = pflichtenDao; this.pflichtenDao = pflichtenDao;
this.calendarAdapter = calendarAdapter;
} }
@Override @Override
@ -52,6 +55,10 @@ public class EventDetails extends GridLayout implements NamedView {
Navigator navigator = event.getNavigator(); Navigator navigator = event.getNavigator();
eventView = new SingleEventView(true); eventView = new SingleEventView(true);
eventView.setCalendarAdapter(calendarAdapter);
eventView.setEventBusiness(eventBusiness);
eventView.setDeletedHandler(() -> navigator.navigateTo(((NamedView) event.getOldView()).getViewName()));
eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType()); eventView.addDataUpdatedListener(() -> eventBusiness.storeEventType());
eventAltersgruppen = new EventAltersgruppen(pflichtenDao, eventBusiness); eventAltersgruppen = new EventAltersgruppen(pflichtenDao, eventBusiness);

@ -1,5 +1,6 @@
package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components; package de.kreth.vaadin.clubhelper.vaadinclubhelper.ui.components;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@ -14,6 +15,8 @@ import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Notification; import com.vaadin.ui.Notification;
import com.vaadin.ui.TextField; 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.ClubEvent;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType;
import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type; import de.kreth.vaadin.clubhelper.vaadinclubhelper.data.CompetitionType.Type;
@ -35,7 +38,12 @@ public class SingleEventView extends CustomComponent {
private Binder<ClubEvent> binder; private Binder<ClubEvent> binder;
private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler(); private DefaultDataUpdateHandler updateHandler = new DefaultDataUpdateHandler();
private Button deleteEvent; private Button deleteButton;
private CalendarAdapter calendarAdapter;
private EventBusiness eventBusiness;
private Runnable deletedHandler;
public SingleEventView(boolean showCompetitionType) { public SingleEventView(boolean showCompetitionType) {
setCaption("Gewählte Veranstaltung"); setCaption("Gewählte Veranstaltung");
@ -84,22 +92,46 @@ public class SingleEventView extends CustomComponent {
layout = new GridLayout(2, 2); layout = new GridLayout(2, 2);
} }
deleteEvent = new Button("Löschen"); deleteButton = new Button("Löschen");
layout.setMargin(true); layout.setMargin(true);
layout.setSpacing(true); layout.setSpacing(true);
layout.addComponents(textTitle, startDate, textLocation, endDate); layout.addComponents(textTitle, startDate, textLocation, endDate);
if (showCompetitionType) { if (showCompetitionType) {
layout.addComponent(competitionType); layout.addComponent(competitionType);
deleteEvent = new Button("Löschen"); deleteButton = new Button("Löschen");
deleteEvent.addClickListener(ev -> deleteEvent()); deleteButton.addClickListener(ev -> deleteEvent());
layout.addComponent(deleteEvent); layout.addComponent(deleteButton);
} }
setCompositionRoot(layout); setCompositionRoot(layout);
} }
private void deleteEvent() { private void deleteEvent() {
Notification.show("Termin löschen?", "Soll " + binder.getBean() + " wirklich gelöscht werden?", ClubEvent bean = binder.getBean();
Notification.Type.HUMANIZED_MESSAGE);
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<LocalDate> event) { void endDateVisibleCheck(ValueChangeEvent<LocalDate> event) {
@ -122,6 +154,10 @@ public class SingleEventView extends CustomComponent {
return updateHandler.remove(o); return updateHandler.remove(o);
} }
public void setDeletedHandler(Runnable deletedHandler) {
this.deletedHandler = deletedHandler;
}
void setTitle(String value) { void setTitle(String value) {
if (value == null) { if (value == null) {
value = ""; value = "";
@ -141,13 +177,21 @@ public class SingleEventView extends CustomComponent {
binder.setBean(ev); binder.setBean(ev);
if (ev != null) { if (ev != null) {
deleteEvent.setEnabled(true); deleteButton.setEnabled(true);
} else { } else {
setTitle(""); setTitle("");
setLocation(""); setLocation("");
endDate.setVisible(false); 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;
} }
} }

Loading…
Cancel
Save