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