Search in sources :

Example 16 with HippoBean

use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.

the class SearchComponent method buildAndExecuteHstSearch.

private void buildAndExecuteHstSearch(HstRequest request, SearchComponentInfo paramInfo) {
    HippoFacetNavigationBean facetNavigationBean = getFacetNavigationBean(request);
    if (facetNavigationBean != null) {
        HippoResultSetBean resultSet = facetNavigationBean.getResultSet();
        if (resultSet != null) {
            Pageable<HippoBean> pageable = getPageableFactory().createPageable(resultSet.getDocumentIterator(HippoBean.class), facetNavigationBean.getCount().intValue(), paramInfo.getPageSize(), getCurrentPage(request));
            request.setAttribute("pageable", pageable);
            request.setAttribute("pageNumbers", getHstPageNumbers(pageable));
        }
    }
    setCommonSearchRequestAttributes(request, paramInfo);
    request.setAttribute("area", getAreaOption(request).toString());
    request.setAttribute("facets", facetNavigationBean);
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) HippoFacetNavigationBean(org.hippoecm.hst.content.beans.standard.HippoFacetNavigationBean) HippoResultSetBean(org.hippoecm.hst.content.beans.standard.HippoResultSetBean)

Example 17 with HippoBean

use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.

the class NavigationBlockComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    NavigationBlockComponentInfo componentInfo = getComponentParametersInfo(request);
    final String theme = componentInfo.getTheme();
    final String size = componentInfo.getSize();
    final String position = componentInfo.getPosition();
    final String heading = componentInfo.getHeading();
    List<HippoBean> allDocuments = new ArrayList<>();
    HippoBean document1 = getHippoBeanForPath(componentInfo.getDocument1(), HippoBean.class);
    allDocuments.add(document1);
    HippoBean document2 = getHippoBeanForPath(componentInfo.getDocument2(), HippoBean.class);
    allDocuments.add(document2);
    HippoBean document3 = getHippoBeanForPath(componentInfo.getDocument3(), HippoBean.class);
    allDocuments.add(document3);
    HippoBean document4 = getHippoBeanForPath(componentInfo.getDocument4(), HippoBean.class);
    allDocuments.add(document4);
    HippoBean document5 = getHippoBeanForPath(componentInfo.getDocument5(), HippoBean.class);
    allDocuments.add(document5);
    HippoBean document6 = getHippoBeanForPath(componentInfo.getDocument6(), HippoBean.class);
    allDocuments.add(document6);
    request.setAttribute("theme", theme);
    request.setAttribute("size", size);
    request.setAttribute("position", position);
    request.setAttribute("heading", heading);
    request.setAttribute("documents", buildDocumentsList(allDocuments));
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) ArrayList(java.util.ArrayList) NavigationBlockComponentInfo(uk.nhs.digital.common.components.info.NavigationBlockComponentInfo)

Example 18 with HippoBean

use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.

the class WrappedListPickerComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    final WrappedListPickerComponentInfo info = getComponentParametersInfo(request);
    final HippoBean document = getHippoBeanForPath(info.getWrappingDocument(), HippoBean.class);
    final Boolean showIcon = info.getShowIcon();
    request.setAttribute("wrappingDocument", document);
    request.setAttribute("currentDate", Calendar.getInstance());
    request.setAttribute("showIcon", showIcon);
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) WrappedListPickerComponentInfo(uk.nhs.digital.common.components.info.WrappedListPickerComponentInfo)

Example 19 with HippoBean

use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.

the class PageSectionGrouper method groupSections.

public List<Object> groupSections(List<? extends HippoBean> sections) {
    // convert the section into a grouped list so we can
    // show multiple images next to each other in a section
    List<Object> groupedSections = new ArrayList<>();
    for (HippoBean section : sections) {
        if (isHalfImage(section)) {
            // if the last entry was a Image Pair with a space then we are the second one
            ImageSection imageSection = (ImageSection) section;
            Object last = groupedSections.size() > 0 ? groupedSections.get(groupedSections.size() - 1) : null;
            if (isImagePairWithSpace(last)) {
                ((ImagePairSection) last).setSecond(imageSection);
            } else {
                groupedSections.add(new ImagePairSection(imageSection));
            }
        } else {
            // just add it, no grouping required
            groupedSections.add(section);
        }
    }
    return groupedSections;
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean) ArrayList(java.util.ArrayList) ImageSection(uk.nhs.digital.ps.beans.ImageSection)

Example 20 with HippoBean

use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.

the class PublicationBase method getParentDocument.

public HippoBean getParentDocument() {
    assertPropertyPermitted(PropertyKeys.PARENT_SERIES);
    HippoBean parentBean = null;
    HippoBean folder = getParentBean();
    while (!HippoBeanHelper.isRootFolder(folder)) {
        List<HippoBean> parentBeans = new ArrayList<>();
        // The parent object of the publication could be either
        // Series or Archive and this will find which of those
        // it is and return the parents bean
        parentBeans.addAll(folder.getChildBeans(Series.class));
        parentBeans.addAll(folder.getChildBeans(Archive.class));
        Iterator<HippoBean> iterator = parentBeans.iterator();
        if (iterator.hasNext()) {
            parentBean = iterator.next();
            break;
        } else {
            folder = folder.getParentBean();
        }
    }
    return parentBean;
}
Also used : HippoBean(org.hippoecm.hst.content.beans.standard.HippoBean)

Aggregations

HippoBean (org.hippoecm.hst.content.beans.standard.HippoBean)46 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)10 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)10 ArrayList (java.util.ArrayList)7 HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)7 HippoBeanIterator (org.hippoecm.hst.content.beans.standard.HippoBeanIterator)7 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)6 HstQueryBuilder (org.hippoecm.hst.content.beans.query.builder.HstQueryBuilder)5 HstComponentException (org.hippoecm.hst.core.component.HstComponentException)5 SimpleDateFormat (java.text.SimpleDateFormat)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)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 DateTools (org.hippoecm.repository.util.DateTools)4 ParseException (java.text.ParseException)3 Function (java.util.function.Function)3 Node (javax.jcr.Node)3 ConstraintBuilder.and (org.hippoecm.hst.content.beans.query.builder.ConstraintBuilder.and)3