use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.
the class CommonFieldsBean method getInitialQuery.
protected <T extends HippoBean> HstQuery getInitialQuery(List<String> properties, Class<T> beanClass) throws HstComponentException, QueryException {
final HstRequestContext context = RequestContextProvider.get();
HstQuery query = ContentBeanUtils.createIncomingBeansQuery(this.getCanonicalBean(), context.getSiteContentBaseBean(), properties, beanClass, false);
return query;
}
use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.
the class PolicyPage method getPolicy.
public Policy getPolicy() {
final HstRequestContext context = RequestContextProvider.get();
try {
HstQuery linkedBeanQuery = ContentBeanUtils.createIncomingBeansQuery(this.getCanonicalBean(), context.getSiteContentBaseBean(), "website:childPage/@hippo:docbase", Policy.class, false);
linkedBeanQuery.setLimit(1);
return (Policy) linkedBeanQuery.execute().getHippoBeans().nextHippoBean();
} catch (QueryException queryException) {
log.warn("QueryException ", queryException);
}
return null;
}
use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.
the class HubNewsAndEvents method getLatestBlog.
public List<HippoBean> getLatestBlog() throws QueryException {
HstRequestContext requestContext = RequestContextProvider.get();
HippoBean scope = requestContext.getSiteContentBaseBean();
HstQuery hstBlogQuery = HstQueryBuilder.create(scope).ofTypes(Blog.class).orderByDescending("website:dateofpublication").build();
HstQueryResult blogResult = hstBlogQuery.execute();
return toList(blogResult.getHippoBeans());
}
use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.
the class HubNewsAndEvents method getLatestNewsArticles.
public List<HippoBean> getLatestNewsArticles() throws QueryException {
HstRequestContext requestContext = RequestContextProvider.get();
HippoBean scope = requestContext.getSiteContentBaseBean().getBean("news/latest-news");
HstQuery hstNewsQuery = HstQueryBuilder.create(scope).ofTypes(News.class).orderByDescending("website:publisheddatetime").build();
HstQueryResult newsResult = hstNewsQuery.execute();
return toList(newsResult.getHippoBeans());
}
use of org.hippoecm.hst.core.request.HstRequestContext in project hippo by NHS-digital-website.
the class SupplementaryInformationHubComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
super.doBeforeRender(request, response);
final HstRequestContext context = request.getRequestContext();
final SupplementaryInformationHub document = (SupplementaryInformationHub) context.getContentBean();
if (document != null) {
request.setAttribute("document", document);
}
List<SupplementaryInformation> si = getListOfSupplementaryInformation();
request.setAttribute("years", years(si));
String selectedYear = DocumentUtils.findYearOrDefault(getSelectedYear(request), Calendar.getInstance().get(Calendar.YEAR));
request.setAttribute("selectedYear", selectedYear);
final Month selectedMonth = findMonthOrNull(getSelectedMonth(request));
if (Objects.nonNull(selectedMonth)) {
request.setAttribute("selectedMonth", selectedMonth);
}
request.setAttribute("months", months(Integer.parseInt(selectedYear), si));
}
Aggregations