Search in sources :

Example 6 with BooleanFilter

use of com.enonic.xp.query.filter.BooleanFilter in project xp by enonic.

the class SetPublishInfoCommand method findNodesWithoutPublishFirstAndFrom.

private NodeIds findNodesWithoutPublishFirstAndFrom(final NodeIds nodesToPush) {
    if (nodesToPush.isEmpty()) {
        return NodeIds.empty();
    }
    final BooleanFilter containPublishFirstAndFromFilter = BooleanFilter.create().must(ExistsFilter.create().fieldName(ContentIndexPath.PUBLISH_FIRST.getPath()).build()).must(ExistsFilter.create().fieldName(ContentIndexPath.PUBLISH_FROM.getPath()).build()).build();
    final NodeQuery query = NodeQuery.create().addQueryFilter(BooleanFilter.create().mustNot(containPublishFirstAndFromFilter).must(IdFilter.create().fieldName(ContentIndexPath.ID.getPath()).values(nodesToPush).build()).build()).size(NodeQuery.ALL_RESULTS_SIZE_FLAG).build();
    final FindNodesByQueryResult result = this.nodeService.findByQuery(query);
    return result.getNodeIds();
}
Also used : BooleanFilter(com.enonic.xp.query.filter.BooleanFilter) FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) NodeQuery(com.enonic.xp.node.NodeQuery)

Aggregations

BooleanFilter (com.enonic.xp.query.filter.BooleanFilter)6 Filter (com.enonic.xp.query.filter.Filter)4 Filters (com.enonic.xp.query.filter.Filters)4 Test (org.junit.jupiter.api.Test)4 ExistsFilter (com.enonic.xp.query.filter.ExistsFilter)3 IdFilter (com.enonic.xp.query.filter.IdFilter)3 ValueFilter (com.enonic.xp.query.filter.ValueFilter)3 HashMap (java.util.HashMap)3 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)1 NodeQuery (com.enonic.xp.node.NodeQuery)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1