Revision 7f6dcdcf
Added by Andreas Kohlbecker almost 11 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonListController.java | ||
---|---|---|
32 | 32 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
33 | 33 |
import eu.etaxonomy.cdm.api.service.ITermService; |
34 | 34 |
import eu.etaxonomy.cdm.api.service.TaxaAndNamesSearchMode; |
35 |
import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl; |
|
36 |
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator; |
|
35 | 37 |
import eu.etaxonomy.cdm.api.service.pager.Pager; |
36 | 38 |
import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException; |
37 | 39 |
import eu.etaxonomy.cdm.api.service.search.SearchResult; |
... | ... | |
45 | 47 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
46 | 48 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
47 | 49 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
50 |
import eu.etaxonomy.cdm.persistence.query.MatchMode; |
|
48 | 51 |
import eu.etaxonomy.cdm.persistence.query.OrderHint; |
49 | 52 |
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters; |
50 | 53 |
import eu.etaxonomy.cdm.remote.editor.UuidList; |
... | ... | |
121 | 124 |
* @throws ParseException |
122 | 125 |
*/ |
123 | 126 |
@RequestMapping(method = RequestMethod.GET, value={"search"}) |
124 |
public Pager<SearchResult<TaxonBase>> doFindTaxaAndNames(
|
|
127 |
public Pager<SearchResult<TaxonBase>> doSearch(
|
|
125 | 128 |
@RequestParam(value = "query", required = true) String query, |
126 | 129 |
@RequestParam(value = "tree", required = false) UUID treeUuid, |
127 | 130 |
@RequestParam(value = "area", required = false) Set<NamedArea> areas, |
... | ... | |
169 | 172 |
null, initializationStrategy); |
170 | 173 |
} |
171 | 174 |
|
175 |
/** |
|
176 |
* Find Taxa, Synonyms, Common Names by name, either globally or in a specific geographic area. |
|
177 |
* <p> |
|
178 |
* URI: <b>/{datasource-name}/portal/taxon/find</b> |
|
179 |
* |
|
180 |
* @param query |
|
181 |
* the string to query for. Since the wildcard character '*' |
|
182 |
* internally always is appended to the query string, a search |
|
183 |
* always compares the query string with the beginning of a name. |
|
184 |
* - <i>required parameter</i> |
|
185 |
* @param treeUuid |
|
186 |
* the {@link UUID} of a {@link Classification} to which the |
|
187 |
* search is to be restricted. - <i>optional parameter</i> |
|
188 |
* @param areas |
|
189 |
* restrict the search to a set of geographic {@link NamedArea}s. |
|
190 |
* The parameter currently takes a list of TDWG area labels. |
|
191 |
* - <i>optional parameter</i> |
|
192 |
* @param pageNumber |
|
193 |
* the number of the page to be returned, the first page has the |
|
194 |
* pageNumber = 1 - <i>optional parameter</i> |
|
195 |
* @param pageSize |
|
196 |
* the maximum number of entities returned per page (can be -1 |
|
197 |
* to return all entities in a single page) - <i>optional parameter</i> |
|
198 |
* @param doTaxa |
|
199 |
* weather to search for instances of {@link Taxon} - <i>optional parameter</i> |
|
200 |
* @param doSynonyms |
|
201 |
* weather to search for instances of {@link Synonym} - <i>optional parameter</i> |
|
202 |
* @param doTaxaByCommonNames |
|
203 |
* for instances of {@link Taxon} by a common name used - <i>optional parameter</i> |
|
204 |
* @param matchMode |
|
205 |
* valid values are "EXACT", "BEGINNING", "ANYWHERE", "END" (case sensitive !!!) |
|
206 |
* @return a Pager on a list of {@link IdentifiableEntity}s initialized by |
|
207 |
* the following strategy {@link #SIMPLE_TAXON_INIT_STRATEGY} |
|
208 |
* @throws IOException |
|
209 |
*/ |
|
210 |
@RequestMapping(method = RequestMethod.GET, value={"findTaxaAndNames"}) |
|
211 |
public Pager<IdentifiableEntity> doFindTaxaAndNames( |
|
212 |
@RequestParam(value = "query", required = true) String query, |
|
213 |
@RequestParam(value = "tree", required = false) UUID treeUuid, |
|
214 |
@RequestParam(value = "area", required = false) Set<NamedArea> areas, |
|
215 |
@RequestParam(value = "pageNumber", required = false) Integer pageNumber, |
|
216 |
@RequestParam(value = "pageSize", required = false) Integer pageSize, |
|
217 |
@RequestParam(value = "doTaxa", required = false) Boolean doTaxa, |
|
218 |
@RequestParam(value = "doSynonyms", required = false) Boolean doSynonyms, |
|
219 |
@RequestParam(value = "doMisappliedNames", required = false) Boolean doMisappliedNames, |
|
220 |
@RequestParam(value = "doTaxaByCommonNames", required = false) Boolean doTaxaByCommonNames, |
|
221 |
@RequestParam(value = "matchMode", required = false) MatchMode matchMode, |
|
222 |
HttpServletRequest request, |
|
223 |
HttpServletResponse response |
|
224 |
) |
|
225 |
throws IOException { |
|
226 |
|
|
227 |
|
|
228 |
logger.info("findTaxaAndNames : " + request.getRequestURI() + "?" + request.getQueryString() ); |
|
229 |
|
|
230 |
PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber); |
|
231 |
pagerParams.normalizeAndValidate(response); |
|
232 |
|
|
233 |
IFindTaxaAndNamesConfigurator config = new FindTaxaAndNamesConfiguratorImpl(); |
|
234 |
|
|
235 |
config.setTaxonPropertyPath(initializationStrategy); |
|
236 |
|
|
237 |
config.setPageNumber(pagerParams.getPageIndex()); |
|
238 |
config.setPageSize(pagerParams.getPageSize()); |
|
239 |
config.setTitleSearchString(query); |
|
240 |
config.setDoTaxa(doTaxa!= null ? doTaxa : Boolean.FALSE ); |
|
241 |
config.setDoSynonyms(doSynonyms != null ? doSynonyms : Boolean.FALSE ); |
|
242 |
config.setDoMisappliedNames(doMisappliedNames != null ? doMisappliedNames : Boolean.FALSE); |
|
243 |
config.setDoTaxaByCommonNames(doTaxaByCommonNames != null ? doTaxaByCommonNames : Boolean.FALSE ); |
|
244 |
config.setMatchMode(matchMode != null ? matchMode : MatchMode.BEGINNING); |
|
245 |
// config.setTaxonPropertyPath(SIMPLE_TAXON_INIT_STRATEGY); |
|
246 |
config.setNamedAreas(areas); |
|
247 |
if(treeUuid != null){ |
|
248 |
Classification classification = classificationService.find(treeUuid); |
|
249 |
config.setClassification(classification); |
|
250 |
} |
|
251 |
|
|
252 |
return service.findTaxaAndNames(config); |
|
253 |
|
|
254 |
} |
|
255 |
|
|
256 |
|
|
172 | 257 |
/** |
173 | 258 |
* @param clazz |
174 | 259 |
* @param queryString |
Also available in: Unified diff
restoring old findTaxaAndNames controller methods