// $Id$\r
/**\r
* Copyright (C) 2007 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
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.servlet.ModelAndView;\r
\r
import eu.etaxonomy.cdm.api.service.INameService;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
import eu.etaxonomy.cdm.model.name.NonViralName;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
\r
/**\r
* TODO write controller documentation\r
- * \r
+ *\r
* @author a.kohlbecker\r
* @date 24.03.2009\r
*/\r
\r
@Controller\r
@RequestMapping(value = {"/name/{uuid}"})\r
-public class NameController extends AnnotatableController<TaxonNameBase, INameService>\r
+public class NameController extends BaseController<TaxonNameBase, INameService>\r
{\r
- \r
- private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "typeStatus.representations",\r
- "typifiedNames",\r
- "typeSpecimen",\r
- "typeName",\r
- "citation",\r
- "citation.authorTeam.$",\r
- });\r
- \r
- private static final List<String> NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{\r
- \r
- });\r
- \r
- public NameController(){\r
- super();\r
- setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed????\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)\r
- */\r
- @Autowired\r
- @Override\r
- public void setService(INameService service) {\r
- this.service = service;\r
- }\r
- \r
- \r
- /**\r
- * Get the list of {@link TypeDesignationBase}s of the \r
- * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a List of {@link TypeDesignationBase} entities which are initialized\r
- * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}\r
- * @throws IOException\r
- *///TODO obsolete method?\r
- @RequestMapping(value = { "typeDesignations" }, method = RequestMethod.GET)\r
- public List<TypeDesignationBase> doGetNameTypeDesignations(\r
- @PathVariable("uuid") UUID uuid, HttpServletRequest request,\r
- HttpServletResponse response) throws IOException {\r
- \r
- logger.info("doGetTypeDesignations()" + request.getServletPath());\r
- TaxonNameBase tnb = getCdmBaseInstance(uuid, response,\r
- (List<String>) null);\r
- Pager<TypeDesignationBase> p = service.getTypeDesignations(tnb, null,\r
- null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
- return p.getRecords();\r
- \r
- }\r
- \r
- //TODO obsolete method?\r
- @RequestMapping(\r
- value = {"nameCache"},\r
- method = RequestMethod.GET)\r
- public List<String> doGetNameCache(@PathVariable("uuid") UUID uuid, \r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
- \r
- logger.info("doGetNameCache()" + request.getServletPath());\r
- TaxonNameBase tnb = getCdmBaseInstance(uuid, response, NAME_CACHE_INIT_STRATEGY);\r
- NonViralName nvn = (NonViralName) tnb;\r
- String nameCacheString = nvn.getNameCache();\r
- List result = new ArrayList<String>();\r
- result.add(nameCacheString);\r
- return result;\r
+\r
+ private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "typeStatus.representations",\r
+ "typifiedNames",\r
+ "typeSpecimen",\r
+ "typeName",\r
+ "citation",\r
+ "citation.authorTeam.$",\r
+ });\r
+\r
+ private static final List<String> NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{\r
+\r
+ });\r
+\r
+ public NameController(){\r
+ super();\r
+ setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed????\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)\r
+ */\r
+ @Autowired\r
+ @Override\r
+ public void setService(INameService service) {\r
+ this.service = service;\r
+ }\r
+\r
+\r
+ /**\r
+ * Get the list of {@link TypeDesignationBase}s of the\r
+ * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link TypeDesignationBase} entities which are initialized\r
+ * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}\r
+ * @throws IOException\r
+ *///TODO obsolete method?\r
+ @RequestMapping(value = { "typeDesignations" }, method = RequestMethod.GET)\r
+ public List<TypeDesignationBase> doGetNameTypeDesignations(\r
+ @PathVariable("uuid") UUID uuid, HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+\r
+ logger.info("doGetTypeDesignations()" + request.getServletPath());\r
+ TaxonNameBase tnb = getCdmBaseInstance(uuid, response,\r
+ (List<String>) null);\r
+ Pager<TypeDesignationBase> p = service.getTypeDesignations(tnb, null,\r
+ null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
+ return p.getRecords();\r
+\r
+ }\r
+\r
+ @RequestMapping(\r
+ value = {"nameCache"},\r
+ method = RequestMethod.GET)\r
+ public List<String> doGetNameCache(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+\r
+ logger.info("doGetNameCache()" + request.getServletPath());\r
+ TaxonNameBase tnb = getCdmBaseInstance(uuid, response, NAME_CACHE_INIT_STRATEGY);\r
+ NonViralName nvn = (NonViralName) tnb;\r
+ String nameCacheString = nvn.getNameCache();\r
+ List result = new ArrayList<String>();\r
+ result.add(nameCacheString);\r
+ return result;\r
+\r
+ }\r
+\r
+ @RequestMapping(value = "taggedName", method = RequestMethod.GET)\r
+ public ModelAndView doGetTaggedName(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("doGetDescriptionElementsByType() - " + request.getServletPath());\r
+\r
+ ModelAndView mv = new ModelAndView();\r
+ mv.addObject(service.getTaggedName(uuid));\r
+ return mv;\r
+ }\r
+ \r
+ @RequestMapping(value = "/name/namesByName/{taxonName}", method = RequestMethod.GET)\r
+ public TaxonNameBase findByName(\r
+ @PathVariable("taxonName") String taxonName,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response)throws IOException {\r
\r
- }\r
- \r
+ List<TaxonNameBase> listTNB = service.getNamesByName(taxonName);\r
+ \r
+ TaxonNameBase tnb = null;\r
+ service.getNamesByName(taxonName);\r
+ if (listTNB.size()>0) {\r
+ tnb = listTNB.get(0);\r
+ }\r
+ \r
+ return tnb;\r
+ \r
+ }\r
+\r
}\r