import eu.etaxonomy.cdm.api.service.IDescriptionService;\r
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;\r
import eu.etaxonomy.cdm.api.service.INameService;\r
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;\r
import eu.etaxonomy.cdm.api.service.ITaxonService;\r
import eu.etaxonomy.cdm.api.service.ITaxonTreeService;\r
import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;\r
import eu.etaxonomy.cdm.persistence.query.MatchMode;\r
import eu.etaxonomy.cdm.remote.editor.MatchModePropertyEditor;\r
import eu.etaxonomy.cdm.remote.editor.NamedAreaPropertyEditor;\r
-import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;\r
\r
/**\r
* The TaxonPortalController class is a Spring MVC Controller.\r
@Autowired\r
private IDescriptionService descriptionService;\r
\r
+ @Autowired\r
+ private IOccurrenceService occurrenceService;\r
+ \r
@Autowired\r
private ITaxonTreeService taxonTreeService;\r
\r
"elements.media.title",\r
});\r
\r
+ protected static final List<String> DESCRIPTION_ELEMENT_INIT_STRATEGY = Arrays.asList(new String []{\r
+ "$",\r
+ "sources.citation.authorTeam",\r
+ "sources.nameUsedInSource.originalNameString",\r
+ "multilanguageText",\r
+ "media.representations.parts",\r
+ "media.title",\r
+ });\r
+ \r
\r
// private static final List<String> NAMEDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{\r
// "uuid",\r
@RequestMapping(\r
value = {"descriptions"},\r
method = RequestMethod.GET)\r
- public List<TaxonDescription> doGetDescriptions(@PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ public List<TaxonDescription> doGetDescriptions(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response)throws IOException {\r
if(request != null){\r
logger.info("doGetDescriptions()" + request.getServletPath());\r
}\r
Pager<TaxonDescription> p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);\r
return p.getRecords();\r
}\r
+ \r
+ @RequestMapping(value = "descriptions/elementsByType/{classSimpleName}", method = RequestMethod.GET)\r
+ public ModelAndView doGetDescriptionElementsByType(\r
+ @PathVariable("uuid") UUID uuid,\r
+ @PathVariable("classSimpleName") String classSimpleName,\r
+ @RequestParam(value = "count", required = false, defaultValue = "false") Boolean doCount,\r
+ HttpServletRequest request, \r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("doGetDescriptionElementsByType() - " + request.getServletPath());\r
+ \r
+ ModelAndView mv = new ModelAndView();\r
+ \r
+ List<DescriptionElementBase> allElements = new ArrayList<DescriptionElementBase>();\r
+ List<DescriptionElementBase> elements;\r
+ int count = 0;\r
+ \r
+ List<String> initStrategy = doCount ? null : DESCRIPTION_ELEMENT_INIT_STRATEGY; \r
+ \r
+ List<TaxonDescription> taxonDescriptions = doGetDescriptions(uuid, request, response);\r
+ try {\r
+ Class type;\r
+ type = Class.forName("eu.etaxonomy.cdm.model.description."\r
+ + classSimpleName);\r
+ if (taxonDescriptions != null) {\r
+ for (TaxonDescription description : taxonDescriptions) {\r
+ elements = descriptionService.listDescriptionElements(description, null, type, null, 0, initStrategy);\r
+ allElements.addAll(elements);\r
+ count += elements.size();\r
+ }\r
+\r
+ }\r
+ } catch (ClassNotFoundException e) {\r
+ HttpStatusMessage.fromString(e.getLocalizedMessage()).send(response);\r
+ }\r
+ if(doCount){\r
+ mv.addObject(count);\r
+ } else {\r
+ mv.addObject(allElements);\r
+ }\r
+ return mv;\r
+ }\r
+ \r
+// @RequestMapping(value = "specimens", method = RequestMethod.GET)\r
+// public ModelAndView doGetSpecimens(\r
+// @PathVariable("uuid") UUID uuid,\r
+// HttpServletRequest request, \r
+// HttpServletResponse response) throws IOException, ClassNotFoundException {\r
+// logger.info("doGetSpecimens() - " + request.getServletPath());\r
+// \r
+// ModelAndView mv = new ModelAndView();\r
+// \r
+// List<DerivedUnitFacade> derivedUnitFacadeList = new ArrayList<DerivedUnitFacade>();\r
+//\r
+// // find speciemens in the TaxonDescriptions\r
+// List<TaxonDescription> taxonDescriptions = doGetDescriptions(uuid, request, response);\r
+// if (taxonDescriptions != null) {\r
+// \r
+// for (TaxonDescription description : taxonDescriptions) {\r
+// derivedUnitFacadeList.addAll( occurrenceService.listDerivedUnitFacades(description, null) );\r
+// }\r
+// }\r
+// // TODO find speciemens in the NameDescriptions ??\r
+// \r
+// // TODO also find type specimens\r
+// \r
+// mv.addObject(derivedUnitFacadeList);\r
+// \r
+// return mv;\r
+// }\r
\r
/**\r
* Get the {@link Media} attached to the {@link Taxon} instance \r