-// $Id$\r
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy\r
-* http://www.e-taxonomy.eu\r
-*\r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.cdm.remote.controller;\r
-\r
-import java.awt.Color;\r
-import java.io.IOException;\r
-import java.util.Arrays;\r
-import java.util.Collection;\r
-import java.util.EnumSet;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.UUID;\r
-\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.servlet.http.HttpServletResponse;\r
-\r
-import org.codehaus.jackson.JsonParseException;\r
-import org.codehaus.jackson.map.JsonMappingException;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.stereotype.Controller;\r
-import org.springframework.transaction.annotation.Transactional;\r
-import org.springframework.web.bind.WebDataBinder;\r
-import org.springframework.web.bind.annotation.InitBinder;\r
-import org.springframework.web.bind.annotation.PathVariable;\r
-import org.springframework.web.bind.annotation.RequestMapping;\r
-import org.springframework.web.bind.annotation.RequestMethod;\r
-import org.springframework.web.bind.annotation.RequestParam;\r
-import org.springframework.web.servlet.ModelAndView;\r
-\r
-import eu.etaxonomy.cdm.api.service.DistributionTree;\r
-import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
-import eu.etaxonomy.cdm.api.service.ITermService;\r
-import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO;\r
-import eu.etaxonomy.cdm.api.service.dto.DistributionInfoDTO.InfoPart;\r
-import eu.etaxonomy.cdm.api.service.pager.Pager;\r
-import eu.etaxonomy.cdm.api.utility.DescriptionUtility;\r
-import eu.etaxonomy.cdm.ext.geo.EditGeoServiceUtilities;\r
-import eu.etaxonomy.cdm.ext.geo.IEditGeoService;\r
-import eu.etaxonomy.cdm.model.common.Annotation;\r
-import eu.etaxonomy.cdm.model.common.Marker;\r
-import eu.etaxonomy.cdm.model.common.MarkerType;\r
-import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
-import eu.etaxonomy.cdm.model.location.NamedAreaLevel;\r
-import eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList;\r
-import eu.etaxonomy.cdm.remote.editor.NamedAreaLevelPropertyEditor;\r
-import eu.etaxonomy.cdm.remote.editor.TermBaseListPropertyEditor;\r
-import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;\r
-import eu.etaxonomy.cdm.remote.editor.UuidList;\r
-import eu.etaxonomy.cdm.remote.l10n.LocaleContext;\r
-\r
-/**\r
- * IMPORTANT:\r
- *\r
- * This controller is mostly a 1:1 copy of the DescriptionController\r
- * and this provides identical end points which only differ in the depth of the\r
- * object graphs returned.\r
- *\r
- * @author a.kohlbecker\r
- * @date Jun 25, 2013\r
- *\r
- */\r
-@Controller\r
-@Transactional(readOnly=true)\r
-@RequestMapping(value = {\r
- "/portal/description/{uuid}",\r
- "/portal/description/{uuid_list}",\r
- "/portal/descriptionElement/{descriptionelement_uuid}"})\r
-public class DescriptionPortalController extends BaseController<DescriptionBase, IDescriptionService>\r
-{\r
-\r
- protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "$",\r
- "elements.$",\r
- "elements.multilanguageText.*",\r
- "elements.annotations",\r
- "elements.sources.citation.authorTeam.$",\r
- "elements.sources.nameUsedInSource",\r
- "elements.area.level",\r
- "elements.modifyingText",\r
- "elements.stateData.*",\r
- "elements.statisticalValues.*",\r
- "elements.unit",\r
- "elements.media",\r
- "elements.kindOfUnit"\r
-\r
- });\r
-\r
- protected static final List<String> ORDERED_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "elements.$",\r
- "elements.annotations",\r
- "elements.markers",\r
- "elements.sources.citation.authorTeam.$",\r
- "elements.sources.nameUsedInSource",\r
- "elements.area.level",\r
- });\r
-\r
- protected static final List<String> DISTRIBUTION_INFO_INIT_STRATEGY = Arrays.asList(new String []{\r
- "sources.citation.authorTeam.$",\r
- "sources.nameUsedInSource",\r
- "annotations"\r
- });\r
-\r
- @Autowired\r
- private ITermService termService;\r
-\r
- @Autowired\r
- private IEditGeoService geoService;\r
-\r
-\r
- public DescriptionPortalController() {\r
- super();\r
- setInitializationStrategy(DESCRIPTION_INIT_STRATEGY);\r
- }\r
-\r
- @InitBinder\r
- @Override\r
- public void initBinder(WebDataBinder binder) {\r
- super.initBinder(binder);\r
- binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());\r
- binder.registerCustomEditor(NamedAreaLevel.class, new NamedAreaLevelPropertyEditor());\r
- binder.registerCustomEditor(DefinedTermBaseList.class, new TermBaseListPropertyEditor<MarkerType>(termService));\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)\r
- */\r
- @Autowired\r
- @Override\r
- public void setService(IDescriptionService service) {\r
- this.service = service;\r
- }\r
-\r
- @RequestMapping(value = "/portal/descriptionElement/{descriptionelement_uuid}/annotation", method = RequestMethod.GET)\r
- public Pager<Annotation> getAnnotations(\r
- @PathVariable("descriptionelement_uuid") UUID uuid,\r
- HttpServletRequest request,\r
- HttpServletResponse response) throws IOException {\r
- logger.info("getAnnotations() - " + requestPathAndQuery(request) );\r
- DescriptionElementBase annotatableEntity = service.getDescriptionElementByUuid(uuid);\r
- Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, getInitializationStrategy());\r
- return annotations;\r
- }\r
-\r
- /**\r
- * NOTICE: required to have a TreeNodeBeanProcessor configured which suppresses the\r
- * redundant output of distribution.area\r
- *\r
- * @param descriptionUuidList\r
- * @param subAreaPreference\r
- * enables the <b>Sub area preference rule</b> if set to true,\r
- * see {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean}\r
- * @param statusOrderPreference\r
- * enables the <b>Status order preference rule</b> if set to true,\r
- * see {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean}\r
- * @param hideMarkedAreas\r
- * distributions where the area has a {@link Marker} with one of\r
- * the specified {@link MarkerType}s will be skipped, see\r
- * {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean, Set)}\r
- * @param omitLevels\r
- * @param request\r
- * @param response\r
- * @return\r
- */\r
- @RequestMapping(value = "/portal/description/{uuid_list}/DistributionTree", method = RequestMethod.GET)\r
- public DistributionTree doGetOrderedDistributionsB(\r
- @PathVariable("uuid_list") UuidList descriptionUuidList,\r
- @RequestParam(value = "subAreaPreference", required = false) boolean subAreaPreference,\r
- @RequestParam(value = "statusOrderPreference", required = false) boolean statusOrderPreference,\r
- @RequestParam(value = "hideMarkedAreas", required = false) DefinedTermBaseList<MarkerType> hideMarkedAreasList,\r
- @RequestParam(value = "omitLevels", required = false) Set<NamedAreaLevel> omitLevels,\r
- HttpServletRequest request,\r
- HttpServletResponse response) {\r
-\r
- logger.info("getOrderedDistributionsB() - " + requestPathAndQuery(request) );\r
-\r
- Set<TaxonDescription> taxonDescriptions = new HashSet<TaxonDescription>();\r
- TaxonDescription description;\r
- for (UUID descriptionUuid : descriptionUuidList) {\r
- logger.debug(" loading description " + descriptionUuid.toString() );\r
- description = (TaxonDescription) service.load(descriptionUuid, null);\r
- taxonDescriptions.add(description);\r
- }\r
-\r
- Set<MarkerType> hideMarkedAreas = null;\r
- if(hideMarkedAreasList != null){\r
- hideMarkedAreas = hideMarkedAreasList.asSet();\r
- }\r
-\r
- logger.debug(" get ordered distributions ");\r
- DistributionTree distTree = service.getOrderedDistributions(taxonDescriptions, subAreaPreference, statusOrderPreference,\r
- hideMarkedAreas, omitLevels, ORDERED_DISTRIBUTION_INIT_STRATEGY);\r
- if (logger.isDebugEnabled()){ logger.debug("done");}\r
- return distTree;\r
- }\r
-\r
- /**\r
- * @param taxonUuid\r
- * @param parts\r
- * possible values: condensedStatusString, tree, mapUriParams,\r
- * elements,\r
- * @param subAreaPreference\r
- * @param statusOrderPreference\r
- * @param hideMarkedAreasList\r
- * @param omitLevels\r
- * @param request\r
- * @param response\r
- * @return\r
- * @throws IOException\r
- * @throws JsonMappingException\r
- * @throws JsonParseException\r
- */\r
- @RequestMapping(value = "/portal/description/distributionInfoFor/{uuid}", method = RequestMethod.GET)\r
- public ModelAndView doGetDistributionInfo(\r
- @PathVariable("uuid") UUID taxonUuid,\r
- @RequestParam("part") Set<InfoPart> partSet,\r
- @RequestParam(value = "subAreaPreference", required = false) boolean subAreaPreference,\r
- @RequestParam(value = "statusOrderPreference", required = false) boolean statusOrderPreference,\r
- @RequestParam(value = "hideMarkedAreas", required = false) DefinedTermBaseList<MarkerType> hideMarkedAreasList,\r
- @RequestParam(value = "omitLevels", required = false) Set<NamedAreaLevel> omitLevels,\r
- @RequestParam(value = "statusColors", required = false) String statusColorsString,\r
- HttpServletRequest request,\r
- HttpServletResponse response) throws JsonParseException, JsonMappingException, IOException {\r
-\r
- logger.debug("doGetDistributionInfo() - " + requestPathAndQuery(request));\r
-\r
- ModelAndView mv = new ModelAndView();\r
-\r
- Set<MarkerType> hideMarkedAreas = null;\r
- if(hideMarkedAreasList != null){\r
- hideMarkedAreas = hideMarkedAreasList.asSet();\r
- }\r
-\r
- EnumSet<InfoPart> parts = EnumSet.copyOf(partSet);\r
-\r
- Map<PresenceAbsenceTermBase<?>, Color> presenceAbsenceTermColors = EditGeoServiceUtilities.buildStatusColorMap(statusColorsString, termService);\r
-\r
- DistributionInfoDTO dto = geoService.composeDistributionInfoFor(parts, taxonUuid, subAreaPreference, statusOrderPreference,\r
- hideMarkedAreas, omitLevels, presenceAbsenceTermColors, LocaleContext.getLanguages(), DISTRIBUTION_INFO_INIT_STRATEGY);\r
-\r
- mv.addObject(dto);\r
-\r
- return mv;\r
- }\r
-\r
-\r
-}\r
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.cdm.remote.controller;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
+import eu.etaxonomy.cdm.model.common.Annotation;
+import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
+import eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList;
+import eu.etaxonomy.cdm.remote.editor.NamedAreaLevelPropertyEditor;
+import eu.etaxonomy.cdm.remote.editor.TermBaseListPropertyEditor;
+import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
+import eu.etaxonomy.cdm.remote.editor.UuidList;
+import io.swagger.annotations.Api;
+
+/**
+ *
+ * @author a.kohlbecker
+ * @since Jun 25, 2013
+ *
+ */
+@Controller
+@Api("portal_description")
+@Transactional(readOnly=true)
+@RequestMapping(value = {
+ "/portal/description/{uuid}",
+ "/portal/description/{uuid_list}"})
+public class DescriptionPortalController extends BaseController<DescriptionBase, IDescriptionService> {
+
+ private static final Logger logger = Logger.getLogger(DescriptionPortalController.class);
+
+ protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
+ "$",
+ "elements.$",
+ "elements.multilanguageText.*",
+ "elements.annotations",
+ "elements.sources.citation.authorship.$",
+ "elements.sources.nameUsedInSource",
+ "elements.area.level",
+ "elements.modifyingText",
+ "elements.stateData.*",
+ "elements.statisticalValues.*",
+ "elements.unit",
+ "elements.media",
+ "elements.kindOfUnit"
+
+ });
+
+ protected static final List<String> ORDERED_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{
+ "elements.$",
+ "elements.annotations",
+ "elements.markers",
+ "elements.sources.citation.authorship.$",
+ "elements.sources.nameUsedInSource",
+ "elements.area.level",
+ });
+
+ protected static final List<String> DISTRIBUTION_INFO_INIT_STRATEGY = Arrays.asList(new String []{
+ "sources.citation.authorship.$",
+ "sources.nameUsedInSource",
+ "annotations"
+ });
+
+ @Autowired
+ private ITermService termService;
+
+ @Autowired
+ private IVocabularyService vocabularyService ;
+
+
+ @Autowired
+ private IEditGeoService geoService;
+
+
+ public DescriptionPortalController() {
+ super();
+ setInitializationStrategy(DESCRIPTION_INIT_STRATEGY);
+ }
+
+ @InitBinder
+ @Override
+ public void initBinder(WebDataBinder binder) {
+ super.initBinder(binder);
+ binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());
+ binder.registerCustomEditor(NamedAreaLevel.class, new NamedAreaLevelPropertyEditor());
+ binder.registerCustomEditor(DefinedTermBaseList.class, new TermBaseListPropertyEditor<MarkerType>(termService));
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
+ */
+ @Autowired
+ @Override
+ public void setService(IDescriptionService service) {
+ this.service = service;
+ }
+
+ @RequestMapping(value = "//portal/descriptionElement/{descriptionelement_uuid}/annotation", method = RequestMethod.GET) // mapped as absolute path, see CdmAntPathMatcher
+ public Pager<Annotation> getAnnotations(
+ @PathVariable("descriptionelement_uuid") UUID uuid,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ logger.info("getAnnotations() - " + requestPathAndQuery(request) );
+ DescriptionElementBase annotatableEntity = service.getDescriptionElementByUuid(uuid);
+ Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, getInitializationStrategy());
+ return annotations;
+ }
+
+}