private Category getDestination() { // Priority 1: Parameter Category c = getParameterCategory(); if (c != null) { return c; } if (preferNavigationKey && navigationKey != null && navigationKey.isCategory()) { return navigationKey.getCategory(); } return destination; }
/** Component execution. */ public ComponentResponse execute() { if (config == null || categories == null || navigationKey == null || !navigationKey.isCategory()) { return ComponentResponse.OK; } final int distance = config.distance(); if (distance < 1) { return ComponentResponse.OK; } final Category current = navigationKey.getCategory(); final Category category = config.category(); if (!categories.containsKey(current.getId()) || !categories.containsKey(category.getId())) { return ComponentResponse.OK; } final List<Category> list = Lists.newLinkedList(); list.add(current); Category p = current; while ((p = categories.getParent(p.getId())) != null) { if (p.equals(category)) { if (list.isEmpty()) { return ComponentResponse.OK; } else { goTo(list.get(Math.min(list.size() - 1, distance - 1))); } } else { list.add(0, p); } } 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); } }
/** * Returns the category included in the navigation key, if any. * @return The category or {@code null}. */ final Category getCurrent() { if (componentConfig != null && componentConfig.current() != null) { return componentConfig.current(); } else if (config != null && config.current() != null) { return config.current(); } if (navigationKey != null && navigationKey.isCategory()) { Category c = navigationKey.getCategory(); if (categories.containsValue(c)) { return c; } } return null; }
/** Component execution. */ public ComponentResponse execute() { if (config == null) { return ComponentResponse.OK; } final ContentType contentType = config.contentType(); final boolean keepCategory = config.keepCategory().booleanValue(); final boolean keepTag = config.keepTag().booleanValue(); if (navigationKey == null) { if (contentType != null) { navigationKey = NavigationKey.contentType(contentType); } } else { if (keepCategory && navigationKey.isCategory()) { navigationKey = NavigationKey.category(navigationKey.getCategory(), contentType); } else if (keepTag && navigationKey.isTag()) { navigationKey = NavigationKey.tag(navigationKey.getTag(), contentType); } else if (contentType != null) { navigationKey = NavigationKey.contentType(contentType); } else { navigationKey = null; } } return ComponentResponse.OK; }
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; }
if (navigationKey != null && navigationKey.isCategory() && Objects.equal(c, navigationKey.getCategory())) { if (!keepContentKey) { contentKey = null;
private Category getSelected() { if (componentConfig != null && componentConfig.selected() != null) { return componentConfig.selected(); } else if (config != null && config.selected() != null) { return config.selected(); } if (config != null && config.decoupledSelection()) { final PageKey p = route.getPage(); if(p instanceof WithNavigation) { final NavigationKey navigationKey = ((WithNavigation)p).getNavigationKey(); if (navigationKey != null && navigationKey.isCategory()) { Category c = navigationKey.getCategory(); if (categories.containsValue(c)) { return c; } } } } return getCurrent(); }
protected MenuItem createItem(ContentType contentType) { final NavigationKey nk; if (config.navigation() && context.getNavigationKey() != null && context.getNavigationKey().isCategory()) { nk = NavigationKey.category(context.getNavigationKey().getCategory(), contentType); } else { nk = NavigationKey.contentType(contentType); } final PageKey pk = PageKey.navigation(nk); final Route r = (route != null) ? route.toPage(pk) : Route.of(false, pk, null, null); final URI uri = uriGenerator.getURI(r); final Name name = (locale != null) ? contentType.getName().get(locale) : contentType.getDefaultName(); final MenuItem item = new MenuItem(name.getDisplayName(), uri); return item; }