Revision d07e9e4a
Added by Andreas Kohlbecker over 8 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionPortalController.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.remote.controller; |
11 | 11 |
|
12 |
import java.awt.Color; |
|
12 |
import io.swagger.annotations.Api; |
|
13 |
|
|
13 | 14 |
import java.io.IOException; |
14 | 15 |
import java.util.Arrays; |
15 |
import java.util.Collection; |
|
16 |
import java.util.EnumSet; |
|
17 |
import java.util.HashSet; |
|
18 | 16 |
import java.util.List; |
19 |
import java.util.Map; |
|
20 |
import java.util.Set; |
|
21 | 17 |
import java.util.UUID; |
22 | 18 |
|
23 | 19 |
import javax.servlet.http.HttpServletRequest; |
... | ... | |
31 | 27 |
import org.springframework.web.bind.annotation.PathVariable; |
32 | 28 |
import org.springframework.web.bind.annotation.RequestMapping; |
33 | 29 |
import org.springframework.web.bind.annotation.RequestMethod; |
34 |
import org.springframework.web.bind.annotation.RequestParam; |
|
35 |
import org.springframework.web.servlet.ModelAndView; |
|
36 | 30 |
|
37 |
import com.fasterxml.jackson.core.JsonParseException; |
|
38 |
import com.fasterxml.jackson.databind.JsonMappingException; |
|
39 |
|
|
40 |
import eu.etaxonomy.cdm.api.service.DistributionTree; |
|
41 | 31 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
42 | 32 |
import eu.etaxonomy.cdm.api.service.ITermService; |
43 | 33 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
44 |
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO; |
|
45 |
import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart; |
|
46 | 34 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
47 |
import eu.etaxonomy.cdm.api.utility.DescriptionUtility; |
|
48 |
import eu.etaxonomy.cdm.ext.geo.CondensedDistributionRecipe; |
|
49 |
import eu.etaxonomy.cdm.ext.geo.EditGeoServiceUtilities; |
|
50 | 35 |
import eu.etaxonomy.cdm.ext.geo.IEditGeoService; |
51 | 36 |
import eu.etaxonomy.cdm.model.common.Annotation; |
52 |
import eu.etaxonomy.cdm.model.common.Marker; |
|
53 | 37 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
54 | 38 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
55 | 39 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
56 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
57 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
|
58 | 40 |
import eu.etaxonomy.cdm.model.location.NamedAreaLevel; |
59 | 41 |
import eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList; |
60 | 42 |
import eu.etaxonomy.cdm.remote.editor.NamedAreaLevelPropertyEditor; |
61 | 43 |
import eu.etaxonomy.cdm.remote.editor.TermBaseListPropertyEditor; |
62 | 44 |
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor; |
63 | 45 |
import eu.etaxonomy.cdm.remote.editor.UuidList; |
64 |
import eu.etaxonomy.cdm.remote.l10n.LocaleContext; |
|
65 |
import io.swagger.annotations.Api; |
|
66 | 46 |
|
67 | 47 |
/** |
68 | 48 |
* |
... | ... | |
156 | 136 |
return annotations; |
157 | 137 |
} |
158 | 138 |
|
159 |
/** |
|
160 |
* NOTICE: required to have a TreeNodeBeanProcessor configured which suppresses the |
|
161 |
* redundant output of distribution.area |
|
162 |
* |
|
163 |
* @param descriptionUuidList |
|
164 |
* @param subAreaPreference |
|
165 |
* enables the <b>Sub area preference rule</b> if set to true, |
|
166 |
* see {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean} |
|
167 |
* @param statusOrderPreference |
|
168 |
* enables the <b>Status order preference rule</b> if set to true, |
|
169 |
* see {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean} |
|
170 |
* @param hideMarkedAreas |
|
171 |
* distributions where the area has a {@link Marker} with one of |
|
172 |
* the specified {@link MarkerType}s will be skipped, see |
|
173 |
* {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean, Set)} |
|
174 |
* @param omitLevels |
|
175 |
* @param request |
|
176 |
* @param response |
|
177 |
* @return |
|
178 |
*/ |
|
179 |
@RequestMapping(value = "//portal/description/{uuid_list}/DistributionTree", method = RequestMethod.GET) // mapped as absolute path, see CdmAntPathMatcher |
|
180 |
public DistributionTree doGetOrderedDistributionsB( |
|
181 |
@PathVariable("uuid_list") UuidList descriptionUuidList, |
|
182 |
@RequestParam(value = "subAreaPreference", required = false) boolean subAreaPreference, |
|
183 |
@RequestParam(value = "statusOrderPreference", required = false) boolean statusOrderPreference, |
|
184 |
@RequestParam(value = "hideMarkedAreas", required = false) DefinedTermBaseList<MarkerType> hideMarkedAreasList, |
|
185 |
@RequestParam(value = "omitLevels", required = false) Set<NamedAreaLevel> omitLevels, |
|
186 |
HttpServletRequest request, |
|
187 |
HttpServletResponse response) { |
|
188 |
|
|
189 |
logger.info("getOrderedDistributionsB() - " + requestPathAndQuery(request) ); |
|
190 |
|
|
191 |
Set<TaxonDescription> taxonDescriptions = new HashSet<TaxonDescription>(); |
|
192 |
TaxonDescription description; |
|
193 |
for (UUID descriptionUuid : descriptionUuidList) { |
|
194 |
logger.debug(" loading description " + descriptionUuid.toString() ); |
|
195 |
description = (TaxonDescription) service.load(descriptionUuid, null); |
|
196 |
taxonDescriptions.add(description); |
|
197 |
} |
|
198 |
|
|
199 |
Set<MarkerType> hideMarkedAreas = null; |
|
200 |
if(hideMarkedAreasList != null){ |
|
201 |
hideMarkedAreas = hideMarkedAreasList.asSet(); |
|
202 |
} |
|
203 |
|
|
204 |
logger.debug(" get ordered distributions "); |
|
205 |
DistributionTree distTree = service.getOrderedDistributions(taxonDescriptions, subAreaPreference, statusOrderPreference, |
|
206 |
hideMarkedAreas, omitLevels, ORDERED_DISTRIBUTION_INIT_STRATEGY); |
|
207 |
if (logger.isDebugEnabled()){ logger.debug("done");} |
|
208 |
return distTree; |
|
209 |
} |
|
210 |
|
|
211 |
/** |
|
212 |
* @param taxonUuid |
|
213 |
* @param parts |
|
214 |
* possible values: condensedStatus, tree, mapUriParams, |
|
215 |
* elements, |
|
216 |
* @param subAreaPreference |
|
217 |
* @param statusOrderPreference |
|
218 |
* @param hideMarkedAreasList |
|
219 |
* @param recipe |
|
220 |
* The recipe for creating the condensed distribution status |
|
221 |
* @param omitLevels |
|
222 |
* @param request |
|
223 |
* @param response |
|
224 |
* @return |
|
225 |
* @throws IOException |
|
226 |
* @throws JsonMappingException |
|
227 |
* @throws JsonParseException |
|
228 |
*/ |
|
229 |
@RequestMapping(value = "//portal/description/distributionInfoFor/{uuid}", method = RequestMethod.GET) // mapped as absolute path, see CdmAntPathMatcher |
|
230 |
public ModelAndView doGetDistributionInfo( |
|
231 |
@PathVariable("uuid") UUID taxonUuid, |
|
232 |
@RequestParam("part") Set<InfoPart> partSet, |
|
233 |
@RequestParam(value = "subAreaPreference", required = false) boolean subAreaPreference, |
|
234 |
@RequestParam(value = "statusOrderPreference", required = false) boolean statusOrderPreference, |
|
235 |
@RequestParam(value = "hiddenAreaMarkerType", required = false) DefinedTermBaseList<MarkerType> hideMarkedAreasList, |
|
236 |
@RequestParam(value = "omitLevels", required = false) Set<NamedAreaLevel> omitLevels, |
|
237 |
@RequestParam(value = "statusColors", required = false) String statusColorsString, |
|
238 |
@RequestParam(value = "recipe", required = false, defaultValue="EuroPlusMed") CondensedDistributionRecipe recipe, |
|
239 |
|
|
240 |
HttpServletRequest request, |
|
241 |
HttpServletResponse response) throws JsonParseException, JsonMappingException, IOException { |
|
242 |
|
|
243 |
logger.info("doGetDistributionInfo() - " + requestPathAndQuery(request)); |
|
244 |
|
|
245 |
ModelAndView mv = new ModelAndView(); |
|
246 |
|
|
247 |
Set<MarkerType> hideMarkedAreas = null; |
|
248 |
if(hideMarkedAreasList != null){ |
|
249 |
hideMarkedAreas = hideMarkedAreasList.asSet(); |
|
250 |
} |
|
251 |
|
|
252 |
EnumSet<InfoPart> parts = EnumSet.copyOf(partSet); |
|
253 |
|
|
254 |
Map<PresenceAbsenceTerm, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService, vocabularyService); |
|
255 |
|
|
256 |
DistributionInfoDTO dto = geoService.composeDistributionInfoFor(parts, taxonUuid, |
|
257 |
subAreaPreference, statusOrderPreference, hideMarkedAreas, omitLevels, |
|
258 |
presenceAbsenceTermColors, LocaleContext.getLanguages(), |
|
259 |
DISTRIBUTION_INFO_INIT_STRATEGY, recipe, null); |
|
260 |
|
|
261 |
mv.addObject(dto); |
|
262 |
|
|
263 |
return mv; |
|
264 |
} |
|
265 |
|
|
266 |
|
|
267 | 139 |
} |
Also available in: Unified diff
removing depreceted controller methods