Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeTypeTemplate


    @Ignore // TODO implement node type support
    @Test
    public void mixin() throws RepositoryException {
        NodeTypeManager ntMgr = getSession().getWorkspace().getNodeTypeManager();
        NodeTypeTemplate mixTest = ntMgr.createNodeTypeTemplate();
        mixTest.setName("mix:test");
        mixTest.setMixin(true);
        ntMgr.registerNodeType(mixTest, false);

        Node testNode = getNode(TEST_PATH);
        NodeType[] mix = testNode.getMixinNodeTypes();
        assertEquals(0, mix.length);
View Full Code Here


    @Test
    public void nodeTypeRegistry() throws RepositoryException {
        NodeTypeManager ntMgr = getAdminSession().getWorkspace().getNodeTypeManager();
        assertFalse(ntMgr.hasNodeType("foo"));

        NodeTypeTemplate ntd = ntMgr.createNodeTypeTemplate();
        ntd.setName("foo");
        ntMgr.registerNodeType(ntd, false);
        assertTrue(ntMgr.hasNodeType("foo"));

        ntMgr.unregisterNodeType("foo");
        assertFalse(ntMgr.hasNodeType("foo"));
View Full Code Here

    }

    @Test
    public void mixin() throws RepositoryException {
        NodeTypeManager ntMgr = getAdminSession().getWorkspace().getNodeTypeManager();
        NodeTypeTemplate mixTest = ntMgr.createNodeTypeTemplate();
        mixTest.setName("mix:test");
        mixTest.setMixin(true);
        ntMgr.registerNodeType(mixTest, false);

        Node testNode = getNode(TEST_PATH);
        NodeType[] mix = testNode.getMixinNodeTypes();
        assertEquals(0, mix.length);
View Full Code Here

    @Test // OAK-2038
    public void importWithRegisteredType() throws Exception {
        Session session = getAdminSession();
        NodeTypeManager ntMgr = getAdminSession().getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntd = ntMgr.createNodeTypeTemplate();
        ntd.setName("fooType");
        PropertyDefinitionTemplate propDefTemplate = ntMgr.createPropertyDefinitionTemplate();
        propDefTemplate.setName("fooProp");
        propDefTemplate.setRequiredType(PropertyType.STRING);
        ntd.getPropertyDefinitionTemplates().add(propDefTemplate);
        ntMgr.registerNodeType(ntd, false);

        Node node = session.getRootNode().addNode("node", "fooType");
        node.setProperty("fooProp", "fooValue");
        session.save();
View Full Code Here

    @Test
    public void nodeTypeRegistry() throws RepositoryException {
        NodeTypeManager ntMgr = getAdminSession().getWorkspace().getNodeTypeManager();
        assertFalse(ntMgr.hasNodeType("foo"));

        NodeTypeTemplate ntd = ntMgr.createNodeTypeTemplate();
        ntd.setName("foo");
        ntMgr.registerNodeType(ntd, false);
        assertTrue(ntMgr.hasNodeType("foo"));

        ntMgr.unregisterNodeType("foo");
        assertFalse(ntMgr.hasNodeType("foo"));
View Full Code Here

    }

    @Test
    public void mixin() throws RepositoryException {
        NodeTypeManager ntMgr = getAdminSession().getWorkspace().getNodeTypeManager();
        NodeTypeTemplate mixTest = ntMgr.createNodeTypeTemplate();
        mixTest.setName("mix:test");
        mixTest.setMixin(true);
        ntMgr.registerNodeType(mixTest, false);

        Node testNode = getNode(TEST_PATH);
        NodeType[] mix = testNode.getMixinNodeTypes();
        assertEquals(0, mix.length);
View Full Code Here

     * @throws RepositoryException if an error occurs.
     */
    @SuppressWarnings("unchecked")
    public NodeTypeDefinition create(QNodeTypeDefinition qNtd)
            throws RepositoryException {
        NodeTypeTemplate nt = ntMgr.createNodeTypeTemplate();
        nt.setName(getJCRName(qNtd.getName()));
        nt.setDeclaredSuperTypeNames(getJCRNames(qNtd.getSupertypes()));
        nt.setAbstract(qNtd.isAbstract());
        nt.setMixin(qNtd.isMixin());
        nt.setOrderableChildNodes(qNtd.hasOrderableChildNodes());
        nt.setPrimaryItemName(getJCRName(qNtd.getPrimaryItemName()));
        nt.setQueryable(qNtd.isQueryable());
        List nodeDefs = nt.getNodeDefinitionTemplates();
        for (QNodeDefinition qNd: qNtd.getChildNodeDefs()) {
            nodeDefs.add(create(qNd));
        }
        List propDefs = nt.getPropertyDefinitionTemplates();
        for (QPropertyDefinition qPd: qNtd.getPropertyDefs()) {
            propDefs.add(create(qPd));
        }
        return nt;
    }
View Full Code Here

        super.tearDown();
    }

    public void testEmptyNodeTypeTemplate() throws Exception {

        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
        assertNull(ntt.getName());

        assertFalse(ntt.isMixin());
        assertFalse(ntt.isAbstract());
        assertFalse(ntt.hasOrderableChildNodes());
       
        // note: isQueryable cannot be tested as defautl value is defined
        // by the implementation

        assertNotNull(ntt.getDeclaredSupertypeNames());
        assertEquals(0, ntt.getDeclaredSupertypeNames().length);

        assertNull(ntt.getPrimaryItemName());

        assertNull(ntt.getDeclaredChildNodeDefinitions());
        assertNull(ntt.getDeclaredPropertyDefinitions());

        assertNotNull(ntt.getNodeDefinitionTemplates());
        assertTrue(ntt.getNodeDefinitionTemplates().isEmpty());

        assertNotNull(ntt.getPropertyDefinitionTemplates());
        assertTrue(ntt.getPropertyDefinitionTemplates().isEmpty());
    }
View Full Code Here

    }
   
    public void testNonEmptyNodeTypeTemplate() throws Exception {

        NodeTypeDefinition ntd = ntm.getNodeType("nt:address");
        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate(ntm.getNodeType("nt:address"));

        assertEquals(ntt.getName(), ntd.getName());
        assertEquals(ntt.isMixin(), ntd.isMixin());
        assertEquals(ntt.isAbstract(), ntd.isAbstract());
        assertEquals(ntt.hasOrderableChildNodes(), ntd.hasOrderableChildNodes());
        assertEquals(ntt.isQueryable(), ntd.isQueryable());
        assertEquals(ntt.getPrimaryItemName(), ntd.getPrimaryItemName());
        assertTrue(Arrays.equals(ntt.getDeclaredSupertypeNames(), ntd.getDeclaredSupertypeNames()));
        NodeDefinition[] nda = ntt.getDeclaredChildNodeDefinitions();
        NodeDefinition[] nda1 = ntd.getDeclaredChildNodeDefinitions();
        assertEquals(nda.length, nda1.length);
        for (int i = 0; i < nda.length; i++) {
            assertEquals(nda[i].getName(), nda1[i].getName());
            assertEquals(nda[i].allowsSameNameSiblings(), nda1[i].allowsSameNameSiblings());
            assertTrue(Arrays.equals(nda[i].getRequiredPrimaryTypeNames(), nda1[i].getRequiredPrimaryTypeNames()));
            assertEquals(nda[i].getDefaultPrimaryTypeName(), nda1[i].getDefaultPrimaryTypeName());
            assertEquals(nda[i].getRequiredPrimaryTypeNames(), nda1[i].getRequiredPrimaryTypeNames());
        }

        PropertyDefinition[] pda = ntt.getDeclaredPropertyDefinitions();
        PropertyDefinition[] pda1 = ntd.getDeclaredPropertyDefinitions();
        assertEquals(pda.length, pda1.length);
        for (int i = 0; i < pda.length; i++) {
            assertEquals(pda[i].getName(), pda1[i].getName());
            assertEquals(pda[i].getRequiredType(), pda1[i].getRequiredType());
View Full Code Here

    public void testNewNodeTypeTemplate() throws Exception {
       
        String expandedName = "{" + NS_MIX_URI + "}" + "littlemixin";
        String jcrName = superuser.getNamespacePrefix(NS_MIX_URI) + ":littlemixin";
       
        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();

        ntt.setName(expandedName);
        assertEquals(jcrName, ntt.getName());
        ntt.setName(jcrName);
        assertEquals(jcrName, ntt.getName());

        ntt.setAbstract(false);
        assertFalse(ntt.isAbstract());

        try {
            ntt.setDeclaredSuperTypeNames(null);
            fail("null isn't a valid array of jcr name");
        } catch (ConstraintViolationException e) {
            // success
        }
        assertNotNull(ntt.getDeclaredSupertypeNames());
        assertEquals(0, ntt.getDeclaredSupertypeNames().length);

        ntt.setDeclaredSuperTypeNames(new String[] {mixReferenceable});
        assertNotNull(ntt.getDeclaredSupertypeNames());
        assertEquals(1, ntt.getDeclaredSupertypeNames().length);
        assertEquals(mixReferenceable, ntt.getDeclaredSupertypeNames()[0]);

        ntt.setMixin(true);
        assertTrue(ntt.isMixin());

        ntt.setOrderableChildNodes(true);
        assertTrue(ntt.hasOrderableChildNodes());

        ntt.setQueryable(false);
        assertFalse(ntt.isQueryable());

        ntt.setPrimaryItemName(null);
        assertNull(ntt.getPrimaryItemName());

        ntt.setPrimaryItemName(jcrPrimaryType);
        assertEquals(jcrPrimaryType, ntt.getPrimaryItemName());

        PropertyDefinitionTemplate pdTemplate = createBooleanPropTemplate();

        List pdefs = ntt.getPropertyDefinitionTemplates();
        pdefs.add(pdTemplate);

        assertNotNull(ntt.getDeclaredPropertyDefinitions());
        assertEquals(1, ntt.getDeclaredPropertyDefinitions().length);
        assertEquals(pdTemplate, ntt.getDeclaredPropertyDefinitions()[0]);

        pdefs = ntt.getPropertyDefinitionTemplates();
        assertEquals(1, pdefs.size());
        assertEquals(pdTemplate, pdefs.get(0));

        NodeDefinitionTemplate ndTemplate = ntm.createNodeDefinitionTemplate();

        List ndefs = ntt.getNodeDefinitionTemplates();
        ndefs.add(ndTemplate);

        assertNotNull(ntt.getDeclaredChildNodeDefinitions());
        assertEquals(1, ntt.getDeclaredChildNodeDefinitions().length);
        assertEquals(ndTemplate, ntt.getDeclaredChildNodeDefinitions()[0]);

        ndefs = ntt.getNodeDefinitionTemplates();
        assertEquals(1, ndefs.size());
        assertEquals(ndTemplate, ndefs.get(0));
    }
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeTypeTemplate

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.