Search in sources :

Example 81 with QPropertyDefinition

use of org.apache.jackrabbit.spi.QPropertyDefinition in project jackrabbit-oak by apache.

the class RepositoryUpgrade method createNodeTypeTemplate.

private NodeTypeTemplate createNodeTypeTemplate(ValueFactory valueFactory, NodeTypeManager ntMgr, String oakName, QNodeTypeDefinition def) throws RepositoryException {
    NodeTypeTemplate tmpl = ntMgr.createNodeTypeTemplate();
    tmpl.setName(oakName);
    tmpl.setAbstract(def.isAbstract());
    tmpl.setMixin(def.isMixin());
    tmpl.setOrderableChildNodes(def.hasOrderableChildNodes());
    tmpl.setQueryable(def.isQueryable());
    Name primaryItemName = def.getPrimaryItemName();
    if (primaryItemName != null) {
        tmpl.setPrimaryItemName(getOakName(primaryItemName));
    }
    Name[] supertypes = def.getSupertypes();
    if (supertypes != null && supertypes.length > 0) {
        List<String> names = newArrayListWithCapacity(supertypes.length);
        for (Name supertype : supertypes) {
            names.add(getOakName(supertype));
        }
        tmpl.setDeclaredSuperTypeNames(names.toArray(new String[names.size()]));
    }
    List<PropertyDefinitionTemplate> propertyDefinitionTemplates = tmpl.getPropertyDefinitionTemplates();
    for (QPropertyDefinition qpd : def.getPropertyDefs()) {
        PropertyDefinitionTemplate pdt = createPropertyDefinitionTemplate(valueFactory, ntMgr, qpd);
        propertyDefinitionTemplates.add(pdt);
    }
    // + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition protected sns
    List<NodeDefinitionTemplate> nodeDefinitionTemplates = tmpl.getNodeDefinitionTemplates();
    for (QNodeDefinition qnd : def.getChildNodeDefs()) {
        NodeDefinitionTemplate ndt = createNodeDefinitionTemplate(ntMgr, qnd);
        nodeDefinitionTemplates.add(ndt);
    }
    return tmpl;
}
Also used : NodeDefinitionTemplate(javax.jcr.nodetype.NodeDefinitionTemplate) NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) PropertyDefinitionTemplate(javax.jcr.nodetype.PropertyDefinitionTemplate) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) QNodeDefinition(org.apache.jackrabbit.spi.QNodeDefinition) Name(org.apache.jackrabbit.spi.Name)

Aggregations

QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)81 Name (org.apache.jackrabbit.spi.Name)32 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)22 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)19 RepositoryException (javax.jcr.RepositoryException)14 QValue (org.apache.jackrabbit.spi.QValue)12 QItemDefinition (org.apache.jackrabbit.spi.QItemDefinition)9 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)9 ArrayList (java.util.ArrayList)8 Value (javax.jcr.Value)7 InternalValue (org.apache.jackrabbit.core.value.InternalValue)7 ItemExistsException (javax.jcr.ItemExistsException)6 NodeId (org.apache.jackrabbit.core.id.NodeId)6 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)5 EffectiveNodeType (org.apache.jackrabbit.core.nodetype.EffectiveNodeType)5 PropertyState (org.apache.jackrabbit.core.state.PropertyState)5 QNodeTypeDefinition (org.apache.jackrabbit.spi.QNodeTypeDefinition)5 ValueConstraint (org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint)5 NodeState (org.apache.jackrabbit.core.state.NodeState)4 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)4