private void goTo(Category category) { final boolean keepContentType = config.keepContentType().booleanValue(); if (keepContentType && navigationKey.isContentType()) { navigationKey = NavigationKey.category(category, navigationKey.getContentType()); } else if (category != null) { navigationKey = NavigationKey.category(category); } else { navigationKey = null; } }
@Override NodeQuery and() { if (getNavigationKey() == null) { return null; } final ContentType contentType = getNavigationKey().getContentType(); if (contentType == null) { return null; } return NodeQueries.term(Schema.TYPE, contentType.getId()); }
/** * Navigation key query. * @param key Navigation key to filter. * @return The requested query or {@code null} if the argument is {@code null}. */ public static NodeQuery navigationKey(NavigationKey key) { if (key == null) { return null; } return all(category(key.getCategory()), tag(key.getTag()), contentType(key.getContentType())); }
/** Component execution. */ public ComponentResponse execute() { if (config == null) { return ComponentResponse.OK; } final Category category = config.category(); final boolean keepContentType = config.keepContentType().booleanValue(); if (navigationKey == null) { if (category != null) { navigationKey = NavigationKey.category(category); } } else { if (keepContentType && navigationKey.isContentType()) { navigationKey = NavigationKey.category(category, navigationKey.getContentType()); } else if (category != null) { navigationKey = NavigationKey.category(category); } else { navigationKey = null; } } return ComponentResponse.OK; }
/** * Adds items related to a navigation. * * @param navigationKey * Navigation to add. * @param category * True if the category navigation must be included. * @param contentType * True if the content type navigation must be included. */ protected final void add(NavigationKey navigationKey, boolean category, boolean contentType) { if (navigationKey == null || config == null) { return; } if (category && navigationKey.isCategory()) { add(navigationKey.getCategory()); } if (contentType && navigationKey.isContentType()) { add(navigationKey.getContentType(), navigationKey); } }
/** * Adds a (REQUIRED) navigation key filter. * @param key Navigation key to filter. If {@null} the method call is ignored. * @return This criteria for method chaining. */ public ContentCriteria navigation(NavigationKey key) { if (key != null) { categories().apply(key.getCategory(), FilterType.REQUIRED); contentTypes().apply(key.getContentType(), FilterType.REQUIRED); tags().apply(key.getTag(), FilterType.REQUIRED); } return this; }
public ComponentResponse execute() { final ContentCriteria criteria = contentLoader.newCriteria(); pagination = loadPagination(Pagination.SIZE); if (componentConfig.navigation() && navigationKey != null) { if (navigationKey.isCategory()) { criteria.categories().apply(navigationKey.getCategory(), FilterType.REQUIRED); } if (navigationKey.isContentType()) { criteria.contentTypes().apply(navigationKey.getContentType(), FilterType.REQUIRED); } /* * if (navigationKey.isCategory() && navigationKey.isContentType()) { * criteria.category(navigationKey.getCategory()).contentType(navigationKey.getContentType()); } else if * (navigationKey.isCategory() && !navigationKey.isContentType()) { * criteria.category(navigationKey.getCategory()); } else if (!navigationKey.isCategory() && * navigationKey.isContentType()) { * * } */ } final List<String> f = fields(); if (param != null && !"".equals(param.trim()) && !f.isEmpty()) { criteria.must(NodeQueries.anyString(param, f)); } setPage(criteria.getPage(pagination)); return ComponentResponse.OK; }