Search in sources :

Example 11 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-repository by Alfresco.

the class VirtualNodeServiceExtensionTest method testGetChildAssocs_2.

@Test
public void testGetChildAssocs_2() throws Exception {
    // semi-virtual folder with 2 virtual folder nodes
    List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(virtualFolder1NodeRef);
    assertEquals(2, childAssocs.size());
    setUpTestAssociations(virtualFolder1NodeRef);
    NodeRef node2 = nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "Node2");
    NodeRef node2_1 = nodeService.getChildByName(node2, ContentModel.ASSOC_CONTAINS, "Node2_1");
    childAssocs = nodeService.getChildAssocs(node2, ContentModel.ASSOC_ARCHIVED_LINK, ContentModel.ASSOC_ARCHIVED_LINK, 7, true);
    assertTrue(childAssocs.isEmpty());
    childAssocs = nodeService.getChildAssocs(node2, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, 7, true);
    assertEquals(2, childAssocs.size());
    assertAssocNames(childAssocs, copyOf(node2ChildrenQNames, 2));
    childAssocs = nodeService.getChildAssocs(virtualFolder1NodeRef, RegexQNamePattern.MATCH_ALL, new QNamePattern() {

        @Override
        public boolean isMatch(QName qname) {
            return qname.getLocalName().startsWith("test") && qname.getLocalName().endsWith("txt");
        }
    }, 15, true);
    assertEquals(11, childAssocs.size());
    // reference child
    if (logger.isDebugEnabled()) {
        logger.debug("Getting children of node2 " + node2);
    }
    childAssocs = nodeService.getChildAssocs(node2, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, 2, true);
    if (logger.isDebugEnabled()) {
        logger.debug("Got children of node2 " + childAssocs);
    }
    assertEquals(2, childAssocs.size());
    // one virtual folder with a virtual node reference child
    childAssocs = nodeService.getChildAssocs(node2_1, RegexQNamePattern.MATCH_ALL, RegexQNamePattern.MATCH_ALL, 10, true);
    assertEquals(10, childAssocs.size());
    assertAssocNames(childAssocs, copyOf(node2_1ChildrenQNames, 10));
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QName(org.alfresco.service.namespace.QName) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) QNamePattern(org.alfresco.service.namespace.QNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef) Test(org.junit.Test) VirtualizationIntegrationTest(org.alfresco.repo.virtual.VirtualizationIntegrationTest)

Example 12 with QNamePattern

use of org.alfresco.service.namespace.QNamePattern in project alfresco-repository by Alfresco.

the class ThumbnailServiceImplTest method checkRenditioned.

private void checkRenditioned(NodeRef contentNodeRef, List<ExpectedAssoc> expectedAssocs) {
    assertTrue("Renditioned aspect should have been applied", this.secureNodeService.hasAspect(contentNodeRef, RenditionModel.ASPECT_RENDITIONED));
    for (ExpectedAssoc expectedAssoc : expectedAssocs) {
        QNamePattern qNamePattern = expectedAssoc.getAssocName() != null ? QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, expectedAssoc.getAssocName()) : null;
        List<ChildAssociationRef> assocs = this.secureNodeService.getChildAssocs(contentNodeRef, expectedAssoc.getAssocTypeQName(), qNamePattern);
        assertNotNull(assocs);
        assertEquals(expectedAssoc + " association count mismatch", expectedAssoc.getCount(), assocs.size());
    }
}
Also used : QNamePattern(org.alfresco.service.namespace.QNamePattern) RegexQNamePattern(org.alfresco.service.namespace.RegexQNamePattern) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Aggregations

QNamePattern (org.alfresco.service.namespace.QNamePattern)12 RegexQNamePattern (org.alfresco.service.namespace.RegexQNamePattern)10 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)7 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 WebApiDescription (org.alfresco.rest.framework.WebApiDescription)5 AssociationRef (org.alfresco.service.cmr.repository.AssociationRef)3 QName (org.alfresco.service.namespace.QName)3 Query (org.alfresco.rest.framework.resource.parameters.where.Query)2 MapBasedQueryWalker (org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker)2 ArrayList (java.util.ArrayList)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 VirtualizationIntegrationTest (org.alfresco.repo.virtual.VirtualizationIntegrationTest)1 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)1 NamespaceException (org.alfresco.service.namespace.NamespaceException)1 Test (org.junit.Test)1