Merge branch 'release/4.5.0'
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / ClassificationPortalListController.java
index 9aa7afe544b3f73cdc45ce31eaf55272b94806d9..6c95400081ea883d5a3dd029390b054d07a03541 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$\r
 /**\r
  * Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy\r
  * http://www.e-taxonomy.eu\r
@@ -9,6 +8,8 @@
 \r
 package eu.etaxonomy.cdm.remote.controller;\r
 \r
+import io.swagger.annotations.Api;\r
+\r
 import java.io.IOException;\r
 import java.util.Arrays;\r
 import java.util.List;\r
@@ -42,16 +43,19 @@ import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;
  * @date 20.03.2009\r
  */\r
 @Controller\r
-public class ClassificationPortalListController extends IdentifiableListController<Classification,IClassificationService> {\r
+@Api("portal_classification")\r
+@RequestMapping(value="/portal/classification")\r
+public class ClassificationPortalListController extends AbstractIdentifiableListController<Classification,IClassificationService> {\r
 \r
 \r
     private static final List<String> CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[]{\r
-            "reference.authorTeam"\r
+            "reference.authorship"\r
+\r
     });\r
 \r
     private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[]{\r
-            "taxon.sec",\r
-            "taxon.name.rank"\r
+            "taxon.name.rank",\r
+            "taxon.sec"\r
             });\r
 \r
 \r
@@ -59,10 +63,12 @@ public class ClassificationPortalListController extends IdentifiableListControll
 \r
     private ITaxonService taxonService;\r
 \r
-    private IClassificationService service;\r
-\r
     private ITermService termService;\r
 \r
+    public ClassificationPortalListController() {\r
+        setInitializationStrategy(CLASSIFICATION_INIT_STRATEGY);\r
+    }\r
+\r
     @Override\r
     @Autowired\r
     public void setService(IClassificationService service) {\r
@@ -88,33 +94,16 @@ public class ClassificationPortalListController extends IdentifiableListControll
     }\r
 \r
 \r
-    /**\r
-     * Lists all available {@link Classification}s.\r
-     * <p>\r
-     * URI: <b>&#x002F;{datasource-name}&#x002F;portal&#x002F;classification</b>\r
-     *\r
-     * @param request\r
-     * @param response\r
-     * @return a list of {@link Classification}s initialized by\r
-     *         the {@link #CLASSIFICATION_INIT_STRATEGY}\r
-     * @throws IOException\r
-     */\r
-    @RequestMapping(value = { "/portal/classification" }, method = RequestMethod.GET)\r
-    public List<Classification> getClassifications(HttpServletRequest request, HttpServletResponse response)\r
-            throws IOException {\r
-        logger.info("getClassification() " + requestPathAndQuery(request));\r
-        return service.list(null, null, null,null, CLASSIFICATION_INIT_STRATEGY);\r
-    }\r
-\r
-\r
     /**\r
      * @param treeUuid\r
      * @param response\r
      * @return\r
-     * @throws IOException\r
+     * @throws IOException+\r
+     *\r
+     * @Deprecated use {@link ClassificationController#getChildNodes(UUID, HttpServletResponse)} instead\r
      */\r
     @RequestMapping(\r
-            value = {"/portal/classification/{treeUuid}/childNodes"},\r
+            value = {"{treeUuid}/childNodes"},\r
             method = RequestMethod.GET)\r
     public List<TaxonNode> getChildNodes(\r
             @PathVariable("treeUuid") UUID treeUuid,\r
@@ -126,8 +115,19 @@ public class ClassificationPortalListController extends IdentifiableListControll
     }\r
 \r
 \r
+    /**\r
+     *\r
+     * @param treeUuid\r
+     * @param rankUuid\r
+     * @param request\r
+     * @param response\r
+     * @return\r
+     * @throws IOException\r
+     *\r
+     * @Deprecated use {@link ClassificationController#getChildNodesAtRank(UUID, UUID, HttpServletResponse)} instead\r
+     */\r
     @RequestMapping(\r
-            value = {"/portal/classification/{treeUuid}/childNodesAt/{rankUuid}"},\r
+            value = {"{treeUuid}/childNodesAt/{rankUuid}"},\r
             method = RequestMethod.GET)\r
     public List<TaxonNode> getChildNodesAtRank(\r
             @PathVariable("treeUuid") UUID treeUuid,\r
@@ -150,7 +150,10 @@ public class ClassificationPortalListController extends IdentifiableListControll
         }\r
         rank = findRank(rankUuid);\r
 \r
-        return service.listRankSpecificRootNodes(tree, rank, null, null, NODE_INIT_STRATEGY);\r
+//        long start = System.currentTimeMillis();\r
+        List<TaxonNode> rootNodes = service.listRankSpecificRootNodes(tree, rank, null, null, NODE_INIT_STRATEGY);\r
+//        System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start));\r
+        return rootNodes;\r
     }\r
 \r
 \r
@@ -174,7 +177,7 @@ public class ClassificationPortalListController extends IdentifiableListControll
      *         the {@link #NODE_INIT_STRATEGY}\r
      */\r
     @RequestMapping(\r
-            value = {"/portal/classification/{treeUuid}/childNodesOf/{taxonUuid}"},\r
+            value = {"{treeUuid}/childNodesOf/{taxonUuid}"},\r
             method = RequestMethod.GET)\r
     public List<TaxonNode> getChildNodesOfTaxon(\r
             @PathVariable("treeUuid") UUID treeUuid,\r
@@ -183,9 +186,24 @@ public class ClassificationPortalListController extends IdentifiableListControll
             HttpServletResponse response) throws IOException {\r
         logger.info("getChildNodesOfTaxon() " + request.getRequestURI());\r
 \r
-        Classification tree = service.find(treeUuid);\r
-        Taxon taxon = (Taxon) taxonService.load(taxonUuid);\r
-        List<TaxonNode> childs = service.loadChildNodesOfTaxon(taxon, tree, NODE_INIT_STRATEGY);\r
+\r
+        List<TaxonNode> childs = service.listChildNodesOfTaxon(taxonUuid, treeUuid, null, null, NODE_INIT_STRATEGY);\r
+        return childs;\r
+\r
+    }\r
+\r
+    @RequestMapping(\r
+            value = {"{treeUuid}/siblingsOf/{taxonUuid}"},\r
+            method = RequestMethod.GET)\r
+    public List<TaxonNode> getSiblingsOfTaxon(\r
+            @PathVariable("treeUuid") UUID treeUuid,\r
+            @PathVariable("taxonUuid") UUID taxonUuid,\r
+            HttpServletRequest request,\r
+            HttpServletResponse response) throws IOException {\r
+        logger.info("getSiblingsOfTaxon() " + request.getRequestURI());\r
+\r
+        //FIXME return pager\r
+        List<TaxonNode> childs = service.listSiblingsOfTaxon(taxonUuid, treeUuid, null, null, NODE_INIT_STRATEGY);\r
         return childs;\r
 \r
     }\r
@@ -208,7 +226,7 @@ public class ClassificationPortalListController extends IdentifiableListControll
      *         the {@link #NODE_INIT_STRATEGY}\r
      */\r
     @RequestMapping(\r
-            value = {"/portal/classification/{treeUuid}/pathFrom/{taxonUuid}/toRank/{rankUuid}"},\r
+            value = {"{treeUuid}/pathFrom/{taxonUuid}/toRank/{rankUuid}"},\r
             method = RequestMethod.GET)\r
     public List<TaxonNode> getPathFromTaxonToRank(\r
             @PathVariable("treeUuid") UUID treeUuid,\r
@@ -242,7 +260,7 @@ public class ClassificationPortalListController extends IdentifiableListControll
      *         the {@link #NODE_INIT_STRATEGY}\r
      */\r
     @RequestMapping(\r
-            value = {"/portal/classification/{treeUuid}/pathFrom/{taxonUuid}"},\r
+            value = {"{treeUuid}/pathFrom/{taxonUuid}"},\r
             method = RequestMethod.GET)\r
     public List<TaxonNode> getPathFromTaxon(\r
             @PathVariable("treeUuid") UUID treeUuid,\r
@@ -268,4 +286,4 @@ public class ClassificationPortalListController extends IdentifiableListControll
     }\r
 \r
 \r
-}
\ No newline at end of file
+}