use of org.hippoecm.hst.core.component.HstResponse in project hippo by NHS-digital-website.
the class TaskHubComponent method doBeforeRender.
@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
super.doBeforeRender(request, response);
final ComponentList bean = (ComponentList) request.getRequestContext().getContentBean();
List<?> priorityTaskList = getTasksFromLinkBlocks(bean.getBlocks()).filter(task -> ((Task) task).getPriorityAction()).collect(Collectors.toList());
request.setAttribute("priorityTasks", priorityTaskList);
List<?> alternativeTaskList = getTasksFromLinkBlocks(bean.getBlocks()).flatMap(task -> addAlternativeNameEntries((Task) task)).collect(Collectors.toList());
request.setAttribute("alternativeTasks", alternativeTaskList);
}
use of org.hippoecm.hst.core.component.HstResponse in project hippo by NHS-digital-website.
the class FeedHubComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
super.doBeforeRender(request, response);
filters = new ArrayList<>();
filterValues = new HashMap<>();
String[] yearParams = getPublicRequestParameters(request, "year");
filterValues.put("year", yearParams);
if (yearParams.length > 0) {
filterValues.put("month", getPublicRequestParameters(request, "month"));
}
filterValues.put("type[]", getPublicRequestParameters(request, "type[]"));
filterValues.put("severity", getPublicRequestParameters(request, "severity"));
request.setAttribute("filterValues", filterValues);
long filterCount = filterValues.values().stream().filter(value -> value.length > 0).count();
request.setAttribute("filterCount", filterCount);
queryText = getPublicRequestParameter(request, "query");
if (queryText == null) {
queryText = "";
}
request.setAttribute("query", queryText);
sort = getPublicRequestParameter(request, "sort");
if (sort == null) {
sort = "date-desc";
}
request.setAttribute("sort", sort);
String activeFiltersString = getPublicRequestParameter(request, "active-filters");
if (activeFiltersString != null) {
String[] activeFilters = activeFiltersString.split(",");
request.setAttribute("activeFilters", activeFilters);
}
try {
List<HippoBean> feed = getFeed(request);
request.setAttribute("feed", feed);
Pageable<HippoBean> pagedFeed = pageResults(feed, request);
request.setAttribute("pageable", pagedFeed);
final HstRequestContext context = request.getRequestContext();
FeedHub feedHub = (FeedHub) context.getContentBean();
switch(feedHub.getFeedType()) {
case "News":
getNewsFilters(feed);
break;
case "Supplementary information":
getSupInfoFilters(feed);
break;
case "Events":
getEventFilters(feed);
break;
case "Cyber Alerts":
getCyberAlertFilters(feed);
break;
default:
}
request.setAttribute("filters", filters);
} catch (QueryException e) {
e.printStackTrace();
}
}
Aggregations