Search in sources :

Example 56 with QPropertyDefinition

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

the class TestAll method testVersionItem.

/** Test for the <code>version</code> parent version action. */
public void testVersionItem() {
    QPropertyDefinition def = getPropDef("itemNodeType", "versionItem");
    assertEquals("versionItem onParentVersion", OnParentVersionAction.VERSION, def.getOnParentVersion());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 57 with QPropertyDefinition

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

the class TestAll method testStringProperty.

/** Test for the <code>string</code> property definition type. */
public void testStringProperty() {
    QPropertyDefinition def = getPropDef("propertyNodeType", "stringProperty");
    assertEquals("stringProperty requiredType", PropertyType.STRING, def.getRequiredType());
    assertEquals("stringProperty valueConstraints", 1, def.getValueConstraints().length);
    assertEquals("stringProperty valueConstraints[0]", "bananas?", (def.getValueConstraints())[0].getString());
    assertEquals("stringProperty defaultValues", 2, def.getDefaultValues().length);
    assertEquals("stringProperty defaultValues[0]", "banana", getDefaultValue(def, 0));
    assertEquals("stringProperty defaultValues[1]", "bananas", getDefaultValue(def, 1));
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 58 with QPropertyDefinition

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

the class TestAll method testEmptyItem.

/** Test for the empty item definition. */
public void testEmptyItem() {
    QPropertyDefinition def = getPropDef("itemNodeType", "emptyItem");
    assertEquals("emptyItem autoCreate", false, def.isAutoCreated());
    assertEquals("emptyItem mandatory", false, def.isMandatory());
    assertEquals("emptyItem onParentVersion", OnParentVersionAction.IGNORE, def.getOnParentVersion());
    assertEquals("emptyItem protected", false, def.isProtected());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 59 with QPropertyDefinition

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

the class TestAll method testMandatoryItem.

/** Test for the <code>mandatory</code> item definition attribute. */
public void testMandatoryItem() {
    QPropertyDefinition def = getPropDef("itemNodeType", "mandatoryItem");
    assertEquals("mandatoryItem mandatory", true, def.isMandatory());
}
Also used : QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition)

Example 60 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