// $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 eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;\r
-import eu.etaxonomy.cdm.strategy.TaggedTextGenerator;\r
\r
/**\r
* TODO write controller documentation\r
- * \r
+ *\r
* @author a.kohlbecker\r
* @date 20.07.2009\r
*\r
*/\r
@Controller\r
@RequestMapping(value = {"/taxon/{uuid}"})\r
-public class TaxonController extends AnnotatableController<TaxonBase, ITaxonService>\r
+public class TaxonController extends BaseController<TaxonBase, ITaxonService>\r
{\r
- public static final Logger logger = Logger.getLogger(TaxonController.class);\r
- \r
- @Autowired\r
- private IOccurrenceService occurrenceService;\r
- @Autowired\r
- private INameService nameService;\r
- \r
- protected static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String []{\r
- "taxonNodes"\r
- });\r
- \r
- public TaxonController(){\r
- super();\r
- setInitializationStrategy(Arrays.asList(new String[]{"$","name.nomenclaturalReference"}));\r
- }\r
- \r
-\r
- @Autowired\r
- public void setService(ITaxonService service) {\r
- this.service = service;\r
- }\r
- \r
-\r
- /**\r
- * Get the set of accepted {@link Taxon} entities for a given\r
- * {@link TaxonBase} entity identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/taxon/{taxon-uuid}/accepted</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a set on a list of {@link Taxon} entities which are initialized\r
- * using the following initialization strategy:\r
- * {@link #DEFAULT_INIT_STRATEGY}\r
- * @throws IOException\r
- */\r
- @RequestMapping(value = "accepted", method = RequestMethod.GET)\r
- public Set<TaxonBase> doGetAccepted(\r
- @PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response) throws IOException {\r
- logger.info("getAccepted() " + request.getServletPath());\r
- TaxonBase tb = service.load(uuid);\r
- HashSet<TaxonBase> resultset = new HashSet<TaxonBase>();\r
- if(tb instanceof Taxon){\r
- //the taxon already is accepted\r
- //FIXME take the current view into account once views are implemented!!!\r
- resultset.add((Taxon)tb);\r
- } else {\r
- Synonym syn = (Synonym)tb;\r
- resultset.addAll(syn.getAcceptedTaxa());\r
- //TODO init Synonyms\r
- }\r
- return resultset;\r
- }\r
- \r
- @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)\r
- public Set<TaxonNode> doGetTaxonNodes(\r
- @PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response) throws IOException {\r
- TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);\r
- if(tb instanceof Taxon){\r
- return ((Taxon)tb).getTaxonNodes();\r
- } else {\r
- HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
- return null;\r
- }\r
- }\r
- \r
- @RequestMapping(value = "specimensOrObersvations", method = RequestMethod.GET)\r
- public ModelAndView doListSpecimensOrObersvations(\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
+ public static final Logger logger = Logger.getLogger(TaxonController.class);\r
\r
- TaxonBase tb = service.load(uuid);\r
- \r
- List<OrderHint> orderHints = new ArrayList<OrderHint>();\r
- orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));\r
- \r
- if(tb instanceof Taxon){\r
- List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAnyAssociation(\r
- null, (Taxon)tb, null, 0, orderHints, null);\r
- mv.addObject(specimensOrObersvations);\r
- } else {\r
- HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
- return null;\r
- }\r
- \r
- return mv;\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
- \r
- TaxonBase tb = service.load(uuid, Arrays.asList(new String[] {"name"}));\r
- mv.addObject(nameService.getTaggedName(tb.getName().getUuid()));\r
- return mv;\r
- }\r
+ @Autowired\r
+ private IOccurrenceService occurrenceService;\r
+ @Autowired\r
+ private INameService nameService;\r
+ @Autowired \r
+ private ITaxonService taxonService; \r
+ \r
+\r
+ protected static final List<String> TAXONNODE_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "taxonNodes"\r
+ });\r
+\r
+ public TaxonController(){\r
+ super();\r
+ setInitializationStrategy(Arrays.asList(new String[]{"$","name.nomenclaturalReference"}));\r
+ }\r
+\r
+\r
+ @Autowired\r
+ public void setService(ITaxonService service) {\r
+ this.service = service;\r
+ }\r
+\r
+\r
+ /**\r
+ * Get the set of accepted {@link Taxon} entities for a given\r
+ * {@link TaxonBase} entity identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/taxon/{taxon-uuid}/accepted</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a set on a list of {@link Taxon} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #DEFAULT_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(value = "accepted", method = RequestMethod.GET)\r
+ public Set<TaxonBase> doGetAccepted(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("getAccepted() " + request.getServletPath());\r
+ TaxonBase tb = service.load(uuid);\r
+ HashSet<TaxonBase> resultset = new HashSet<TaxonBase>();\r
+ if(tb instanceof Taxon){\r
+ //the taxon already is accepted\r
+ //FIXME take the current view into account once views are implemented!!!\r
+ resultset.add((Taxon)tb);\r
+ } else {\r
+ Synonym syn = (Synonym)tb;\r
+ resultset.addAll(syn.getAcceptedTaxa());\r
+ //TODO init Synonyms\r
+ }\r
+ return resultset;\r
+ }\r
+\r
+ @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)\r
+ public Set<TaxonNode> doGetTaxonNodes(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);\r
+ if(tb instanceof Taxon){\r
+ return ((Taxon)tb).getTaxonNodes();\r
+ } else {\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ return null;\r
+ }\r
+ }\r
+ \r
+\r
+ @RequestMapping(value = "specimensOrObersvations", method = RequestMethod.GET)\r
+ public ModelAndView doListSpecimensOrObersvations(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("doListSpecimensOrObersvations() - " + request.getServletPath());\r
+\r
+ ModelAndView mv = new ModelAndView();\r
+\r
+ TaxonBase tb = service.load(uuid);\r
+\r
+ List<OrderHint> orderHints = new ArrayList<OrderHint>();\r
+ orderHints.add(new OrderHint("titleCache", SortOrder.DESCENDING));\r
+\r
+ if(tb instanceof Taxon){\r
+ List<SpecimenOrObservationBase> specimensOrObersvations = occurrenceService.listByAnyAssociation(\r
+ null, (Taxon)tb, null, 0, orderHints, null);\r
+ mv.addObject(specimensOrObersvations);\r
+ } else {\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ return null;\r
+ }\r
+\r
+ return mv;\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
+\r
+ TaxonBase tb = service.load(uuid, Arrays.asList(new String[] {"name"}));\r
+ mv.addObject(nameService.getTaggedName(tb.getName().getUuid()));\r
+ return mv;\r
+ }\r
+ \r
+ /**\r
+ * FIXME change @RequestMapping to /taxon/findBestMatchingTaxon and also move into TaxonListController\r
+ */\r
+ @RequestMapping(value = "/bestMatchingTaxon/{taxonName}", method = RequestMethod.GET)\r
+ public TaxonBase doFindBestMatchingTaxon(\r
+ @PathVariable("taxonName") String taxonName,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response)throws IOException {\r
\r
+ Taxon bestMatchingTaxon = taxonService.findBestMatchingTaxon(taxonName);\r
+ \r
+ return bestMatchingTaxon;\r
+ \r
+ \r
+ }\r
+\r
}
\ No newline at end of file