Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeTypeDefinition


        assertTrue(ntt.getPropertyDefinitionTemplates().isEmpty());
    }
   
    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());
            assertTrue(Arrays.equals(pda[i].getAvailableQueryOperators(), pda1[i].getAvailableQueryOperators()));
View Full Code Here


                ntt.setDeclaredSuperTypeNames(new String[] {NT_BASE});
            } else {
                // Check whether we need to add the implicit "nt:base" supertype
                boolean needsNtBase = true;
                for (String name : supertypes) {
                    NodeTypeDefinition std = templates.get(name);
                    if (std == null) {
                        std = nodeTypeManager.getNodeType(name);
                    }
                    if (std != null && !std.isMixin()) {
                        needsNtBase = false;
                    }
                }
                if (needsNtBase) {
                    String[] withNtBase = new String[supertypes.length + 1];
View Full Code Here

        assertTrue(ntt.getPropertyDefinitionTemplates().isEmpty());
    }
   
    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());
            assertTrue(Arrays.equals(pda[i].getAvailableQueryOperators(), pda1[i].getAvailableQueryOperators()));
View Full Code Here

                    return false;
                }
                List<NodeTypeDefinition> nodeTypeDefinitions = new ArrayList<NodeTypeDefinition>(
                                                                                                 importer.getNodeTypeDefinitions());
                for (Iterator<NodeTypeDefinition> nodeTypeDefinitionIterator = nodeTypeDefinitions.iterator(); nodeTypeDefinitionIterator.hasNext();) {
                    NodeTypeDefinition nodeTypeDefinition = nodeTypeDefinitionIterator.next();
                    String name = nodeTypeDefinition.getName();
                    // keep only the exact types that we know have changed to keep the overhead to a minimum
                    if (ModeShapeLexicon.ACCESS_CONTROLLABLE_STRING.equalsIgnoreCase(name)
                        || ModeShapeLexicon.ACCESS_LIST_NODE_TYPE_STRING.equalsIgnoreCase(name)
                        || ModeShapeLexicon.PERMISSION.getString().equalsIgnoreCase(name)
                        || ModeShapeLexicon.LOCK.getString().equalsIgnoreCase(name)) {
View Full Code Here

        assertThat(ns.getNamespaceUri(), is("http://namespace.com/ns"));

        List<NodeTypeDefinition> defns = importer.getNodeTypeDefinitions();
        assertThat(defns.size(), is(1));

        NodeTypeDefinition defn = defns.get(0);
        assertThat(defn.getName(), is("ex:NodeType"));
        assertThat(defn.isAbstract(), is(true));
        assertThat(defn.hasOrderableChildNodes(), is(true));
        assertThat(defn.isMixin(), is(true));
        assertThat(defn.isQueryable(), is(false));
        assertThat(defn.getPrimaryItemName(), is("ex:property"));
        String[] supertypeNames = defn.getDeclaredSupertypeNames();
        assertThat(supertypeNames[0], is("ex:ParentType1"));
        assertThat(supertypeNames[1], is("ex:ParentType2"));

        PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
        assertThat(propDefns.length, is(1));
        PropertyDefinition propDefn = propDefns[0];
        assertThat(propDefn.getName(), is("ex:property"));
        assertThat(propDefn.getRequiredType(), is(PropertyType.STRING));
        assertThat(propDefn.isMandatory(), is(true));
        assertThat(propDefn.isAutoCreated(), is(true));
        assertThat(propDefn.isProtected(), is(true));
        assertThat(propDefn.isMultiple(), is(true));
        assertThat(propDefn.getOnParentVersion(), is(OnParentVersionAction.VERSION));
        assertThat(propDefn.isFullTextSearchable(), is(false));
        assertThat(propDefn.isQueryOrderable(), is(false));
        Value[] defaultValues = propDefn.getDefaultValues();
        assertThat(defaultValues[0].getString(), is("default1"));
        assertThat(defaultValues[1].getString(), is("default2"));
        String[] queryOps = propDefn.getAvailableQueryOperators();
        assertThat(queryOps[0], is("="));
        assertThat(queryOps[1], is("<>"));
        assertThat(queryOps[2], is("<"));
        assertThat(queryOps[3], is("<="));
        assertThat(queryOps[4], is(">"));
        assertThat(queryOps[5], is(">="));
        assertThat(queryOps[6], is("LIKE"));
        String[] constraints = propDefn.getValueConstraints();
        assertThat(constraints[0], is("constraint1"));
        assertThat(constraints[1], is("constraint2"));

        NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
        assertThat(childDefns.length, is(1));
        NodeDefinition childDefn = childDefns[0];
        assertThat(childDefn.getName(), is("ex:node"));
        assertThat(childDefn.getDefaultPrimaryTypeName(), is("ex:defaultType"));
        assertThat(childDefn.isMandatory(), is(true));
View Full Code Here

        assertThat(ns.getNamespaceUri(), is("http://namespace.com/ns"));

        List<NodeTypeDefinition> defns = importer.getNodeTypeDefinitions();
        assertThat(defns.size(), is(1));

        NodeTypeDefinition defn = defns.get(0);
        assertThat(defn.getName(), is("ex:NodeType"));
        assertThat(defn.isAbstract(), is(true));
        assertThat(defn.hasOrderableChildNodes(), is(true));
        assertThat(defn.isMixin(), is(true));
        assertThat(defn.isQueryable(), is(false));
        assertThat(defn.getPrimaryItemName(), is("ex:property"));
        String[] supertypeNames = defn.getDeclaredSupertypeNames();
        assertThat(supertypeNames[0], is("ex:ParentType1"));
        assertThat(supertypeNames[1], is("ex:ParentType2"));

        PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
        assertThat(propDefns.length, is(1));
        PropertyDefinition propDefn = propDefns[0];
        assertThat(propDefn.getName(), is("ex:property"));
        assertThat(propDefn.getRequiredType(), is(PropertyType.STRING));
        assertThat(propDefn.isMandatory(), is(true));
        assertThat(propDefn.isAutoCreated(), is(true));
        assertThat(propDefn.isProtected(), is(true));
        assertThat(propDefn.isMultiple(), is(true));
        assertThat(propDefn.getOnParentVersion(), is(OnParentVersionAction.VERSION));
        assertThat(propDefn.isFullTextSearchable(), is(false));
        assertThat(propDefn.isQueryOrderable(), is(false));
        Value[] defaultValues = propDefn.getDefaultValues();
        assertThat(defaultValues[0].getString(), is("default1"));
        assertThat(defaultValues[1].getString(), is("default2"));
        String[] queryOps = propDefn.getAvailableQueryOperators();
        assertThat(queryOps[0], is("="));
        assertThat(queryOps[1], is("<>"));
        assertThat(queryOps[2], is("<"));
        assertThat(queryOps[3], is("<="));
        assertThat(queryOps[4], is(">"));
        assertThat(queryOps[5], is(">="));
        assertThat(queryOps[6], is("LIKE"));
        String[] constraints = propDefn.getValueConstraints();
        assertThat(constraints[0], is("constraint1"));
        assertThat(constraints[1], is("constraint2"));

        NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
        assertThat(childDefns.length, is(1));
        NodeDefinition childDefn = childDefns[0];
        assertThat(childDefn.getName(), is("ex:node"));
        assertThat(childDefn.getDefaultPrimaryTypeName(), is("ex:defaultType"));
        assertThat(childDefn.isMandatory(), is(true));
View Full Code Here

        }
        return opv;
    }

    protected NodeTypeDefinition defn( String name ) {
        NodeTypeDefinition result = null;
        for (NodeTypeDefinition defn : importer.getNodeTypeDefinitions()) {
            if (defn.getName().equals(name)) {
                result = defn;
                break;
            }
View Full Code Here

                                   NodeOptions... nodeOptions ) {
        Set<NodeOptions> options = new HashSet<NodeOptions>();
        for (NodeOptions option : nodeOptions)
            options.add(option);

        NodeTypeDefinition defn = defn(name);
        assertThat(defn.getName(), is(name));
        assertThat(defn.isAbstract(), is(options.contains(NodeOptions.Abstract)));
        assertThat(defn.hasOrderableChildNodes(), is(options.contains(NodeOptions.Ordered)));
        assertThat(defn.isMixin(), is(options.contains(NodeOptions.Mixin)));
        assertThat(defn.isQueryable(), is(options.contains(NodeOptions.Queryable)));
        assertThat(defn.getPrimaryItemName(), is(primaryItemName));
        String[] supertypeNames = defn.getDeclaredSupertypeNames();
        assertThat(supertypeNames, is(superTypes));
    }
View Full Code Here

                                   String... valueConstraints ) throws RepositoryException {
        Set<PropertyOptions> options = new HashSet<PropertyOptions>();
        for (PropertyOptions option : propertyOptions)
            options.add(option);

        NodeTypeDefinition defn = defn(nodeTypeName);
        PropertyDefinition propDefn = propDefn(defn, propertyName);

        assertThat(propDefn.getName(), is(propertyName));
        assertThat(propDefn.getRequiredType(), is(jcrPropertyType(requiredType)));
        assertThat(propDefn.isMandatory(), is(options.contains(PropertyOptions.Mandatory)));
View Full Code Here

                                OnParentVersion onParentVersioning ) {
        Set<ChildOptions> options = new HashSet<ChildOptions>();
        for (ChildOptions option : childOptions)
            options.add(option);

        NodeTypeDefinition defn = defn(nodeTypeName);
        NodeDefinition childDefn = childDefn(defn, childName);

        assertThat(childDefn.getName(), is(childName));
        assertThat(childDefn.getDefaultPrimaryTypeName(), is(defaultPrimaryType));
        assertThat(childDefn.isMandatory(), is(options.contains(ChildOptions.Mandatory)));
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeTypeDefinition

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.