first fully working swagger doc on the cdm remote api. Model scan ist still disabled...
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / TaxonListController.java
index a77f8cd651435b1b08934db2aac495230bf9bcc4..a240faad3187a73400c74269a41d3d78d214a445 100644 (file)
@@ -33,6 +33,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;\r
 import org.springframework.web.bind.annotation.RequestParam;\r
 \r
+import com.wordnik.swagger.annotations.Api;\r
+\r
 import eu.etaxonomy.cdm.api.service.IClassificationService;\r
 import eu.etaxonomy.cdm.api.service.ITaxonService;\r
 import eu.etaxonomy.cdm.api.service.ITermService;\r
@@ -46,7 +48,7 @@ import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.Language;\r
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
 import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.description.PresenceAbsenceTermBase;\r
+import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;\r
 import eu.etaxonomy.cdm.model.location.NamedArea;\r
 import eu.etaxonomy.cdm.model.taxon.Classification;\r
 import eu.etaxonomy.cdm.model.taxon.Synonym;\r
@@ -66,10 +68,16 @@ import eu.etaxonomy.cdm.remote.editor.UuidList;
  * @date 20.03.2009\r
  */\r
 @Controller\r
+@Api("taxon")\r
 @RequestMapping(value = {"/taxon"})\r
 public class TaxonListController extends IdentifiableListController<TaxonBase, ITaxonService> {\r
 \r
 \r
+    private static final List<String> SIMPLE_TAXON_INIT_STRATEGY = DEFAULT_INIT_STRATEGY;\r
+    protected List<String> getSimpleTaxonInitStrategy() {\r
+        // TODO Auto-generated method stub\r
+        return SIMPLE_TAXON_INIT_STRATEGY;\r
+    }\r
 \r
     /**\r
      *\r
@@ -104,7 +112,7 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
     /**\r
      * Find Taxa, Synonyms, Common Names by name, either globally or in a specific geographic area.\r
      * <p>\r
-     * URI: <b>&#x002F;{datasource-name}&#x002F;portal&#x002F;taxon&#x002F;find</b>\r
+     * URI: <b>taxon&#x002F;search</b>\r
      *\r
      * @param query\r
      *            the string to query for. Since the wildcard character '*'\r
@@ -141,7 +149,7 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
             @RequestParam(value = "query", required = true) String query,\r
             @RequestParam(value = "tree", required = false) UUID treeUuid,\r
             @RequestParam(value = "area", required = false) DefinedTermBaseList<NamedArea> areaList,\r
-            @RequestParam(value = "status", required = false) Set<PresenceAbsenceTermBase<?>> status,\r
+            @RequestParam(value = "status", required = false) Set<PresenceAbsenceTerm> status,\r
             @RequestParam(value = "pageNumber", required = false) Integer pageNumber,\r
             @RequestParam(value = "pageSize", required = false) Integer pageSize,\r
             @RequestParam(value = "doTaxa", required = false) Boolean doTaxa,\r
@@ -189,7 +197,7 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
         return service.findTaxaAndNamesByFullText(searchModes, query,\r
                 classification, areaSet, status, null,\r
                 false, pagerParams.getPageSize(), pagerParams.getPageIndex(),\r
-                OrderHint.NOMENCLATURAL_SORT_ORDER, initializationStrategy);\r
+                OrderHint.NOMENCLATURAL_SORT_ORDER, getSimpleTaxonInitStrategy());\r
     }\r
 \r
     /**\r
@@ -227,8 +235,8 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
      *         the following strategy {@link #SIMPLE_TAXON_INIT_STRATEGY}\r
      * @throws IOException\r
      */\r
-    @RequestMapping(method = RequestMethod.GET, value={"findTaxaAndNames"}) // TODO should be find, see TaxonListPortaController\r
-    public Pager<IdentifiableEntity> doFindTaxaAndNames(\r
+    @RequestMapping(method = RequestMethod.GET, value={"find"})\r
+    public Pager<IdentifiableEntity> doFind(\r
             @RequestParam(value = "query", required = true) String query,\r
             @RequestParam(value = "tree", required = false) UUID treeUuid,\r
             @RequestParam(value = "area", required = false) Set<NamedArea> areas,\r
@@ -245,15 +253,12 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
              throws IOException {\r
 \r
 \r
-        logger.info("findTaxaAndNames : " + request.getRequestURI() + "?" + request.getQueryString() );\r
+        logger.info("find : " + request.getRequestURI() + "?" + request.getQueryString() );\r
 \r
         PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);\r
         pagerParams.normalizeAndValidate(response);\r
 \r
         IFindTaxaAndNamesConfigurator config = new FindTaxaAndNamesConfiguratorImpl();\r
-\r
-        config.setTaxonPropertyPath(initializationStrategy);\r
-\r
         config.setPageNumber(pagerParams.getPageIndex());\r
         config.setPageSize(pagerParams.getPageSize());\r
         config.setTitleSearchString(query);\r
@@ -262,7 +267,7 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
         config.setDoMisappliedNames(doMisappliedNames != null ? doMisappliedNames : Boolean.FALSE);\r
         config.setDoTaxaByCommonNames(doTaxaByCommonNames != null ? doTaxaByCommonNames : Boolean.FALSE );\r
         config.setMatchMode(matchMode != null ? matchMode : MatchMode.BEGINNING);\r
-//        config.setTaxonPropertyPath(SIMPLE_TAXON_INIT_STRATEGY);\r
+        config.setTaxonPropertyPath(getSimpleTaxonInitStrategy());\r
         config.setNamedAreas(areas);\r
         if(treeUuid != null){\r
             Classification classification = classificationService.find(treeUuid);\r
@@ -326,8 +331,8 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
 \r
         Pager<SearchResult<TaxonBase>> pager = service.findByDescriptionElementFullText(\r
                 clazz, queryString, classification, features, languages, highlighting,\r
-                pagerParams.getPageSize(), pagerParams.getPageIndex(), ((List<OrderHint>)null),\r
-                initializationStrategy);\r
+                pagerParams.getPageSize(), pagerParams.getPageIndex(),\r
+                ((List<OrderHint>)null), getSimpleTaxonInitStrategy());\r
         return pager;\r
     }\r
 \r
@@ -404,7 +409,7 @@ public class TaxonListController extends IdentifiableListController<TaxonBase, I
      * @param areaSet\r
      */\r
     static public void includeAllSubAreas(Set<NamedArea> areaSet, ITermService termService) {\r
-       Collection<NamedArea> tmpAreas = new HashSet<NamedArea>(areaSet);\r
+        Collection<NamedArea> tmpAreas = new HashSet<NamedArea>(areaSet);\r
         // expand all areas to include also the sub areas\r
         Pager<NamedArea> pager = null;\r
         while(true){\r