/** * Tries to return a bean that is located in a faceted navigation tree below a result set. When it cannot be found, * or the bean is not of type <code>beanMappingClass</code>, <code>null</code> will be returned. * * @param <T> * @param query the free text search as {@link HstQuery} that is used for this faceted navigation * @param beanMappingClass the class T must be of * @return The faceted navigation result document of type T and <code>null</code> if it cannot be found or is not of type <code>T</code> */ public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, Class<T> beanMappingClass) { if(query == null) { return getFacetedNavigationResultDocument((String)null, beanMappingClass); } try { String queryAsString = "xpath("+query.getQueryAsString(true)+")"; return getFacetedNavigationResultDocument(queryAsString, beanMappingClass); } catch (QueryException e) { throw new HstComponentException("Unable to create a string representation of query", e); } }
/** * Tries to return a bean that is located in a faceted navigation tree below a result set. When it cannot be found, * or the bean is not of type <code>beanMappingClass</code>, <code>null</code> will be returned. * * @param <T> * @param query the free text search as {@link HstQuery} that is used for this faceted navigation * @param relPath the relative path from site base content to the faceted navigation node, which must not start with a / and is relative to the site content base path * @param beanMappingClass the class T must be of * @return The faceted navigation result document of type T and <code>null</code> if it cannot be found or is not of type <code>T</code> */ public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, String relPath, Class<T> beanMappingClass) { if(query == null) { return getFacetedNavigationResultDocument((String)null, relPath, beanMappingClass); } try { String queryAsString = "xpath("+query.getQueryAsString(true)+")"; return getFacetedNavigationResultDocument(queryAsString, relPath, beanMappingClass); } catch (QueryException e) { throw new HstComponentException("Unable to create a string representation of query", e); } }
/** * Tries to return a bean that is located in a faceted navigation tree below a result set. When it cannot be found, * or the bean is not of type <code>beanMappingClass</code>, <code>null</code> will be returned. * * @param <T> * @param query the free text search as {@link HstQuery} that is used for this faceted navigation * @param absBasePath the absolute path (starting with /) from where to get the faceted navigation bean for <code>relPath</code> and * <code>query</code>. The <code>absBasePath</code> is NOT allowed to point to or to a descendant of a faceted navigation * node * @param relPath the relative path from <code>absBasePath</code> to the faceted navigation node, which must not start with a / and is relative to the site content base path * @param beanMappingClass the class T must be of * @return The faceted navigation result document of type T and <code>null</code> if it cannot be found or is not of type <code>T</code> */ public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, String absBasePath, String relPath, Class<T> beanMappingClass) { if(query == null) { return getFacetedNavigationResultDocument((String)null, absBasePath, relPath, beanMappingClass); } try { String queryAsString = "xpath("+query.getQueryAsString(true)+")"; return getFacetedNavigationResultDocument(queryAsString, absBasePath, relPath, beanMappingClass); } catch (QueryException e) { throw new HstComponentException("Unable to create a string representation of query", e); } }
/** * Tries to return a bean that is located in a faceted navigation tree below a result set. When it cannot be found, * or the bean is not of type <code>beanMappingClass</code>, <code>null</code> will be returned. * * @param <T> * @param query the free text search as String that is used for this faceted navigation. The query should already * have been processed by {@link org.hippoecm.hst.util.SearchInputParsingUtils#parse(String, boolean)} * if necessary. * @param relPath the relative path from site base content to the faceted navigation node, which must not start with a / and is relative to the site content base path * @param beanMappingClass the class T must be of * @return The faceted navigation result document of type T and <code>null</code> if it cannot be found or is not of type <code>T</code> */ public static <T extends HippoBean> T getFacetedNavigationResultDocument(final String query, final String relPath, final Class<T> beanMappingClass) { final HstRequestContext requestContext = RequestContextProvider.get(); if (requestContext == null) { throw new HstComponentException("Cannot call #getFacetNavigationBean without HstRequestContext"); } return getFacetedNavigationResultDocument(query, "/"+requestContext.getSiteContentBasePath(), relPath, beanMappingClass); }
/** * Tries to return a bean that is located in a faceted navigation tree below a result set. When it cannot be found, * or the bean is not of type <code>beanMappingClass</code>, <code>null</code> will be returned. * * @param <T> * @param query the free text search as String that is used for this faceted navigation * @param beanMappingClass the class T must be of * @return The faceted navigation result document of type T and <code>null</code> if it cannot be found or is not of type <code>T</code> */ public static <T extends HippoBean> T getFacetedNavigationResultDocument(String query, Class<T> beanMappingClass) { final HstRequestContext requestContext = RequestContextProvider.get(); if (requestContext == null) { throw new HstComponentException("Cannot call #getFacetNavigationBean without HstRequestContext"); } ResolvedSiteMapItem resolvedSiteMapItem = requestContext.getResolvedSiteMapItem(); String relPath = PathUtils.normalizePath(resolvedSiteMapItem.getRelativeContentPath()); return getFacetedNavigationResultDocument(query, relPath, beanMappingClass); }