View Javadoc
1   /*
2    * #%L
3    * Coser :: Web
4    * %%
5    * Copyright (C) 2010 - 2011 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.map;
23  
24  import fr.ifremer.coser.result.request.GetSpeciesForMapResultRequest;
25  import fr.ifremer.coser.result.request.GetZonesForMapResultRequest;
26  import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction;
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  
30  import java.util.Map;
31  
32  /**
33   * Recupere la liste des especes correspondant a une campagne.
34   *
35   * @author chatellier
36   * @version $Revision$
37   *          <p/>
38   *          Last update : $Date$
39   *          By : $Author$
40   */
41  public class SpeciesAction extends AbstractCoserJspAction {
42  
43      /** serialVersionUID. */
44      private static final long serialVersionUID = 1663244944108703571L;
45  
46      private static final Log log = LogFactory.getLog(SpeciesAction.class);
47  
48      protected String facade;
49  
50      protected String zone;
51  
52      protected Map<String, String> species;
53  
54      public String getFacade() {
55          return facade;
56      }
57  
58      public void setFacade(String facade) {
59          this.facade = facade;
60      }
61  
62      public String getZone() {
63          return zone;
64      }
65  
66      public void setZone(String zone) {
67          this.zone = zone;
68      }
69  
70      public Map<String, String> getSpecies() {
71          return species;
72      }
73  
74      public String getFacadeDisplayName() {
75          return getService().getFacadeDisplayName(facade);
76      }
77  
78      public String getZoneDisplayName() {
79          GetZonesForMapResultRequest request =
80                  requestBuilder(GetZonesForMapResultRequest.class).
81                          addFacade(facade).
82                          toRequest();
83          return getService().getZoneDisplayName(request, zone);
84      }
85  
86      @Override
87      public String execute() {
88  
89          if (log.isInfoEnabled()) {
90              log.info("Looking for species for zone " + zone);
91          }
92  
93          GetSpeciesForMapResultRequest request =
94                  requestBuilder(GetSpeciesForMapResultRequest.class).
95                          addFacade(facade).
96                          addZone(zone).
97                          toRequest();
98          species = getService().toMap(request);
99  
100 
101         if (log.isDebugEnabled()) {
102             log.debug("Species are : " + species);
103         }
104 
105         return SUCCESS;
106     }
107 
108 //    public String getFacadeDisplayName() {
109 //        WebService webService = ServiceFactory.getWebService();
110 //        String displayName = null;
111 //        try {
112 //            displayName = webService.getFacades().get(facade);
113 //        } catch (CoserBusinessException ex) {
114 //            throw new CoserWebException("Can't get species display name", ex);
115 //        }
116 //        return displayName;
117 //    }
118 //
119 //    public String getZoneDisplayName() {
120 //        WebService webService = ServiceFactory.getWebService();
121 //        String displayName = null;
122 //        try {
123 //            displayName = webService.getZoneForFacade(facade, false, true).get(zone);
124 //        } catch (CoserBusinessException ex) {
125 //            throw new CoserWebException("Can't get zone display name", ex);
126 //        }
127 //        return displayName;
128 //    }
129 //
130 //    @Override
131 //    public String execute() {
132 //
133 //        if (log.isInfoEnabled()) {
134 //            log.info("Looking for species for zone " + zone);
135 //        }
136 //
137 //        WebService webService = ServiceFactory.getWebService();
138 //
139 //        try {
140 //            species = webService.getSpecies(zone, true);
141 //
142 //            if (log.isDebugEnabled()) {
143 //                log.debug("Species are : " + species);
144 //            }
145 //        } catch (CoserBusinessException ex) {
146 //            throw new CoserWebException("Can't get zone species", ex);
147 //        }
148 //
149 //        return SUCCESS;
150 //    }
151 }