Package org.apache.commons.collections.iterators

Examples of org.apache.commons.collections.iterators.AbstractIteratorDecorator


            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        ChildNodeEntry cne =
                                (ChildNodeEntry) super.next();
                        try {
View Full Code Here


     * @throws IOException         if an error occurs while updating the index.
     */
    public void updateNodes(NodeIdIterator remove, NodeStateIterator add)
            throws RepositoryException, IOException {
        checkOpen();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                return ((NodeId) super.next()).getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
View Full Code Here

            throws RepositoryException, IOException {
        checkOpen();
        final Map aggregateRoots = new HashMap();
        final Set removedNodeIds = new HashSet();
        final Set addedNodeIds = new HashSet();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId nodeId = (NodeId) super.next();
                removedNodeIds.add(nodeId);
                return nodeId.getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
                addedNodeIds.add(state.getNodeId());
                removedNodeIds.remove(state.getNodeId());
                Document doc = null;
                try {
                    doc = createDocument(state, getNamespaceMappings(),
                            index.getIndexFormatVersion());
                    retrieveAggregateRoot(state, aggregateRoots);
                } catch (RepositoryException e) {
                    log.warn("Exception while creating document for node: "
                            + state.getNodeId() + ": " + e.toString());
                }
                return doc;
            }
        });

        // remove any aggregateRoot nodes that are new
        // and therefore already up-to-date
        aggregateRoots.keySet().removeAll(addedNodeIds);

        // based on removed NodeIds get affected aggregate root nodes
        retrieveAggregateRoot(removedNodeIds, aggregateRoots);

        // update aggregates if there are any affected
        if (aggregateRoots.size() > 0) {
            index.update(new AbstractIteratorDecorator(
                    aggregateRoots.keySet().iterator()) {
                public Object next() {
                    return ((NodeId) super.next()).getUUID();
                }
            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                public Object next() {
                    NodeState state = (NodeState) super.next();
                    try {
                        return createDocument(state, getNamespaceMappings(),
                                index.getIndexFormatVersion());
View Full Code Here

            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        NodeState.ChildNodeEntry cne =
                                (NodeState.ChildNodeEntry) super.next();
                        try {
View Full Code Here

            // get iterator along specified axis
            Iterator nodeStates;
            if (axis == SELF) {
                nodeStates = Collections.singletonList(context).iterator();
            } else if (axis == CHILD) {
                nodeStates = new AbstractIteratorDecorator(
                        context.getChildNodeEntries().iterator()) {
                    public Object next() {
                        NodeState.ChildNodeEntry cne =
                                (NodeState.ChildNodeEntry) super.next();
                        try {
View Full Code Here

            throws RepositoryException, IOException {
        checkOpen();
        final Map aggregateRoots = new HashMap();
        final Set removedNodeIds = new HashSet();
        final Set addedNodeIds = new HashSet();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId nodeId = (NodeId) super.next();
                removedNodeIds.add(nodeId);
                return nodeId.getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
                addedNodeIds.add(state.getNodeId());
                removedNodeIds.remove(state.getNodeId());
                Document doc = null;
                try {
                    doc = createDocument(state, getNamespaceMappings(),
                            index.getIndexFormatVersion());
                    retrieveAggregateRoot(state, aggregateRoots);
                } catch (RepositoryException e) {
                    log.warn("Exception while creating document for node: "
                            + state.getNodeId() + ": " + e.toString());
                }
                return doc;
            }
        });

        // remove any aggregateRoot nodes that are new
        // and therefore already up-to-date
        aggregateRoots.keySet().removeAll(addedNodeIds);

        // based on removed NodeIds get affected aggregate root nodes
        retrieveAggregateRoot(removedNodeIds, aggregateRoots);

        // update aggregates if there are any affected
        if (aggregateRoots.size() > 0) {
            index.update(new AbstractIteratorDecorator(
                    aggregateRoots.keySet().iterator()) {
                public Object next() {
                    return ((NodeId) super.next()).getUUID();
                }
            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                public Object next() {
                    NodeState state = (NodeState) super.next();
                    try {
                        return createDocument(state, getNamespaceMappings(),
                                index.getIndexFormatVersion());
View Full Code Here

      final Map<String, NodeData> aggregateRoots = new HashMap<String, NodeData>();
      final Set<String> removedNodeIds = new HashSet<String>();
      final Set<String> addedNodeIds = new HashSet<String>();

      index.update(new AbstractIteratorDecorator(remove)
      {
         public Object next()
         {
            String nodeId = (String)super.next();
            removedNodeIds.add(nodeId);
            return nodeId;
         }
      }, new AbstractIteratorDecorator(add)
      {
         public Object next()
         {
            NodeData state = (NodeData)super.next();
            if (state == null)
            {
               return null;
            }
            addedNodeIds.add(state.getIdentifier());
            removedNodeIds.remove(state.getIdentifier());
            Document doc = null;
            try
            {
               doc = createDocument(state, getNamespaceMappings(), index.getIndexFormatVersion());
               retrieveAggregateRoot(state, aggregateRoots);
            }
            catch (RepositoryException e)
            {
               log
                  .warn("Exception while creating document for node: " + state.getIdentifier() + ": " + e.toString(), e);

            }
            return doc;
         }
      });

      // remove any aggregateRoot nodes that are new
      // and therefore already up-to-date
      aggregateRoots.keySet().removeAll(addedNodeIds);

      // based on removed NodeIds get affected aggregate root nodes
      retrieveAggregateRoot(removedNodeIds, aggregateRoots);

      // update aggregates if there are any affected
      if (aggregateRoots.size() > 0)
      {
         index.update(new AbstractIteratorDecorator(aggregateRoots.keySet().iterator())
         {
            public Object next()
            {
               return super.next();
            }
         }, new AbstractIteratorDecorator(aggregateRoots.values().iterator())
         {
            public Object next()
            {
               NodeData state = (NodeData)super.next();
               try
View Full Code Here

            throws RepositoryException, IOException {
        checkOpen();
        final Map aggregateRoots = new HashMap();
        final Set removedNodeIds = new HashSet();
        final Set addedNodeIds = new HashSet();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId nodeId = (NodeId) super.next();
                removedNodeIds.add(nodeId);
                return nodeId.getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
                addedNodeIds.add(state.getNodeId());
                removedNodeIds.remove(state.getNodeId());
                Document doc = null;
                try {
                    doc = createDocument(state, getNamespaceMappings(),
                            index.getIndexFormatVersion());
                    retrieveAggregateRoot(state, aggregateRoots);
                } catch (RepositoryException e) {
                    log.warn("Exception while creating document for node: "
                            + state.getNodeId() + ": " + e.toString());
                }
                return doc;
            }
        });

        // remove any aggregateRoot nodes that are new
        // and therefore already up-to-date
        aggregateRoots.keySet().removeAll(addedNodeIds);

        // based on removed NodeIds get affected aggregate root nodes
        retrieveAggregateRoot(removedNodeIds, aggregateRoots);

        // update aggregates if there are any affected
        if (aggregateRoots.size() > 0) {
            index.update(new AbstractIteratorDecorator(
                    aggregateRoots.keySet().iterator()) {
                public Object next() {
                    return ((NodeId) super.next()).getUUID();
                }
            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                public Object next() {
                    NodeState state = (NodeState) super.next();
                    try {
                        return createDocument(state, getNamespaceMappings(),
                                index.getIndexFormatVersion());
View Full Code Here

     * @throws IOException         if an error occurs while updating the index.
     */
    public void updateNodes(NodeIdIterator remove, NodeStateIterator add)
            throws RepositoryException, IOException {
        checkOpen();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId id = (NodeId) super.next();
                return new Term(FieldNames.UUID, id.getUUID().toString());
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
View Full Code Here

            throws RepositoryException, IOException {
        checkOpen();
        final Map aggregateRoots = new HashMap();
        final Set removedNodeIds = new HashSet();
        final Set addedNodeIds = new HashSet();
        index.update(new AbstractIteratorDecorator(remove) {
            public Object next() {
                NodeId nodeId = (NodeId) super.next();
                removedNodeIds.add(nodeId);
                return nodeId.getUUID();
            }
        }, new AbstractIteratorDecorator(add) {
            public Object next() {
                NodeState state = (NodeState) super.next();
                if (state == null) {
                    return null;
                }
                addedNodeIds.add(state.getNodeId());
                removedNodeIds.remove(state.getNodeId());
                Document doc = null;
                try {
                    doc = createDocument(state, getNamespaceMappings(),
                            index.getIndexFormatVersion());
                    retrieveAggregateRoot(state, aggregateRoots);
                } catch (RepositoryException e) {
                    log.warn("Exception while creating document for node: "
                            + state.getNodeId() + ": " + e.toString());
                }
                return doc;
            }
        });

        // remove any aggregateRoot nodes that are new
        // and therefore already up-to-date
        aggregateRoots.keySet().removeAll(addedNodeIds);

        // based on removed NodeIds get affected aggregate root nodes
        retrieveAggregateRoot(removedNodeIds, aggregateRoots);

        // update aggregates if there are any affected
        if (aggregateRoots.size() > 0) {
            index.update(new AbstractIteratorDecorator(
                    aggregateRoots.keySet().iterator()) {
                public Object next() {
                    return ((NodeId) super.next()).getUUID();
                }
            }, new AbstractIteratorDecorator(aggregateRoots.values().iterator()) {
                public Object next() {
                    NodeState state = (NodeState) super.next();
                    try {
                        return createDocument(state, getNamespaceMappings(),
                                index.getIndexFormatVersion());
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.iterators.AbstractIteratorDecorator

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.