package eu.etaxonomy.cdm.remote.controller;\r
\r
import java.io.IOException;\r
+import java.util.ArrayList;\r
import java.util.Arrays;\r
-import java.util.Hashtable;\r
import java.util.List;\r
-import java.util.Map;\r
import java.util.UUID;\r
\r
import javax.servlet.http.HttpServletRequest;\r
\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Controller;\r
-import org.springframework.util.Assert;\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.servlet.ModelAndView;\r
\r
-import eu.etaxonomy.cdm.api.service.AnnotatableServiceBase;\r
import eu.etaxonomy.cdm.api.service.INameService;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
-import eu.etaxonomy.cdm.model.description.TaxonNameDescription;\r
+import eu.etaxonomy.cdm.model.name.NonViralName;\r
+import eu.etaxonomy.cdm.model.name.Rank;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
-import eu.etaxonomy.cdm.persistence.dao.common.IAnnotatableDao;\r
+import eu.etaxonomy.cdm.remote.dto.tdwg.voc.TaxonName;\r
+import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;\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 = {"/*/name/*", "/*/name/*/*", "/*/name/*/annotation"})\r
+@RequestMapping(value = {"/name/{uuid}"})\r
public class NameController extends AnnotatableController<TaxonNameBase, INameService>\r
{\r
\r
private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{\r
- "$",\r
- "citation.authorTeam",\r
- "typifiedNames.taggedName"\r
+ "typeStatus.representations",\r
+ "typifiedNames.titleCache",\r
+ "typeSpecimen.titleCache",\r
+ "typeName.titleCache",\r
+ "citation",\r
+ "citation.authorTeam.$",\r
+ });\r
+ \r
+ private static final List<String> NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "titleCache"\r
});\r
\r
public NameController(){\r
super();\r
- setUuidParameterPattern("^/(?:[^/]+)/name/([^/?#&\\.]+).*");\r
- setInitializationStrategy(Arrays.asList(new String[]{"$"}));\r
+ setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed????\r
}\r
\r
/* (non-Javadoc)\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 = {"/*/name/*/typeDesignations"},\r
+ value = {"nameCache"},\r
method = RequestMethod.GET)\r
- public List<TypeDesignationBase> doGetNameDesignations(HttpServletRequest request, HttpServletResponse response)throws IOException {\r
- TaxonNameBase tnb = getCdmBase(request, response, null, TaxonNameBase.class);\r
- Pager<TypeDesignationBase> p = service.getTypeDesignations(tnb, null, null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
- return p.getRecords();\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
}\r