Search in sources :

Example 1 with PagerParameters

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);
    }
}
Also used : CdmApplicationAwareDefaultExport(eu.etaxonomy.cdm.io.common.CdmApplicationAwareDefaultExport) DefaultPagerImpl(eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl) PagerParameters(eu.etaxonomy.cdm.remote.controller.util.PagerParameters) CsvDemoExportConfigurator(eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoExportConfigurator) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException) CsvDemoRecord(eu.etaxonomy.cdm.io.csv.redlist.demo.CsvDemoRecord) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PagerParameters

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;
}
Also used : TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) PagerParameters(eu.etaxonomy.cdm.remote.controller.util.PagerParameters) Classification(eu.etaxonomy.cdm.model.taxon.Classification) SearchResult(eu.etaxonomy.cdm.api.service.search.SearchResult) List(java.util.List) UuidList(eu.etaxonomy.cdm.remote.editor.UuidList) ArrayList(java.util.ArrayList) DefinedTermBaseList(eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList) UUID(java.util.UUID) Feature(eu.etaxonomy.cdm.model.description.Feature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with PagerParameters

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>&#x002F;{datasource-name}&#x002F;portal&#x002F;taxon&#x002F;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);
}
Also used : IFindTaxaAndNamesConfigurator(eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) PagerParameters(eu.etaxonomy.cdm.remote.controller.util.PagerParameters) Classification(eu.etaxonomy.cdm.model.taxon.Classification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PagerParameters

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;
}
Also used : TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) PagerParameters(eu.etaxonomy.cdm.remote.controller.util.PagerParameters) Classification(eu.etaxonomy.cdm.model.taxon.Classification) SearchResult(eu.etaxonomy.cdm.api.service.search.SearchResult) List(java.util.List) UuidList(eu.etaxonomy.cdm.remote.editor.UuidList) ArrayList(java.util.ArrayList) DefinedTermBaseList(eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PagerParameters

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);
}
Also used : PagerParameters(eu.etaxonomy.cdm.remote.controller.util.PagerParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PagerParameters (eu.etaxonomy.cdm.remote.controller.util.PagerParameters)34 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)33 Classification (eu.etaxonomy.cdm.model.taxon.Classification)7 TaxonNode (eu.etaxonomy.cdm.model.taxon.TaxonNode)7 ArrayList (java.util.ArrayList)7 SearchResult (eu.etaxonomy.cdm.api.service.search.SearchResult)4 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)4 UuidList (eu.etaxonomy.cdm.remote.editor.UuidList)4 List (java.util.List)4 UUID (java.util.UUID)4 DefaultPagerImpl (eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl)3 OrderHint (eu.etaxonomy.cdm.persistence.query.OrderHint)3 DefinedTermBaseList (eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList)3 IOException (java.io.IOException)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 MarkerType (eu.etaxonomy.cdm.model.common.MarkerType)2 Feature (eu.etaxonomy.cdm.model.description.Feature)2 PolytomousKey (eu.etaxonomy.cdm.model.description.PolytomousKey)2 TaxonBase (eu.etaxonomy.cdm.model.taxon.TaxonBase)2 TaxonNodeAgentRelation (eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation)2