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;
}
Aggregations