use of eu.etaxonomy.cdm.remote.controller.util.PagerParameters in project cdmlib by cybertaxonomy.
the class ChecklistDemoController method doGeneralExport.
/**
* This service endpoint generates a json and xml view of the exported list.
* It takes advantage of pagination.
*
* @param classification uuid of the classification to export
* @param pageIndex
* @param pageSize
* @param response
* @param request
* @return
* @throws IOException
*/
@RequestMapping(value = { "export" }, method = { RequestMethod.GET })
public ModelAndView doGeneralExport(@RequestParam(value = "classification", required = false) String classificationUUID, @RequestParam(value = "pageIndex", required = false) Integer pageIndex, @RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletResponse response, HttpServletRequest request) throws IOException {
try {
if (pageSize == null) {
pageSize = 20;
}
if (pageIndex == null) {
pageIndex = 0;
}
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
List<CsvDemoRecord> recordList = new ArrayList<>();
CsvDemoExportConfigurator config = setTaxExportConfigurator(null, classificationUUID, null, null, null, false, false);
config.setPageSize(pagerParams.getPageSize());
config.setPageNumber(pagerParams.getPageIndex());
config.setRecordList(recordList);
@SuppressWarnings("unchecked") CdmApplicationAwareDefaultExport<CsvDemoExportConfigurator> defaultExport = (CdmApplicationAwareDefaultExport<CsvDemoExportConfigurator>) appContext.getBean("defaultExport");
defaultExport.invoke(config);
DefaultPagerImpl<CsvDemoRecord> dpi = new DefaultPagerImpl<>(pagerParams.getPageIndex(), config.getTaxonNodeListSize(), pagerParams.getPageSize(), recordList);
ModelAndView mv = new ModelAndView();
// mv.addObject(recordList);f
mv.addObject(dpi);
return mv;
} catch (Exception e) {
Resource resource = resourceLoader.getResource("classpath:eu/etaxonomy/cdm/doc/remote/apt/checklist-catalogue-export.apt");
return exportGetExplanation(response, request, resource);
}
}
use of eu.etaxonomy.cdm.remote.controller.util.PagerParameters in project cdmlib by cybertaxonomy.
the class TaxonListController method doFindByDescriptionElementFullText.
/**
* @param clazz
* @param queryString
* @param treeUuid TODO unimplemented in TaxonServiceImpl !!!!
* @param languages
* @param pageIndex
* @param pageSize
* @param request
* @param response
* @return
* @throws IOException
* @throws ParseException
*/
@RequestMapping(method = RequestMethod.GET, value = { "findByDescriptionElementFullText" })
public Pager<SearchResult<TaxonBase>> doFindByDescriptionElementFullText(@RequestParam(value = "clazz", required = false) Class<? extends DescriptionElementBase> clazz, @RequestParam(value = "query", required = true) String queryString, @RequestParam(value = "tree", required = false) UUID treeUuid, @RequestParam(value = "subtree", required = false) UUID subtreeUuid, @RequestParam(value = "features", required = false) UuidList featureUuids, @RequestParam(value = "languages", required = false) List<Language> languages, @RequestParam(value = "hl", required = false) Boolean highlighting, @RequestParam(value = "pageIndex", required = false) Integer pageIndex, @RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletRequest request, HttpServletResponse response) throws IOException, LuceneParseException {
logger.info("findByDescriptionElementFullText : " + requestPathAndQuery(request));
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
if (highlighting == null) {
highlighting = false;
}
Classification classification = getClassificationOrError(treeUuid, classificationService, response);
TaxonNode subtree = getSubtreeOrError(subtreeUuid, taxonNodeService, response);
List<Feature> features = null;
if (featureUuids != null) {
features = new ArrayList<>(featureUuids.size());
for (UUID uuid : featureUuids) {
// TODO error if null
Feature feature = (Feature) termService.find(uuid);
features.add(feature);
}
}
Pager<SearchResult<TaxonBase>> pager = service.findByDescriptionElementFullText(clazz, queryString, classification, subtree, features, languages, highlighting, pagerParams.getPageSize(), pagerParams.getPageIndex(), ((List<OrderHint>) null), getSimpleTaxonInitStrategy());
return pager;
}
use of eu.etaxonomy.cdm.remote.controller.util.PagerParameters in project cdmlib by cybertaxonomy.
the class TaxonListController method doFind.
/**
* Find Taxa, Synonyms, Common Names by name, either globally or in a specific geographic area.
* <p>
* URI: <b>/{datasource-name}/portal/taxon/find</b>
*
* @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.
* - <i>required parameter</i>
* @param treeUuid
* the {@link UUID} of a {@link Classification} to which the
* search is to be restricted. - <i>optional parameter</i>
* @param areas
* restrict the search to a set of geographic {@link NamedArea}s.
* The parameter currently takes a list of TDWG area labels.
* - <i>optional parameter</i>
* @param pageIndex
* the number of the page to be returned, the first page has the
* pageNumber = 1 - <i>optional parameter</i>
* @param pageSize
* the maximum number of entities returned per page (can be -1
* to return all entities in a single page) - <i>optional parameter</i>
* @param doTaxa
* weather to search for instances of {@link Taxon} - <i>optional parameter</i>
* @param doSynonyms
* weather to search for instances of {@link Synonym} - <i>optional parameter</i>
* @param doTaxaByCommonNames
* for instances of {@link Taxon} by a common name used - <i>optional parameter</i>
* @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 = { "find" })
public Pager<IdentifiableEntity> doFind(@RequestParam(value = "query", required = true) String query, @RequestParam(value = "tree", required = false) UUID classificationUuid, @RequestParam(value = "subtree", required = false) UUID subtreeUuid, @RequestParam(value = "area", required = false) Set<NamedArea> areas, @RequestParam(value = "pageIndex", required = false) Integer pageIndex, @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, @RequestParam(value = "order", required = false, defaultValue = "ALPHA") NameSearchOrder order, @RequestParam(value = "includeAuthors", required = false) Boolean includeAuthors, HttpServletRequest request, HttpServletResponse response) throws IOException {
boolean includeUnpublished = NO_UNPUBLISHED;
logger.info("doFind() " + requestPathAndQuery(request));
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
IFindTaxaAndNamesConfigurator config = FindTaxaAndNamesConfiguratorImpl.NewInstance();
config.setIncludeUnpublished(includeUnpublished);
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(getSimpleTaxonInitStrategy());
config.setNamedAreas(areas);
config.setDoIncludeAuthors(includeAuthors != null ? includeAuthors : Boolean.FALSE);
config.setOrder(order);
if (classificationUuid != null) {
Classification classification = classificationService.find(classificationUuid);
config.setClassification(classification);
}
TaxonNode subtree = getSubtreeOrError(subtreeUuid, taxonNodeService, response);
config.setSubtree(subtree);
return service.findTaxaAndNames(config);
}
use of eu.etaxonomy.cdm.remote.controller.util.PagerParameters in project cdmlib by cybertaxonomy.
the class TaxonListController method doFindByFullText.
@RequestMapping(method = RequestMethod.GET, value = { "findByFullText" })
public Pager<SearchResult<TaxonBase>> doFindByFullText(@RequestParam(value = "clazz", required = false) Class<? extends TaxonBase> clazz, @RequestParam(value = "query", required = true) String queryString, @RequestParam(value = "tree", required = false) UUID classificationUuid, @RequestParam(value = "subtree", required = false) UUID subtreeUuid, @RequestParam(value = "languages", required = false) List<Language> languages, @RequestParam(value = "hl", required = false) Boolean highlighting, @RequestParam(value = "pageIndex", required = false) Integer pageIndex, @RequestParam(value = "pageSize", required = false) Integer pageSize, HttpServletRequest request, HttpServletResponse response) throws IOException, LuceneParseException {
boolean includeUnpublished = NO_UNPUBLISHED;
logger.info("doFindByFullText() " + requestPathAndQuery(request));
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
if (highlighting == null) {
highlighting = false;
}
Classification classification = null;
if (classificationUuid != null) {
classification = classificationService.find(classificationUuid);
}
TaxonNode subtree = getSubtreeOrError(subtreeUuid, taxonNodeService, response);
Pager<SearchResult<TaxonBase>> pager = service.findByFullText(clazz, queryString, classification, subtree, includeUnpublished, languages, highlighting, pagerParams.getPageSize(), pagerParams.getPageIndex(), ((List<OrderHint>) null), initializationStrategy);
return pager;
}
use of eu.etaxonomy.cdm.remote.controller.util.PagerParameters in project cdmlib by cybertaxonomy.
the class NameListController method doFindTitleCache.
@RequestMapping(method = RequestMethod.GET, value = { "findTitleCache" })
public Pager<String> doFindTitleCache(@RequestParam(value = "query", required = true) String query, @RequestParam(value = "pageIndex", required = false) Integer pageIndex, @RequestParam(value = "pageSize", required = false) Integer pageSize, @RequestParam(value = "matchMode", required = false) MatchMode matchMode, HttpServletRequest request, HttpServletResponse response) throws IOException {
logger.info("doFindTitleCache() " + requestPathAndQuery(request));
PagerParameters pagerParams = new PagerParameters(pageSize, pageIndex);
pagerParams.normalizeAndValidate(response);
return service.findTitleCache(null, query, pagerParams.getPageSize(), pagerParams.getPageIndex(), null, matchMode);
}
Aggregations