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.com;
23  
24  import fr.ifremer.coser.result.request.GetIndicatorsForCommunityIndicatorResultRequest;
25  import fr.ifremer.coser.result.request.GetSpeciesListForCommunityIndicatorResultRequest;
26  import fr.ifremer.coser.result.request.GetZonesForCommunityIndicatorResultRequest;
27  import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction;
28  
29  import java.util.Map;
30  
31  /**
32   * Affiche le graphique demandé.
33   * <p/>
34   * Parametre : zone, species, indicator.
35   *
36   * @author chatellier
37   * @version $Revision$
38   *          <p/>
39   *          Last update : $Date$
40   *          By : $Author$
41   */
42  public class GraphAction extends AbstractCoserJspAction {
43  
44      /** serialVersionUID. */
45      private static final long serialVersionUID = 3385467755357775199L;
46  
47      protected String facade;
48  
49      protected String zone;
50  
51      protected String indicator;
52  
53      /** La liste des nom de liste du fichier de communauté pour l'indicateur. */
54      protected Map<String, String> lists;
55  
56      /** La liste actuellement selectionnée (cas null géré). */
57      protected String list;
58  
59      public String getFacade() {
60          return facade;
61      }
62  
63      public void setFacade(String facade) {
64          this.facade = facade;
65      }
66  
67      public String getZone() {
68          return zone;
69      }
70  
71      public void setZone(String zone) {
72          this.zone = zone;
73      }
74  
75      public String getIndicator() {
76          return indicator;
77      }
78  
79      public void setIndicator(String indicator) {
80          this.indicator = indicator;
81      }
82  
83      public Map<String, String> getLists() {
84          return lists;
85      }
86  
87      public String getList() {
88          return list;
89      }
90  
91      public void setList(String list) {
92          this.list = list;
93      }
94  
95      public String getFacadeDisplayName() {
96          return getService().getFacadeDisplayName(facade);
97      }
98  
99      public String getZoneDisplayName() {
100         GetZonesForCommunityIndicatorResultRequest request =
101                 requestBuilder(GetZonesForCommunityIndicatorResultRequest.class).
102                         addFacade(facade).
103                         toRequest();
104         return getService().getZoneDisplayName(request, zone);
105     }
106 
107     public String getIndicatorDisplayName() {
108         GetIndicatorsForCommunityIndicatorResultRequest request =
109                 requestBuilder(GetIndicatorsForCommunityIndicatorResultRequest.class).
110                         addFacade(facade).
111                         addZone(zone).
112                         toRequest();
113         return getService().getIndicatorDisplayName(request, indicator);
114     }
115 
116     @Override
117     public String execute() {
118         GetSpeciesListForCommunityIndicatorResultRequest request =
119                 requestBuilder(GetSpeciesListForCommunityIndicatorResultRequest.class).
120                         addFacade(facade).
121                         addZone(zone).
122                         addIndicator(indicator).
123                         toRequest();
124         lists = getService().toMap(request);
125         return SUCCESS;
126     }
127 
128 //    public String getFacadeDisplayName() {
129 //        WebService webService = ServiceFactory.getWebService();
130 //        String displayName = null;
131 //        try {
132 //            displayName = webService.getFacades().get(facade);
133 //        } catch (CoserBusinessException ex) {
134 //            throw new CoserWebException("Can't get facade display name", ex);
135 //        }
136 //        return displayName;
137 //    }
138 //
139 //    public String getZoneDisplayName() {
140 //        WebService webService = ServiceFactory.getWebService();
141 //        String displayName = null;
142 //        try {
143 //            displayName = webService.getZoneForFacade(facade, false, false).get(zone);
144 //        } catch (CoserBusinessException ex) {
145 //            throw new CoserWebException("Can't get zone display name", ex);
146 //        }
147 //        return displayName;
148 //    }
149 //
150 //    public String getIndicatorDisplayName() {
151 //
152 //        Locale locale = getLocale();
153 //
154 //        WebService webService = ServiceFactory.getWebService();
155 //        String displayName = null;
156 //        try {
157 //            displayName = webService.getIndicators(zone, null, locale).get(indicator);
158 //        } catch (CoserBusinessException ex) {
159 //            throw new CoserWebException("Can't get species display name", ex);
160 //        }
161 //        return displayName;
162 //    }
163 //
164 //    @Override
165 //    public String execute() {
166 //
167 //        Locale locale = getLocale();
168 //
169 //        WebService webService = ServiceFactory.getWebService();
170 //        try {
171 //            lists = webService.getIndicatorLists(zone, indicator, locale);
172 //        } catch (CoserBusinessException ex) {
173 //            throw new CoserWebException("Can't get indicator's list names", ex);
174 //        }
175 //        return SUCCESS;
176 //    }
177 }