X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/325bc7e9b4e70a2a569b87385c89eca9e5726bf8..bd4fc52bfb928e6b017c5fbd887b29e3d64f713a:/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationPortalListController.java diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationPortalListController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationPortalListController.java index 9aa7afe544..6c95400081 100644 --- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationPortalListController.java +++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationPortalListController.java @@ -1,4 +1,3 @@ -// $Id$ /** * Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu @@ -9,6 +8,8 @@ package eu.etaxonomy.cdm.remote.controller; +import io.swagger.annotations.Api; + import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -42,16 +43,19 @@ import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor; * @date 20.03.2009 */ @Controller -public class ClassificationPortalListController extends IdentifiableListController { +@Api("portal_classification") +@RequestMapping(value="/portal/classification") +public class ClassificationPortalListController extends AbstractIdentifiableListController { private static final List CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[]{ - "reference.authorTeam" + "reference.authorship" + }); private static final List NODE_INIT_STRATEGY = Arrays.asList(new String[]{ - "taxon.sec", - "taxon.name.rank" + "taxon.name.rank", + "taxon.sec" }); @@ -59,10 +63,12 @@ public class ClassificationPortalListController extends IdentifiableListControll private ITaxonService taxonService; - private IClassificationService service; - private ITermService termService; + public ClassificationPortalListController() { + setInitializationStrategy(CLASSIFICATION_INIT_STRATEGY); + } + @Override @Autowired public void setService(IClassificationService service) { @@ -88,33 +94,16 @@ public class ClassificationPortalListController extends IdentifiableListControll } - /** - * Lists all available {@link Classification}s. - *

- * URI: /{datasource-name}/portal/classification - * - * @param request - * @param response - * @return a list of {@link Classification}s initialized by - * the {@link #CLASSIFICATION_INIT_STRATEGY} - * @throws IOException - */ - @RequestMapping(value = { "/portal/classification" }, method = RequestMethod.GET) - public List getClassifications(HttpServletRequest request, HttpServletResponse response) - throws IOException { - logger.info("getClassification() " + requestPathAndQuery(request)); - return service.list(null, null, null,null, CLASSIFICATION_INIT_STRATEGY); - } - - /** * @param treeUuid * @param response * @return - * @throws IOException + * @throws IOException+ + * + * @Deprecated use {@link ClassificationController#getChildNodes(UUID, HttpServletResponse)} instead */ @RequestMapping( - value = {"/portal/classification/{treeUuid}/childNodes"}, + value = {"{treeUuid}/childNodes"}, method = RequestMethod.GET) public List getChildNodes( @PathVariable("treeUuid") UUID treeUuid, @@ -126,8 +115,19 @@ public class ClassificationPortalListController extends IdentifiableListControll } + /** + * + * @param treeUuid + * @param rankUuid + * @param request + * @param response + * @return + * @throws IOException + * + * @Deprecated use {@link ClassificationController#getChildNodesAtRank(UUID, UUID, HttpServletResponse)} instead + */ @RequestMapping( - value = {"/portal/classification/{treeUuid}/childNodesAt/{rankUuid}"}, + value = {"{treeUuid}/childNodesAt/{rankUuid}"}, method = RequestMethod.GET) public List getChildNodesAtRank( @PathVariable("treeUuid") UUID treeUuid, @@ -150,7 +150,10 @@ public class ClassificationPortalListController extends IdentifiableListControll } rank = findRank(rankUuid); - return service.listRankSpecificRootNodes(tree, rank, null, null, NODE_INIT_STRATEGY); +// long start = System.currentTimeMillis(); + List rootNodes = service.listRankSpecificRootNodes(tree, rank, null, null, NODE_INIT_STRATEGY); +// System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start)); + return rootNodes; } @@ -174,7 +177,7 @@ public class ClassificationPortalListController extends IdentifiableListControll * the {@link #NODE_INIT_STRATEGY} */ @RequestMapping( - value = {"/portal/classification/{treeUuid}/childNodesOf/{taxonUuid}"}, + value = {"{treeUuid}/childNodesOf/{taxonUuid}"}, method = RequestMethod.GET) public List getChildNodesOfTaxon( @PathVariable("treeUuid") UUID treeUuid, @@ -183,9 +186,24 @@ public class ClassificationPortalListController extends IdentifiableListControll HttpServletResponse response) throws IOException { logger.info("getChildNodesOfTaxon() " + request.getRequestURI()); - Classification tree = service.find(treeUuid); - Taxon taxon = (Taxon) taxonService.load(taxonUuid); - List childs = service.loadChildNodesOfTaxon(taxon, tree, NODE_INIT_STRATEGY); + + List childs = service.listChildNodesOfTaxon(taxonUuid, treeUuid, null, null, NODE_INIT_STRATEGY); + return childs; + + } + + @RequestMapping( + value = {"{treeUuid}/siblingsOf/{taxonUuid}"}, + method = RequestMethod.GET) + public List getSiblingsOfTaxon( + @PathVariable("treeUuid") UUID treeUuid, + @PathVariable("taxonUuid") UUID taxonUuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + logger.info("getSiblingsOfTaxon() " + request.getRequestURI()); + + //FIXME return pager + List childs = service.listSiblingsOfTaxon(taxonUuid, treeUuid, null, null, NODE_INIT_STRATEGY); return childs; } @@ -208,7 +226,7 @@ public class ClassificationPortalListController extends IdentifiableListControll * the {@link #NODE_INIT_STRATEGY} */ @RequestMapping( - value = {"/portal/classification/{treeUuid}/pathFrom/{taxonUuid}/toRank/{rankUuid}"}, + value = {"{treeUuid}/pathFrom/{taxonUuid}/toRank/{rankUuid}"}, method = RequestMethod.GET) public List getPathFromTaxonToRank( @PathVariable("treeUuid") UUID treeUuid, @@ -242,7 +260,7 @@ public class ClassificationPortalListController extends IdentifiableListControll * the {@link #NODE_INIT_STRATEGY} */ @RequestMapping( - value = {"/portal/classification/{treeUuid}/pathFrom/{taxonUuid}"}, + value = {"{treeUuid}/pathFrom/{taxonUuid}"}, method = RequestMethod.GET) public List getPathFromTaxon( @PathVariable("treeUuid") UUID treeUuid, @@ -268,4 +286,4 @@ public class ClassificationPortalListController extends IdentifiableListControll } -} \ No newline at end of file +}