View Javadoc

1   package de.tivsource.page.admin.actions.others.gallery;
2   
3   import java.util.Arrays;
4   import java.util.List;
5   
6   import org.apache.logging.log4j.LogManager;
7   import org.apache.logging.log4j.Logger;
8   import org.apache.struts2.convention.annotation.Action;
9   import org.apache.struts2.convention.annotation.Actions;
10  import org.apache.struts2.convention.annotation.Result;
11  import org.apache.struts2.tiles.annotation.TilesDefinition;
12  import org.apache.struts2.tiles.annotation.TilesDefinitions;
13  import org.apache.struts2.tiles.annotation.TilesPutAttribute;
14  
15  import de.tivsource.ejb3plugin.InjectEJB;
16  import de.tivsource.page.admin.actions.EmptyAction;
17  import de.tivsource.page.common.css.CSSGroup;
18  import de.tivsource.page.dao.cssgroup.CSSGroupDaoLocal;
19  import de.tivsource.page.dao.gallery.GalleryDaoLocal;
20  import de.tivsource.page.dao.picture.PictureDaoLocal;
21  import de.tivsource.page.entity.gallery.Gallery;
22  import de.tivsource.page.entity.picture.Picture;
23  import de.tivsource.page.enumeration.GalleryType;
24  
25  /**
26   * 
27   * @author Marc Michele
28   *
29   */
30  @TilesDefinitions({
31    @TilesDefinition(name="galleryAddForm",  extend = "adminTemplate", putAttributes = {
32      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
33      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
34      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/gallery/add_form.jsp")
35    }),
36    @TilesDefinition(name="galleryEditForm", extend = "adminTemplate", putAttributes = {
37      @TilesPutAttribute(name = "meta",       value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
38      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
39      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/gallery/edit_form.jsp")
40    }),
41    @TilesDefinition(name="galleryDeleteForm", extend = "adminTemplate", putAttributes = {
42      @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
43      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/gallery/delete_form.jsp")
44    })
45  })
46  public class FormAction extends EmptyAction {
47  
48  	/**
49  	 * Serial Version UID.
50  	 */
51  	private static final long serialVersionUID = -3282620598068445927L;
52  
53  	/**
54       * Statischer Logger der Klasse.
55       */
56      private static final Logger LOGGER = LogManager.getLogger(FormAction.class);
57  
58      @InjectEJB(name = "CSSGroupDao")
59      private CSSGroupDaoLocal cssGroupDaoLocal;
60  
61      @InjectEJB(name="GalleryDao")
62      private GalleryDaoLocal galleryDaoLocal;
63  
64      @InjectEJB(name="PictureDao")
65      private PictureDaoLocal pictureDaoLocal;
66  
67      private Gallery gallery;
68  
69      private String uncheckGallery;
70  
71      private String lang = "DE";
72  
73      private List<Picture> pictureList;
74  
75      private List<CSSGroup> cssGroupList;
76  
77      public Gallery getGallery() {
78          return gallery;
79      }
80  
81  	public void setGallery(String uncheckGallery) {
82          this.uncheckGallery = uncheckGallery;
83      }
84  
85  	public String getLang() {
86  	    return lang;
87  	}
88  
89  	public void setLang(String lang) {
90  	    this.lang = lang;
91  	}
92  
93      @Override
94      public void prepare() {
95          super.prepare();
96          cssGroupList = cssGroupDaoLocal.findAll(0, cssGroupDaoLocal.countAll());
97      }
98  
99  	@Override
100     @Actions({
101         @Action(
102             value = "editForm",
103             results = { @Result(name = "success", type="tiles", location = "galleryEditForm") }
104         ),
105         @Action(
106             value = "addForm",
107             results = { @Result(name = "success", type="tiles", location = "galleryAddForm") }
108         ),
109         @Action(
110             value = "deleteForm",
111             results = { @Result(name = "success", type="tiles", location = "galleryDeleteForm") }
112         )
113     })
114     public String execute() throws Exception {
115     	LOGGER.info("execute() aufgerufen.");
116     	this.loadPageParameter();
117     	return SUCCESS;
118     }// Ende execute()
119 
120 	public List<GalleryType> getGalleryTypeList() {
121 	    return Arrays.asList(GalleryType.values());
122 	}
123 
124     public List<Picture> getPictureList() {
125         return pictureList;
126     }// Ende getPictureList()
127 
128     public List<CSSGroup> getCssGroupList() {
129         LOGGER.info("getCssGroupList() aufgerufen.");
130         LOGGER.info("Anzahl der CSS-Gruppen in der Liste: " + cssGroupList.size());
131         return cssGroupList;
132     }// Ende getCssGroupList()
133 
134 	private void loadPageParameter() {
135 	    LOGGER.info("loadPageParameter() aufgerufen.");
136 		if( uncheckGallery != null && uncheckGallery != "" && uncheckGallery.length() > 0) {
137 		    gallery = galleryDaoLocal.findByUuid(uncheckGallery);
138 		    pictureList = pictureDaoLocal.findAll(uncheckGallery);
139 		} else {
140 		    gallery = new Gallery();
141 		}
142 	}// Ende loadPageParameter()
143 
144 }// Ende class