a little bit documentation
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / PolytomousKeyListController.java
index d06e0247b275a5599fbf301f92ef734d18db391b..f9f2658e9b3c516418f1054f0c8cfbb4525a6d71 100644 (file)
@@ -1,20 +1,36 @@
 // $Id$\r
 /**\r
 * Copyright (C) 2009 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
 package eu.etaxonomy.cdm.remote.controller;\r
 \r
+import java.io.IOException;\r
+import java.util.List;\r
+import java.util.UUID;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.apache.log4j.Logger;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.stereotype.Controller;\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.IPolytomousKeyService;\r
+import eu.etaxonomy.cdm.api.service.ITaxonService;\r
+import eu.etaxonomy.cdm.api.service.pager.Pager;\r
 import eu.etaxonomy.cdm.model.description.PolytomousKey;\r
+import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;\r
 \r
 /**\r
  * @author a.kohlbecker\r
@@ -23,12 +39,42 @@ import eu.etaxonomy.cdm.model.description.PolytomousKey;
  */\r
 @Controller\r
 @RequestMapping(value = {"/polytomousKey"})\r
-public class PolytomousKeyListController extends BaseListController<PolytomousKey, IPolytomousKeyService> {\r
+public class PolytomousKeyListController extends IdentifiableListController<PolytomousKey, IPolytomousKeyService> {\r
+\r
+    public static final Logger logger = Logger.getLogger(PolytomousKeyListController.class);\r
+\r
+    private ITaxonService taxonService;\r
+\r
+    @Autowired\r
+    public void setService(IPolytomousKeyService service) {\r
+        this.service = service;\r
+    }\r
+\r
+    @Autowired\r
+    public void setService(ITaxonService taxonService) {\r
+        this.taxonService = taxonService;\r
+    }\r
+\r
+    @RequestMapping(\r
+            params = {"findByTaxonomicScope"},\r
+            method = RequestMethod.GET)\r
+    public Pager<PolytomousKey> doFindByTaxonomicScope(\r
+            @RequestParam(value = "findByTaxonomicScope") UUID taxonUuid,\r
+            @RequestParam(value = "pageNumber", required = false) Integer pageNumber,\r
+            @RequestParam(value = "pageSize", required = false) Integer pageSize,\r
+            HttpServletRequest request,\r
+            HttpServletResponse response)throws IOException {\r
+\r
+        logger.info("doFindByTaxonomicScope: " + request.getRequestURI() + request.getQueryString());\r
+\r
+        PagerParameters pagerParameters = new PagerParameters(pageSize, pageNumber);\r
+        pagerParameters.normalizeAndValidate(response);\r
+\r
+\r
+        TaxonBase taxon = taxonService.find(taxonUuid);\r
+        Pager<PolytomousKey> pager = service.findByTaxonomicScope(taxon, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null);\r
+        return pager;\r
+    }\r
 \r
-       @Autowired\r
-       public void setService(IPolytomousKeyService service) {\r
-               this.service = service;\r
-       }\r
-       \r
 }\r
-       \r
+\r