/** * Ancestors for a page is a list of same ROOT node with different children. * Basically, these different ROOTs (with same ID, because we are still within one taxonomy) contain * different children for different paths your page may be in. * <p>Unless other methods for descendants, this method returns {@link List} because the root Taxonomies will be the same object * even if page is in multiple places.</p> * * @param uris URIs of your current context taxonomy node * @param requestDto current request data * @return a list of roots of taxonomy with different paths for items */ @NotNull private List<SitemapItemModelData> collectAncestorsForPage(@NotNull TaxonomyUrisHolder uris, @NotNull SitemapRequestDto requestDto) { if (!uris.isPage()) { throw new IllegalArgumentException(String.format("Method for pages was called for not a page! uris: %s, request: %s", uris, requestDto)); } TaxonomyFilter depthFilter = new DepthFilter(DepthFilter.UNLIMITED_DEPTH, DepthFilter.FILTER_UP); Keyword[] keywords = getRelationTaxonomyKeywords(uris, depthFilter); if (keywords == null || keywords.length == 0) { log.debug("Page {} is not classified in taxonomy {}", uris.getPageUri(), uris.getTaxonomyUri()); return Collections.emptyList(); } return Arrays.stream(keywords) .map(keyword -> createTaxonomyNode(keyword, requestDto.toBuilder().expandLevels(DepthCounter.UNLIMITED_DEPTH).build())) .collect(Collectors.toList()); }
public synchronized SitemapRequestDto nextExpandLevel() { return this.toBuilder().expandLevels(new DepthCounter(expandLevels.getCounter() - 1)).build(); }
/** * One single ancestor for a given keyword. Although same keyword may be in few places, we don't expect it due to * technical limitation in CME. So basically we ignore the fact that keyword may be in many places (like page) and * expect only a single entry. Because of that we have only one taxonomy root for Keyword's ancestors. * * @param uris URIs of your current context taxonomy node * @param requestDto current request data * @return root of a taxonomy */ @NotNull private Optional<SitemapItemModelData> expandAncestorsForKeyword(TaxonomyUrisHolder uris, SitemapRequestDto requestDto) { if (!uris.isKeyword()) { throw new IllegalArgumentException(String.format("Method for keywords was called for not a keyword! uris: %s, request: %s", uris, requestDto)); } TaxonomyFilter depthFilter = new DepthFilter(DepthFilter.UNLIMITED_DEPTH, DepthFilter.FILTER_UP); Keyword taxonomyRoot = taxonomyFactory.getTaxonomyKeywords(uris.getTaxonomyUri(), depthFilter, uris.getKeywordUri()); if (taxonomyRoot == null) { log.warn("Keyword {} in taxonomy {} wasn't found", uris.getKeywordUri(), uris.getTaxonomyUri()); return Optional.empty(); } return Optional.of(createTaxonomyNode(taxonomyRoot, requestDto.toBuilder().expandLevels(DepthCounter.UNLIMITED_DEPTH).build())); }
log.trace("Original sitemapRequestDto {}", requestDto); SitemapRequestDto request = requestDto.toBuilder() .expandLevels(new DepthCounter(requestDto.getNavigationFilter().getDescendantLevels())) .build();