View Javadoc

1   package de.tivsource.page.user.actions.reservation;
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.dao.location.LocationDaoLocal;
16  import de.tivsource.page.dao.page.PageDaoLocal;
17  import de.tivsource.page.dao.property.PropertyDaoLocal;
18  import de.tivsource.page.entity.location.Location;
19  import de.tivsource.page.entity.page.Page;
20  import de.tivsource.page.user.actions.EmptyAction;
21  
22  /**
23   * 
24   * @author Marc Michele
25   *
26   */
27  @TilesDefinitions({
28    @TilesDefinition(name="reservation", extend = "userTemplate", putAttributes = {
29      @TilesPutAttribute(name = "content",    value = "/WEB-INF/tiles/active/view/reservation/reservation.jsp")
30    })
31  })
32  public class IndexAction extends EmptyAction {
33  
34      /**
35       * Serial Version UID.
36       */
37      private static final long serialVersionUID = -3953411070248396460L;
38  
39      /**
40  	 * Statischer Logger der Klasse.
41  	 */
42      private static final Logger LOGGER = LogManager.getLogger(IndexAction.class);
43  
44      @InjectEJB(name="PageDao")
45      private PageDaoLocal pageDaoLocal;
46  
47      @InjectEJB(name="PropertyDao")
48      private PropertyDaoLocal propertyDaoLocal;
49  
50      @InjectEJB(name="LocationDao")
51      private LocationDaoLocal locationDaoLocal;
52  
53      private Page page;
54  
55      @Override
56      public void prepare() {
57          // Lade die Übersichtsseite aus der Datenbank
58          page = pageDaoLocal.findByTechnical("reservation");
59      }
60  
61      @Override
62      @Actions({
63          @Action(
64          		value = "index", 
65          		results = {
66          		  @Result(name = "success", type="tiles", location = "reservation"),
67          		  @Result(name = "error", type = "redirectAction", location = "index.html", params={"namespace", "/"})
68          		}
69          )
70      })
71      public String execute() throws Exception {
72      	LOGGER.info("execute() aufgerufen.");
73  
74      	// Hole Eigenschaft aus der Datenbank
75      	boolean moduleEnabled = propertyDaoLocal.findByKey("module.reservation").getValue().equals("true") ? true : false;
76  
77      	// Prüfe ob das Module aktiviert ist
78      	if(moduleEnabled) {
79              // Hole Action Locale
80              this.getLanguageFromActionContext();
81      	    return SUCCESS;
82      	} else {
83      	    return ERROR;
84      	}
85      }// Ende execute()
86  
87      public Page getPage() {
88      	return page;
89      }// Ende getPage()
90  
91      public List<Location> getList() {
92          return locationDaoLocal.findAllEventLocation();
93      }
94  
95  }// Ende class