use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class FeedHubComponent method getSupInfoFilters.
private void getSupInfoFilters(List<HippoBean> supInfoFeed) throws QueryException {
Map<String, Long> yearFilters = supInfoFeed.stream().map(e -> (SupplementaryInformation) e).map(SupplementaryInformation::getPublishedDate).map(e -> e != null ? String.valueOf(e.get(Calendar.YEAR)) : "Unknown").collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
addFilter("Year", "year", yearFilters);
if (yearFilters.size() > 0 && filterValues.get("year").length > 0) {
Map<String, Long> monthFilters = supInfoFeed.stream().map(e -> (SupplementaryInformation) e).map(SupplementaryInformation::getPublishedDate).filter(Objects::nonNull).map(e -> new SimpleDateFormat("MMMMM").format(e.getTime())).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
addFilter("Month", "month", monthFilters);
}
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class GeneralArticleComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest hstRequest, final HstResponse hstResponse) {
super.doBeforeRender(hstRequest, hstResponse);
final HstRequestContext context = RequestContextProvider.get();
HttpServletRequest request = context.getServletRequest();
Object bean = hstRequest.getAttribute(REQUEST_ATTR_DOCUMENT);
if (bean != null && bean instanceof HippoBean) {
General generalDocument = (General) bean;
if (StringUtils.isNotBlank(generalDocument.getEarlyAccessKey()) && !generalDocument.getEarlyAccessKey().equals(request.getParameter("key"))) {
LOGGER.debug("Early access key is set and no or wrong key is being used. Redirecting to 404 error code");
hstResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
HstResponseUtils.sendRedirect(hstRequest, hstResponse, "/error/404");
}
}
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class CaseStudyAndBlogBase method getCategories.
public String getCategories() {
List<String> strList = new ArrayList<>();
List<HippoBean> relatedSubjectDoc = getLinkedBeans("website:relatedsubjects", HippoBean.class);
for (HippoBean bean : relatedSubjectDoc) {
String title = bean.getSingleProperty("website:title");
strList.add(title);
}
String[] topics = getMultipleProperty("hippotaxonomy:keys");
if (topics != null && topics.length > 0) {
strList.addAll(Arrays.asList(topics));
}
return strList.size() > 0 ? strList.toString() : null;
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class Role method getPrimaryroles.
@HippoEssentialsGenerated(internalName = "website:primaryrole", allowModifications = false)
public List<String> getPrimaryroles() {
List<String> roles = new ArrayList<String>();
List<HippoBean> rolepickers = this.getRolepicker();
for (HippoBean picker : rolepickers) {
JobRolePicker rolepicker = (JobRolePicker) picker;
if (rolepicker != null && rolepicker.getPrimaryrolepicker() != null) {
JobRole jobrole = rolepicker.getPrimaryrolepicker();
if (jobrole != null) {
roles.add(jobrole.getTitle());
}
}
}
if (roles.size() == 0) {
roles.add(getSingleProperty("website:primaryrole"));
}
return roles;
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class ProjectUpdate method getParentFeed.
public ProjectFeed getParentFeed() {
ProjectFeed parentBean = null;
HippoBean folder = getParentBean();
while (!HippoBeanHelper.isRootFolder(folder)) {
Iterator<ProjectFeed> iterator = folder.getChildBeans(ProjectFeed.class).iterator();
if (iterator.hasNext()) {
parentBean = iterator.next();
break;
} else {
folder = folder.getParentBean();
}
}
return parentBean;
}
Aggregations