Search in sources :

Example 1 with PolicyPage

use of uk.nhs.digital.website.beans.PolicyPage in project hippo by NHS-digital-website.

the class PolicyPageLinkedBeansComponent method doBeforeRender.

@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
    super.doBeforeRender(request, response);
    // linkPath property contains the relative path of the links property in the published workflow document
    String linkPath = getComponentParameter("linkPath");
    final HstRequestContext context = request.getRequestContext();
    // we assume a PublishedWorkChapter as content bean, thus expect a PublishedWork as "parent" document
    PolicyPage policyPage = context.getContentBean(PolicyPage.class);
    try {
        HstQuery linkedBeanQuery = ContentBeanUtils.createIncomingBeansQuery(policyPage, context.getSiteContentBaseBean(), linkPath, Policy.class, false);
        // chapter cannot be re-used across different publishedworkflow
        linkedBeanQuery.setLimit(1);
        // linked documents will contain the publishedworkflow document containing all the chapters
        HstQueryResult linkedDocuments = linkedBeanQuery.execute();
        request.setAttribute("linkeddocuments", linkedDocuments);
    } catch (QueryException queryException) {
        log.warn("QueryException ", queryException);
    }
}
Also used : HstQuery(org.hippoecm.hst.content.beans.query.HstQuery) QueryException(org.hippoecm.hst.content.beans.query.exceptions.QueryException) PolicyPage(uk.nhs.digital.website.beans.PolicyPage) HstRequestContext(org.hippoecm.hst.core.request.HstRequestContext) HstQueryResult(org.hippoecm.hst.content.beans.query.HstQueryResult)

Aggregations

HstQuery (org.hippoecm.hst.content.beans.query.HstQuery)1 HstQueryResult (org.hippoecm.hst.content.beans.query.HstQueryResult)1 QueryException (org.hippoecm.hst.content.beans.query.exceptions.QueryException)1 HstRequestContext (org.hippoecm.hst.core.request.HstRequestContext)1 PolicyPage (uk.nhs.digital.website.beans.PolicyPage)1