View Javadoc

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