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.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.IDescriptionService;\r
import eu.etaxonomy.cdm.api.service.INameService;\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
-import eu.etaxonomy.cdm.database.UpdatableRoutingDataSource;\r
+import eu.etaxonomy.cdm.model.description.TaxonNameDescription;\r
import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;\r
\r
*/\r
\r
@Controller\r
-@RequestMapping(value = {"/portal/name/*","/portal/name/{uuid}"})\r
-public class NamePortalController extends NameController\r
+@RequestMapping(value = {"/portal/name/{uuid}"})\r
+public class NamePortalController extends BaseController<TaxonNameBase, INameService>\r
{\r
\r
private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{ \r
"typeName.$",\r
- "typeName.titleCache",\r
- "typeSpecimen.titleCache",\r
+ "typeSpecimen",\r
"typeStatus.representations",\r
- "typeStatus.representations",\r
- "typifiedNames.titleCache",\r
- "citation",\r
+ "typifiedNames",\r
"citation.authorTeam.$",\r
"typeSpecimen.media.representations.parts"\r
});\r
\r
+ \r
+ private static final List<String> NAMEDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "uuid",\r
+ "feature",\r
+ "elements.$",\r
+ "elements.multilanguageText",\r
+ "elements.media.representations.parts",\r
+ "elements.media.title",\r
+ });\r
+ \r
+ \r
public NamePortalController(){\r
super();\r
- setUuidParameterPattern("^/portal/name/([^/?#&\\.]+).*");\r
- setInitializationStrategy(Arrays.asList(new String[]{"$"}));\r
+ setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO required???\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
+ @Autowired\r
+ private IDescriptionService descriptionService;\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}/portal/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 following initialization strategy:\r
+ * {@link #TYPEDESIGNATION_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @SuppressWarnings("unchecked")\r
+ @RequestMapping(\r
+ value = {"typeDesignations"},\r
+ method = RequestMethod.GET)\r
+ public ModelAndView doGetTypeDesignations(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ ModelAndView mv = new ModelAndView();\r
+ TaxonNameBase tnb = getCdmBaseInstance(uuid, response, (List<String>)null);\r
+ Pager<TypeDesignationBase> p = service.getTypeDesignations(tnb, null, null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
+ mv.addObject(p.getRecords());\r
+ return mv;\r
+ }\r
+ \r
+ /**\r
+ * Get the list of {@link TaxonNameDescription}s of the Name associated with the \r
+ * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/name/{name-uuid}/descriptions</b>\r
+ * \r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link TaxonNameDescription} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #NAMEDESCRIPTION_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"taxonNameDescriptions"},\r
+ method = RequestMethod.GET)\r
+ public List<TaxonNameDescription> doGetNameDescriptions(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ logger.info("doGetNameDescriptions()" + request.getServletPath());\r
+ TaxonNameBase tnb = service.load(uuid, null);\r
+ Pager<TaxonNameDescription> p = descriptionService.getTaxonNameDescriptions(tnb, null, null, NAMEDESCRIPTION_INIT_STRATEGY);\r
+ return p.getRecords();\r
+ }\r
+\r
+\r
}\r