use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class IndicatorComponent method getIndicator.
private Indicator getIndicator(HstRequestContext ctx) throws HstComponentException {
HippoBean content = ctx.getContentBean();
if (content instanceof Indicator) {
return (Indicator) content;
}
log.warn("Cannot find Indicator document for: {}", content.getPath());
throw new HstComponentException("Cannot find Indicator document based on request content");
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class ArchiveComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
super.doBeforeRender(request, response);
final HstRequestContext requestContext = request.getRequestContext();
final HippoBean contentBean = requestContext.getContentBean();
final Archive archiveIndexDocument;
if (contentBean.isHippoFolderBean()) {
final List<Archive> archiveIndexDocuments = contentBean.getChildBeans(Archive.class);
if (archiveIndexDocuments.size() != 1) {
reportInvalidTarget(request, contentBean, archiveIndexDocuments.size());
return;
}
archiveIndexDocument = archiveIndexDocuments.get(0);
} else if (contentBean instanceof Archive) {
archiveIndexDocument = (Archive) contentBean;
} else {
reportInvalidInvocation(request, contentBean);
return;
}
request.setAttribute("archive", archiveIndexDocument);
try {
final HstQuery query = requestContext.getQueryManager().createQuery(archiveIndexDocument.getParentBean(), Publication.class, LegacyPublication.class);
query.addOrderByDescending("publicationsystem:NominalDate");
final HstQueryResult hstQueryResult = query.execute();
request.setAttribute("publications", hstQueryResult.getHippoBeans());
} catch (QueryException queryException) {
log.error("Failed to find publications for archive " + archiveIndexDocument.getTitle(), queryException);
reportDisplayError(request, archiveIndexDocument.getTitle());
}
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class HippoBeanHelper method getFullTaxonomyList.
public static List<String> getFullTaxonomyList(HippoBean bean) {
String[] fullTaxonomy = bean.getMultipleProperty("common:FullTaxonomy");
if (isEmpty(fullTaxonomy)) {
return emptyList();
}
// Lookup Taxonomy Tree
TaxonomyManager taxonomyManager = HstServices.getComponentManager().getComponent(TaxonomyManager.class.getName());
Taxonomy taxonomyTree = taxonomyManager.getTaxonomies().getTaxonomy(PUBLICATION_TAXONOMY);
return Arrays.stream(fullTaxonomy).map(key -> taxonomyTree.getCategoryByKey(key).getInfo(Locale.UK).getName()).collect(Collectors.toList());
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class PublicationComponent method getPublication.
private Publication getPublication(HstRequestContext ctx) throws HstComponentException {
HippoBean content = ctx.getContentBean();
if (content.getClass().equals(Publication.class)) {
return (Publication) content;
}
if (content.getClass().equals(HippoFolder.class)) {
return Publication.getPublicationInFolder((HippoFolder) content, Publication.class);
}
log.warn("Cannot find Publication document for: {}", content.getPath());
throw new HstComponentException("Cannot find Publication document based on request content");
}
use of org.hippoecm.hst.content.beans.standard.HippoBean in project hippo by NHS-digital-website.
the class ProjectUpdateFeedComponent method doBeforeRender.
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) {
super.doBeforeRender(request, response);
final HippoBean document = request.getRequestContext().getContentBean();
if (document != null) {
request.setAttribute("document", document);
}
try {
List<ProjectUpdate> unfilteredResults = toList(HstQueryBuilder.create(document.getParentBean()).ofTypes(ProjectUpdate.class).build().execute().getHippoBeans());
request.setAttribute("organisations", organisations(unfilteredResults));
request.setAttribute("updateTypes", types(unfilteredResults));
request.setAttribute("years", years(unfilteredResults));
} catch (QueryException e) {
log.error("Query for filter generation failed: {}", e.getMessage());
}
request.setAttribute("selectedOrganisation", getSelectedOrganisationTitle(request));
request.setAttribute("selectedUpdateType", getSelectedUpdateType(request));
request.setAttribute("selectedYear", getYearToFilter(request));
}
Aggregations