Package org.modeshape.jcr.cache

Examples of org.modeshape.jcr.cache.ChildReferences$Context


        // Check the properties ...
        assertThat(node.getProperty(JcrLexicon.UUID, cache).getFirstValue().toString(), is(node.getKey().getIdentifier()));
        assertThat(node.getProperty(JcrLexicon.PRIMARY_TYPE, cache).getFirstValue(), is((Object)ModeShapeLexicon.ROOT));

        // Check the child references ...
        ChildReferences refs = node.getChildReferences(cache);
        assertThat(refs, is(notNullValue()));
        assertThat(refs.size(), is(3L));
        Iterator<ChildReference> iter = refs.iterator();

        ChildReference system = refs.getChild(JcrLexicon.SYSTEM);
        ChildReference childA = refs.getChild(name("childA"));
        ChildReference childB = refs.getChild(name("childB"));

        assertThat(system.getKey().toString(), is("source1system-jcrsystem"));
        assertThat(childA.getKey().toString(), is("source1works1-childA"));
        assertThat(childB.getKey().toString(), is("source1works1-childB"));
View Full Code Here


        assertThat(system.getProperty(JcrLexicon.UUID, cache).getFirstValue().toString(),
                   is("56b3feae-3def-44f7-a433-586413f312e4"));
        assertThat(system.getProperty(JcrLexicon.PRIMARY_TYPE, cache).getFirstValue(), is((Object)ModeShapeLexicon.SYSTEM));

        // Check the child references ...
        ChildReferences refs = system.getChildReferences(cache);
        assertThat(refs, is(notNullValue()));
        assertThat(refs.size(), is(1L));
        Iterator<ChildReference> iter = refs.iterator();

        ChildReference namespaces = refs.getChild(ModeShapeLexicon.NAMESPACES);
        assertThat(namespaces.getKey().toString(), is("source1system-jcrnamespaces"));
        assertThat(namespaces.getName(), is(ModeShapeLexicon.NAMESPACES));

        assertThat(iter.next(), is(namespaces));
        assertThat(iter.hasNext(), is(false));
View Full Code Here

    @Test
    public void shouldLoadChildrenReferencesWhenBackedByMultipleBlocks() {
        CachedNode root = cache.getNode(cache.getRootKey());
        CachedNode childB = cache.getNode(root.getChildReferences(cache).getChild(name("childB")));

        ChildReferences refs = childB.getChildReferences(cache);
        assertThat(refs, is(notNullValue()));
        assertThat(refs.size(), is(2L));
        Iterator<ChildReference> iter = refs.iterator();

        ChildReference childC = refs.getChild(name("childC"));
        ChildReference childD = refs.getChild(name("childD"));

        assertThat(childC.getKey().toString(), is("source1works1-childC"));
        assertThat(childD.getKey().toString(), is("source1works1-childD"));

        assertThat(iter.next(), is(childC)); // from first block
View Full Code Here

        }

        public CachedNode node( Path path ) {
            CachedNode node = rootNode();
            for (Segment segment : path) {
                ChildReferences children = node.getChildReferences(cache);
                ChildReference child = children.getChild(segment);
                if (child == null) {
                    throw new PathNotFoundException(path, node.getKey(), node.getPath(cache));
                }
                NodeKey childKey = child.getKey();
                CachedNode childNode = cache.getNode(childKey);
View Full Code Here

        // Mock the ChildReferences and stub out the only method we'll call ...
        final List<NodeKey> childKeyList = new ArrayList<NodeKey>();
        for (String childKey : childKeys) {
            childKeyList.add(nodeKey(childKey));
        }
        ChildReferences childRefs = Mockito.mock(ChildReferences.class);
        when(childRefs.getAllKeys()).thenAnswer(new Answer<Iterator<NodeKey>>() {
            @Override
            public Iterator<NodeKey> answer( InvocationOnMock invocation ) throws Throwable {
                // Need to create a new iterator every time ...
                return childKeyList.iterator();
            }
View Full Code Here

                        childCopy = targetCache.mutable(childKey);
                    } else {
                        // The child is a normal child of this node ...

                        // check if there is a child with the same segment in the target which was not processed yet
                        ChildReferences targetNodeChildReferences = targetNode.getChildReferences(targetCache);
                        ChildReference targetChildSameSegment = targetNodeChildReferences.getChild(sourceChildReference.getSegment());
                        if (targetChildSameSegment != null && !sourceToTargetKeys.containsValue(targetChildSameSegment.getKey())) {
                            // we found a child of the target node which has the same segment and has not been processed yet
                            // meaning it was present in the target before the deep copy/clone started (e.g. an autocreated node)
                            childCopy = targetCache.mutable(targetChildSameSegment.getKey());
                            if (!isExternal) {
View Full Code Here

                NodeKey nodeKey = keys.remove();

                // Find the node in the session and/or workspace ...
                SessionNode node = this.changedNodes.put(nodeKey, REMOVED);
                boolean cleanupReferences = false;
                ChildReferences children = null;
                if (node != null) {
                    if (node == REMOVED) {
                        continue;
                    }
                    // There was a node within this cache ...
View Full Code Here

            // Find the node by path ...
            NodeCache cache = repo.getWorkspaceCache(workspaceName);
            CachedNode parentNode = getNodeAtPath(parentPath, cache);
            if (parentNode != null) {
                // Only add those children that are queryable ...
                ChildReferences childRefs = parentNode.getChildReferences(cache);
                List<CachedNode> results = new ArrayList<CachedNode>((int)childRefs.size());
                for (ChildReference childRef : childRefs) {
                    CachedNode child = cache.getNode(childRef);
                    if (compositeFilter.includeNode(child, cache)) {
                        results.add(child);
                    }
View Full Code Here

        boolean hasChildren = document.containsField(CHILDREN);
        boolean hasFederatedSegments = document.containsField(FEDERATED_SEGMENTS);
        if (!hasChildren && !hasFederatedSegments) {
            return ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
        }
        ChildReferences internalChildRefs = hasChildren ? ImmutableChildReferences.create(this, document, CHILDREN) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;
        ChildReferences externalChildRefs = hasFederatedSegments ? ImmutableChildReferences.create(this, document,
                                                                                                   FEDERATED_SEGMENTS) : ImmutableChildReferences.EMPTY_CHILD_REFERENCES;

        // Now look at the 'childrenInfo' document for info about the next block of children ...
        ChildReferencesInfo info = getChildReferencesInfo(document);
        if (!hasChildren) {
View Full Code Here

            // using the same key as the persisted node. Therefore, we do NOT want to use the persisted node in this case ...
            return new SessionChildReferences(null, appended.get(), changedChildren);
        }
        // Find the persisted information, since the info we have is relative to it ...
        CachedNode persistedNode = nodeInWorkspace(session(cache));
        ChildReferences persisted = persistedNode != null ? persistedNode.getChildReferences(cache) : null;

        // And create a transient implementation ...
        return new SessionChildReferences(persisted, appended.get(), changedChildren);
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.cache.ChildReferences$Context

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.