1 package de.tivsource.page.admin.actions.others.appointment;
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.appointment.AppointmentDaoLocal;
18 import de.tivsource.page.dao.cssgroup.CSSGroupDaoLocal;
19 import de.tivsource.page.dao.picture.PictureDaoLocal;
20 import de.tivsource.page.dao.property.PropertyDaoLocal;
21 import de.tivsource.page.entity.appointment.Appointment;
22 import de.tivsource.page.entity.picture.Picture;
23
24
25
26
27
28
29 @TilesDefinitions({
30 @TilesDefinition(name="appointmentAddForm", extend = "adminTemplate", putAttributes = {
31 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
32 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
33 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/appointment/add_form.jsp")
34 }),
35 @TilesDefinition(name="appointmentEditForm", extend = "adminTemplate", putAttributes = {
36 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
37 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
38 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/appointment/edit_form.jsp")
39 }),
40 @TilesDefinition(name="appointmentCopyForm", extend = "adminTemplate", putAttributes = {
41 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
42 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
43 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/appointment/copy_form.jsp")
44 }),
45 @TilesDefinition(name="appointmentDeleteForm", extend = "adminTemplate", putAttributes = {
46 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
47 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/appointment/delete_form.jsp")
48 })
49 })
50 public class FormAction extends EmptyAction {
51
52
53
54
55 private static final long serialVersionUID = -1717965175888317083L;
56
57
58
59
60 private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
61
62 @InjectEJB(name="AppointmentDao")
63 private AppointmentDaoLocal appointmentDaoLocal;
64
65 @InjectEJB(name = "CSSGroupDao")
66 private CSSGroupDaoLocal cssGroupDaoLocal;
67
68 @InjectEJB(name="PictureDao")
69 private PictureDaoLocal pictureDaoLocal;
70
71 @InjectEJB(name="PropertyDao")
72 private PropertyDaoLocal propertyDaoLocal;
73
74 private Appointment appointment;
75
76 private String uncheckAppointment;
77
78 private String lang = "DE";
79
80 private List<Picture> pictureList;
81
82 private List<CSSGroup> cssGroupList;
83
84 public Appointment getAppointment() {
85 return appointment;
86 }
87
88 public void setAppointment(String uncheckAppointment) {
89 this.uncheckAppointment = uncheckAppointment;
90 }
91
92 public String getLang() {
93 return lang;
94 }
95
96 public void setLang(String lang) {
97 this.lang = lang;
98 }
99
100 @Override
101 public void prepare() {
102 super.prepare();
103 pictureList = pictureDaoLocal.findAll(propertyDaoLocal.findByKey("gallery.uuid.for.appointment.picture").getValue());
104 cssGroupList = cssGroupDaoLocal.findAll(0, cssGroupDaoLocal.countAll());
105 }
106
107 @Override
108 @Actions({
109 @Action(
110 value = "editForm",
111 results = { @Result(name = "success", type="tiles", location = "appointmentEditForm") }
112 ),
113 @Action(
114 value = "addForm",
115 results = { @Result(name = "success", type="tiles", location = "appointmentAddForm") }
116 ),
117 @Action(
118 value = "copyForm",
119 results = { @Result(name = "success", type="tiles", location = "appointmentCopyForm") }
120 ),
121 @Action(
122 value = "deleteForm",
123 results = { @Result(name = "success", type="tiles", location = "appointmentDeleteForm") }
124 )
125 })
126 public String execute() throws Exception {
127 LOGGER.info("execute() aufgerufen.");
128
129 this.loadPageParameter();
130 return SUCCESS;
131 }
132
133 private void loadPageParameter() {
134
135 if( uncheckAppointment != null && uncheckAppointment != "" && uncheckAppointment.length() > 0) {
136 appointment = appointmentDaoLocal.findByUuid(uncheckAppointment);
137 } else {
138 appointment = new Appointment();
139 }
140
141 }
142
143 public List<Picture> getPictureList() {
144 return pictureList;
145 }
146
147 public List<CSSGroup> getCssGroupList() {
148 LOGGER.info("getCssGroupList() aufgerufen.");
149 LOGGER.info("Anzahl der CSS-Gruppen in der Liste: " + cssGroupList.size());
150 return cssGroupList;
151 }
152
153 }