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.repository.ResultRepositoryType;
25 import fr.ifremer.coser.result.repository.echobase.EchoBaseResultRepositoryType;
26 import fr.ifremer.coser.result.request.GetMatchingRepositoryTypeForMapResultRequest;
27 import fr.ifremer.coser.result.request.GetSpeciesForMapResultRequest;
28 import fr.ifremer.coser.result.request.GetZonesForMapResultRequest;
29 import fr.ifremer.coser.web.actions.common.AbstractCoserJspAction;
30
31 /**
32 * Action index, recupere la liste des resultats.
33 *
34 * @author chatellier
35 * @version $Revision$
36 * <p/>
37 * Last update : $Date$
38 * By : $Author$
39 */
40 public class MapAction extends AbstractCoserJspAction {
41
42 /** serialVersionUID. */
43 private static final long serialVersionUID = 1663244944108703571L;
44
45 protected String facade;
46
47 protected String zone;
48
49 protected String species;
50
51 protected ResultRepositoryType matchingrepositoryType;
52
53 public void setFacade(String facade) {
54 this.facade = facade;
55 }
56
57 public String getFacade() {
58 return 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 getFacadeDisplayName() {
78 return getService().getFacadeDisplayName(facade);
79 }
80
81 public String getZoneDisplayName() {
82 GetZonesForMapResultRequest request =
83 requestBuilder(GetZonesForMapResultRequest.class).
84 addFacade(facade).
85 toRequest();
86 return getService().getZoneDisplayName(request, zone);
87 }
88
89 public String getSpeciesDisplayName() {
90 GetSpeciesForMapResultRequest request =
91 requestBuilder(GetSpeciesForMapResultRequest.class).
92 addFacade(facade).
93 addZone(zone).
94 toRequest();
95 return getService().getSpeciesDisplayName(request, species);
96 }
97
98 public boolean isEchobaseResult() {
99 return getMatchingrepositoryType().getId().equals(EchoBaseResultRepositoryType.ID);
100 }
101
102 protected ResultRepositoryType getMatchingrepositoryType() {
103 if (matchingrepositoryType == null) {
104 GetMatchingRepositoryTypeForMapResultRequest request =
105 requestBuilder(GetMatchingRepositoryTypeForMapResultRequest.class).
106 addFacade(facade).
107 addZone(zone).
108 addSpecies(species).
109 toRequest();
110 try {
111 matchingrepositoryType = getService().getMatchingRepositoryType(request);
112 } catch (Exception e) {
113 e.printStackTrace();
114 }
115 }
116 return matchingrepositoryType;
117 }
118
119 // public String getFacadeDisplayName() {
120 // WebService webService = ServiceFactory.getWebService();
121 // String displayName = null;
122 // try {
123 // displayName = webService.getFacades().get(facade);
124 // } catch (CoserBusinessException ex) {sm
125 // throw new CoserWebException("Can't get species display name", ex);
126 // }
127 // return displayName;
128 // }
129 //
130 // public String getZoneDisplayName() {
131 // WebService webService = ServiceFactory.getWebService();
132 // String displayName = null;
133 // try {
134 // displayName = webService.getZoneForFacade(facade, false, true).get(zone);
135 // } catch (CoserBusinessException ex) {
136 // throw new CoserWebException("Can't get zone display name", ex);
137 // }
138 // return displayName;
139 // }
140 //
141 // public String getSpeciesDisplayName() {
142 // WebService webService = ServiceFactory.getWebService();
143 // String displayName = null;
144 // try {
145 // displayName = webService.getSpecies(zone, true).get(species);
146 // } catch (CoserBusinessException ex) {
147 // throw new CoserWebException("Can't get species display name", ex);
148 // }
149 // return displayName;
150 // }
151 }