X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/f0254f6b82939d3025ba4fb1b5b8c64b6b248b0c..b73b424de63c9a3672ad61fae004a88109fcd2e9:/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java index 6b66d0cb3f..db67793213 100644 --- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java +++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameController.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -24,6 +24,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; import eu.etaxonomy.cdm.api.service.INameService; import eu.etaxonomy.cdm.api.service.pager.Pager; @@ -33,85 +34,98 @@ import eu.etaxonomy.cdm.model.name.TypeDesignationBase; /** * TODO write controller documentation - * + * * @author a.kohlbecker * @date 24.03.2009 */ @Controller @RequestMapping(value = {"/name/{uuid}"}) -public class NameController extends AnnotatableController +public class NameController extends BaseController { - - private static final List TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{ - "typeStatus.representations", - "typifiedNames", - "typeSpecimen", - "typeName", - "citation", - "citation.authorTeam.$", - }); - - private static final List NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{ - - }); - - public NameController(){ - super(); - setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed???? - } - - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService) - */ - @Autowired - @Override - public void setService(INameService service) { - this.service = service; - } - - - /** - * Get the list of {@link TypeDesignationBase}s of the - * {@link TaxonNameBase} instance identified by the {name-uuid}. - *

- * URI: /{datasource-name}/name/{name-uuid}/typeDesignations - * - * @param request - * @param response - * @return a List of {@link TypeDesignationBase} entities which are initialized - * using the {@link #TYPEDESIGNATION_INIT_STRATEGY} - * @throws IOException - *///TODO obsolete method? - @RequestMapping(value = { "typeDesignations" }, method = RequestMethod.GET) - public List doGetNameTypeDesignations( - @PathVariable("uuid") UUID uuid, HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("doGetTypeDesignations()" + request.getServletPath()); - TaxonNameBase tnb = getCdmBaseInstance(uuid, response, - (List) null); - Pager p = service.getTypeDesignations(tnb, null, - null, null, TYPEDESIGNATION_INIT_STRATEGY); - return p.getRecords(); - - } - - //TODO obsolete method? - @RequestMapping( - value = {"nameCache"}, - method = RequestMethod.GET) - public List doGetNameCache(@PathVariable("uuid") UUID uuid, - HttpServletRequest request, HttpServletResponse response)throws IOException { - - logger.info("doGetNameCache()" + request.getServletPath()); - TaxonNameBase tnb = getCdmBaseInstance(uuid, response, NAME_CACHE_INIT_STRATEGY); - NonViralName nvn = (NonViralName) tnb; - String nameCacheString = nvn.getNameCache(); - List result = new ArrayList(); - result.add(nameCacheString); - return result; - - } - + + private static final List TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{ + "typeStatus.representations", + "typifiedNames", + "typeSpecimen", + "typeName", + "citation", + "citation.authorTeam.$", + }); + + private static final List NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{ + + }); + + public NameController(){ + super(); + setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed???? + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService) + */ + @Autowired + @Override + public void setService(INameService service) { + this.service = service; + } + + + /** + * Get the list of {@link TypeDesignationBase}s of the + * {@link TaxonNameBase} instance identified by the {name-uuid}. + *

+ * URI: /{datasource-name}/name/{name-uuid}/typeDesignations + * + * @param request + * @param response + * @return a List of {@link TypeDesignationBase} entities which are initialized + * using the {@link #TYPEDESIGNATION_INIT_STRATEGY} + * @throws IOException + * + * TODO obsolete method? + */ + @RequestMapping(value = { "typeDesignations" }, method = RequestMethod.GET) + public List doGetNameTypeDesignations( + @PathVariable("uuid") UUID uuid, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("doGetTypeDesignations()" + request.getServletPath()); + TaxonNameBase tnb = getCdmBaseInstance(uuid, response, + (List) null); + Pager p = service.getTypeDesignations(tnb, null, + null, null, TYPEDESIGNATION_INIT_STRATEGY); + return p.getRecords(); + } + + @RequestMapping( + value = {"nameCache"}, + method = RequestMethod.GET) + public List doGetNameCache(@PathVariable("uuid") UUID uuid, + HttpServletRequest request, HttpServletResponse response)throws IOException { + + logger.info("doGetNameCache()" + request.getServletPath()); + TaxonNameBase tnb = getCdmBaseInstance(uuid, response, NAME_CACHE_INIT_STRATEGY); + NonViralName nvn = (NonViralName) tnb; + String nameCacheString = nvn.getNameCache(); + List result = new ArrayList(); + result.add(nameCacheString); + return result; + + } + + @RequestMapping(value = "taggedName", method = RequestMethod.GET) + public ModelAndView doGetTaggedName( + @PathVariable("uuid") UUID uuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + logger.info("doGetDescriptionElementsByType() - " + request.getServletPath()); + + ModelAndView mv = new ModelAndView(); + mv.addObject(service.getTaggedName(uuid)); + return mv; + } + + }