Search in sources :

Example 1 with ExcludeEntry

use of com.enonic.xp.repo.impl.version.search.ExcludeEntry in project xp by enonic.

the class DiffQueryFactory method wrapInPathQueryIfNecessary.

private FilteredQueryBuilder wrapInPathQueryIfNecessary(final BoolQueryBuilder sourceTargetCompares) {
    final BoolQueryBuilder pathFilter = new BoolQueryBuilder();
    boolean addedPathFilter = false;
    if (this.nodePath != null && !this.nodePath.isRoot()) {
        addedPathFilter = true;
        pathFilter.must(hasPath(this.nodePath, true));
    }
    if (!this.excludes.isEmpty()) {
        addedPathFilter = true;
        for (final ExcludeEntry exclude : excludes) {
            pathFilter.mustNot(hasPath(exclude.getNodePath(), exclude.isRecursive()));
        }
    }
    return addedPathFilter ? new FilteredQueryBuilder(pathFilter, sourceTargetCompares) : new FilteredQueryBuilder(QueryBuilders.matchAllQuery(), sourceTargetCompares);
}
Also used : BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) ExcludeEntry(com.enonic.xp.repo.impl.version.search.ExcludeEntry) FilteredQueryBuilder(org.elasticsearch.index.query.FilteredQueryBuilder)

Example 2 with ExcludeEntry

use of com.enonic.xp.repo.impl.version.search.ExcludeEntry in project xp by enonic.

the class FindNodesWithVersionDifferenceCommand method getExcludePaths.

private ExcludeEntries getExcludePaths(final InternalContext context) {
    if (this.excludes.isEmpty()) {
        return ExcludeEntries.empty();
    }
    final ExcludeEntries.Builder builder = ExcludeEntries.create();
    final NodeBranchEntries result = this.nodeStorageService.getBranchNodeVersions(excludes, false, context);
    for (final NodeBranchEntry entry : result) {
        builder.add(new ExcludeEntry(entry.getNodePath(), false));
    }
    return builder.build();
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) ExcludeEntry(com.enonic.xp.repo.impl.version.search.ExcludeEntry) ExcludeEntries(com.enonic.xp.repo.impl.version.search.ExcludeEntries) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 3 with ExcludeEntry

use of com.enonic.xp.repo.impl.version.search.ExcludeEntry in project xp by enonic.

the class HasUnpublishedChildrenCommand method execute.

public boolean execute() {
    final Node parentNode = doGetById(parent);
    if (parentNode == null) {
        return false;
    }
    final SearchResult result = nodeSearchService.query(NodeVersionDiffQuery.create().source(ContextAccessor.current().getBranch()).target(target).nodePath(parentNode.path()).size(0).excludes(ExcludeEntries.create().add(new ExcludeEntry(parentNode.path(), false)).build()).build(), SingleRepoStorageSource.create(ContextAccessor.current().getRepositoryId(), SingleRepoStorageSource.Type.VERSION));
    return result.getTotalHits() > 0;
}
Also used : ExcludeEntry(com.enonic.xp.repo.impl.version.search.ExcludeEntry) Node(com.enonic.xp.node.Node) SearchResult(com.enonic.xp.repo.impl.search.result.SearchResult)

Aggregations

ExcludeEntry (com.enonic.xp.repo.impl.version.search.ExcludeEntry)3 Node (com.enonic.xp.node.Node)1 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)1 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)1 SearchResult (com.enonic.xp.repo.impl.search.result.SearchResult)1 ExcludeEntries (com.enonic.xp.repo.impl.version.search.ExcludeEntries)1 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)1 FilteredQueryBuilder (org.elasticsearch.index.query.FilteredQueryBuilder)1