Search in sources :

Example 1 with CompositeItemFilter

use of org.craftercms.core.service.impl.CompositeItemFilter in project engine by craftercms.

the class SiteItemServiceImpl method getSiteTree.

@Deprecated
@Override
public SiteItem getSiteTree(String url, int depth, String includeByNameRegex, String excludeByNameRegex, Map<String, String> nodeXPathAndExpectedValuePairs) {
    CompositeItemFilter compositeFilter = new CompositeItemFilter();
    if (CollectionUtils.isNotEmpty(defaultFilters)) {
        for (ItemFilter defaultFilter : defaultFilters) {
            compositeFilter.addFilter(defaultFilter);
        }
    }
    if (StringUtils.isNotEmpty(includeByNameRegex)) {
        compositeFilter.addFilter(new IncludeByNameItemFilter(includeByNameRegex));
    }
    if (StringUtils.isNotEmpty(excludeByNameRegex)) {
        compositeFilter.addFilter(new ExcludeByNameItemFilter(excludeByNameRegex));
    }
    if (MapUtils.isNotEmpty(nodeXPathAndExpectedValuePairs)) {
        for (Map.Entry<String, String> pair : nodeXPathAndExpectedValuePairs.entrySet()) {
            compositeFilter.addFilter(new ExpectedNodeValueItemFilter(pair.getKey(), pair.getValue()));
        }
    }
    Tree tree = storeService.findTree(getSiteContext().getContext(), null, url, depth, compositeFilter, null);
    if (tree != null) {
        return createItemWrapper(tree);
    } else {
        return null;
    }
}
Also used : ExpectedNodeValueItemFilter(org.craftercms.engine.service.filter.ExpectedNodeValueItemFilter) CompositeItemFilter(org.craftercms.core.service.impl.CompositeItemFilter) IncludeByNameItemFilter(org.craftercms.engine.service.filter.IncludeByNameItemFilter) ExcludeByNameItemFilter(org.craftercms.engine.service.filter.ExcludeByNameItemFilter) ItemFilter(org.craftercms.core.service.ItemFilter) ExpectedNodeValueItemFilter(org.craftercms.engine.service.filter.ExpectedNodeValueItemFilter) ExcludeByNameItemFilter(org.craftercms.engine.service.filter.ExcludeByNameItemFilter) Tree(org.craftercms.core.service.Tree) CompositeItemFilter(org.craftercms.core.service.impl.CompositeItemFilter) IncludeByNameItemFilter(org.craftercms.engine.service.filter.IncludeByNameItemFilter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with CompositeItemFilter

use of org.craftercms.core.service.impl.CompositeItemFilter in project engine by craftercms.

the class SiteItemServiceImpl method getSiteTree.

@Override
public SiteItem getSiteTree(String url, int depth, ItemFilter filter, ItemProcessor processor) {
    if (CollectionUtils.isNotEmpty(defaultFilters)) {
        CompositeItemFilter compositeFilter = new CompositeItemFilter(new ArrayList<>(defaultFilters));
        if (filter != null) {
            compositeFilter.addFilter(filter);
        }
        filter = compositeFilter;
    }
    if (CollectionUtils.isNotEmpty(defaultProcessors)) {
        ItemProcessorPipeline processorPipeline = new ItemProcessorPipeline(new ArrayList<>(defaultProcessors));
        if (processor != null) {
            processorPipeline.addProcessor(processor);
        }
        processor = processorPipeline;
    }
    Tree tree = storeService.findTree(getSiteContext().getContext(), null, url, depth, filter, processor);
    if (tree != null) {
        return createItemWrapper(tree);
    } else {
        return null;
    }
}
Also used : ItemProcessorPipeline(org.craftercms.core.processors.impl.ItemProcessorPipeline) Tree(org.craftercms.core.service.Tree) CompositeItemFilter(org.craftercms.core.service.impl.CompositeItemFilter)

Aggregations

Tree (org.craftercms.core.service.Tree)2 CompositeItemFilter (org.craftercms.core.service.impl.CompositeItemFilter)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ItemProcessorPipeline (org.craftercms.core.processors.impl.ItemProcessorPipeline)1 ItemFilter (org.craftercms.core.service.ItemFilter)1 ExcludeByNameItemFilter (org.craftercms.engine.service.filter.ExcludeByNameItemFilter)1 ExpectedNodeValueItemFilter (org.craftercms.engine.service.filter.ExpectedNodeValueItemFilter)1 IncludeByNameItemFilter (org.craftercms.engine.service.filter.IncludeByNameItemFilter)1