\r
package eu.etaxonomy.cdm.remote.controller;\r
\r
+import java.io.IOException;\r
import java.util.Arrays;\r
import java.util.List;\r
+import java.util.UUID;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\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
+import org.springframework.web.bind.annotation.RequestParam;\r
+import org.springframework.web.servlet.ModelAndView;\r
\r
-import eu.etaxonomy.cdm.api.service.AnnotatableServiceBase;\r
import eu.etaxonomy.cdm.api.service.IReferenceService;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.persistence.dao.common.IAnnotatableDao;\r
+import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;\r
\r
/**\r
+ * TODO write controller documentation\r
+ * \r
* @author a.kohlbecker\r
* @date 24.03.2009\r
*/\r
\r
@Controller\r
-@RequestMapping(value = {"/*/reference/*","/*/reference/annotation/*"})\r
-public class ReferenceController extends AnnotatableController<ReferenceBase, IReferenceService>\r
+@RequestMapping(value = {"/reference/{uuid}"})\r
+public class ReferenceController extends BaseController<Reference, IReferenceService>\r
{\r
\r
+ private static final List<String> NOMENCLATURAL_CITATION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "$",\r
+ "authorTeam", // TODO obsolete??\r
+ "inReference.authorTeam"\r
+ });\r
+ \r
+ private static final List<String> CITATION_WITH_AUTHORTEAM_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "authorTeam.$" // TODO obsolete??\r
+ });\r
+ \r
public ReferenceController(){\r
- super();\r
- setUuidParameterPattern("^/(?:[^/]+)/reference/([^/?#&\\.]+).*");\r
setInitializationStrategy(Arrays.asList(new String[]{\r
"$",\r
- "authorTeam.$"}));\r
+ "authorTeam.$" // TODO obsolete??\r
+ }));\r
}\r
\r
/* (non-Javadoc)\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 = {"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
+ Reference 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
}\r