View Javadoc

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