- return resultset;\r
- }\r
- \r
- /**\r
- * Get the list of {@link TaxonRelationship}s for the given \r
- * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/taxonRelationships</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a List of {@link TaxonRelationship} entities which are initialized\r
- * using the following initialization strategy:\r
- * {@link #TAXONRELATIONSHIP_INIT_STRATEGY}\r
- * @throws IOException\r
- */\r
- @RequestMapping(\r
- value = {"taxonRelationships"},\r
- method = RequestMethod.GET)\r
- public List<TaxonRelationship> doGetTaxonRelations(@PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
-\r
- logger.info("doGetTaxonRelations()" + request.getServletPath());\r
- Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
- List<TaxonRelationship> relations = new ArrayList<TaxonRelationship>();\r
- List<TaxonRelationship> results = service.listToTaxonRelationships(taxon, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);\r
- relations.addAll(results);\r
- results = service.listToTaxonRelationships(taxon, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);\r
- relations.addAll(results);\r
-\r
- return relations;\r
- }\r
- \r
- /**\r
- * Get the list of {@link NameRelationship}s of the Name associated with the \r
- * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a List of {@link NameRelationship} entities which are initialized\r
- * using the following initialization strategy:\r
- * {@link #NAMERELATIONSHIP_INIT_STRATEGY}\r
- * @throws IOException\r
- */\r
- @RequestMapping(\r
- value = {"toNameRelationships"},\r
- method = RequestMethod.GET)\r
- public List<NameRelationship> doGetToNameRelations(@PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
- logger.info("doGetNameRelations()" + request.getServletPath());\r
- TaxonBase taxonBase = getCdmBaseInstance(TaxonBase.class, uuid, response, (List<String>)null);\r
- List<NameRelationship> list = nameService.listToNameRelationships(taxonBase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
- return list;\r
- }\r
- \r
- /**\r
- * Get the list of {@link NameRelationship}s of the Name associated with the \r
- * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a List of {@link NameRelationship} entities which are initialized\r
- * using the following initialization strategy:\r
- * {@link #NAMERELATIONSHIP_INIT_STRATEGY}\r
- * @throws IOException\r
- */\r
- @RequestMapping(\r
- value = {"fromNameRelationships"},\r
- method = RequestMethod.GET)\r
- public List<NameRelationship> doGetFromNameRelations(@PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
- logger.info("doGetNameFromNameRelations()" + request.getServletPath());\r
-\r
- TaxonBase taxonbase = getCdmBaseInstance(TaxonBase.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);\r
- List<NameRelationship> list = nameService.listFromNameRelationships(taxonbase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
- return list;\r
- }\r
- \r
- /**\r
- * Get the list of {@link TypeDesignationBase}s of the \r
- * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameTypeDesignations</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
- * @Deprecated use /name/{uuid}/typeDesignations & /derivedunitfacade/{uuid} instead\r
- */\r
- @Deprecated\r
- @RequestMapping(\r
- value = {"nameTypeDesignations"},\r
- method = RequestMethod.GET)\r
- public List<TypeDesignationBase> doGetNameTypeDesignations(@PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, HttpServletResponse response)throws IOException {\r
- logger.info("doGetNameTypeDesignations()" + request.getServletPath());\r
- Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);\r
- Pager<TypeDesignationBase> p = nameService.getTypeDesignations(taxon.getName(), null, null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
- return p.getRecords();\r
- }\r
- \r
- @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)\r
- public Set<TaxonNode> doGetTaxonNodes(\r
- @PathVariable("uuid") UUID uuid,\r
- HttpServletRequest request, \r
- HttpServletResponse response) throws IOException {\r
- TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);\r
- if(tb instanceof Taxon){\r
- return ((Taxon)tb).getTaxonNodes();\r
- } else {\r
- HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
- return null;\r
- }\r
- }\r
- \r
- /**\r
- * Get the list of {@link TaxonDescription}s of the \r
- * {@link Taxon} instance identified by the <code>{taxon-uuid}</code>.\r
- * <p>\r
- * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/descriptions</b>\r
- * \r
- * @param request\r
- * @param response\r
- * @return a List of {@link TaxonDescription} entities which are initialized\r
- * using the following initialization strategy:\r
- * {@link #TAXONDESCRIPTION_INIT_STRATEGY}\r
- * @throws IOException\r
- */\r
- @RequestMapping(\r
- value = {"descriptions"},\r
- method = RequestMethod.GET)\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
- Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\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
+ return resultset;\r
+ }\r
+\r
+ /**\r
+ * Get the list of {@link TaxonRelationship}s for the given\r
+ * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/taxonRelationships</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link TaxonRelationship} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #TAXONRELATIONSHIP_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"taxonRelationships"},\r
+ method = RequestMethod.GET)\r
+ public List<TaxonRelationship> doGetTaxonRelations(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+\r
+ logger.info("doGetTaxonRelations()" + request.getServletPath());\r
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
+ List<TaxonRelationship> toRelationships = service.listToTaxonRelationships(taxon, null, null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);\r
+ List<TaxonRelationship> fromRelationships = service.listFromTaxonRelationships(taxon, null, null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);\r
+\r
+ List<TaxonRelationship> allRelationships = new ArrayList<TaxonRelationship>(toRelationships.size() + fromRelationships.size());\r
+ allRelationships.addAll(toRelationships);\r
+ allRelationships.addAll(fromRelationships);\r
+\r
+ return allRelationships;\r
+ }\r
+\r
+ /**\r
+ * Get the list of {@link NameRelationship}s of the Name associated with the\r
+ * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link NameRelationship} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #NAMERELATIONSHIP_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"toNameRelationships"},\r
+ method = RequestMethod.GET)\r
+ public List<NameRelationship> doGetToNameRelations(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ logger.info("doGetNameRelations()" + request.getServletPath());\r
+ TaxonBase taxonBase = getCdmBaseInstance(TaxonBase.class, uuid, response, (List<String>)null);\r
+ List<NameRelationship> list = nameService.listNameRelationships(taxonBase.getName(), Direction.relatedTo, null, null, 0, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
+ //List<NameRelationship> list = nameService.listToNameRelationships(taxonBase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
+ return list;\r
+ }\r
+\r
+ /**\r
+ * Get the list of {@link NameRelationship}s of the Name associated with the\r
+ * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link NameRelationship} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #NAMERELATIONSHIP_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"fromNameRelationships"},\r
+ method = RequestMethod.GET)\r
+ public List<NameRelationship> doGetFromNameRelations(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ logger.info("doGetNameFromNameRelations()" + request.getServletPath());\r
+\r
+ TaxonBase taxonbase = getCdmBaseInstance(TaxonBase.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);\r
+ List<NameRelationship> list = nameService.listNameRelationships(taxonbase.getName(), Direction.relatedFrom, null, null, 0, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
+ //List<NameRelationship> list = nameService.listFromNameRelationships(taxonbase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);\r
+ return list;\r
+ }\r
+\r
+ /**\r
+ * Get the list of {@link TypeDesignationBase}s of the\r
+ * {@link TaxonBase} instance identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/nameTypeDesignations</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
+ * @Deprecated use /name/{uuid}/typeDesignations & /derivedunitfacade/{uuid} instead\r
+ * also see http://dev.e-taxonomy.eu/trac/ticket/2280\r
+ */\r
+ @Deprecated\r
+ @RequestMapping(\r
+ value = {"nameTypeDesignations"},\r
+ method = RequestMethod.GET)\r
+ public List<TypeDesignationBase> doGetNameTypeDesignations(@PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request, HttpServletResponse response)throws IOException {\r
+ logger.info("doGetNameTypeDesignations()" + request.getServletPath());\r
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);\r
+ Pager<TypeDesignationBase> p = nameService.getTypeDesignations(taxon.getName(), null, null, null, TYPEDESIGNATION_INIT_STRATEGY);\r
+ return p.getRecords();\r
+ }\r
+\r
+ @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)\r
+ public Set<TaxonNode> doGetTaxonNodes(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);\r
+ if(tb instanceof Taxon){\r
+ return ((Taxon)tb).getTaxonNodes();\r
+ } else {\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ return null;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Get the list of {@link TaxonDescription}s of the\r
+ * {@link Taxon} instance identified by the <code>{taxon-uuid}</code>.\r
+ * <p>\r
+ * URI: <b>/{datasource-name}/portal/taxon/{taxon-uuid}/descriptions</b>\r
+ *\r
+ * @param request\r
+ * @param response\r
+ * @return a List of {@link TaxonDescription} entities which are initialized\r
+ * using the following initialization strategy:\r
+ * {@link #TAXONDESCRIPTION_INIT_STRATEGY}\r
+ * @throws IOException\r
+ */\r
+ @RequestMapping(\r
+ value = {"descriptions"},\r
+ method = RequestMethod.GET)\r
+ public List<TaxonDescription> doGetDescriptions(\r
+ @PathVariable("uuid") UUID uuid,\r
+ @RequestParam(value = "markerTypes", required = false) UuidList markerTypeUUIDs,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response)throws IOException {\r
+ if(request != null){\r
+ logger.info("doGetDescriptions()" + request.getServletPath());\r
+ }\r
+ List<DefinedTermBase> markerTypeTerms = null;\r
+ Set<UUID> sMarkerTypeUUIDs = null;\r
+\r
+ if(markerTypeUUIDs != null && !markerTypeUUIDs.isEmpty()){\r
+ sMarkerTypeUUIDs = new HashSet<UUID>(markerTypeUUIDs);\r
+ markerTypeTerms = termService.find(sMarkerTypeUUIDs);\r
+ } else if(markerTypeUUIDs != null && markerTypeUUIDs.isEmpty()){\r
+ markerTypeTerms = new ArrayList<DefinedTermBase>();\r
+ }\r
+ Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+ List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>();\r
+ if (markerTypeTerms != null) {\r
+ for (DefinedTermBase markerTypeTerm : markerTypeTerms) {\r
+ markerTypes.add((MarkerType)markerTypeTerm);\r
+ }\r
+ }\r
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
+ if (markerTypeTerms == null) {\r
+\r
+ Pager<TaxonDescription> p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);\r
+ descriptions = p.getRecords();\r
+ }\r
+\r
+ else if (markerTypeTerms != null && markerTypeTerms.isEmpty()) {\r
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+\r
+ }\r
+ else {\r
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+ /*for (TaxonDescription description: descriptions) {\r
+ for (IdentifiableSource source :description.getSources()) {\r
+ if (source.getOriginalNameString() != null) {\r
+ description.\r
+ }\r
+\r
+ }\r
+\r
+\r
+ }*/\r
+ }\r
+ return descriptions;\r
+ }\r
+\r
+ @RequestMapping(value = "useDescriptions", method = RequestMethod.GET)\r
+ public List<TaxonDescription> doGetUseDescriptions(\r
+ @PathVariable("uuid") UUID uuid,\r
+ HttpServletRequest request,\r
+ HttpServletResponse response) throws IOException {\r
+ logger.info("doGetDescriptionElements() - " + request.getServletPath());\r
+\r
+ //ModelAndView mv = new ModelAndView();\r
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List<String>)null);\r
+\r
+ //MarkerType useMarkerType = (MarkerType) markerTypeService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));\r
+ MarkerType useMarkerType = (MarkerType) termService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));\r
+\r
+ //find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));\r
+ Set<MarkerType> markerTypes = new HashSet<MarkerType>();\r
+ markerTypes.add(useMarkerType);\r
+ List<TaxonDescription> descriptionElements = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);\r
+ //getDescriptionElements(description, features, type, pageSize, pageNumber, propertyPaths) load(uuid);\r
+\r
+ /*if(!(description instanceof TaxonDescription)){\r
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);\r
+ // will terminate thread\r
+ }*/\r
+\r
+ //boolean hasStructuredData = service. hasStructuredData(description);\r
+\r
+ //mv.addObject(hasStructuredData);\r
+\r
+ return descriptionElements;\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 = "markerTypes", required = false) UuidList markerTypeUUIDs,\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, markerTypeUUIDs, 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