private NavigationElementTree convert(NavigationElement navigationElement) { NavigationElementTree navigationElementTree = new NavigationElementTree(); String name = navigationElement.getName(); if (navigationElement.getTextResourceVersion() != null) { name = navigationElement.getTextResourceVersion().getText(); } navigationElementTree.setName(name); navigationElementTree.setUrlPath(navigationElement.getUrlPath()); navigationElementTree.setPageUrl(navigationElement.getPageUrl()); navigationElementTree.setElementType(navigationElement.getElementType()); navigationElementTree.setPath(navigationElement.getPath()); navigationElementTree.setLookup(navigationElement.getLookup()); navigationElementTree.setSortPosition(navigationElement.getSortPosition()); navigationElementTree.setChildren(new ArrayList<NavigationElementTree>()); navigationElementTree.setAllowDrag(false); navigationElementTree.setAllowDrop(false); navigationElementTree.setExpandable(true); navigationElementTree.setExpanded(false); navigationElementTree.setHidden( navigationElement.getHidden() != null && navigationElement.getHidden()); return navigationElementTree; }
private void buildTree( NavigationElementTree parentNavigationElementTree, NavigationElement parent, List<NavigationElement> navigationElementList, boolean lazyLoadResource) { List<NavigationElementTree> children = parentNavigationElementTree.getChildren(); for (NavigationElement navigationElement : navigationElementList) { if (parent.getLookup().endsWith(navigationElement.getPath())) { OpenFlamePrincipal principal = OPFContext.getContext().getPrincipal(); if (principal.checkUserPermission(navigationElement)) { if (!lazyLoadResource) { initResourceContents(navigationElement); } NavigationElementTree navigationElementTree = convert(navigationElement); children.add(navigationElementTree); buildTree( navigationElementTree, navigationElement, navigationElementList, lazyLoadResource); } } } Collections.sort(children, NavigationElementTree.SORT_POSITION); }