View Javadoc

1   package de.tivsource.page.user.actions.sitemap;
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  
11  import de.tivsource.ejb3plugin.InjectEJB;
12  import de.tivsource.page.dao.event.EventDaoLocal;
13  import de.tivsource.page.dao.location.LocationDaoLocal;
14  import de.tivsource.page.entity.event.Event;
15  import de.tivsource.page.entity.location.Location;
16  import de.tivsource.page.user.actions.EmptyAction;
17  
18  /**
19   * 
20   * @author Marc Michele
21   *
22   */
23  public class IndexAction extends EmptyAction {
24  
25      /**
26       * Serial Version UID.
27       */
28  	private static final long serialVersionUID = 7064780265619899524L;
29  
30  	/**
31       * Statischer Logger der Klasse.
32       */
33      private static final Logger LOGGER = LogManager.getLogger(IndexAction.class);
34  
35      @InjectEJB(name="LocationDao")
36      private LocationDaoLocal locationDaoLocal;
37  
38      @InjectEJB(name="EventDao")
39      private EventDaoLocal eventDaoLocal;
40  
41      @Override
42      @Actions({
43          @Action(value = "main", results = {
44              @Result(name = "success", type = "tiles", location = "sitemapTemplate")
45          })
46      })
47      public String execute() throws Exception {
48          LOGGER.info("execute() aufgerufen.");
49  
50          // Hole Action Locale
51          this.getLanguageFromActionContext();
52  
53          return SUCCESS;
54      }// Ende execute()
55  
56      public List<Location> getLocation() {
57          return locationDaoLocal.findAllEventLocation();
58      }
59  
60      public Integer getMaxLocationPages(String locationUuid) {
61      	Integer TO = 7;
62          LOGGER.debug("getDBCount() aufgerufen.");
63          Integer dbQuantity = this.eventDaoLocal.countAll(locationUuid);
64          LOGGER.debug("DbQuantity: " + dbQuantity);
65          // Berechne die Maximal mögliche Seitenzahl
66          Integer maxPages = (dbQuantity % TO == 0) ? (dbQuantity / TO) : (dbQuantity / TO) + 1;
67          LOGGER.debug("MaxPages: " + maxPages);
68      	return maxPages;
69      }
70  
71      public List<Event> getEvents(String locationUuid) {
72      	return eventDaoLocal.findAll(locationUuid, 0, eventDaoLocal.countAll(locationUuid));
73      }
74  
75  }// Ende class