1 package de.tivsource.page.admin.actions.locations.reservation;
2
3 import org.apache.logging.log4j.LogManager;
4 import org.apache.logging.log4j.Logger;
5 import org.apache.struts2.convention.annotation.Action;
6 import org.apache.struts2.convention.annotation.Actions;
7 import org.apache.struts2.convention.annotation.Result;
8
9 import de.tivsource.ejb3plugin.InjectEJB;
10 import de.tivsource.page.admin.actions.EmptyAction;
11 import de.tivsource.page.dao.reservation.ReservationDaoLocal;
12 import de.tivsource.page.entity.reservation.Reservation;
13
14
15
16
17
18
19 public class DeleteAction extends EmptyAction {
20
21
22
23
24 private static final long serialVersionUID = 2932939605984995920L;
25
26
27
28
29 private static final Logger LOGGER = LogManager.getLogger(DeleteAction.class);
30
31 @InjectEJB(name="ReservationDao")
32 private ReservationDaoLocal reservationDaoLocal;
33
34 private String redirect;
35
36 private Reservation reservation;
37
38 public Reservation getReservation() {
39 return reservation;
40 }
41
42 public void setReservation(Reservation reservation) {
43 this.reservation = reservation;
44 }
45
46 public String getRedirect() {
47 return redirect;
48 }
49
50 @Override
51 @Actions({
52 @Action(
53 value = "delete",
54 results = {
55 @Result(name = "success", type = "redirectAction", location = "${redirect}"),
56 @Result(name = "input", type="tiles", location = "reservationDeleteForm"),
57 @Result(name = "error", type="tiles", location = "reservationDeleteError")
58 }
59 )
60 })
61 public String execute() throws Exception {
62 LOGGER.info("execute() aufgerufen.");
63
64 if(reservation != null) {
65 Reservation dbReservation = reservationDaoLocal.findByUuid(reservation.getUuid());
66 redirect = "index.html?event=" + dbReservation.getEvent().getUuid();
67 reservationDaoLocal.delete(dbReservation);
68 return SUCCESS;
69 }
70 else {
71 return ERROR;
72 }
73
74
75 }
76
77 }