Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeDefinitionTemplate


        // register mixin
        NodeTypeManager ntm = superuser.getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntd = ntm.createNodeTypeTemplate();
        ntd.setName("testMixin");
        ntd.setMixin(true);
        NodeDefinitionTemplate nodeDef = ntm.createNodeDefinitionTemplate();
        nodeDef.setName("child");
        nodeDef.setRequiredPrimaryTypeNames(new String[] {"nt:folder"});
        nodeDef.setDefaultPrimaryTypeName("nt:folder");
        ntd.getNodeDefinitionTemplates().add(nodeDef);
        ntm.registerNodeType(ntd, true);

        // create node and add mixin
        Node node = testRootNode.addNode(nodeName1, "nt:resource");
View Full Code Here


                            if (this.isPropertyType(field.getJcrType())) {
                                final PropertyDefinitionTemplate pdt = getPropertyDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                propertyDefinitionTemplates.add(pdt);
                            } else {
                                final NodeDefinitionTemplate ndt = getNodeDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                nodeDefinitionTemplates.add(ndt);
                            }
                        }
                    }

                    if (classDescriptor.getCollectionDescriptors() != null) {
                        Iterator collectionIterator = classDescriptor.getCollectionDescriptors().iterator();
                        while (collectionIterator.hasNext()) {
                            CollectionDescriptor field = (CollectionDescriptor) collectionIterator.next();
                            if (this.isPropertyType(field.getJcrType())) {
                                final PropertyDefinitionTemplate pdt = getPropertyDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                propertyDefinitionTemplates.add(pdt);
                            } else {
                                final NodeDefinitionTemplate ndt = getNodeDefinition(ntm, session.getValueFactory(), field);
                                // add the just created pdt to the nodetypetemplate
                                nodeDefinitionTemplates.add(ndt);
                            }
                        }
                    }
View Full Code Here

    private NodeDefinitionTemplate getNodeDefinition(final javax.jcr.nodetype.NodeTypeManager ntm,
                                                     final ValueFactory valueFactory,
                                                     final ChildNodeDefDescriptor field) throws RepositoryException {


        final NodeDefinitionTemplate ndt = ntm.createNodeDefinitionTemplate();
        if (field.getJcrName() != null) {
            ndt.setName(field.getJcrName());
        } else {
            ndt.setName("*");
        }

        int onParentVersion = OnParentVersionAction.IGNORE;

        if (field.getJcrOnParentVersion() != null
                && field.getJcrOnParentVersion().length() > 0) {
            onParentVersion = OnParentVersionAction.valueFromName(field.getJcrOnParentVersion());
        }
        ndt.setOnParentVersion(onParentVersion);
        ndt.setSameNameSiblings(field.isJcrSameNameSiblings());

        ndt.setAutoCreated(field.isJcrAutoCreated());
        ndt.setDefaultPrimaryTypeName(field.getDefaultPrimaryType());
        ndt.setMandatory(field.isJcrMandatory());
        ndt.setProtected(field.isJcrProtected());
        ndt.setRequiredPrimaryTypeNames(getJcrSuperTypes(field.getJcrType()));

        return ndt;
    }
View Full Code Here

     * @return The corresponding JCR node definition.
     * @throws RepositoryException if an error occurs.
     */
    public NodeDefinition create(QNodeDefinition qNd)
            throws RepositoryException {
        NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
        nt.setName(getJCRName(qNd.getName()));
        nt.setAutoCreated(qNd.isAutoCreated());
        nt.setMandatory(qNd.isMandatory());
        nt.setOnParentVersion(qNd.getOnParentVersion());
        nt.setProtected(qNd.isProtected());
        nt.setSameNameSiblings(qNd.allowsSameNameSiblings());
        nt.setDefaultPrimaryTypeName(getJCRName(qNd.getDefaultPrimaryType()));
        nt.setRequiredPrimaryTypeNames(getJCRNames(qNd.getRequiredPrimaryTypes()));
        return nt;
    }
View Full Code Here

        // node type with default child-node type of to nt:base
        String ntName = "test";
        NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
        ntt.setName(ntName);
        NodeDefinitionTemplate child = ntm.createNodeDefinitionTemplate();
        child.setName("*");
        child.setDefaultPrimaryTypeName("nt:base");
        child.setRequiredPrimaryTypeNames(new String[] {"nt:base"});
        List<NodeDefinition> children = ntt.getNodeDefinitionTemplates();
        children.add(child);
        ntm.registerNodeType(ntt, true);

        // try to create a node with the default nt:base
View Full Code Here

    t.setMultiple( false );
    return t;
  }

  private NodeDefinitionTemplate getTitleNode( final NodeTypeManager ntMgr ) throws RepositoryException {
    NodeDefinitionTemplate t = ntMgr.createNodeDefinitionTemplate();
    t.setName( PHO + "title" ); //$NON-NLS-1$
    t.setRequiredPrimaryTypeNames( new String[] { PHO_NT + "localizedString" } ); //$NON-NLS-1$
    t.setOnParentVersion( OnParentVersionAction.COPY );
    t.setSameNameSiblings( false );
    return t;
  }
View Full Code Here

    t.setSameNameSiblings( false );
    return t;
  }

  private NodeDefinitionTemplate getDescriptionNode( final NodeTypeManager ntMgr ) throws RepositoryException {
    NodeDefinitionTemplate t = ntMgr.createNodeDefinitionTemplate();
    t.setName( PHO + "description" ); //$NON-NLS-1$
    t.setRequiredPrimaryTypeNames( new String[] { PHO_NT + "localizedString" } ); //$NON-NLS-1$
    t.setOnParentVersion( OnParentVersionAction.COPY );
    t.setSameNameSiblings( false );
    return t;
  }
View Full Code Here

    t.setSameNameSiblings( false );
    return t;
  }

  private NodeDefinitionTemplate getMetadataNode( final NodeTypeManager ntMgr ) throws RepositoryException {
    NodeDefinitionTemplate t = ntMgr.createNodeDefinitionTemplate();
    t.setName( PHO + "metadata" ); //$NON-NLS-1$
    t.setRequiredPrimaryTypeNames( new String[] { NT + "unstructured" } ); //$NON-NLS-1$
    t.setOnParentVersion( OnParentVersionAction.COPY );
    t.setSameNameSiblings( false );
    return t;
  }
View Full Code Here

    t.setSameNameSiblings( false );
    return t;
  }

  private NodeDefinitionTemplate getLocaleNode( final NodeTypeManager ntMgr ) throws RepositoryException {
    NodeDefinitionTemplate t = ntMgr.createNodeDefinitionTemplate();
    t.setName( PHO + "locales" ); //$NON-NLS-1$
    t.setRequiredPrimaryTypeNames( new String[] { PHO_NT + "locale" } ); //$NON-NLS-1$
    t.setOnParentVersion( OnParentVersionAction.COPY );
    t.setSameNameSiblings( false );
    return t;
  }
View Full Code Here

    return t;
  }

  private NodeDefinitionTemplate getWildcardNode( final NodeTypeManager ntMgr, final ValueFactory vFac )
    throws RepositoryException {
    NodeDefinitionTemplate t = ntMgr.createNodeDefinitionTemplate();
    t.setName( "*" ); //$NON-NLS-1$
    t.setRequiredPrimaryTypeNames( new String[] { NT + "base" } ); //$NON-NLS-1$
    t.setDefaultPrimaryTypeName( NT + "unstructured" ); //$NON-NLS-1$
    t.setOnParentVersion( OnParentVersionAction.IGNORE );
    t.setSameNameSiblings( false );
    return t;
  }
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeDefinitionTemplate

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.