1 package de.tivsource.page.admin.actions.locations.location;
2
3
4 import java.util.ArrayList;
5 import java.util.Arrays;
6 import java.util.List;
7
8 import org.apache.logging.log4j.LogManager;
9 import org.apache.logging.log4j.Logger;
10 import org.apache.struts2.convention.annotation.Action;
11 import org.apache.struts2.convention.annotation.Actions;
12 import org.apache.struts2.convention.annotation.Result;
13 import org.apache.struts2.tiles.annotation.TilesDefinition;
14 import org.apache.struts2.tiles.annotation.TilesDefinitions;
15 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
16
17 import de.tivsource.ejb3plugin.InjectEJB;
18 import de.tivsource.page.admin.actions.EmptyAction;
19 import de.tivsource.page.dao.location.LocationDaoLocal;
20 import de.tivsource.page.entity.location.Location;
21 import de.tivsource.page.entity.location.OpeningHour;
22 import de.tivsource.page.enumeration.Weekday;
23
24
25
26
27
28
29 @TilesDefinitions({
30 @TilesDefinition(name="openingHourDeleteForm", extend = "adminTemplate", putAttributes = {
31 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/default.jsp"),
32 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/locations.jsp"),
33 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/location/opening_hour_delete_form.jsp")
34 })
35 })
36 public class OpeningHourDeleteFormAction extends EmptyAction {
37
38
39
40
41 private static final long serialVersionUID = -3637008080563139796L;
42
43
44
45
46 private static final Logger LOGGER = LogManager.getLogger(OpeningHourDeleteFormAction.class);
47
48 @InjectEJB(name="LocationDao")
49 private LocationDaoLocal locationDaoLocal;
50
51 private Location location;
52
53 private String uncheckLocation;
54
55 private Integer openingHoursIndex;
56
57 public Location getLocation() {
58 return location;
59 }
60
61 public void setLocationUuid(String location) {
62 this.uncheckLocation = location;
63 }
64
65 public Integer getOpeningHours() {
66 return openingHoursIndex;
67 }
68
69 public void setOpeningHours(Integer openingHoursIndex) {
70 this.openingHoursIndex = openingHoursIndex;
71 }
72
73 @Override
74 @Actions({
75 @Action(
76 value = "openingHourDeleteForm",
77 results = { @Result(name = "success", type="tiles", location = "openingHourDeleteForm") }
78 )
79 })
80 public String execute() throws Exception {
81 LOGGER.info("execute() aufgerufen.");
82
83 this.loadPageParameter();
84 return SUCCESS;
85 }
86
87 public OpeningHour getOpeningHour() {
88 List<OpeningHour> openingHours = new ArrayList<OpeningHour>(location.getOpeningHours());
89 return openingHours.get(openingHoursIndex);
90 }
91
92 public List<Weekday> getWeekdays() {
93 return Arrays.asList(Weekday.values());
94 }
95
96 private void loadPageParameter() {
97
98 if( uncheckLocation != null && uncheckLocation != "" && uncheckLocation.length() > 0) {
99 location = locationDaoLocal.findByUuid(uncheckLocation);
100 }
101
102 }
103
104 }