View Javadoc
1   /*
2    * #%L
3    * Coser :: Web
4    * %%
5    * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric, Chemit Tony
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Affero General Public License as published by
9    * the Free Software Foundation, either version 3 of the License, or
10   * (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   * 
17   * You should have received a copy of the GNU Affero General Public License
18   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19   * #L%
20   */
21  
22  package fr.ifremer.coser.web.actions.pop;
23  
24  import fr.ifremer.coser.result.request.GetIndicatorsForPopulationIndicatorResultRequest;
25  import fr.ifremer.coser.result.request.GetSpeciesForPopulationIndicatorResultRequest;
26  import fr.ifremer.coser.result.request.GetZonesForPopulationIndicatorResultRequest;
27  import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction;
28  
29  /**
30   * Affiche le graphique demandé.
31   * <p/>
32   * Parametre : zone, species, indicator.
33   *
34   * @author chatellier
35   * @version $Revision$
36   *          <p/>
37   *          Last update : $Date$
38   *          By : $Author$
39   */
40  public class GraphAction extends AbstractCoserJspAction {
41  
42      /** serialVersionUID. */
43      private static final long serialVersionUID = 3385467755357775199L;
44  
45      protected String facade;
46  
47      protected String zone;
48  
49      protected String species;
50  
51      protected String indicator;
52  
53      public String getFacade() {
54          return facade;
55      }
56  
57      public void setFacade(String facade) {
58          this.facade = facade;
59      }
60  
61      public String getZone() {
62          return zone;
63      }
64  
65      public void setZone(String zone) {
66          this.zone = zone;
67      }
68  
69      public String getSpecies() {
70          return species;
71      }
72  
73      public void setSpecies(String species) {
74          this.species = species;
75      }
76  
77      public String getIndicator() {
78          return indicator;
79      }
80  
81      public void setIndicator(String indicator) {
82          this.indicator = indicator;
83      }
84  
85      public String getFacadeDisplayName() {
86          return getService().getFacadeDisplayName(facade);
87      }
88  
89      public String getZoneDisplayName() {
90          GetZonesForPopulationIndicatorResultRequest request =
91                  requestBuilder(GetZonesForPopulationIndicatorResultRequest.class).
92                          addFacade(facade).
93                          toRequest();
94          return getService().getZoneDisplayName(request, zone);
95      }
96  
97      public String getSpeciesDisplayName() {
98          GetSpeciesForPopulationIndicatorResultRequest request =
99                  requestBuilder(GetSpeciesForPopulationIndicatorResultRequest.class).
100                         addFacade(facade).
101                         addZone(zone).
102                         toRequest();
103         return getService().getSpeciesDisplayName(request, species);
104     }
105 
106     public String getIndicatorDisplayName() {
107         GetIndicatorsForPopulationIndicatorResultRequest request =
108                 requestBuilder(GetIndicatorsForPopulationIndicatorResultRequest.class).
109                         addFacade(facade).
110                         addZone(zone).
111                         addSpecies(species).
112                         toRequest();
113         return getService().getIndicatorDisplayName(request, indicator);
114     }
115 
116 //    public String getFacadeDisplayName() {
117 //        WebService webService = ServiceFactory.getWebService();
118 //        String displayName = null;
119 //        try {
120 //            displayName = webService.getFacades().get(facade);
121 //        } catch (CoserBusinessException ex) {
122 //            throw new CoserWebException("Can't get facade display name", ex);
123 //        }
124 //        return displayName;
125 //    }
126 //
127 //    public String getZoneDisplayName() {
128 //        WebService webService = ServiceFactory.getWebService();
129 //        String displayName = null;
130 //        try {
131 //            displayName = webService.getZoneForFacade(facade, false, false).get(zone);
132 //        } catch (CoserBusinessException ex) {
133 //            throw new CoserWebException("Can't get zone display name", ex);
134 //        }
135 //        return displayName;
136 //    }
137 //
138 //    public String getSpeciesDisplayName() {
139 //        WebService webService = ServiceFactory.getWebService();
140 //        String displayName = null;
141 //        try {
142 //            displayName = webService.getSpecies(zone, false).get(species);
143 //        } catch (CoserBusinessException ex) {
144 //            throw new CoserWebException("Can't get species display name", ex);
145 //        }
146 //        return displayName;
147 //    }
148 //
149 //    public String getIndicatorDisplayName() {
150 //
151 //        Locale locale = getLocale();
152 //
153 //        WebService webService = ServiceFactory.getWebService();
154 //        String displayName = null;
155 //        try {
156 //            displayName = webService.getIndicators(zone, species, locale).get(indicator);
157 //        } catch (CoserBusinessException ex) {
158 //            throw new CoserWebException("Can't get species display name", ex);
159 //        }
160 //        return displayName;
161 //    }
162 }