1 package de.tivsource.page.admin.actions.locations.event;
2
3 import java.util.List;
4
5 import org.apache.logging.log4j.LogManager;
6 import org.apache.logging.log4j.Logger;
7 import org.apache.struts2.convention.annotation.Action;
8 import org.apache.struts2.convention.annotation.Actions;
9 import org.apache.struts2.convention.annotation.Result;
10 import org.apache.struts2.tiles.annotation.TilesDefinition;
11 import org.apache.struts2.tiles.annotation.TilesDefinitions;
12 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
13
14 import de.tivsource.ejb3plugin.InjectEJB;
15 import de.tivsource.page.admin.actions.EmptyAction;
16 import de.tivsource.page.common.css.CSSGroup;
17 import de.tivsource.page.dao.cssgroup.CSSGroupDaoLocal;
18 import de.tivsource.page.dao.event.EventDaoLocal;
19 import de.tivsource.page.dao.location.LocationDaoLocal;
20 import de.tivsource.page.dao.picture.PictureDaoLocal;
21 import de.tivsource.page.dao.property.PropertyDaoLocal;
22 import de.tivsource.page.entity.event.Event;
23 import de.tivsource.page.entity.location.Location;
24 import de.tivsource.page.entity.picture.Picture;
25
26
27
28
29
30
31 @TilesDefinitions({
32 @TilesDefinition(name="eventAddForm", extend = "adminTemplate", putAttributes = {
33 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
34 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
35 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/event/add_form.jsp")
36 }),
37 @TilesDefinition(name="eventEditForm", extend = "adminTemplate", putAttributes = {
38 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
39 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
40 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/event/edit_form.jsp")
41 }),
42 @TilesDefinition(name="eventCopyForm", extend = "adminTemplate", putAttributes = {
43 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
44 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
45 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/event/copy_form.jsp")
46 }),
47 @TilesDefinition(name="eventDeleteForm", extend = "adminTemplate", putAttributes = {
48 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
49 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/event/delete_form.jsp")
50 })
51 })
52 public class FormAction extends EmptyAction {
53
54
55
56
57 private static final long serialVersionUID = -8430298776289373788L;
58
59
60
61
62 private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
63
64 @InjectEJB(name = "CSSGroupDao")
65 private CSSGroupDaoLocal cssGroupDaoLocal;
66
67 @InjectEJB(name="EventDao")
68 private EventDaoLocal eventDaoLocal;
69
70 @InjectEJB(name="LocationDao")
71 private LocationDaoLocal locationDaoLocal;
72
73 @InjectEJB(name="PictureDao")
74 private PictureDaoLocal pictureDaoLocal;
75
76 @InjectEJB(name="PropertyDao")
77 private PropertyDaoLocal propertyDaoLocal;
78
79 private Event event;
80
81 private String uncheckEvent;
82
83 private String lang;
84
85 private List<Location> locationList;
86
87 private List<Picture> pictureList;
88
89 private List<CSSGroup> cssGroupList;
90
91 public Event getEvent() {
92 return event;
93 }
94
95 public void setEvent(String uncheckEvent) {
96 this.uncheckEvent = uncheckEvent;
97 }
98
99 public String getLang() {
100 return lang;
101 }
102
103 public void setLang(String lang) {
104 this.lang = lang;
105 }
106
107 @Override
108 public void prepare() {
109 super.prepare();
110 locationList = locationDaoLocal.findAll(0, locationDaoLocal.countAll());
111 pictureList = pictureDaoLocal.findAll(propertyDaoLocal.findByKey("gallery.uuid.for.event.picture").getValue());
112 cssGroupList = cssGroupDaoLocal.findAll(0, cssGroupDaoLocal.countAll());
113 }
114
115 @Override
116 @Actions({
117 @Action(
118 value = "editForm",
119 results = { @Result(name = "success", type="tiles", location = "eventEditForm") }
120 ),
121 @Action(
122 value = "addForm",
123 results = { @Result(name = "success", type="tiles", location = "eventAddForm") }
124 ),
125 @Action(
126 value = "copyForm",
127 results = { @Result(name = "success", type="tiles", location = "eventCopyForm") }
128 ),
129 @Action(
130 value = "deleteForm",
131 results = { @Result(name = "success", type="tiles", location = "eventDeleteForm") }
132 )
133 })
134 public String execute() throws Exception {
135 LOGGER.info("execute() aufgerufen.");
136 this.loadPageParameter();
137 return SUCCESS;
138 }
139
140 public List<Location> getLocationList() {
141 return locationList;
142 }
143
144 public List<Picture> getPictureList() {
145 return pictureList;
146 }
147
148 public List<CSSGroup> getCssGroupList() {
149 LOGGER.info("getCssGroupList() aufgerufen.");
150 LOGGER.info("Anzahl der CSS-Gruppen in der Liste: " + cssGroupList.size());
151 return cssGroupList;
152 }
153
154 private void loadPageParameter() {
155 if( uncheckEvent != null && uncheckEvent != "" && uncheckEvent.length() > 0) {
156 event = eventDaoLocal.findByUuid(uncheckEvent);
157 } else {
158 event = new Event();
159 }
160 }
161
162 }