/** * Returns a HstQuery for incoming beans (incoming beans within scope {@code scope}). You can add filters and ordering to the query before executing it * You need to add a <code>linkPath</code>: this is that path, that the incoming beans use to link to the HippoDocumentBean {@code bean}. For example, with 'myproject:link/@hippo:docbase' or even 'wildcard/@hippo:docbase' or * 'wildcard/wildcard/@hippo:docbase' where wildcard = * * * @param bean The HippoDocumentBean that you have, and for which you want to find the other beans that have a link to it (incoming beans) * @param scope the scope (hierarchical location) to search below for 'incoming beans' * @param linkPath the path where the 'incoming beans' have there link (mirror) stored, for example at myns:links/@hippo:docbase * @param beanMappingClass the type the 'incoming beans' should be of * @param includeSubTypes <code>true</code> when subtypes of beanMappingClass should be included in the result * @return a HstQuery that contains the constraints for 'incoming beans' to your <code>bean</code> * @throws QueryException when there is no HstRequestContext available, or another unexpected exception occurs */ public static HstQuery createIncomingBeansQuery(final HippoDocumentBean bean, final HippoBean scope, final String linkPath, final Class<? extends HippoBean> beanMappingClass, final boolean includeSubTypes) throws QueryException { final List<String> linkPaths = new ArrayList<>(); linkPaths.add(linkPath); return createIncomingBeansQuery(bean, scope, linkPaths, beanMappingClass, includeSubTypes); }
/** * Returns a HstQuery for incoming beans (incoming beans within scope {@code scope}). * You can add filters and ordering to the query before executing it. * You need to add a <code>linkPath</code>: this is the path where the link to the HippoDocumentBean {@code bean} * can be found on the 'incoming bean'. * For example, with 'myproject:link/@hippo:docbase' or even 'wildcard/@hippo:docbase' or * 'wildcard/wildcard/@hippo:docbase' where wildcard = * * * @param bean The HippoDocumentBean that you have and for which you want to find the other beans that have a link to it (incoming beans) * @param scope the scope (hierarchical location) to search below for 'incoming beans' * @param linkPath the path where the 'incoming beans' have there link (mirror) stored, for example at myns:links/@hippo:docbase * @param beanMappingClass the type the 'incoming beans' should have * @return a HstQuery that contains the constraints for 'incoming beans' to your <code>bean</code> * @throws QueryException when there is no HstRequestContext available, or another unexpected exception occurs */ public static HstQuery createIncomingBeansQuery(final HippoDocumentBean bean, final HippoBean scope, final String linkPath, final Class<? extends HippoBean> beanMappingClass) throws QueryException { final List<String> linkPaths = new ArrayList<>(); linkPaths.add(linkPath); return createIncomingBeansQuery(bean, scope, linkPaths, beanMappingClass, false); }
/** * Returns a HstQuery for incoming beans (incoming beans within scope {@code scope}). You can add filters and ordering to the query before executing it * You need to add a <code>depth</code>: this is the maximum depth, that the incoming beans use to link to the HippoDocumentBean {@code bean}. For example, with 'myproject:link/@hippo:docbase' is depth 1, * 'myproject:somecompound/myproject:link/@hippo:docbase' is depth 2 * * @param bean The HippoDocumentBean that you have, and for which you want to find the other beans that have a link to it (incoming beans) * @param scope the scope (hierarchical location) to search below for 'incoming beans' * @param depth the <code>depth</code> until which the links below the HippoDocuments you want to find can be. Maximum depth is 4, when larger, a QueryException is thrown * @param beanMappingClass the type the 'incoming beans' should be of * @param includeSubTypes <code>true</code> when subtypes of beanMappingClass should be included in the result * @return a HstQuery that contains the constraints for 'incoming beans' to your <code>bean</code> * @throws QueryException when <code>depth</code> is larger than 4 */ public static HstQuery createIncomingBeansQuery(final HippoDocumentBean bean, final HippoBean scope, final int depth, Class<? extends HippoBean> beanMappingClass, final boolean includeSubTypes) throws QueryException { if (depth < 0 || depth > 4) { throw new FilterException("Depth must be between 0 and 4 (inclusive)"); } String path = "@hippo:docbase"; final List<String> linkPaths = new ArrayList<>(); linkPaths.add(path); for (int i = 1; i <= depth; i++) { path = "*/" + path; linkPaths.add(path); } return createIncomingBeansQuery(bean, scope, linkPaths, beanMappingClass, includeSubTypes); }
/** * Returns a HstQuery for incoming beans (incoming beans within scope {@code scope}). * You can add filters and ordering to the query before executing it. * You need to add a <code>depth</code>: this is the maximum depth that the incoming beans use to link to the * HippoDocumentBean {@code bean}. For example, with 'myproject:link/@hippo:docbase' is depth 1, * 'myproject:somecompound/myproject:link/@hippo:docbase' is depth 2. * The link is assumed to be at path @hippo:docbase. * @param bean The HippoDocumentBean that you have and for which you want to find the other beans that have a link to it (incoming beans) * @param scope the scope (hierarchical location) to search below for 'incoming beans' * @param depth the <code>depth</code> until which the links below the HippoDocuments you want to find can be. Maximum depth is 4, when larger, a QueryException is thrown * @param beanMappingClass the specific type the 'incoming beans' should have * @return a HstQuery that contains the constraints for 'incoming beans' to your <code>bean</code> * @throws QueryException when <code>depth</code> is larger than 4 */ public static HstQuery createIncomingBeansQuery(final HippoDocumentBean bean, final HippoBean scope, final int depth, final Class<? extends HippoBean> beanMappingClass) throws QueryException { if (depth < 0 || depth > 4) { throw new FilterException("Depth must be between 0 and 4 (inclusive)"); } String path = "@hippo:docbase"; List<String> linkPaths = new ArrayList<>(); linkPaths.add(path); for (int i = 1; i <= depth; i++) { path = "*/" + path; linkPaths.add(path); } return createIncomingBeansQuery(bean, scope, linkPaths, beanMappingClass, false); }
try { for (AuthorEntry author : authors) { final HstQuery hstQuery = ContentBeanUtils.createIncomingBeansQuery(author, scopeBean, getSearchDepth(), clazz, true); hstQuery.setLimit(limit); hstQuery.addOrderByDescending(sortField);