// $Id$\r
/**\r
* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
* http://www.e-taxonomy.eu\r
-* \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
import org.springframework.stereotype.Controller;\r
import org.springframework.web.bind.WebDataBinder;\r
import org.springframework.web.bind.annotation.InitBinder;\r
-import org.springframework.web.bind.annotation.ModelAttribute;\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
\r
-import eu.etaxonomy.cdm.api.service.AnnotatableServiceBase;\r
-import eu.etaxonomy.cdm.api.service.DescriptionServiceImpl;\r
import eu.etaxonomy.cdm.api.service.DistributionTree;\r
import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
-import eu.etaxonomy.cdm.api.service.IFeatureTreeService;\r
-import eu.etaxonomy.cdm.api.service.NamedAreaTree;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
import eu.etaxonomy.cdm.model.description.DescriptionBase;\r
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
-import eu.etaxonomy.cdm.model.description.FeatureTree;\r
import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;\r
import eu.etaxonomy.cdm.remote.editor.NamedAreaLevelPropertyEditor;\r
-\r
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;\r
-import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;\r
import eu.etaxonomy.cdm.remote.editor.UuidList;\r
\r
/**\r
- * TODO write controller documentation\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 24.03.2009\r
+ * @date Jun 25, 2013\r
+ *\r
*/\r
-\r
@Controller\r
-@RequestMapping(value = {"/portal/description/{uuid}", "/portal/description/{uuid_list}", "/portal/descriptionElement/{descriptionelement_uuid}", "/portal/featureTree/{featuretree_uuid}"})\r
-public class DescriptionPortalController extends AnnotatableController<DescriptionBase, IDescriptionService>\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
- @Autowired\r
- private IFeatureTreeService featureTreeService;\r
- \r
- private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(\r
- new String[]{\r
- "representations",\r
- "root.feature.representations",\r
- "root.children.feature.representations",\r
- });\r
- private static final List<String> DESCRIPTIONS_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "elements.sources.citation.$",\r
- "elements.area.$",\r
- });\r
- protected static final List<String> TAXONDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "$",\r
- "elements.$",\r
- "elements.sources.citation.authorTeam.$",\r
- "elements.sources.nameUsedInSource.originalNameString",\r
- "elements.area.level",\r
- "elements.modifyingText",\r
- });\r
- \r
- @InitBinder\r
- public void initBinder(WebDataBinder binder) {\r
- binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());\r
- binder.registerCustomEditor(NamedAreaLevel.class, new NamedAreaLevelPropertyEditor());\r
- super.initBinder(binder);\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
- /**\r
- * TODO write controller method documentation\r
- * \r
- * @param request\r
- * @param response\r
- * @return\r
- * @throws IOException\r
- */\r
- \r
- @RequestMapping(value = {"/portal/featureTree/{featuretree_uuid}"}, method = RequestMethod.GET)\r
- public FeatureTree doGetFeatureTree(\r
- @PathVariable("featuretree_uuid") UUID featureUuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response)throws IOException {\r
- //UUID featureTreeUuid = readValueUuid(request, null);\r
- FeatureTree featureTree = featureTreeService.load(featureUuid, FEATURETREE_INIT_STRATEGY);\r
- if(featureTree == null){\r
- HttpStatusMessage.UUID_NOT_FOUND.send(response);\r
- }\r
- return featureTree;\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() - " + request.getServletPath());\r
- DescriptionElementBase annotatableEntity = service.getDescriptionElementByUuid(uuid);\r
- Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, ANNOTATION_INIT_STRATEGY);\r
- return annotations;\r
- }\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 = "omitLevels", required = false) Set<NamedAreaLevel> levels,\r
- HttpServletRequest request, HttpServletResponse response) {\r
- logger.info("getOrderedDistributionsB(" + ObjectUtils.toString(levels) + ") - " + request.getServletPath());\r
- Set<TaxonDescription> taxonDescriptions = new HashSet<TaxonDescription>();\r
- TaxonDescription description;\r
- for (UUID descriptionUuid : descriptionUuidList) {\r
- description = (TaxonDescription) service.load(descriptionUuid, TAXONDESCRIPTION_INIT_STRATEGY);\r
- taxonDescriptions.add(description);\r
- }\r
- DistributionTree distTree = service.getOrderedDistributions(taxonDescriptions, levels, TAXONDESCRIPTION_INIT_STRATEGY);\r
- return distTree;\r
- }\r
- \r
+\r
+ protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "$",\r
+ "elements.$",\r
+ "elements.sources.citation.authorTeam.$",\r
+ "elements.sources.nameUsedInSource.originalNameString",\r
+ "elements.area.level",\r
+ "elements.modifyingText",\r
+ "elements.states.*",\r
+ "elements.media",\r
+ });\r
+ \r
+ protected static final List<String> ORDERED_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "elements.$",\r
+ "elements.sources.citation.authorTeam.$",\r
+ "elements.sources.nameUsedInSource.originalNameString",\r
+ "elements.area.level",\r
+ });\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
+ }\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() - " + request.getRequestURI());\r
+ DescriptionElementBase annotatableEntity = service.getDescriptionElementByUuid(uuid);\r
+ Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, getInitializationStrategy());\r
+ return annotations;\r
+ }\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 = "omitLevels", required = false) Set<NamedAreaLevel> levels,\r
+ HttpServletRequest request, HttpServletResponse response) {\r
+ logger.info("getOrderedDistributionsB(" + ObjectUtils.toString(levels) + ") - " + request.getRequestURI());\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
+ logger.debug(" get ordered distributions ");\r
+ DistributionTree distTree = service.getOrderedDistributions(taxonDescriptions, levels, ORDERED_DISTRIBUTION_INIT_STRATEGY);\r
+ logger.debug("done");\r
+ return distTree;\r
+ }\r
\r
}\r