Search in sources :

Example 21 with QueryException

use of org.hippoecm.hst.content.beans.query.exceptions.QueryException in project hippo by NHS-digital-website.

the class BloomreachSearchProvider method getBloomreachResults.

public Pageable<HippoBean> getBloomreachResults(String queryString, int pageSize, int currentPage, SearchArea searchArea) {
    HstQuery query = getQuery(queryString, searchArea);
    query.setLimit(pageSize);
    query.setOffset((currentPage - 1) * pageSize);
    if (queryString == null) {
        query.addOrderByDescending("hippostdpubwf:lastModificationDate");
    }
    try {
        final HstQueryResult execute = query.execute();
        return pageableFactory.createPageable(execute.getHippoBeans(), execute.getTotalSize(), pageSize, currentPage);
    } catch (QueryException e) {
        LOG.error("Error running query: {}", e.getMessage());
        LOG.debug("Query exception: ", e);
        return null;
    }
}
Also used : HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult)

Example 22 with QueryException

use of org.hippoecm.hst.content.beans.query.exceptions.QueryException in project hippo by NHS-digital-website.

the class FolderComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
    super.doBeforeRender(request, response);
    HippoFolder folder = (HippoFolder) request.getRequestContext().getContentBean();
    try {
        request.setAttribute("publications", findAllDocuments(folder));
    } catch (QueryException queryException) {
        throw new HstComponentException("Exception occurred during folder search.", queryException);
    }
}
Also used : QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HippoFolder(org.hippoecm.hst.content.beans.standard.HippoFolder) HstComponentException(org.hippoecm.hst.core.component.HstComponentException)

Example 23 with QueryException

use of org.hippoecm.hst.content.beans.query.exceptions.QueryException in project hippo by NHS-digital-website.

the class PublicationBase method getDatasets.

public List<Dataset> getDatasets() throws HstComponentException {
    assertPropertyPermitted(PropertyKeys.DATASETS);
    HstQueryResult hstQueryResult;
    try {
        hstQueryResult = HstQueryBuilder.create(getParentBean()).ofTypes(Dataset.class).build().execute();
    } catch (QueryException queryException) {
        log.error("Failed to find datasets for publication " + getCanonicalPath(), queryException);
        throw new HstComponentException("Failed to find datasets for publication " + getCanonicalPath(), queryException);
    }
    ArrayList<Dataset> hippoBeans = Lists.newArrayList((Iterator) hstQueryResult.getHippoBeans());
    hippoBeans.sort(DocumentTitleComparator.COMPARATOR);
    return hippoBeans;
}
Also used : QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) HstComponentException(org.hippoecm.hst.core.component.HstComponentException) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult)

Aggregations

QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)23 HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)15 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)14 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)10 HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)8 HstQueryBuilder (org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder)7 HstComponentException (org.hippoecm.hst.core.component.HstComponentException)6 HippoBeanIterator (org.hippoecm.hst.content.beans.standard.HippoBeanIterator)5 java.util (java.util)4 IteratorUtils.toList (org.apache.commons.collections.IteratorUtils.toList)4 RequestContextProvider (org.hippoecm.hst.container.RequestContextProvider)4 Constraint (org.hippoecm.hst.content.beans.query.builder.Constraint)4 ConstraintBuilder.constraint (org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.constraint)4 ConstraintBuilder.or (org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.or)4 Filter (org.hippoecm.hst.content.beans.query.filter.Filter)4 HstRequest (org.hippoecm.hst.core.component.HstRequest)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3