Examples of ItemVisitor


Examples of com.vividsolutions.jts.index.ItemVisitor

  public boolean snap(HotPixel hotPixel, SegmentString parentEdge, int hotPixelVertexIndex)
  {
    final Envelope pixelEnv = hotPixel.getSafeEnvelope();
    final HotPixelSnapAction hotPixelSnapAction = new HotPixelSnapAction(hotPixel, parentEdge, hotPixelVertexIndex);

    index.query(pixelEnv, new ItemVisitor() {
      public void visitItem(Object item) {
        MonotoneChain testChain = (MonotoneChain) item;
        testChain.select(pixelEnv, hotPixelSnapAction);
      }
    }
View Full Code Here

Examples of com.vividsolutions.jts.index.ItemVisitor

                Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
        final ProgressListener progress = listener != null ? listener : new NullProgressListener();
        progress.started();
        final float size = (float) size();
        final IOException problem[] = new IOException[1];
        index.query(everything, new ItemVisitor() {
            float count = 0f;

            public void visitItem(Object item) {
                SimpleFeature feature = null;
                try {
View Full Code Here

Examples of javax.jcr.ItemVisitor

                throw new RepositoryException(e);
            }
            return Collections.singletonList(info).iterator();
        } else {
            final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                @Override
                protected void entering(Property property, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                @Override
                protected void entering(Node node, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                @Override
                protected void leaving(Property property, int i) {
                    // nothing to do
                }
                @Override
                protected void leaving(Node node, int i) {
                    // nothing to do
                }
            };
            visitor.visit(node);
            return itemInfos.iterator();
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

        altimaModel = cache.findJcrProperty(altima.nodeId, altima.path(), Vehicles.Lexicon.MODEL);
    }

    @Test
    public void shouldAllowVisitation() throws Exception {
        ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
        altimaModel.accept(visitor);
        Mockito.verify(visitor).visit(altimaModel);
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

     * Visitors
     */

    @Test
    public void shouldAllowVisitation() throws Exception {
        ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
        hybrid.accept(visitor);
        Mockito.verify(visitor).visit(hybrid);
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

            }
        } else {
            // workaround for failure of Node#getWeakReferences
            // traverse the tree below groups-path and collect membership manually.
            log.info("Traversing groups tree to collect membership.");
            ItemVisitor visitor = new TraversingItemVisitor.Default() {
                @Override
                protected void entering(Property property, int level) throws RepositoryException {
                    PropertyImpl pImpl = (PropertyImpl) property;
                    NodeImpl n = (NodeImpl) pImpl.getParent();
                    if (P_MEMBERS.equals(pImpl.getQName()) && n.isNodeType(NT_REP_GROUP)) {
                        for (Value value : property.getValues()) {
                            if (value.getString().equals(node.getIdentifier())) {
                                Group gr = (Group) userManager.getAuthorizable(n);
                                groups.add(gr);
                            }
                        }
                    }
                }
            };
            Node groupsNode = getSession().getNode(userManager.getGroupsPath());
            visitor.visit(groupsNode);
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

                throw new RepositoryException(e);
            }
            return Collections.singletonList(info).iterator();
        } else {
            final List<ItemInfo> itemInfos = new ArrayList<ItemInfo>();
            ItemVisitor visitor = new TraversingItemVisitor(false, depth) {
                @Override
                protected void entering(Property property, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new PropertyInfoImpl(property, idFactory, sInfo.getNamePathResolver(), getQValueFactory()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                @Override
                protected void entering(Node node, int i) throws RepositoryException {
                    try {
                        itemInfos.add(new NodeInfoImpl(node, idFactory, sInfo.getNamePathResolver()));
                    } catch (NameException e) {
                        throw new RepositoryException(e);
                    }
                }
                @Override
                protected void leaving(Property property, int i) {
                    // nothing to do
                }
                @Override
                protected void leaving(Node node, int i) {
                    // nothing to do
                }
            };
            visitor.visit(node);
            return itemInfos.iterator();
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

            testRoot = rn.getNode(name);
        }
        System.out.println("Import deep tree: " + (System.currentTimeMillis()-start));

        final List<String> paths = new ArrayList<String>();
        ItemVisitor v = new TraversingItemVisitor.Default() {
            @Override
            protected void entering(Node node, int i) throws RepositoryException {
                paths.add(node.getPath());
                super.entering(node, i);
            }
            @Override
            protected void entering(Property prop, int i) throws RepositoryException {
                paths.add(prop.getPath());
                super.entering(prop, i);
            }
        };
        v.visit(testRoot);
        allPaths = paths;

        System.out.println("All paths: " + allPaths.size());
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

    @Override
    protected void beforeSuite() throws Exception {
        super.beforeSuite();

        ItemVisitor visitor = new TraversingItemVisitor.Default() {
            int counter = 0;
            @Override
            protected void entering(Node node, int level) throws RepositoryException {
                if (++counter == 10) {
                    addPolicy(node);
                    counter = 0;
                }
                super.entering(node, level);
            }

            private void addPolicy(Node node) throws RepositoryException {
                AccessControlManager acMgr = node.getSession().getAccessControlManager();
                String path = node.getPath();
                int level = 0;
                if (node.isNodeType(AccessControlConstants.NT_REP_POLICY)) {
                    level = 1;
                } else if (node.isNodeType(AccessControlConstants.NT_REP_ACE)) {
                    level = 2;
                } else if (node.isNodeType(AccessControlConstants.NT_REP_RESTRICTIONS)) {
                    level = 3;
                }
                if (level > 0) {
                    path = Text.getRelativeParent(path, level);
                }
                AccessControlPolicyIterator acIterator = acMgr.getApplicablePolicies(path);
                if (acIterator.hasNext()) {
                    AccessControlPolicy policy = acIterator.nextAccessControlPolicy();
                    if (policy instanceof AccessControlList) {
                        AccessControlList acl = (AccessControlList) policy;
                        Privilege[] privileges = new Privilege[] {
                                acMgr.privilegeFromName(Privilege.JCR_READ),
                                acMgr.privilegeFromName(Privilege.JCR_READ_ACCESS_CONTROL)
                        };
                        if (acl.addAccessControlEntry(EveryonePrincipal.getInstance(), privileges)) {
                            acMgr.setPolicy(path, acl);
                            node.getSession().save();
                        }
                    }
                }
            }
        };

        visitor.visit(testRoot);

        for (int i = 0; i < bgReaders; i++) {
            addBackgroundJob(new RandomRead(getTestSession()));
        }
    }
View Full Code Here

Examples of javax.jcr.ItemVisitor

     *
     */
    public void testAccept() throws RepositoryException {
        final Node n = testRootNode;

        ItemVisitor itemVisitor = new ItemVisitor() {
            public void visit(Property property) {
                fail("Wrong accept method executed.");
            }

            public void visit(Node node) throws RepositoryException {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.