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