Search in sources :

Example 1 with HippoDocument

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

the class CardListComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
    LOGGER.info("Card List Component Info");
    CardListComponentInfo info = getComponentParametersInfo(request);
    String headerText = info.getHeader();
    String introductionText = info.getIntroduction();
    request.setAttribute("headerText", headerText);
    request.setAttribute("introText", introductionText);
    String button1Title = info.getButton1Title();
    String button1Url = info.getButton1Link();
    String button2Title = info.getButton2Title();
    String button2Url = info.getButton2Link();
    request.setAttribute("button1Title", button1Title);
    request.setAttribute("button1Url", button1Url);
    request.setAttribute("button2Title", button2Title);
    request.setAttribute("button2Url", button2Url);
    List<HippoDocument> cardComponents = getCardComponents(info);
    request.setAttribute("cardList", cardComponents);
    String template = info.getTemplate();
    request.setAttribute("template", template);
}
Also used : HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) CardListComponentInfo(uk.nhs.digital.common.components.info.CardListComponentInfo)

Example 2 with HippoDocument

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

the class AzListComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    final AzListComponentInfo componentParametersInfo = getComponentParametersInfo(request);
    String headerText = componentParametersInfo.getHeaderText();
    request.setAttribute("headerText", headerText);
    String buttonText = componentParametersInfo.getButtonText();
    request.setAttribute("buttonText", buttonText);
    String navigationDocumentPath = componentParametersInfo.getNavigationDocument();
    HippoDocument bean = this.getHippoBeanForPath(navigationDocumentPath, HippoDocument.class);
    request.setAttribute("navigationDocument", bean);
}
Also used : HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) AzListComponentInfo(uk.nhs.digital.common.components.info.AzListComponentInfo)

Example 3 with HippoDocument

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

the class ProjectUpdateFeedComponent method addOrganisationFilter.

private void addOrganisationFilter(List<BaseFilter> filters, HstRequest request, HstQuery query) {
    String organisationTitle = getSelectedOrganisationTitle(request);
    if (StringUtils.isNotBlank(organisationTitle)) {
        HippoBeanIterator organisationBeans;
        try {
            final HstRequestContext requestContext = request.getRequestContext();
            HstQuery orgQuery = requestContext.getQueryManager().createQuery(requestContext.getSiteContentBaseBean(), Organisation.class);
            Filter orgNameFilter = orgQuery.createFilter();
            orgNameFilter.addEqualToCaseInsensitive("website:title", organisationTitle);
            orgQuery.setFilter(orgNameFilter);
            organisationBeans = orgQuery.execute().getHippoBeans();
        } catch (QueryException e) {
            log.debug("Error finding organisation with title {}: {}", organisationTitle, e);
            return;
        }
        if (organisationBeans.getSize() == 0) {
            return;
        }
        String jcrQuery;
        if (organisationBeans.getSize() > 1) {
            StringBuilder jcrQueryBuilder = new StringBuilder(String.format("((website:organisation/@hippo:docbase = '%s')", ((HippoDocument) organisationBeans.nextHippoBean()).getCanonicalHandleUUID()));
            while (organisationBeans.hasNext()) {
                jcrQueryBuilder.append(String.format(" or (website:organisation/@hippo:docbase = '%s')", ((HippoDocument) organisationBeans.nextHippoBean()).getCanonicalHandleUUID()));
            }
            jcrQueryBuilder.append(")");
            jcrQuery = jcrQueryBuilder.toString();
        } else {
            jcrQuery = String.format("(website:organisation/@hippo:docbase = '%s')", ((HippoDocument) organisationBeans.nextHippoBean()).getCanonicalHandleUUID());
        }
        Filter filter = query.createFilter();
        filter.addJCRExpression(jcrQuery);
        filters.add(filter);
    }
}
Also used : HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) BaseFilter(org.hippoecm.hst.content.beans.query.filter.BaseFilter) Filter(org.hippoecm.hst.content.beans.query.filter.Filter) HippoBeanIterator(org.hippoecm.hst.content.beans.standard.HippoBeanIterator) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext)

Example 4 with HippoDocument

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

the class ListPickerComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
    final ListPickerComponentInfo paramInfo = getComponentParametersInfo(request);
    final List<HippoDocument> documentItems = getDocumentItems(paramInfo);
    final int pageSize = getPageSize(request, paramInfo);
    final int page = getAnyIntParameter(request, REQUEST_PARAM_PAGE, 1);
    final Pageable<HippoDocument> pageable = getPageableFactory().createPageable(documentItems, page, pageSize);
    request.setModel(REQUEST_ATTR_PAGEABLE, pageable);
    request.setAttribute(REQUEST_ATTR_PARAM_INFO, paramInfo);
}
Also used : HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) ListPickerComponentInfo(uk.nhs.digital.common.components.info.ListPickerComponentInfo)

Example 5 with HippoDocument

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

the class HeaderComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    final HeaderComponentInfo componentParametersInfo = getComponentParametersInfo(request);
    String bannerDocPath = componentParametersInfo.getBannerDoc();
    HippoDocument banner = this.getHippoBeanForPath(bannerDocPath, HippoDocument.class);
    request.setAttribute("banner", banner);
    String colour = componentParametersInfo.getColour();
    if ("Dark Blue".equalsIgnoreCase(colour)) {
        request.setAttribute("colour", "Dark Blue Multicolour");
    } else {
        request.setAttribute("colour", colour);
    }
    String digiblockPosition = componentParametersInfo.getDigiblockPosition();
    request.setAttribute("digiblockposition", digiblockPosition);
    String alignment = componentParametersInfo.getAlignment();
    request.setAttribute("alignment", alignment);
    String button1text = componentParametersInfo.getButton1Text();
    String button1Url = componentParametersInfo.getButton1Url();
    request.setAttribute("button1Text", button1text);
    request.setAttribute("button1Url", button1Url);
    String button2text = componentParametersInfo.getButton2Text();
    String button2Url = componentParametersInfo.getButton2Url();
    request.setAttribute("button2Text", button2text);
    request.setAttribute("button2Url", button2Url);
    request.getRequestContext().setAttribute("headerPresent", true);
    request.setAttribute("stripTagsContentRewriter", stripTagsContentRewriter);
    DocumentUtils.setMetaTags(request, this);
}
Also used : HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) HeaderComponentInfo(uk.nhs.digital.common.components.info.HeaderComponentInfo)

Aggregations

HippoDocument (org.hippoecm.hst.content.beans.standard.HippoDocument)7 HashMap (java.util.HashMap)1 HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)1 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)1 BaseFilter (org.hippoecm.hst.content.beans.query.filter.BaseFilter)1 Filter (org.hippoecm.hst.content.beans.query.filter.Filter)1 HippoBeanIterator (org.hippoecm.hst.content.beans.standard.HippoBeanIterator)1 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)1 HstSiteMenu (org.hippoecm.hst.core.sitemenu.HstSiteMenu)1 HstSiteMenuItem (org.hippoecm.hst.core.sitemenu.HstSiteMenuItem)1 AzListComponentInfo (uk.nhs.digital.common.components.info.AzListComponentInfo)1 CardListComponentInfo (uk.nhs.digital.common.components.info.CardListComponentInfo)1 HeaderComponentInfo (uk.nhs.digital.common.components.info.HeaderComponentInfo)1 ListPickerComponentInfo (uk.nhs.digital.common.components.info.ListPickerComponentInfo)1 SocialMediaComponentInfo (uk.nhs.digital.common.components.info.SocialMediaComponentInfo)1 SocialMediaLink (uk.nhs.digital.website.beans.SocialMediaLink)1