Package org.apache.jackrabbit.commons.predicate

Examples of org.apache.jackrabbit.commons.predicate.Predicate


    /**
     * Filtering ignored properties from the given properties.
     */
    private Iterator<Property> filterProperties(Iterator<Property> properties) {
        return new FilterIterator<Property>(properties, new Predicate() {
            public boolean evaluate(Object object) {
                try {
                    Property p = (Property) object;
                    return !ignoredProperties.contains(p.getName());
                }
View Full Code Here


     * <code>iterator</code>.
     */
    private static <T extends Item> Iterator<T> filter(final Iterator<T> iterator,
            final InclusionPolicy<? super T> inclusionPolicy) {

        return new FilterIterator<T>(iterator, new Predicate() {
            @SuppressWarnings("unchecked")
            public boolean evaluate(Object object) {
                return inclusionPolicy.include((T) object);
            }
        });
View Full Code Here

        try {
            JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
                    session, reader, index.getContext().getItemStateManager());
            searcher.setSimilarity(index.getSimilarity());

            Predicate filter = Predicate.TRUE;
            BooleanQuery query = new BooleanQuery();

            QueryPair qp = new QueryPair(query);

            query.add(create(selector), MUST);
            if (constraint != null) {
                String name = selector.getSelectorName();
                NodeType type =
                    ntManager.getNodeType(selector.getNodeTypeName());
                filter = mapConstraintToQueryAndFilter(qp,
                        constraint, Collections.singletonMap(name, type),
                        searcher, reader);
            }

            List<Row> rows = new ArrayList<Row>();
            QueryHits hits = searcher.evaluate(qp.mainQuery);
            ScoreNode node = hits.nextScoreNode();
            while (node != null) {
                try {
                    Row row = new SelectorRow(
                            columns, evaluator, selector.getSelectorName(),
                            session.getNodeById(node.getNodeId()),
                            node.getScore());
                    if (filter.evaluate(row)) {
                        rows.add(row);
                    }
                } catch (ItemNotFoundException e) {
                    // skip the node
                }
View Full Code Here

    protected Predicate mapConstraintToQueryAndFilter(
            QueryPair query, Constraint constraint,
            Map<String, NodeType> selectorMap,
            JackrabbitIndexSearcher searcher, IndexReader reader)
            throws RepositoryException, IOException {
        Predicate filter = Predicate.TRUE;
        if (constraint instanceof And) {
            And and = (And) constraint;
            filter = mapConstraintToQueryAndFilter(
                    query, and.getConstraint1(), selectorMap, searcher, reader);
            Predicate other = mapConstraintToQueryAndFilter(
                    query, and.getConstraint2(), selectorMap, searcher, reader);
            if (filter == Predicate.TRUE) {
                filter = other;
            } else if (other != Predicate.TRUE) {
                filter = Predicates.and(filter, other);
View Full Code Here

        try {
            JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
                    session, reader, index.getContext().getItemStateManager());
            searcher.setSimilarity(index.getSimilarity());

            Predicate filter = Predicate.TRUE;
            BooleanQuery query = new BooleanQuery();

            QueryPair qp = new QueryPair(query);

            query.add(create(selector), MUST);
            if (constraint != null) {
                String name = selector.getSelectorName();
                NodeType type =
                    ntManager.getNodeType(selector.getNodeTypeName());
                filter = mapConstraintToQueryAndFilter(qp,
                        constraint, Collections.singletonMap(name, type),
                        searcher, reader);
            }

            List<Row> rows = new ArrayList<Row>();

            // TODO depending on the filters, we could push the offset info
            // into the searcher
            hits = searcher.evaluate(qp.mainQuery, sort, offset + limit);
            int currentNode = 0;
            int addedNodes = 0;

            ScoreNode node = hits.nextScoreNode();
            while (node != null) {
                Row row = null;
                try {
                    row = new SelectorRow(columns, evaluator,
                            selector.getSelectorName(),
                            session.getNodeById(node.getNodeId()),
                            node.getScore());
                } catch (ItemNotFoundException e) {
                    // skip the node
                }
                if (row != null && filter.evaluate(row)) {
                    if (externalSort) {
                        // return everything and not worry about sort
                        rows.add(row);
                    } else {
                        // apply limit and offset rules locally
View Full Code Here

    protected Predicate mapConstraintToQueryAndFilter(
            QueryPair query, Constraint constraint,
            Map<String, NodeType> selectorMap,
            JackrabbitIndexSearcher searcher, IndexReader reader)
            throws RepositoryException, IOException {
        Predicate filter = Predicate.TRUE;
        if (constraint instanceof And) {
            And and = (And) constraint;
            filter = mapConstraintToQueryAndFilter(
                    query, and.getConstraint1(), selectorMap, searcher, reader);
            Predicate other = mapConstraintToQueryAndFilter(
                    query, and.getConstraint2(), selectorMap, searcher, reader);
            if (filter == Predicate.TRUE) {
                filter = other;
            } else if (other != Predicate.TRUE) {
                filter = Predicates.and(filter, other);
View Full Code Here

     */
    public FilteredEventIterator(
            SessionImpl session, Iterator<?> eventStates,
            long timestamp, String userData,
            final EventFilter filter, final Set<?> denied) {
        super(new FilteredRangeIterator(eventStates, new Predicate() {
            public boolean evaluate(Object object) {
                try {
                    EventState state = (EventState) object;
                    return !denied.contains(state.getTargetId())
                        && !filter.blocks(state);
View Full Code Here

    /**
     * Filtering ignored properties from the given properties.
     */
    private Iterator<Property> filterProperties(Iterator<Property> properties) {
        return new FilterIterator<Property>(properties, new Predicate() {
            public boolean evaluate(Object object) {
                try {
                    Property p = (Property) object;
                    return !ignoredProperties.contains(p.getName());
                }
View Full Code Here

        try {
            JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
                    session, reader, index.getContext().getItemStateManager());
            searcher.setSimilarity(index.getSimilarity());

            Predicate filter = Predicate.TRUE;
            BooleanQuery query = new BooleanQuery();

            QueryPair qp = new QueryPair(query);

            query.add(create(selector), MUST);
            if (constraint != null) {
                String name = selector.getSelectorName();
                NodeType type =
                    ntManager.getNodeType(selector.getNodeTypeName());
                filter = mapConstraintToQueryAndFilter(qp,
                        constraint, Collections.singletonMap(name, type),
                        searcher, reader);
            }


            // Added by jahia
            Set<String> foundIds = new HashSet<String>();
            List<ScoreNode> nodes = new ArrayList<ScoreNode>();
            // End

            List<Row> rows = new ArrayList<Row>();
            QueryHits hits = searcher.evaluate(qp.mainQuery);
            ScoreNode node = hits.nextScoreNode();
            while (node != null) {
                if (foundIds.add(getId(node, reader))) {  // <-- Added by jahia
                    try {
                        NodeImpl objectNode = session.getNodeById(node.getNodeId());
                        if (objectNode.isNodeType("jnt:translation")) {
                            objectNode = (NodeImpl) objectNode.getParent();
                        }
                        Row row = new SelectorRow(
                                columns, evaluator, selector.getSelectorName(),
                                provider.getNodeWrapper(objectNode, jcrSession),
                                node.getScore());
                        if (filter.evaluate(row)) {
                            rows.add(row);
                            nodes.add(node); // <-- Added by jahia
                        }
                    } catch (PathNotFoundException e) {
                    } catch (ItemNotFoundException e) {
View Full Code Here

        try {
            JackrabbitIndexSearcher searcher = new JackrabbitIndexSearcher(
                    session, reader, index.getContext().getItemStateManager());
            searcher.setSimilarity(index.getSimilarity());

            Predicate filter = Predicate.TRUE;
            BooleanQuery query = new BooleanQuery();

            QueryPair qp = new QueryPair(query);

            query.add(create(selector), MUST);
            if (constraint != null) {
                String name = selector.getSelectorName();
                NodeType type =
                    ntManager.getNodeType(selector.getNodeTypeName());
                filter = mapConstraintToQueryAndFilter(qp,
                        constraint, Collections.singletonMap(name, type),
                        searcher, reader);
            }

            List<Row> rows = new ArrayList<Row>();
            hits = searcher.evaluate(qp.mainQuery);
            ScoreNode node = hits.nextScoreNode();
            while (node != null) {
                try {
                    Row row = new SelectorRow(
                            columns, evaluator, selector.getSelectorName(),
                            session.getNodeById(node.getNodeId()),
                            node.getScore());
                    if (filter.evaluate(row)) {
                        rows.add(row);
                    }
                } catch (ItemNotFoundException e) {
                    // skip the node
                }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.commons.predicate.Predicate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.