Revision 3cf47767
Added by Andreas Müller almost 8 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonListController.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.remote.controller; |
11 | 11 |
|
12 |
import io.swagger.annotations.Api; |
|
13 |
|
|
14 | 12 |
import java.io.IOException; |
15 | 13 |
import java.util.ArrayList; |
16 | 14 |
import java.util.Arrays; |
... | ... | |
47 | 45 |
import eu.etaxonomy.cdm.api.service.search.SearchResult; |
48 | 46 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
49 | 47 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
48 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
50 | 49 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
51 | 50 |
import eu.etaxonomy.cdm.model.common.Language; |
52 | 51 |
import eu.etaxonomy.cdm.model.description.DescriptionElementBase; |
53 | 52 |
import eu.etaxonomy.cdm.model.description.Feature; |
54 | 53 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
55 | 54 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
55 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
56 | 56 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
57 | 57 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
58 | 58 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
63 | 63 |
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters; |
64 | 64 |
import eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList; |
65 | 65 |
import eu.etaxonomy.cdm.remote.editor.MatchModePropertyEditor; |
66 |
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor; |
|
66 | 67 |
import eu.etaxonomy.cdm.remote.editor.TermBaseListPropertyEditor; |
67 | 68 |
import eu.etaxonomy.cdm.remote.editor.UuidList; |
69 |
import io.swagger.annotations.Api; |
|
68 | 70 |
|
69 | 71 |
/** |
70 | 72 |
* TODO write controller documentation |
... | ... | |
92 | 94 |
setInitializationStrategy(Arrays.asList(new String[]{"$","name.nomenclaturalReference"})); |
93 | 95 |
} |
94 | 96 |
|
95 |
/* (non-Javadoc) |
|
96 |
* @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService) |
|
97 |
*/ |
|
98 | 97 |
@Override |
99 | 98 |
@Autowired |
100 | 99 |
public void setService(ITaxonService service) { |
... | ... | |
117 | 116 |
super.initBinder(binder); |
118 | 117 |
binder.registerCustomEditor(DefinedTermBaseList.class, new TermBaseListPropertyEditor<NamedArea>(termService)); |
119 | 118 |
binder.registerCustomEditor(MatchMode.class, new MatchModePropertyEditor()); |
119 |
binder.registerCustomEditor(Rank.class, new RankPropertyEditor()); |
|
120 | 120 |
|
121 | 121 |
} |
122 | 122 |
|
... | ... | |
440 | 440 |
HttpServletRequest request, |
441 | 441 |
HttpServletResponse response)throws IOException { |
442 | 442 |
|
443 |
logger.info("doFindBestMatchingTaxon : " + requestPathAndQuery(request) ); |
|
444 |
|
|
443 | 445 |
Taxon bestMatchingTaxon = service.findBestMatchingTaxon(taxonName); |
444 | 446 |
|
445 | 447 |
return bestMatchingTaxon; |
... | ... | |
497 | 499 |
return service.findByIdentifier(type, identifier, definedTerm , subTree, matchMode, includeEntity, pagerParams.getPageSize(), pagerParams.getPageIndex(), initializationStrategy); |
498 | 500 |
} |
499 | 501 |
|
502 |
@RequestMapping(value = "doFindByNameParts", method = RequestMethod.GET) |
|
503 |
public Pager<TaxonBase> doFindByNameParts( |
|
504 |
@RequestParam(value = "genusOrUninomial", required = false) String genusOrUninomial, |
|
505 |
@RequestParam(value = "infragenericEpithet", required = false) String infragenericEpithet, |
|
506 |
@RequestParam(value = "specificEpithet", required = false) String specificEpithet, |
|
507 |
@RequestParam(value = "infraspecificEpithet", required = false) String infraspecificEpithet, |
|
508 |
@RequestParam(value = "authorship", required = false) String authorship, |
|
509 |
@RequestParam(value = "rankUuid", required = false) UUID rankUuid, |
|
510 |
@RequestParam(value = "pageNumber", required = false) Integer pageNumber, |
|
511 |
@RequestParam(value = "pageSize", required = false) Integer pageSize, |
|
512 |
HttpServletRequest request, |
|
513 |
HttpServletResponse response)throws IOException { |
|
514 |
|
|
515 |
logger.info("doFindByNameParts : " + requestPathAndQuery(request) ); |
|
516 |
|
|
517 |
if (genusOrUninomial == null && infragenericEpithet == null && specificEpithet == null && infraspecificEpithet == null){ |
|
518 |
response.sendError(404 , "At least 1 name part must be defined " ); |
|
519 |
return null; |
|
520 |
} |
|
521 |
|
|
522 |
Rank rank = null; |
|
523 |
if (rankUuid != null){ |
|
524 |
rank = findRank(rankUuid); |
|
525 |
} |
|
526 |
|
|
527 |
Pager<TaxonBase> result = service.findTaxaByName(null, genusOrUninomial, infragenericEpithet, specificEpithet, infraspecificEpithet, authorship, rank, pageSize, pageNumber); |
|
528 |
|
|
529 |
return result; |
|
530 |
} |
|
531 |
|
|
532 |
|
|
533 |
private Rank findRank(UUID rankUuid) { |
|
534 |
Rank rank = null; |
|
535 |
if(rankUuid != null){ |
|
536 |
DefinedTermBase<?> definedTermBase = termService.find(rankUuid); |
|
537 |
if(definedTermBase instanceof Rank){ |
|
538 |
rank = (Rank) definedTermBase; |
|
539 |
} else { |
|
540 |
throw new IllegalArgumentException("DefinedTermBase is not a Rank"); |
|
541 |
} |
|
542 |
} |
|
543 |
return rank; |
|
544 |
} |
|
545 |
|
|
500 | 546 |
} |
Also available in: Unified diff
#5958 Implement name part search as web service