TAXONNODE_INIT_STRATEGY = Arrays.asList(new String []{
+ "taxonNodes.classification"
+ });
+
+
+
+ private static final String featureTreeUuidPattern = "^/taxon(?:(?:/)([^/?#&\\.]+))+.*";
+
+ public TaxonPortalController(){
+ super();
+ setInitializationStrategy(TAXON_INIT_STRATEGY);
+ }
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
+ */
+ @Autowired
+ @Override
+ public void setService(ITaxonService service) {
+ this.service = service;
+ }
+
+ @InitBinder
+ @Override
public void initBinder(WebDataBinder binder) {
- binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor());
- binder.registerCustomEditor(NamedArea.class, new NamedAreaPropertyEditor());
- binder.registerCustomEditor(MatchMode.class, new MatchModePropertyEditor());
- }
-
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.cdm.remote.controller.BaseController#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
-
- @Override
- @RequestMapping(method = RequestMethod.GET)
- public TaxonBase doGet(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGet()");
- TaxonBase tb = getCdmBase(request, response, TAXON_INIT_STRATEGY, TaxonBase.class);
- return tb;
- }
- */
- /**
- * Find Taxa, Synonyms, Common Names by name, either globally or in a specific geographic area.
- *
- * URI: /{datasource-name}/portal/taxon/find
- *
- * @param query
- * the string to query for. Since the wildcard character '*'
- * internally always is appended to the query string, a search
- * always compares the query string with the beginning of a name.
- * - required parameter
- * @param treeUuid
- * the {@link UUID} of a {@link TaxonomicTree} to which the
- * search is to be restricted. - optional parameter
- * @param areas
- * restrict the search to a set of geographic {@link NamedArea}s.
- * The parameter currently takes a list of TDWG area labels.
- * - optional parameter
- * @param page
- * the number of the page to be returned, the first page has the
- * pageNumber = 1 - optional parameter
- * @param pageSize
- * the maximum number of entities returned per page (can be -1
- * to return all entities in a single page) - optional parameter
- * @param doTaxa
- * weather to search for instances of {@link Taxon} - optional parameter
- * @param doSynonyms
- * weather to search for instances of {@link Synonym} - optional parameter
- * @param doTaxaByCommonNames
- * for instances of {@link Taxon} by a common name used - optional parameter
- * @param matchMode
- * valid values are "EXACT", "BEGINNING", "ANYWHERE", "END" (case sensitive !!!)
- * @return a Pager on a list of {@link IdentifiableEntity}s initialized by
- * the following strategy {@link #SIMPLE_TAXON_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(method = RequestMethod.GET,
- value = {"/portal/taxon/find"}) //TODO map to path /*/portal/taxon/
- public Pager doFind(
- @RequestParam(value = "query", required = false) String query,
- @RequestParam(value = "tree", required = false) UUID treeUuid,
- @RequestParam(value = "area", required = false) Set areas,
- @RequestParam(value = "page", required = false) Integer page,
- @RequestParam(value = "pageSize", required = false) Integer pageSize,
- @RequestParam(value = "doTaxa", required = false) Boolean doTaxa,
- @RequestParam(value = "doSynonyms", required = false) Boolean doSynonyms,
- @RequestParam(value = "doTaxaByCommonNames", required = false) Boolean doTaxaByCommonNames,
- @RequestParam(value = "matchMode", required = false) MatchMode matchMode
- )
- throws IOException {
-
- logger.info("doFind( " +
- "query=\"" + ObjectUtils.toString(query) + "\", treeUuid=" + ObjectUtils.toString(treeUuid) +
- ", area=" + ObjectUtils.toString(areas) +
- ", pageSize=" + ObjectUtils.toString(pageSize) + ", page=" + ObjectUtils.toString(page) +
- ", doTaxa=" + ObjectUtils.toString(doTaxa) + ", doSynonyms=" + ObjectUtils.toString(doSynonyms)
- +", doTaxaByCommonNames=" + ObjectUtils.toString(doTaxaByCommonNames) +")" );
-
- if(page == null){ page = BaseListController.DEFAULT_PAGE_NUMBER;}
- if(pageSize == null){ pageSize = BaseListController.DEFAULT_PAGESIZE;}
- if(pageSize == -1){
- pageSize = null;
- }
-
- ITaxonServiceConfigurator config = new TaxonServiceConfiguratorImpl();
- config.setPageNumber(page);
- config.setPageSize(pageSize);
- config.setSearchString(query);
- config.setDoTaxa(doTaxa!= null ? doTaxa : Boolean.FALSE );
- config.setDoSynonyms(doSynonyms != null ? doSynonyms : Boolean.FALSE );
- config.setDoTaxaByCommonNames(doTaxaByCommonNames != null ? doTaxaByCommonNames : Boolean.FALSE );
- config.setMatchMode(matchMode != null ? matchMode : MatchMode.BEGINNING);
- config.setTaxonPropertyPath(SIMPLE_TAXON_INIT_STRATEGY);
- config.setNamedAreas(areas);
- if(treeUuid != null){
- TaxonomicTree taxonomicTree = taxonTreeService.find(treeUuid);
- config.setTaxonomicTree(taxonomicTree);
- }
-
- return (Pager) service.findTaxaAndNames(config);
- }
-
- /**
- * Get the synonymy for a taxon identified by the {taxon-uuid}
.
- * The synonymy consists
- * of two parts: The group of homotypic synonyms of the taxon and the
- * heterotypic synonymy groups of the taxon. The synonymy is ordered
- * historically by the type designations and by the publication date of the
- * nomenclatural reference
- *
- * URI:
- * /{datasource-name}/portal/taxon/{taxon-uuid}/synonymy
- *
- *
- * @param request
- * @param response
- * @return a Map with to entries which are mapped by the following keys:
- * "homotypicSynonymsByHomotypicGroup", "heterotypicSynonymyGroups",
- * containing lists of {@link Synonym}s which are initialized using the
- * following initialization strategy: {@link #SYNONYMY_INIT_STRATEGY}
- *
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/synonymy"},
- method = RequestMethod.GET)
- public ModelAndView doGetSynonymy(HttpServletRequest request, HttpServletResponse response)throws IOException {
-
- logger.info("doGetSynonymy() " + request.getServletPath());
- ModelAndView mv = new ModelAndView();
- TaxonBase tb = getCdmBase(request, response, null, Taxon.class);
- Taxon taxon = (Taxon)tb;
- Map> synonymy = new Hashtable>();
- synonymy.put("homotypicSynonymsByHomotypicGroup", service.getHomotypicSynonymsByHomotypicGroup(taxon, SYNONYMY_INIT_STRATEGY));
- synonymy.put("heterotypicSynonymyGroups", service.getHeterotypicSynonymyGroups(taxon, SYNONYMY_INIT_STRATEGY));
- mv.addObject(synonymy);
- return mv;
- }
-
- /**
- * Get the set of accepted {@link Taxon} entities for a given
- * {@link TaxonBase} entity identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/accepted
- *
- * @param request
- * @param response
- * @return a Set of {@link Taxon} entities which are initialized
- * using the following initialization strategy:
- * {@link #SYNONYMY_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(value = "/portal/taxon/*/accepted", method = RequestMethod.GET)
- public Set getAccepted(HttpServletRequest request, HttpServletResponse response) throws IOException {
-
- logger.info("getAccepted() " + request.getServletPath());
-
- UUID uuid = readValueUuid(request, null);
- TaxonBase tb = service.load(uuid, SYNONYMY_INIT_STRATEGY);
- if(tb == null){
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "A taxon with the uuid " + uuid + " does not exist");
- return null;
- }
- HashSet resultset = new HashSet();
- if(tb instanceof Taxon){
- //the taxon already is accepted
- //FIXME take the current view into account once views are implemented!!!
- resultset.add((Taxon)tb);
- } else {
- Synonym syn = (Synonym)tb;
- for(TaxonBase accepted : syn.getAcceptedTaxa()){
- accepted = service.load(accepted.getUuid(), SIMPLE_TAXON_INIT_STRATEGY);
- resultset.add(accepted);
- }
- }
- return resultset;
- }
-
- /**
- * Get the list of {@link TaxonRelationship}s for the given
- * {@link TaxonBase} instance identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/taxonRelationships
- *
- * @param request
- * @param response
- * @return a List of {@link TaxonRelationship} entities which are initialized
- * using the following initialization strategy:
- * {@link #TAXONRELATIONSHIP_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/taxonRelationships"},
- method = RequestMethod.GET)
- public List doGetTaxonRelations(HttpServletRequest request, HttpServletResponse response)throws IOException {
-
- logger.info("doGetTaxonRelations()" + request.getServletPath());
- TaxonBase tb = getCdmBase(request, response, null, Taxon.class);
- Taxon taxon = (Taxon)tb;
- List relations = new ArrayList();
- List results = service.listToTaxonRelationships(taxon, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);
- relations.addAll(results);
- results = service.listToTaxonRelationships(taxon, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);
- relations.addAll(results);
-
- return relations;
- }
-
- /**
- * Get the list of {@link NameRelationship}s of the Name associated with the
- * {@link TaxonBase} instance identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships
- *
- * @param request
- * @param response
- * @return a List of {@link NameRelationship} entities which are initialized
- * using the following initialization strategy:
- * {@link #NAMERELATIONSHIP_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/toNameRelationships"},
- method = RequestMethod.GET)
- public List doGetToNameRelations(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetNameRelations()" + request.getServletPath());
- TaxonBase tb = getCdmBase(request, response, SIMPLE_TAXON_INIT_STRATEGY, Taxon.class);
- List list = nameService.listToNameRelationships(tb.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);
- return list;
- }
-
- /**
- * Get the list of {@link NameRelationship}s of the Name associated with the
- * {@link TaxonBase} instance identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships
- *
- * @param request
- * @param response
- * @return a List of {@link NameRelationship} entities which are initialized
- * using the following initialization strategy:
- * {@link #NAMERELATIONSHIP_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/fromNameRelationships"},
- method = RequestMethod.GET)
- public List doGetFromNameRelations(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetNameFromNameRelations()" + request.getServletPath());
- TaxonBase tb = getCdmBase(request, response, SIMPLE_TAXON_INIT_STRATEGY, Taxon.class);
- List list = nameService.listFromNameRelationships(tb.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);
- return list;
- }
-
- /**
- * Get the list of {@link TaxonNameDescription}s of the Name associated with the
- * {@link TaxonNameBase} instance identified by the {name-uuid}
.
- *
- * URI: /{datasource-name}/portal/name/{name-uuid}/descriptions
- *
- * @param request
- * @param response
- * @return a List of {@link TaxonNameDescription} entities which are initialized
- * using the following initialization strategy:
- * {@link #NAMEDESCRIPTION_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/name/*/descriptions"},
- method = RequestMethod.GET)
- public List doGetNameDescriptions(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetNameDescriptions()" + request.getServletPath());
- UUID nameUuuid = readValueUuid(request, null);
- TaxonNameBase tnb = nameService.load(nameUuuid, null);
- Pager p = descriptionService.getTaxonNameDescriptions(tnb, null, null, NAMEDESCRIPTION_INIT_STRATEGY);
- return p.getRecords();
- }
-
- /**
- * Get the list of {@link TypeDesignationBase}s of the
- * {@link TaxonBase} instance identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameTypeDesignations
- *
- * @param request
- * @param response
- * @return a List of {@link TypeDesignationBase} entities which are initialized
- * using the following initialization strategy:
- * {@link #TYPEDESIGNATION_INIT_STRATEGY}
- * @throws IOException
- * @Deprecated use /name/{uuid}/typeDesignations & /derivedunitfacade/{uuid} instead
- */
- @Deprecated
- @RequestMapping(
- value = {"/portal/taxon/*/nameTypeDesignations"},
- method = RequestMethod.GET)
- public List doGetNameTypeDesignations(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetNameTypeDesignations()" + request.getServletPath());
- TaxonBase tb = getCdmBase(request, response, SIMPLE_TAXON_INIT_STRATEGY, Taxon.class);
- Pager p = nameService.getTypeDesignations(tb.getName(), null, null, null, TYPEDESIGNATION_INIT_STRATEGY);
- return p.getRecords();
- }
-
- @RequestMapping(value = "{uuid}/taxonNodes", method = RequestMethod.GET)
- public Set doGetTaxonNodes(
- @PathVariable("uuid") UUID uuid,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);
- if(tb instanceof Taxon){
- return ((Taxon)tb).getTaxonNodes();
- } else {
- HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
- return null;
- }
- }
-
- /**
- * Get the list of {@link TaxonDescription}s of the
- * {@link Taxon} instance identified by the {taxon-uuid}
.
- *
- * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/descriptions
- *
- * @param request
- * @param response
- * @return a List of {@link TaxonDescription} entities which are initialized
- * using the following initialization strategy:
- * {@link #TAXONDESCRIPTION_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/descriptions"},
- method = RequestMethod.GET)
- public List doGetDescriptions(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetDescriptions()" + request.getServletPath());
- Taxon t = getCdmBase(request, response, null, Taxon.class);
- Pager p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);
- return p.getRecords();
- }
-
- /**
- * Get the {@link Media} attached to the {@link Taxon} instance
- * identified by the {taxon-uuid}
.
- *
- * Usage /{datasource-name}/portal/taxon/{taxon-
- * uuid}/media/{mime type
- * list}/{size}[,[widthOrDuration}][,{height}]/
- *
- * Whereas
- *
- * - {mime type list}: a comma separated list of mime types, in the
- * order of preference. The forward slashes contained in the mime types must
- * be replaced by a colon. Regular expressions can be used. Each media
- * associated with this given taxon is being searched whereas the first
- * matching mime type matching a representation always rules.
- * - {size},{widthOrDuration},{height}: not jet implemented
- * valid values are an integer or the asterisk '*' as a wildcard
- *
- *
- * @param request
- * @param response
- * @return a List of {@link Media} entities which are initialized
- * using the following initialization strategy:
- * {@link #TAXONDESCRIPTION_INIT_STRATEGY}
- * @throws IOException
- */
- @RequestMapping(
- value = {"/portal/taxon/*/media/*/*"},
- method = RequestMethod.GET)
- public List doGetMedia(HttpServletRequest request, HttpServletResponse response) throws IOException {
- logger.info("doGetMedia()" + request.getServletPath());
- Taxon t = getCdmBase(request, response, null, Taxon.class);
- String path = request.getServletPath();
- List returnMedia = getMediaForTaxon(t, path, 5);
- return returnMedia;
- }
-
- @RequestMapping(
- value = {"/portal/taxon/*/subtree/media/*/*"},
- method = RequestMethod.GET)
- public List doGetSubtreeMedia(HttpServletRequest request, HttpServletResponse response)throws IOException {
- logger.info("doGetMedia()" + request.getServletPath());
- Taxon t = getCdmBase(request, response, TAXON_WITH_NODES_INIT_STRATEGY, Taxon.class);
- String path = request.getServletPath();
- List returnMedia = getMediaForTaxon(t, path, 6);
- TaxonNode node;
- //looking for all medias of genus
- if (t.getTaxonNodes().size()>0){
- Set nodes = t.getTaxonNodes();
- Iterator iterator = nodes.iterator();
- //TaxonNode holen
- node = iterator.next();
- //überprüfen, ob der TaxonNode zum aktuellen Baum gehört.
-
- node = taxonTreeService.loadTaxonNode(node, TAXONNODE_WITHTAXON_INIT_STRATEGY);
- Set children = node.getChildNodes();
- Taxon childTaxon;
- for (TaxonNode child : children){
- childTaxon = child.getTaxon();
- childTaxon = (Taxon)taxonService.load(childTaxon.getUuid(), null);
- returnMedia.addAll(getMediaForTaxon(childTaxon, path, 6));
- }
- }
- return returnMedia;
- }
-
-
- private List getMediaForTaxon(Taxon taxon, String path, int mimeTypeTokenPosition){
-
- Pager p =
- descriptionService.getTaxonDescriptions(taxon, null, null, null, null, TAXONDESCRIPTION_MEDIA_INIT_STRATEGY);
-
- // pars the media and quality parameters
-
-
- // collect all media of the given taxon
- boolean limitToGalleries = false;
- List taxonMedia = new ArrayList();
- for(TaxonDescription desc : p.getRecords()){
- if(!limitToGalleries || desc.isImageGallery()){
- for(DescriptionElementBase element : desc.getElements()){
- for(Media media : element.getMedia()){
- taxonMedia.add(media);
- }
- }
- }
- }
-
- String[] pathTokens = path.split("/");
-
- String[] mimeTypes = pathTokens[mimeTypeTokenPosition].split(",");
- String[] sizeTokens = pathTokens[mimeTypeTokenPosition + 1].split(",");
- Integer widthOrDuration = null;
- Integer height = null;
- Integer size = null;
-
- List returnMedia = MediaUtils.findPreferredMedia(taxonMedia, mimeTypes,
- sizeTokens, widthOrDuration, height, size);
-
- return returnMedia;
- }
-
-
+ super.initBinder(binder);
+ binder.registerCustomEditor(NamedArea.class, new NamedAreaPropertyEditor());
+ binder.registerCustomEditor(MatchMode.class, new MatchModePropertyEditor());
+ binder.registerCustomEditor(Class.class, new CdmTypePropertyEditor());
+ binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see eu.etaxonomy.cdm.remote.controller.BaseController#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+
+ @Override
+ @RequestMapping(method = RequestMethod.GET)
+ public TaxonBase doGet(HttpServletRequest request, HttpServletResponse response)throws IOException {
+ logger.info("doGet()");
+ TaxonBase tb = getCdmBase(request, response, TAXON_INIT_STRATEGY, TaxonBase.class);
+ return tb;
+ }
+ */
+ /**
+ * Find Taxa, Synonyms, Common Names by name, either globally or in a specific geographic area.
+ *
+ * URI: /{datasource-name}/portal/taxon/find
+ *
+ * @param query
+ * the string to query for. Since the wildcard character '*'
+ * internally always is appended to the query string, a search
+ * always compares the query string with the beginning of a name.
+ * - required parameter
+ * @param treeUuid
+ * the {@link UUID} of a {@link Classification} to which the
+ * search is to be restricted. - optional parameter
+ * @param areas
+ * restrict the search to a set of geographic {@link NamedArea}s.
+ * The parameter currently takes a list of TDWG area labels.
+ * - optional parameter
+ * @param pageNumber
+ * the number of the page to be returned, the first page has the
+ * pageNumber = 1 - optional parameter
+ * @param pageSize
+ * the maximum number of entities returned per page (can be -1
+ * to return all entities in a single page) - optional parameter
+ * @param doTaxa
+ * weather to search for instances of {@link Taxon} - optional parameter
+ * @param doSynonyms
+ * weather to search for instances of {@link Synonym} - optional parameter
+ * @param doTaxaByCommonNames
+ * for instances of {@link Taxon} by a common name used - optional parameter
+ * @param matchMode
+ * valid values are "EXACT", "BEGINNING", "ANYWHERE", "END" (case sensitive !!!)
+ * @return a Pager on a list of {@link IdentifiableEntity}s initialized by
+ * the following strategy {@link #SIMPLE_TAXON_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(method = RequestMethod.GET,
+ value = {"/portal/taxon/find"}) //TODO map to path /*/portal/taxon/
+ public Pager doFind(
+ @RequestParam(value = "query", required = false) String query,
+ @RequestParam(value = "tree", required = false) UUID treeUuid,
+ @RequestParam(value = "area", required = false) Set areas,
+ @RequestParam(value = "pageNumber", required = false) Integer pageNumber,
+ @RequestParam(value = "pageSize", required = false) Integer pageSize,
+ @RequestParam(value = "doTaxa", required = false) Boolean doTaxa,
+ @RequestParam(value = "doSynonyms", required = false) Boolean doSynonyms,
+ @RequestParam(value = "doMisappliedNames", required = false) Boolean doMisappliedNames,
+ @RequestParam(value = "doTaxaByCommonNames", required = false) Boolean doTaxaByCommonNames,
+ @RequestParam(value = "matchMode", required = false) MatchMode matchMode,
+ HttpServletRequest request,
+ HttpServletResponse response
+ )
+ throws IOException {
+
+ logger.info("doFind : " + request.getRequestURI() + "?" + request.getQueryString() );
+
+ PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);
+ pagerParams.normalizeAndValidate(response);
+
+ IFindTaxaAndNamesConfigurator config = new FindTaxaAndNamesConfiguratorImpl();
+ config.setPageNumber(pagerParams.getPageIndex());
+ config.setPageSize(pagerParams.getPageSize());
+ config.setTitleSearchString(query);
+ config.setDoTaxa(doTaxa!= null ? doTaxa : Boolean.FALSE );
+ config.setDoSynonyms(doSynonyms != null ? doSynonyms : Boolean.FALSE );
+ config.setDoMisappliedNames(doMisappliedNames != null ? doMisappliedNames : Boolean.FALSE);
+ config.setDoTaxaByCommonNames(doTaxaByCommonNames != null ? doTaxaByCommonNames : Boolean.FALSE );
+ config.setMatchMode(matchMode != null ? matchMode : MatchMode.BEGINNING);
+ config.setTaxonPropertyPath(SIMPLE_TAXON_INIT_STRATEGY);
+ config.setNamedAreas(areas);
+ if(treeUuid != null){
+ Classification classification = classificationService.find(treeUuid);
+ config.setClassification(classification);
+ }
+
+ return (Pager) service.findTaxaAndNames(config);
+ }
+
+ /**
+ * @param clazz
+ * @param queryString
+ * @param treeUuid
+ * @param languages
+ * @param features one or more feature uuids
+ * @param pageNumber
+ * @param pageSize
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ParseException
+ */
+ @RequestMapping(method = RequestMethod.GET, value={"/portal/taxon/findByDescriptionElementFullText"})
+ public Pager> dofindByDescriptionElementFullText(
+ @RequestParam(value = "clazz", required = false) Class clazz,
+ @RequestParam(value = "query", required = true) String queryString,
+ @RequestParam(value = "tree", required = false) UUID treeUuid,
+ @RequestParam(value = "features", required = false) UuidList featureUuids,
+ @RequestParam(value = "languages", required = false) List languages,
+ @RequestParam(value = "hl", required = false) Boolean highlighting,
+ @RequestParam(value = "pageNumber", required = false) Integer pageNumber,
+ @RequestParam(value = "pageSize", required = false) Integer pageSize,
+ HttpServletRequest request,
+ HttpServletResponse response
+ )
+ throws IOException, ParseException {
+
+ logger.info("findByDescriptionElementFullText : " + request.getRequestURI() + "?" + request.getQueryString() );
+
+ PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);
+ pagerParams.normalizeAndValidate(response);
+
+ if(highlighting == null){
+ highlighting = false;
+ }
+
+ Classification classification = null;
+ if(treeUuid != null){
+ classification = classificationService.find(treeUuid);
+ }
+
+ List features = null;
+ if(featureUuids != null){
+ features = new ArrayList(featureUuids.size());
+ for(UUID uuid : featureUuids){
+ features.add((Feature) termService.find(uuid));
+ }
+ }
+
+ Pager> pager = service.findByDescriptionElementFullText(clazz, queryString, classification, features, languages, highlighting, pagerParams.getPageSize(), pagerParams.getPageIndex(), ((List)null), SIMPLE_TAXON_INIT_STRATEGY);
+ return pager;
+ }
+
+ /**
+ * Get the synonymy for a taxon identified by the {taxon-uuid}
.
+ * The synonymy consists
+ * of two parts: The group of homotypic synonyms of the taxon and the
+ * heterotypic synonymy groups of the taxon. The synonymy is ordered
+ * historically by the type designations and by the publication date of the
+ * nomenclatural reference
+ *
+ * URI:
+ * /{datasource-name}/portal/taxon/{taxon-uuid}/synonymy
+ *
+ *
+ * @param request
+ * @param response
+ * @return a Map with to entries which are mapped by the following keys:
+ * "homotypicSynonymsByHomotypicGroup", "heterotypicSynonymyGroups",
+ * containing lists of {@link Synonym}s which are initialized using the
+ * following initialization strategy: {@link #SYNONYMY_INIT_STRATEGY}
+ *
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"synonymy"},
+ method = RequestMethod.GET)
+ public ModelAndView doGetSynonymy(@PathVariable("uuid") UUID uuid,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+
+ if(request != null){
+ logger.info("doGetSynonymy() " + request.getServletPath());
+ }
+ ModelAndView mv = new ModelAndView();
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, (List)null);
+ Map> synonymy = new Hashtable>();
+ synonymy.put("homotypicSynonymsByHomotypicGroup", service.getHomotypicSynonymsByHomotypicGroup(taxon, SYNONYMY_INIT_STRATEGY));
+ synonymy.put("heterotypicSynonymyGroups", service.getHeterotypicSynonymyGroups(taxon, SYNONYMY_INIT_STRATEGY));
+ mv.addObject(synonymy);
+ return mv;
+ }
+
+ /**
+ * Get the set of accepted {@link Taxon} entities for a given
+ * {@link TaxonBase} entity identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/accepted
+ *
+ * @param request
+ * @param response
+ * @return a Set of {@link Taxon} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #SYNONYMY_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(value = "accepted/{classification_uuid}", method = RequestMethod.GET)
+ public Set getAccepted(
+ @PathVariable("uuid") UUID uuid,
+ @PathVariable("classification_uuid") UUID classification_uuid,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws IOException {
+
+ if(request != null){
+ logger.info("getAccepted() " + request.getServletPath());
+ }
+
+ TaxonBase tb = service.load(uuid, SYNONYMY_WITH_NODES_INIT_STRATEGY);
+ if(tb == null){
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "A taxon with the uuid " + uuid + " does not exist");
+ return null;
+ }
+
+ HashSet resultset = new HashSet();
+
+ if (tb instanceof Taxon){
+ Taxon taxon = (Taxon) tb;
+ Set nodes = taxon.getTaxonNodes();
+ for (TaxonNode taxonNode : nodes) {
+ if (taxonNode.getClassification().compareTo(classification_uuid) == 0){
+ resultset.add((Taxon) tb);
+ }
+ }
+ if (resultset.size() > 1){
+ //error!! A taxon is not allow to have more taxonnodes for a given classification
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "A taxon with the uuid " + uuid + " has more than one taxon node for the given classification" + classification_uuid);
+ }
+ }else{
+ Synonym syn = (Synonym) tb;
+ for(TaxonBase accepted : syn.getAcceptedTaxa()){
+ tb = service.load(accepted.getUuid(), SIMPLE_TAXON_WITH_NODES_INIT_STRATEGY);
+ if (tb instanceof Taxon){
+ Taxon taxon = (Taxon) tb;
+ Set nodes = taxon.getTaxonNodes();
+ for (TaxonNode taxonNode : nodes) {
+ if (taxonNode.getClassification().compareTo(classification_uuid) == 0){
+ resultset.add((Taxon) tb);
+ }
+ }
+ if (resultset.size() > 1){
+ //error!! A taxon is not allow to have more taxonnodes for a given classification
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "A taxon with the uuid " + uuid + " has more than one taxon node for the given classification" + classification_uuid);
+ }
+ }else{
+ //ERROR!! perhaps missapplied name????
+ //syn.getRelationType((Taxon)accepted);
+ }
+ }
+ }
+/**
+ * OLD CODE!!
+ if(tb instanceof Taxon){
+ //the taxon already is accepted
+ //FIXME take the current view into account once views are implemented!!!
+ resultset.add((Taxon)tb);
+ } else {
+ Synonym syn = (Synonym)tb;
+ for(TaxonBase accepted : syn.getAcceptedTaxa()){
+ accepted = service.load(accepted.getUuid(), SIMPLE_TAXON_INIT_STRATEGY);
+ resultset.add(accepted);
+ }
+ }
+*/
+ return resultset;
+ }
+
+ /**
+ * Get the list of {@link TaxonRelationship}s for the given
+ * {@link TaxonBase} instance identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/taxonRelationships
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link TaxonRelationship} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #TAXONRELATIONSHIP_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"taxonRelationships"},
+ method = RequestMethod.GET)
+ public List doGetTaxonRelations(@PathVariable("uuid") UUID uuid,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+
+ logger.info("doGetTaxonRelations()" + request.getServletPath());
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, (List)null);
+ List toRelationships = service.listToTaxonRelationships(taxon, null, null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);
+ List fromRelationships = service.listFromTaxonRelationships(taxon, null, null, null, null, TAXONRELATIONSHIP_INIT_STRATEGY);
+
+ List allRelationships = new ArrayList(toRelationships.size() + fromRelationships.size());
+ allRelationships.addAll(toRelationships);
+ allRelationships.addAll(fromRelationships);
+
+ return allRelationships;
+ }
+
+ /**
+ * Get the list of {@link NameRelationship}s of the Name associated with the
+ * {@link TaxonBase} instance identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link NameRelationship} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #NAMERELATIONSHIP_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"toNameRelationships"},
+ method = RequestMethod.GET)
+ public List doGetToNameRelations(@PathVariable("uuid") UUID uuid,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+ logger.info("doGetNameRelations()" + request.getServletPath());
+ TaxonBase taxonBase = getCdmBaseInstance(TaxonBase.class, uuid, response, (List)null);
+ List list = nameService.listNameRelationships(taxonBase.getName(), Direction.relatedTo, null, null, 0, null, NAMERELATIONSHIP_INIT_STRATEGY);
+ //List list = nameService.listToNameRelationships(taxonBase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);
+ return list;
+ }
+
+ /**
+ * Get the list of {@link NameRelationship}s of the Name associated with the
+ * {@link TaxonBase} instance identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameRelationships
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link NameRelationship} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #NAMERELATIONSHIP_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"fromNameRelationships"},
+ method = RequestMethod.GET)
+ public List doGetFromNameRelations(@PathVariable("uuid") UUID uuid,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+ logger.info("doGetNameFromNameRelations()" + request.getServletPath());
+
+ TaxonBase taxonbase = getCdmBaseInstance(TaxonBase.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);
+ List list = nameService.listNameRelationships(taxonbase.getName(), Direction.relatedFrom, null, null, 0, null, NAMERELATIONSHIP_INIT_STRATEGY);
+ //List list = nameService.listFromNameRelationships(taxonbase.getName(), null, null, null, null, NAMERELATIONSHIP_INIT_STRATEGY);
+ return list;
+ }
+
+ /**
+ * Get the list of {@link TypeDesignationBase}s of the
+ * {@link TaxonBase} instance identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/nameTypeDesignations
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link TypeDesignationBase} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #TYPEDESIGNATION_INIT_STRATEGY}
+ * @throws IOException
+ * @Deprecated use /name/{uuid}/typeDesignations & /derivedunitfacade/{uuid} instead
+ * also see http://dev.e-taxonomy.eu/trac/ticket/2280
+ */
+ @Deprecated
+ @RequestMapping(
+ value = {"nameTypeDesignations"},
+ method = RequestMethod.GET)
+ public List doGetNameTypeDesignations(@PathVariable("uuid") UUID uuid,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+ logger.info("doGetNameTypeDesignations()" + request.getServletPath());
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, SIMPLE_TAXON_INIT_STRATEGY);
+ Pager p = nameService.getTypeDesignations(taxon.getName(), null, null, null, TYPEDESIGNATION_INIT_STRATEGY);
+ return p.getRecords();
+ }
+
+ @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)
+ public Set doGetTaxonNodes(
+ @PathVariable("uuid") UUID uuid,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ TaxonBase tb = service.load(uuid, TAXONNODE_INIT_STRATEGY);
+ if(tb instanceof Taxon){
+ return ((Taxon)tb).getTaxonNodes();
+ } else {
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
+ return null;
+ }
+ }
+
+ /**
+ * Get the list of {@link TaxonDescription}s of the
+ * {@link Taxon} instance identified by the {taxon-uuid}
.
+ *
+ * URI: /{datasource-name}/portal/taxon/{taxon-uuid}/descriptions
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link TaxonDescription} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #TAXONDESCRIPTION_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"descriptions"},
+ method = RequestMethod.GET)
+ public List doGetDescriptions(
+ @PathVariable("uuid") UUID uuid,
+ @RequestParam(value = "markerTypes", required = false) UuidList markerTypeUUIDs,
+ HttpServletRequest request,
+ HttpServletResponse response)throws IOException {
+ if(request != null){
+ logger.info("doGetDescriptions()" + request.getServletPath());
+ }
+ List markerTypeTerms = null;
+ Set sMarkerTypeUUIDs = null;
+
+ if(markerTypeUUIDs != null && !markerTypeUUIDs.isEmpty()){
+ sMarkerTypeUUIDs = new HashSet(markerTypeUUIDs);
+ markerTypeTerms = termService.find(sMarkerTypeUUIDs);
+ } else if(markerTypeUUIDs != null && markerTypeUUIDs.isEmpty()){
+ markerTypeTerms = new ArrayList();
+ }
+ Set markerTypes = new HashSet();
+ List descriptions = new ArrayList();
+ if (markerTypeTerms != null) {
+ for (DefinedTermBase markerTypeTerm : markerTypeTerms) {
+ markerTypes.add((MarkerType)markerTypeTerm);
+ }
+ }
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List)null);
+ if (markerTypeTerms == null) {
+
+ Pager p = descriptionService.getTaxonDescriptions(t, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);
+ descriptions = p.getRecords();
+ }
+
+ else if (markerTypeTerms != null && markerTypeTerms.isEmpty()) {
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);
+
+ }
+ else {
+ descriptions = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);
+ /*for (TaxonDescription description: descriptions) {
+ for (IdentifiableSource source :description.getSources()) {
+ if (source.getOriginalNameString() != null) {
+ description.
+ }
+
+ }
+
+
+ }*/
+ }
+ return descriptions;
+ }
+
+ @RequestMapping(value = "useDescriptions", method = RequestMethod.GET)
+ public List doGetUseDescriptions(
+ @PathVariable("uuid") UUID uuid,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ logger.info("doGetDescriptionElements() - " + request.getServletPath());
+
+ //ModelAndView mv = new ModelAndView();
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List)null);
+
+ //MarkerType useMarkerType = (MarkerType) markerTypeService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));
+ MarkerType useMarkerType = (MarkerType) termService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039"));
+
+ //find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f059"));
+ Set markerTypes = new HashSet();
+ markerTypes.add(useMarkerType);
+ List descriptionElements = descriptionService.listTaxonDescriptions(t, null, null, markerTypes, null, null, TAXONUSEDESCRIPTION_INIT_STRATEGY);
+ //getDescriptionElements(description, features, type, pageSize, pageNumber, propertyPaths) load(uuid);
+
+ /*if(!(description instanceof TaxonDescription)){
+ HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
+ // will terminate thread
+ }*/
+
+ //boolean hasStructuredData = service. hasStructuredData(description);
+
+ //mv.addObject(hasStructuredData);
+
+ return descriptionElements;
+ }
+
+ @RequestMapping(value = "descriptions/elementsByType/{classSimpleName}", method = RequestMethod.GET)
+ public ModelAndView doGetDescriptionElementsByType(
+ @PathVariable("uuid") UUID uuid,
+ @PathVariable("classSimpleName") String classSimpleName,
+ @RequestParam(value = "markerTypes", required = false) UuidList markerTypeUUIDs,
+ @RequestParam(value = "count", required = false, defaultValue = "false") Boolean doCount,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException {
+ logger.info("doGetDescriptionElementsByType() - " + request.getServletPath());
+
+ ModelAndView mv = new ModelAndView();
+
+ List allElements = new ArrayList();
+ List elements;
+ int count = 0;
+
+ List initStrategy = doCount ? null : DESCRIPTION_ELEMENT_INIT_STRATEGY;
+
+ List taxonDescriptions = doGetDescriptions(uuid, markerTypeUUIDs, request, response);
+ try {
+ Class type;
+ type = Class.forName("eu.etaxonomy.cdm.model.description."
+ + classSimpleName);
+ if (taxonDescriptions != null) {
+ for (TaxonDescription description : taxonDescriptions) {
+ elements = descriptionService.listDescriptionElements(description, null, type, null, 0, initStrategy);
+ allElements.addAll(elements);
+ count += elements.size();
+ }
+
+ }
+ } catch (ClassNotFoundException e) {
+ HttpStatusMessage.fromString(e.getLocalizedMessage()).send(response);
+ }
+ if(doCount){
+ mv.addObject(count);
+ } else {
+ mv.addObject(allElements);
+ }
+ return mv;
+ }
+
+// @RequestMapping(value = "specimens", method = RequestMethod.GET)
+// public ModelAndView doGetSpecimens(
+// @PathVariable("uuid") UUID uuid,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException, ClassNotFoundException {
+// logger.info("doGetSpecimens() - " + request.getServletPath());
+//
+// ModelAndView mv = new ModelAndView();
+//
+// List derivedUnitFacadeList = new ArrayList();
+//
+// // find speciemens in the TaxonDescriptions
+// List taxonDescriptions = doGetDescriptions(uuid, request, response);
+// if (taxonDescriptions != null) {
+//
+// for (TaxonDescription description : taxonDescriptions) {
+// derivedUnitFacadeList.addAll( occurrenceService.listDerivedUnitFacades(description, null) );
+// }
+// }
+// // TODO find speciemens in the NameDescriptions ??
+//
+// // TODO also find type specimens
+//
+// mv.addObject(derivedUnitFacadeList);
+//
+// return mv;
+// }
+
+ /**
+ * Get the {@link Media} attached to the {@link Taxon} instance
+ * identified by the {taxon-uuid}
.
+ *
+ * Usage /{datasource-name}/portal/taxon/{taxon-
+ * uuid}/media/{mime type
+ * list}/{size}[,[widthOrDuration}][,{height}]/
+ *
+ * Whereas
+ *
+ * - {mime type list}: a comma separated list of mime types, in the
+ * order of preference. The forward slashes contained in the mime types must
+ * be replaced by a colon. Regular expressions can be used. Each media
+ * associated with this given taxon is being searched whereas the first
+ * matching mime type matching a representation always rules.
+ * - {size},{widthOrDuration},{height}: not jet implemented
+ * valid values are an integer or the asterisk '*' as a wildcard
+ *
+ *
+ * @param request
+ * @param response
+ * @return a List of {@link Media} entities which are initialized
+ * using the following initialization strategy:
+ * {@link #TAXONDESCRIPTION_INIT_STRATEGY}
+ * @throws IOException
+ */
+ @RequestMapping(
+ value = {"media"},
+ method = RequestMethod.GET)
+ public List doGetMedia(
+ @PathVariable("uuid") UUID uuid,
+ @RequestParam(value = "type", required = false) Class extends MediaRepresentationPart> type,
+ @RequestParam(value = "mimeTypes", required = false) String[] mimeTypes,
+ @RequestParam(value = "widthOrDuration", required = false) Integer widthOrDuration,
+ @RequestParam(value = "height", required = false) Integer height,
+ @RequestParam(value = "size", required = false) Integer size,
+ HttpServletRequest request, HttpServletResponse response) throws IOException {
+
+ logger.info("doGetMedia()" + request.getServletPath());
+ Taxon t = getCdmBaseInstance(Taxon.class, uuid, response, (List)null);
+ String path = request.getServletPath();
+ List returnMedia = getMediaForTaxon(t, type, mimeTypes, widthOrDuration, height, size);
+ return returnMedia;
+ }
+
+ @RequestMapping(
+ value = {"subtree/media"},
+ method = RequestMethod.GET)
+ public List doGetSubtreeMedia(
+ @PathVariable("uuid") UUID uuid,
+ @RequestParam(value = "type", required = false) Class extends MediaRepresentationPart> type,
+ @RequestParam(value = "mimeTypes", required = false) String[] mimeTypes,
+ @RequestParam(value = "widthOrDuration", required = false) Integer widthOrDuration,
+ @RequestParam(value = "height", required = false) Integer height,
+ @RequestParam(value = "size", required = false) Integer size,
+ HttpServletRequest request, HttpServletResponse response)throws IOException {
+ logger.info("doGetMedia()" + request.getServletPath());
+ Taxon taxon = getCdmBaseInstance(Taxon.class, uuid, response, TAXON_WITH_NODES_INIT_STRATEGY);
+ String requestPath = request.getServletPath();
+ List returnMedia = getMediaForTaxon(taxon, type, mimeTypes, widthOrDuration, height, size);
+ TaxonNode node;
+ //looking for all medias of genus
+ if (taxon.getTaxonNodes().size()>0){
+ Set nodes = taxon.getTaxonNodes();
+ Iterator iterator = nodes.iterator();
+ //TaxonNode holen
+ node = iterator.next();
+ //Check if TaxonNode belongs to the current tree
+
+ node = classificationService.loadTaxonNode(node, TAXONNODE_WITHTAXON_INIT_STRATEGY);
+ Set children = node.getChildNodes();
+ Taxon childTaxon;
+ for (TaxonNode child : children){
+ childTaxon = child.getTaxon();
+ childTaxon = (Taxon)taxonService.load(childTaxon.getUuid(), null);
+ returnMedia.addAll(getMediaForTaxon(childTaxon, type, mimeTypes, widthOrDuration, height, size));
+ }
+ }
+ return returnMedia;
+ }
+
+
+ private List getMediaForTaxon(Taxon taxon, Class extends MediaRepresentationPart> type, String[] mimeTypes,
+ Integer widthOrDuration, Integer height, Integer size){
+
+ List taxonGalleryMedia = service.listTaxonDescriptionMedia(taxon, false, TAXONDESCRIPTION_MEDIA_INIT_STRATEGY);
+
+ Map mediaRepresentationMap = MediaUtils.findPreferredMedia(taxonGalleryMedia, type,
+ mimeTypes, null, widthOrDuration, height, size);
+
+ List filteredMedia = new ArrayList(mediaRepresentationMap.size());
+ for(Media media : mediaRepresentationMap.keySet()){
+ media.getRepresentations().clear();
+ media.addRepresentation(mediaRepresentationMap.get(media));
+ filteredMedia.add(media);
+ }
+
+ return filteredMedia;
+ }
+
+
// ---------------------- code snippet preserved for possible later use --------------------
// @RequestMapping(
// value = {"/*/portal/taxon/*/descriptions"},
@@ -723,13 +1002,13 @@ public class TaxonPortalController extends BaseController generalize
// UUID featureTreeUuid = readValueUuid(request, featureTreeUuidPattern);
-//
+//
// FeatureTree featureTree = descriptionService.getFeatureTreeByUuid(featureTreeUuid);
// Pager p = descriptionService.getTaxonDescriptions((Taxon)tb, null, null, null, null, TAXONDESCRIPTION_INIT_STRATEGY);
// List descriptions = p.getRecords();
-//
+//
// if(!featureTree.isDescriptionSeparated()){
-//
+//
// TaxonDescription superDescription = TaxonDescription.NewInstance();
// //put all descriptionElements in superDescription and make it invisible
// for(TaxonDescription description: descriptions){