// $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
\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Controller;\r
-import org.springframework.web.bind.WebDataBinder;\r
-import org.springframework.web.bind.annotation.InitBinder;\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
\r
import eu.etaxonomy.cdm.api.service.IReferenceService;\r
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import io.swagger.annotations.Api;\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 = {"/reference/*","/reference/{uuid}"})\r
-public class ReferenceController extends AnnotatableController<ReferenceBase, IReferenceService>\r
+@Api("reference")\r
+@RequestMapping(value = {"/reference/{uuid}"})\r
+public class ReferenceController extends AbstractIdentifiableController<Reference, IReferenceService>\r
{\r
- \r
- private static final List<String> NOMENCLATURAL_CITATION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "$.authorTeam.titleCache",\r
- "inBook.authorTeam.titleCache",\r
- "inJournal.authorTeam.titleCache",\r
- "inProceedings.authorTeam.titleCache",\r
- });\r
- \r
- private static final List<String> CITATION_WITH_AUTHORTEAM_INIT_STRATEGY = Arrays.asList(new String []{\r
- "authorTeam.$",\r
- "authorTeam.titleCache",\r
- });\r
- \r
- @InitBinder\r
- public void initBinder(WebDataBinder binder) {\r
- binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor());\r
- }\r
- \r
- public ReferenceController(){\r
- super();\r
- setUuidParameterPattern("^/reference/([^/?#&\\.]+).*");\r
- setInitializationStrategy(Arrays.asList(new String[]{\r
- "$",\r
- "authorTeam.$" // TODO obsolete??\r
- }));\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(IReferenceService service) {\r
- this.service = service;\r
- }\r
- \r
- /**\r
- * TODO write controller documentation\r
- * \r
- * @param request\r
- * @param response\r
- * @return\r
- * @throws IOException\r
- */\r
- @RequestMapping(\r
- value = {"{uuid}/nomenclaturalCitation"},\r
- method = RequestMethod.GET)\r
- public ModelAndView doGetNomenclaturalCitation(\r
- @PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response,\r
- @RequestParam(value = "microReference", required = false) String microReference)throws IOException {\r
- ModelAndView mv = new ModelAndView();\r
- ReferenceBase rb = service.load(uuid, NOMENCLATURAL_CITATION_INIT_STRATEGY);\r
- if(INomenclaturalReference.class.isAssignableFrom(rb.getClass())){\r
- String nomRefCit = ((INomenclaturalReference)rb).getNomenclaturalCitation(microReference);\r
- mv.addObject(nomRefCit);\r
- return mv;\r
- } else {\r
- response.sendError(400, "The supplied reference-uuid must specify a INomenclaturalReference.");\r
- }\r
- return mv;\r
- }\r
- \r
- @RequestMapping(\r
- value = {"{uuid}/authorTeam"},\r
- method = RequestMethod.GET)\r
- public ModelAndView doGetAuthorTeam(\r
- @PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response) {\r
- ModelAndView mv = new ModelAndView();\r
- ReferenceBase rb = service.load(uuid, CITATION_WITH_AUTHORTEAM_INIT_STRATEGY);\r
- if(rb.getAuthorTeam() != null){\r
- mv.addObject(rb.getAuthorTeam());\r
- }\r
- return mv;\r
- }\r
+\r
+ private static final List<String> NOMENCLATURAL_CITATION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "$",\r
+ "authorship",\r
+ "inReference.inReference",\r
+ "inReference.authorship"\r
+ });\r
+\r
+ private static final List<String> CITATION_WITH_AUTHORSHIP_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "authorship.$"\r
+ });\r
+\r
+ public ReferenceController(){\r
+ setInitializationStrategy(Arrays.asList(new String[]{\r
+ "$",\r
+ "authorship.$"\r
+ }));\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(IReferenceService service) {\r
+ this.service = service;\r
+ }\r
+\r
+ /**\r
+ * TODO write controller documentation\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"nomenclaturalCitation"},\r
+ method = RequestMethod.GET)\r
+ public ModelAndView doGetNomenclaturalCitation(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response,\r
+ @RequestParam(value = "microReference", required = false) String microReference)throws IOException {\r
+ ModelAndView mv = new ModelAndView();\r
+ Reference rb = service.load(uuid, NOMENCLATURAL_CITATION_INIT_STRATEGY);\r
+ if(INomenclaturalReference.class.isAssignableFrom(rb.getClass())){\r
+ String nomRefCit = ((INomenclaturalReference)rb).getNomenclaturalCitation(microReference);\r
+ mv.addObject(nomRefCit);\r
+ return mv;\r
+ } else {\r
+ response.sendError(400, "The supplied reference-uuid must specify a INomenclaturalReference.");\r
+ }\r
+ return mv;\r
+ }\r
+\r
+ @RequestMapping(\r
+ value = {"authorship"},\r
+ method = RequestMethod.GET)\r
+ public ModelAndView doGetAuthorship(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) {\r
+ ModelAndView mv = new ModelAndView();\r
+ Reference rb = service.load(uuid, CITATION_WITH_AUTHORSHIP_INIT_STRATEGY);\r
+ if(rb.getAuthorship() != null){\r
+ mv.addObject(rb.getAuthorship());\r
+ }\r
+ return mv;\r
+ }\r
\r
}\r