public PageRequestDtoBuilder expansionDepth(int expansionDepth) { Assert.isTrue(expansionDepth > 0, "Expansion depth should be a positive number"); depthCounter(new DepthCounter(expansionDepth)); this.expansionDepth = expansionDepth; return this; }
public synchronized boolean depthIncreaseAndCheckIfSafe() { return isNotTooDeep() && counter-- > 0; }
public synchronized SitemapRequestDto nextExpandLevel() { return this.toBuilder().expandLevels(new DepthCounter(expandLevels.getCounter() - 1)).build(); }
@Override public Collection<SitemapItem> getNavigationSubtree(@Nullable String sitemapItemId, @NonNull NavigationFilter navigationFilter, @NonNull Localization localization) { Optional<Collection<SitemapItemModelData>> subtree; SitemapRequestDto requestDto = SitemapRequestDto .builder(Integer.parseInt(localization.getId())) .navigationFilter(navigationFilter) .expandLevels(new DepthCounter(navigationFilter.getDescendantLevels())) .sitemapId(sitemapItemId) .build(); subtree = onDemandNavigationModelProvider.getNavigationSubtree(requestDto); if (!subtree.isPresent()) { log.debug("Nothing found for the given request {}", requestDto); return Collections.emptyList(); } return subtree.get().stream() .map(this::_convert) .collect(Collectors.toList()); }
private TaxonomyNodeModelData createTaxonomyNode(@NotNull Keyword keyword, @NotNull SitemapRequestDto requestDto) { log.debug("Creating taxonomy node for keyword {} and request {}", keyword.getTaxonomyURI(), requestDto); String taxonomyId = String.valueOf(TcmUtils.getItemId(keyword.getTaxonomyURI())); String taxonomyNodeUrl = null; List<SitemapItemModelData> children = new ArrayList<>(); if (requestDto.getExpandLevels().isNotTooDeep()) { keyword.getKeywordChildren().forEach(child -> children.add(createTaxonomyNode(child, requestDto.nextExpandLevel()))); if (keyword.getReferencedContentCount() > 0 && requestDto.getNavigationFilter().getDescendantLevels() != 0) { List<SitemapItemModelData> pageSitemapItems = getChildrenPages(keyword, taxonomyId, requestDto); taxonomyNodeUrl = findIndexPageUrl(pageSitemapItems).orElse(null); log.trace("taxonomyNodeUrl = {}", taxonomyNodeUrl); children.addAll(pageSitemapItems); } } children.forEach(child -> child.setTitle(removeSequenceFromPageTitle(child.getTitle()))); return createTaxonomyNodeFromKeyword(keyword, taxonomyId, taxonomyNodeUrl, new TreeSet<>(children)); }
.expandLevels(new DepthCounter(requestDto.getNavigationFilter().getDescendantLevels())) .build();