use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationImpl method getItems.
private List<NavigationItem> getItems(Page root) {
List<NavigationItem> pages = new ArrayList<>();
if (root.getDepth() < structureDepth) {
Iterator<Page> it = root.listChildren(new PageFilter());
while (it.hasNext()) {
Page page = it.next();
boolean active = currentPage.getPath().equals(page.getPath()) || currentPage.getPath().startsWith(page.getPath() + "/");
String title = page.getNavigationTitle();
if (title == null) {
title = page.getTitle();
}
List<NavigationItem> children = getItems(page);
int level = page.getDepth() - startLevel;
Page localizedPage = getLocalizedPage(currentPage, page);
if (localizedPage != null) {
page = localizedPage;
}
boolean current = currentPage.getPath().equals(page.getPath());
pages.add(newLanguageNavigationItem(page, active, current, linkHandler, level, children, title, getId(), component));
}
}
return pages;
}
use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImpl method createItems.
private List<NavigationItem> createItems() {
List<NavigationItem> items = new ArrayList<>();
int currentLevel = currentPage.getDepth();
while (startLevel < currentLevel) {
Page page = currentPage.getAbsoluteParent(startLevel);
if (page != null && page.getContentResource() != null) {
boolean isActivePage = page.equals(currentPage);
if (isActivePage && hideCurrent) {
break;
}
if (checkIfNotHidden(page)) {
NavigationItem navigationItem = newBreadcrumbItem(page, isActivePage, linkHandler, currentLevel, Collections.emptyList(), getId(), component);
items.add(navigationItem);
}
}
startLevel++;
}
return items;
}
use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class BreadcrumbImplTest method checkBreadcrumbConsistency.
protected void checkBreadcrumbConsistency(Breadcrumb breadcrumb, String[] expectedPages) {
assertEquals(breadcrumb.getItems().size(), expectedPages.length, "Expected that the returned breadcrumb will contain " + expectedPages.length + " items");
int index = 0;
for (NavigationItem item : breadcrumb.getItems()) {
assertEquals(expectedPages[index++], item.getTitle());
}
}
use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class NavigationImplTest method verifyNavigationItems.
protected void verifyNavigationItems(Object[][] expectedPages, List<NavigationItem> items) {
assertEquals(expectedPages.length, items.size(), "The navigation tree contains a different number of pages than expected.");
int index = 0;
for (NavigationItem item : items) {
assertEquals(expectedPages[index][0], item.getPath(), "The navigation tree doesn't seem to have the correct order.");
assertEquals(expectedPages[index][1], item.getLevel(), "The navigation item's level is not what was expected: " + item.getPath());
assertEquals(expectedPages[index][2], item.isActive(), "The navigation item's active state is not what was expected: " + item.getPath());
String expectedURL = expectedPages[index][3].toString();
if (!expectedURL.startsWith("http")) {
expectedURL = CONTEXT_PATH + expectedURL;
}
assertEquals(expectedURL, item.getURL(), "The navigation item's URL is not what was expected: " + item.getPath());
verifyNavigationItem(expectedPages[index], item);
index++;
}
}
use of com.adobe.cq.wcm.core.components.models.NavigationItem in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class LanguageNavigationImplTest method testLanguageNavigationItems.
@Test
protected void testLanguageNavigationItems() {
LanguageNavigation languageNavigation = getLanguageNavigationUnderTest(NAVIGATION_ROOT + "/LOCALE-1/LOCALE-5/about/jcr:content/root/languagenavigation-component-1");
List<NavigationItem> items = getLanguageNavigationItems(languageNavigation);
verifyLanguageNavigationItems(EXPECTED_PAGES_DEPTH_1, items);
Utils.testJSONExport(languageNavigation, Utils.getTestExporterJSONPath(testBase, "languagenavigation1"));
}
Aggregations