Author: elvisisking
Date: 2012-03-29 16:38:25 -0400 (Thu, 29 Mar 2012)
New Revision: 39924
Added:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/DerbyDdl.cnd
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/OracleDdl.cnd
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/PostgresDdl.cnd
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/StandardDdl.cnd
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItemTest.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Work on some layout
issues, primary item attribute, section toolbars, and validation handling.
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -83,7 +83,8 @@
map.put(Preference.NAMESPACE_MAPPING_DELIMITER, "\n"); //$NON-NLS-1$
map.put(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
map.put(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
Utils.SPACE_STRING);
+ map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER,
Utils.SPACE_STRING);
+ map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
"\n"); //$NON-NLS-1$
map.put(Preference.NODE_TYPE_DEFINITION_DELIMITER, "\n");
//$NON-NLS-1$
map.put(Preference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER, Utils.SPACE_STRING);
map.put(Preference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER, "\n");
//$NON-NLS-1$
@@ -180,11 +181,16 @@
NAMESPACE_MAPPING_SECTION_END_DELIMITER,
/**
- * The delimiter between node type definition attributes.
+ * The delimiter after all the node type definition attributes.
*/
NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
/**
+ * The delimiter between node type definition attributes.
+ */
+ NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER,
+
+ /**
* The delimiter between node type definitions.
*/
NODE_TYPE_DEFINITION_DELIMITER,
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -126,10 +126,12 @@
/**
* @param childNodeDefinition the child node definition being validated (cannot be
<code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingChildNodeNames the existing child node names used to check for a
duplicate (can be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateChildNodeDefinition( final
ChildNodeDefinition childNodeDefinition,
+ final
Collection<String> validNamespacePrefixes,
final
Collection<QualifiedName> existingChildNodeNames ) {
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
@@ -152,26 +154,29 @@
}
// name
- validateName(childNodeDefinition, existingChildNodeNames, status);
+ validateName(childNodeDefinition, validNamespacePrefixes, existingChildNodeNames,
status);
// required types
- validateRequiredTypes(childNodeDefinition, status);
+ validateRequiredTypes(childNodeDefinition, validNamespacePrefixes, status);
// default type
- validateDefaultType(childNodeDefinition, status);
-
+ validateDefaultType(childNodeDefinition, validNamespacePrefixes, status);
+
return status;
}
/**
* @param childNodeDefinition the child node definition being validated (cannot be
<code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingChildNodeNames the existing child node names used to check for a
duplicate (can be <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateChildNodeDefinition( final ChildNodeDefinition
childNodeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingChildNodeNames,
final MultiValidationStatus status )
{
- final ValidationStatus newStatus =
validateChildNodeDefinition(childNodeDefinition, existingChildNodeNames);
+ final ValidationStatus newStatus =
validateChildNodeDefinition(childNodeDefinition, validNamespacePrefixes,
+
existingChildNodeNames);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -180,11 +185,13 @@
/**
* @param nodeTypeName the node type name whose child node definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param childNodeDefinitions the collection of a node type definition's child
node definitions to validate (can be
* <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateChildNodeDefinitions( final String
nodeTypeName,
+ final
Collection<String> validNamespacePrefixes,
final
Collection<ChildNodeDefinition> childNodeDefinitions ) {
Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
@@ -203,7 +210,7 @@
final Collection<String> childNodeNames = new
ArrayList<String>(childNodeDefinitions.size());
for (final ChildNodeDefinition childNodeDefn : childNodeDefinitions) {
- validateChildNodeDefinition(childNodeDefn, null, status);
+ validateChildNodeDefinition(childNodeDefn, validNamespacePrefixes, null,
status);
{ // ERROR - Duplicate child node definition names (allow duplicate residual
names)
final String childNodeName = childNodeDefn.getName();
@@ -224,14 +231,17 @@
/**
* @param nodeTypeName the node type name whose child node definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param childNodeDefinitions the collection of a node type definition's child
node definitions to validate (can be
* <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateChildNodeDefinitions( final String nodeTypeName,
+ final Collection<String>
validNamespacePrefixes,
final
Collection<ChildNodeDefinition> childNodeDefinitions,
final MultiValidationStatus status )
{
- final MultiValidationStatus newStatus =
validateChildNodeDefinitions(nodeTypeName, childNodeDefinitions);
+ final MultiValidationStatus newStatus =
validateChildNodeDefinitions(nodeTypeName, validNamespacePrefixes,
+
childNodeDefinitions);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -271,7 +281,7 @@
if (Utils.isEmpty(nodeTypeDefinitions)) {
noNodeTypeDefinitions = true;
} else {
- validateNodeTypeDefinitions(nodeTypeDefinitions, true, status);
+ validateNodeTypeDefinitions(nodeTypeDefinitions,
cnd.getNamespacePrefixes(), true, status);
}
}
@@ -298,19 +308,23 @@
/**
* @param childNodeDefinition the child node definition whose default type is being
validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
- public static MultiValidationStatus validateDefaultType( final ChildNodeDefinition
childNodeDefinition ) {
+ public static MultiValidationStatus validateDefaultType( final ChildNodeDefinition
childNodeDefinition,
+ final
Collection<String> validNamespacePrefixes ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateDefaultType(childNodeDefinition, status);
+ validateDefaultType(childNodeDefinition, validNamespacePrefixes, status);
return status;
}
/**
* @param childNodeDefinition the child node definition whose default type is being
validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateDefaultType( final ChildNodeDefinition
childNodeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final MultiValidationStatus status ) {
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
Utils.verifyIsNotNull(status, "status"); //$NON-NLS-1$
@@ -319,7 +333,8 @@
if (childNodeDefinition.getState(ChildNodeDefinition.PropertyName.DEFAULT_TYPE)
== Value.IS) {
// ERROR - Invalid default type name
- validateQualifiedName(childNodeDefinition.getDefaultType().getDefaultType(),
Messages.defaultTypeName, status);
+ validateQualifiedName(childNodeDefinition.getDefaultType().getDefaultType(),
Messages.defaultTypeName,
+ validNamespacePrefixes, null, status);
} else if (!Utils.isEmpty(defaultType)) {
String childNodeName = childNodeDefinition.getName();
@@ -451,22 +466,26 @@
/**
* @param childNodeDefinition the child node definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingChildNodeNames the existing child node names used to check for a
duplicate (can be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateName( final ChildNodeDefinition
childNodeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final
Collection<QualifiedName> existingChildNodeNames ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateName(childNodeDefinition, existingChildNodeNames, status);
+ validateName(childNodeDefinition, validNamespacePrefixes, existingChildNodeNames,
status);
return status;
}
/**
* @param childNodeDefinition the child node definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingChildNodeNames the existing child node names used to check for a
duplicate (can be <code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateName( final ChildNodeDefinition childNodeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingChildNodeNames,
final MultiValidationStatus status ) {
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
@@ -474,62 +493,62 @@
// allow residual name
if (!ItemDefinition.RESIDUAL_NAME.equals(childNodeDefinition.getName())) {
// ERROR - Empty or invalid child node definition name
- validateQualifiedName(childNodeDefinition.getQualifiedName(),
Messages.childDefinitionName, status);
-
- if (!Utils.isEmpty(existingChildNodeNames) &&
existingChildNodeNames.contains(childNodeDefinition.getQualifiedName())) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateChildNodeDefinitionName,
-
childNodeDefinition.getName())));
- }
+ validateQualifiedName(childNodeDefinition.getQualifiedName(),
Messages.childDefinitionName, validNamespacePrefixes,
+ existingChildNodeNames, status);
}
}
/**
* @param nodeTypeDefinition the node type definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingNodeTypeNames the existing node type names used to check for a
duplicate (can be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateName( final NodeTypeDefinition
nodeTypeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final
Collection<QualifiedName> existingNodeTypeNames ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateName(nodeTypeDefinition, existingNodeTypeNames, status);
+ validateName(nodeTypeDefinition, validNamespacePrefixes, existingNodeTypeNames,
status);
return status;
}
/**
* @param nodeTypeDefinition the node type definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingNodeTypeNames the existing node type names used to check for a
duplicate (can be <code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateName( final NodeTypeDefinition nodeTypeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingNodeTypeNames,
final MultiValidationStatus status ) {
// ERROR - Empty or invalid node type definition name
- validateQualifiedName(nodeTypeDefinition.getQualifiedName(),
Messages.nodeTypeDefinitionName, status);
-
- if (!Utils.isEmpty(existingNodeTypeNames) &&
existingNodeTypeNames.contains(nodeTypeDefinition.getQualifiedName())) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicateNodeTypeDefinitionName,
-
nodeTypeDefinition.getName())));
- }
+ validateQualifiedName(nodeTypeDefinition.getQualifiedName(),
Messages.nodeTypeDefinitionName, validNamespacePrefixes,
+ existingNodeTypeNames, status);
}
/**
* @param propertyDefinition the property definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingPropertyNames the existing property names used to check for a
duplicate (can be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateName( final PropertyDefinition
propertyDefinition,
+ final Collection<String>
validNamespacePrefixes,
final
Collection<QualifiedName> existingPropertyNames ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateName(propertyDefinition, existingPropertyNames, status);
+ validateName(propertyDefinition, validNamespacePrefixes, existingPropertyNames,
status);
return status;
}
/**
* @param propertyDefinition the property definition whose name is being validated
(cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingPropertyNames the existing property names used to check for a
duplicate (can be <code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateName( final PropertyDefinition propertyDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingPropertyNames,
final MultiValidationStatus status ) {
Utils.verifyIsNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
@@ -537,12 +556,8 @@
// allow residual name
if (!ItemDefinition.RESIDUAL_NAME.equals(propertyDefinition.getName())) {
// ERROR - Empty or invalid child node definition name
- validateQualifiedName(propertyDefinition.getQualifiedName(),
Messages.propertyDefinitionName, status);
-
- if (!Utils.isEmpty(existingPropertyNames) &&
existingPropertyNames.contains(propertyDefinition.getQualifiedName())) {
-
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.duplicatePropertyDefinitionName,
-
propertyDefinition.getName())));
- }
+ validateQualifiedName(propertyDefinition.getQualifiedName(),
Messages.propertyDefinitionName, validNamespacePrefixes,
+ existingPropertyNames, status);
}
}
@@ -714,11 +729,14 @@
/**
* @param nodeTypeDefinition the node type definition being validated (cannot be
<code>null</code>)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
* @param existingNodeTypeNames the existing node type names used to check for a
duplicate (can be <code>null</code> or empty)
* @param validateEachPropertyAndChildNode indicates if property definition and child
node definition validation should be done
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateNodeTypeDefinition( final
NodeTypeDefinition nodeTypeDefinition,
+ final
Collection<String> validNamespacePrefixes,
final
Collection<QualifiedName> existingNodeTypeNames,
final boolean
validateEachPropertyAndChildNode ) {
Utils.verifyIsNotNull(nodeTypeDefinition, "nodeTypeDefinition");
//$NON-NLS-1$
@@ -746,7 +764,7 @@
{ // name
// ERROR - Empty or invalid node type definition name
- validateName(nodeTypeDefinition, existingNodeTypeNames, status);
+ validateName(nodeTypeDefinition, validNamespacePrefixes,
existingNodeTypeNames, status);
}
{ // super types
@@ -757,8 +775,8 @@
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.emptySuperTypes,
nodeTypeDefinitionName)));
}
} else {
- validateSuperTypes(nodeTypeDefinitionName,
nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
- superTypeNames, status);
+ validateSuperTypes(nodeTypeDefinitionName, validNamespacePrefixes,
+
nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES), superTypeNames,
status);
}
}
@@ -767,7 +785,7 @@
if (nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.PRIMARY_ITEM)
== Value.IS) {
// ERROR - Empty or invalid primary item name
- validateQualifiedName(primaryItemName, Messages.primaryItemName,
status);
+ validateQualifiedName(primaryItemName, Messages.primaryItemName,
validNamespacePrefixes, null, status);
} else if (!Utils.isEmpty(primaryItemName.get())) {
// ERROR Cannot have a primary item name when the primary item node type
attribute is marked as a variant
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.primaryItemExistsButMarkedAsVariant,
@@ -785,7 +803,7 @@
if (Utils.isEmpty(propertyDefinitions)) {
noPropertyDefinitions = true;
} else {
- validatePropertyDefinitions(nodeTypeDefinitionName,
propertyDefinitions, status);
+ validatePropertyDefinitions(nodeTypeDefinitionName,
validNamespacePrefixes, propertyDefinitions, status);
}
}
@@ -795,7 +813,7 @@
if (Utils.isEmpty(childNodeDefinitions)) {
noChildNodeDefinitions = true;
} else {
- validateChildNodeDefinitions(nodeTypeDefinitionName,
childNodeDefinitions, status);
+ validateChildNodeDefinitions(nodeTypeDefinitionName,
validNamespacePrefixes, childNodeDefinitions, status);
}
}
} else {
@@ -814,16 +832,19 @@
/**
* @param nodeTypeDefinition the node type definition being validated (cannot be
<code>null</code>)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
* @param existingNodeTypeNames the existing node type names used to check for a
duplicate (can be <code>null</code> or empty)
* @param validateEachPropertyAndChildNode indicates if property definition and child
node definition validation should be done
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateNodeTypeDefinition( final NodeTypeDefinition
nodeTypeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingNodeTypeNames,
final boolean
validateEachPropertyAndChildNode,
final MultiValidationStatus status )
{
- final ValidationStatus newStatus = validateNodeTypeDefinition(nodeTypeDefinition,
existingNodeTypeNames,
-
validateEachPropertyAndChildNode);
+ final ValidationStatus newStatus = validateNodeTypeDefinition(nodeTypeDefinition,
validNamespacePrefixes,
+
existingNodeTypeNames, validateEachPropertyAndChildNode);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -832,10 +853,13 @@
/**
* @param nodeTypeDefinitions the collection of namespace mappings to validate (can
be <code>null</code> or empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
* @param validateEachPropertyAndChildNode indicates if property definition and child
node definition validation should be done
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateNodeTypeDefinitions( final
Collection<NodeTypeDefinition> nodeTypeDefinitions,
+ final
Collection<String> validNamespacePrefixes,
final boolean
validateEachPropertyAndChildNode ) {
/**
* <pre>
@@ -852,7 +876,7 @@
final Collection<String> names = new
ArrayList<String>(nodeTypeDefinitions.size());
for (final NodeTypeDefinition nodeTypeDefinition : nodeTypeDefinitions) {
- validateNodeTypeDefinition(nodeTypeDefinition, null,
validateEachPropertyAndChildNode, status);
+ validateNodeTypeDefinition(nodeTypeDefinition, validNamespacePrefixes, null,
validateEachPropertyAndChildNode, status);
{ // ERROR - Duplicate node type definition names
final String name = nodeTypeDefinition.getName();
@@ -872,13 +896,17 @@
/**
* @param nodeTypeDefinitions the collection of namespace mappings to validate (can
be <code>null</code> or empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
* @param validateEachPropertyAndChildNode indicates if property definition and child
node definition validation should be done
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateNodeTypeDefinitions( final
Collection<NodeTypeDefinition> nodeTypeDefinitions,
+ final Collection<String>
validNamespacePrefixes,
final boolean
validateEachPropertyAndChildNode,
final MultiValidationStatus status )
{
- final ValidationStatus newStatus =
validateNodeTypeDefinitions(nodeTypeDefinitions, validateEachPropertyAndChildNode);
+ final ValidationStatus newStatus =
validateNodeTypeDefinitions(nodeTypeDefinitions, validNamespacePrefixes,
+
validateEachPropertyAndChildNode);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -887,10 +915,12 @@
/**
* @param propertyDefinition the property definition being validated (never
<code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingPropertyNames the existing property names used to check for a
duplicate (can be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validatePropertyDefinition( final
PropertyDefinition propertyDefinition,
+ final
Collection<String> validNamespacePrefixes,
final
Collection<QualifiedName> existingPropertyNames ) {
Utils.verifyIsNotNull(propertyDefinition, "propertyDefinition");
//$NON-NLS-1$
@@ -920,7 +950,7 @@
{ // name
// ERROR - Empty or invalid property definition name
- validateName(propertyDefinition, existingPropertyNames, status);
+ validateName(propertyDefinition, validNamespacePrefixes,
existingPropertyNames, status);
}
{ // property type
@@ -974,13 +1004,16 @@
/**
* @param propertyDefinition the property definition being validated (never
<code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param existingPropertyNames the existing property names used to check for a
duplicate (can be <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validatePropertyDefinition( final PropertyDefinition
propertyDefinition,
+ final Collection<String>
validNamespacePrefixes,
final Collection<QualifiedName>
existingPropertyNames,
final MultiValidationStatus status )
{
- final ValidationStatus newStatus = validatePropertyDefinition(propertyDefinition,
existingPropertyNames);
+ final ValidationStatus newStatus = validatePropertyDefinition(propertyDefinition,
validNamespacePrefixes,
+
existingPropertyNames);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -989,11 +1022,13 @@
/**
* @param nodeTypeName the node type name whose property definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param propertyDefinitions the collection of a node type definition's property
definitions to validate (can be
* <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validatePropertyDefinitions( final String
nodeTypeName,
+ final
Collection<String> validNamespacePrefixes,
final
Collection<PropertyDefinition> propertyDefinitions ) {
Utils.verifyIsNotEmpty(nodeTypeName, "nodeTypeName"); //$NON-NLS-1$
@@ -1012,7 +1047,7 @@
final Collection<String> propNames = new
ArrayList<String>(propertyDefinitions.size());
for (final PropertyDefinition propertyDefn : propertyDefinitions) {
- validatePropertyDefinition(propertyDefn, null, status);
+ validatePropertyDefinition(propertyDefn, validNamespacePrefixes, null,
status);
{ // ERROR - Duplicate property definition names (allow duplicate residual
names)
final String propName = propertyDefn.getName();
@@ -1033,14 +1068,17 @@
/**
* @param nodeTypeName the node type name whose property definitions are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param propertyDefinitions the collection of a node type definition's property
definitions to validate (can be
* <code>null</code> or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validatePropertyDefinitions( final String nodeTypeName,
+ final Collection<String>
validNamespacePrefixes,
final
Collection<PropertyDefinition> propertyDefinitions,
final MultiValidationStatus status )
{
- final MultiValidationStatus newStatus = validatePropertyDefinitions(nodeTypeName,
propertyDefinitions);
+ final MultiValidationStatus newStatus = validatePropertyDefinitions(nodeTypeName,
validNamespacePrefixes,
+
propertyDefinitions);
if (!newStatus.isOk()) {
status.add(newStatus);
@@ -1050,14 +1088,35 @@
/**
* @param qname the qualified name being validated (cannot be
<code>null</code>)
* @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
+ * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
+ * be <code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
- final String propertyName
) {
- Utils.verifyIsNotNull(qname, "qname"); //$NON-NLS-1$
-
+ final String
propertyName,
+ final
Collection<String> validNamespacePrefixes,
+ final
Collection<QualifiedName> existingQNames ) {
final MultiValidationStatus status = new MultiValidationStatus();
+ validateQualifiedName(qname, propertyName, validNamespacePrefixes,
existingQNames, status);
+ return status;
+ }
+ /**
+ * @param qname the qualified name being validated (cannot be
<code>null</code>)
+ * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
+ * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
+ * be <code>null</code> or empty)
+ * @param status the status to add the new status to (never
<code>null</code>)
+ */
+ public static void validateQualifiedName( final QualifiedName qname,
+ final String propertyName,
+ final Collection<String>
validNamespacePrefixes,
+ final Collection<QualifiedName>
existingQNames,
+ final MultiValidationStatus status ) {
{ // qualifier part
final String qualifier = qname.getQualifier();
@@ -1084,43 +1143,6 @@
}
}
- return status;
- }
-
- /**
- * @param qname the qualified name being validated (cannot be
<code>null</code>)
- * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
- * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
- * or empty)
- * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
- * be <code>null</code> or empty)
- * @return the status (never <code>null</code>)
- */
- public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
- final String
propertyName,
- final
Collection<String> validNamespacePrefixes,
- final
Collection<QualifiedName> existingQNames ) {
- final MultiValidationStatus status = new MultiValidationStatus();
- validateQualifiedName(qname, propertyName, validNamespacePrefixes,
existingQNames, status);
- return status;
- }
-
- /**
- * @param qname the qualified name being validated (cannot be
<code>null</code>)
- * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
- * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
- * or empty)
- * @param existingQNames a list of existing qualified names used to make sure the
name being validated is not a duplicate (can
- * be <code>null</code> or empty)
- * @param status the status to add the new status to (never
<code>null</code>)
- */
- public static void validateQualifiedName( final QualifiedName qname,
- final String propertyName,
- final Collection<String>
validNamespacePrefixes,
- final Collection<QualifiedName>
existingQNames,
- final MultiValidationStatus status ) {
- validateQualifiedName(qname, propertyName, status);
-
// make sure qualifier is valid
if (!Utils.isEmpty(validNamespacePrefixes)) {
final String qualifier = qname.getQualifier();
@@ -1141,21 +1163,6 @@
}
/**
- * @param qname the qualified name being validated (cannot be
<code>null</code>)
- * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
- * @param status the status to add the new status to (never
<code>null</code>)
- */
- public static void validateQualifiedName( final QualifiedName qname,
- final String propertyName,
- final MultiValidationStatus status ) {
- final MultiValidationStatus newStatus = validateQualifiedName(qname,
propertyName);
-
- if (!newStatus.isOk()) {
- status.add(newStatus);
- }
- }
-
- /**
* @param operator the query operator being validated (can be
<code>null</code> or empty)
* @param propertyDefinitionName the name of the property definition the query
operator belongs to (cannot be <code>null</code>
* or empty)
@@ -1194,19 +1201,23 @@
/**
* @param childNodeDefinition the child node definition whose required types are
being validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @return the status (never <code>null</code>)
*/
- public static MultiValidationStatus validateRequiredTypes( final ChildNodeDefinition
childNodeDefinition ) {
+ public static MultiValidationStatus validateRequiredTypes( final ChildNodeDefinition
childNodeDefinition,
+ final
Collection<String> validNamespacePrefixes ) {
final MultiValidationStatus status = new MultiValidationStatus();
- validateRequiredTypes(childNodeDefinition, status);
+ validateRequiredTypes(childNodeDefinition, validNamespacePrefixes, status);
return status;
}
/**
* @param childNodeDefinition the child node definition whose required types are
being validated (cannot be <code>null</code>)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param status the status to add the new status to (cannot be
<code>null</code>)
*/
public static void validateRequiredTypes( final ChildNodeDefinition
childNodeDefinition,
+ final Collection<String>
validNamespacePrefixes,
final MultiValidationStatus status ) {
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition");
//$NON-NLS-1$
Utils.verifyIsNotNull(status, "status"); //$NON-NLS-1$
@@ -1227,7 +1238,7 @@
for (final QualifiedName requiredType :
childNodeDefinition.getRequiredTypes()) {
// ERROR - Invalid required type name
- validateQualifiedName(requiredType, Messages.requiredTypeName, status);
+ validateQualifiedName(requiredType, Messages.requiredTypeName,
validNamespacePrefixes, null, status);
// ERROR - Duplicate required type name
if (requiredTypes.contains(requiredType)) {
@@ -1248,12 +1259,14 @@
/**
* @param nodeTypeDefinitionName the node type name whose supertypes are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param superTypesState the supertypes property state (cannot be
<code>null</code>)
* @param superTypeNames the collection of a node type definition's supertype
names to validate (can be <code>null</code> or
* empty)
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateSuperTypes( final String
nodeTypeDefinitionName,
+ final
Collection<String> validNamespacePrefixes,
final Value superTypesState,
final
Collection<QualifiedName> superTypeNames ) {
Utils.verifyIsNotEmpty(nodeTypeDefinitionName,
"nodeTypeDefinitionName"); //$NON-NLS-1$
@@ -1277,7 +1290,7 @@
for (final QualifiedName superTypeName : superTypeNames) {
// ERROR - Invalid super type name
- validateQualifiedName(superTypeName, Messages.superTypeName, status);
+ validateQualifiedName(superTypeName, Messages.superTypeName,
validNamespacePrefixes, null, status);
if (!Utils.isEmpty(superTypeName.get())) {
// ERROR - Duplicate super type name
@@ -1301,16 +1314,19 @@
/**
* @param nodeTypeDefinitionName the node type name whose supertypes are being
checked (cannot be <code>null</code> or empty)
+ * @param validNamespacePrefixes the valid namespace prefixes (can be
<code>null</code> or empty)
* @param superTypesState the supertypes property state (cannot be
<code>null</code>)
* @param superTypeNames the collection of a node type definition's supertype
names to validate (can be <code>null</code> or
* empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateSuperTypes( final String nodeTypeDefinitionName,
+ final Collection<String>
validNamespacePrefixes,
final Value superTypesState,
final Collection<QualifiedName>
superTypeNames,
final MultiValidationStatus status ) {
- final MultiValidationStatus newStatus =
validateSuperTypes(nodeTypeDefinitionName, superTypesState, superTypeNames);
+ final MultiValidationStatus newStatus =
validateSuperTypes(nodeTypeDefinitionName, validNamespacePrefixes, superTypesState,
+ superTypeNames);
if (!newStatus.isOk()) {
status.add(newStatus);
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -10,6 +10,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -218,6 +219,25 @@
}
/**
+ * @return the prefixes of all the namespace mappings (never
<code>null</code> but can be empty)
+ */
+ public Collection<String> getNamespacePrefixes() {
+ final List<NamespaceMapping> namespaces = getNamespaceMappings();
+
+ if (namespaces.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ final List<String> prefixes = new
ArrayList<String>(namespaces.size());
+
+ for (final NamespaceMapping namespace : namespaces) {
+ prefixes.add(namespace.getPrefix());
+ }
+
+ return prefixes;
+ }
+
+ /**
* @return the namespace mappings (never <code>null</code>)
*/
public List<NamespaceMapping> getNamespaceMappings() {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NamespaceMapping.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -19,11 +19,34 @@
public class NamespaceMapping implements CndElement, Comparable {
/**
- * @param namespaceMappingToCopy the namespace mapping being copied (cannot be
<code>null</code>)
- * @return a new namespace mapping exactly equal to the one that was copied (never
<code>null</code>)
+ * The built-in namespace mappings.
*/
- public static NamespaceMapping copy( NamespaceMapping namespaceMappingToCopy ) {
- return new NamespaceMapping(namespaceMappingToCopy.getPrefix(),
namespaceMappingToCopy.getUri());
+ public interface BuiltIns {
+
+ /**
+ * Reserved for items defined within built-in node types.
+ */
+ NamespaceMapping JCR = new NamespaceMapping("jcr",
"http://www.jcp.org/jcr/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for the names of built-in mixin node types.
+ */
+ NamespaceMapping MIX = new NamespaceMapping("mix",
"http://www.jcp.org/jcr/mix/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for the names of built-in primary node types.
+ */
+ NamespaceMapping NT = new NamespaceMapping("nt",
"http://www.jcp.org/jcr/nt/1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * Reserved for reasons of compatibility with XML.
+ */
+ NamespaceMapping XML = new NamespaceMapping("xml",
"http://www.w3.org/XML/1998/namespace"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ /**
+ * A collection of all built-in namespace mappings.
+ */
+ NamespaceMapping[] ALL_BUILT_INS = new NamespaceMapping[] { JCR, NT, MIX, XML };
}
/**
@@ -42,6 +65,14 @@
public static final String NOTATION_SUFFIX = ">"; //$NON-NLS-1$
/**
+ * @param namespaceMappingToCopy the namespace mapping being copied (cannot be
<code>null</code>)
+ * @return a new namespace mapping exactly equal to the one that was copied (never
<code>null</code>)
+ */
+ public static NamespaceMapping copy( final NamespaceMapping namespaceMappingToCopy )
{
+ return new NamespaceMapping(namespaceMappingToCopy.getPrefix(),
namespaceMappingToCopy.getUri());
+ }
+
+ /**
* The registered property change listeners (never <code>null</code>).
*/
private final CopyOnWriteArrayList<PropertyChangeListener> listeners;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/NodeTypeDefinition.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -447,6 +447,17 @@
}
/**
+ * @return the child node definitions and property definitions contained in this node
type definition (never <code>null</code>
+ * but can be empty)
+ */
+ public List<ItemDefinition> getItemDefinitions() {
+ // TODO this needs to be a field and getters for items need to filter this field
appropriately
+ final List<ItemDefinition> currentItems = new
ArrayList<ItemDefinition>(getChildNodeDefinitions());
+ currentItems.addAll(getPropertyDefinitions());
+ return currentItems;
+ }
+
+ /**
* {@inheritDoc}
*
* @see javax.jcr.nodetype.NodeTypeDefinition#getName()
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/NodeTypeAttributes.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -101,10 +101,6 @@
return this.notConcrete;
}
- private String getFormatDelimiter() {
- return
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER);
- }
-
/**
* @return the mixin attribute (never <code>null</code>)
*/
@@ -200,7 +196,7 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String DELIM = getFormatDelimiter();
+ final String DELIM =
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
final StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM,
this.orderable.toCndNotation(notationType));
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItem.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -25,6 +25,25 @@
/**
* {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if ((obj == null) || !getClass().equals(obj.getClass())) {
+ return false;
+ }
+
+ if (this == obj) {
+ return true;
+ }
+
+ PrimaryItem that = (PrimaryItem)obj;
+ return (super.equals(obj) &&
getPrimaryItem().equals(that.getPrimaryItem()));
+ }
+
+ /**
+ * {@inheritDoc}
*
* @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#get()
*/
@@ -81,6 +100,16 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return Utils.hashCode(super.hashCode(), this.primaryItem);
+ }
+
+ /**
* {@inheritDoc} Only can be used to set to variant state.
*
* @see
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState#set(org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value)
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-29
20:38:25 UTC (rev 39924)
@@ -52,7 +52,7 @@
# 0 = node type definition name
emptySuperTypes = The node type definition "{0}" must have at least one super
type.
# 0 = name or type of qualified name
-emptyUnqualifiedName = The "{0}" has an empty unqualified name.
+emptyUnqualifiedName = The {0} has an empty unqualified name.
# 0 = property or attribute name of a node type definition, property definition, or child
node definition
emptyValue = A "{0}" value cannot be empty
# 0 = property definition name
@@ -83,7 +83,7 @@
# 0 = CND line number, 1 = CND column number
multipleKeywordNotValidInJcr2CndFormat = The 'MULTIPLE' attribute at line {0},
column {1} is no longer valid in the JCR 2.0 CND format. Use 'SNS' instead.
# 0 = type of qualified name, 1 = qualifier
-nameQualifierNotFound = The "{0}" has a qualifier of "{1}" that does
not match any namespace prefixes in the CND.
+nameQualifierNotFound = The {0} has a qualifier of "{1}" that does not match
any namespace prefixes in the CND.
namespacePrefix = namespace prefix
namespaceUri = namespace URI
# 0 = node type definition name
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -422,16 +422,28 @@
final Label label = toolkit.createLabel(rightContainer,
CndMessages.requiredTypesLabel);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
- ((GridData)label.getLayoutData()).horizontalSpan = 2;
+ createRequiredTypesActions();
+
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.HORIZONTAL);
+ final ToolBar toolBar = toolBarManager.createControl(rightContainer);
+ toolkit.adapt(toolBar);
+
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addRequiredType);
+ toolBarManager.add(this.editRequiredType);
+ toolBarManager.add(this.deleteRequiredType);
+ toolBarManager.update(true);
+
final Table table = FormUtils.createTable(toolkit, rightContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
+ ((GridData)table.getLayoutData()).horizontalSpan = 2;
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 2;
this.requiredTypesError.setControl(table);
- createRequiredTypesActions();
-
// table context menu
final MenuManager menuManager = new MenuManager();
menuManager.add(new DelegateAction(CndMessages.addRequiredTypeMenuText,
this.addRequiredType));
@@ -441,18 +453,6 @@
createRequiredTypesViewer(table);
- // add toolbar buttons (add, edit, delete)
- final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.VERTICAL);
- final ToolBar toolBar = toolBarManager.createControl(rightContainer);
-
- toolkit.adapt(toolBar);
- final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- toolBar.setCursor(handCursor);
- toolBarManager.add(this.addRequiredType);
- toolBarManager.add(this.editRequiredType);
- toolBarManager.add(this.deleteRequiredType);
- toolBarManager.update(true);
-
// fill with data
this.requiredTypesViewer.setInput(this);
}
@@ -793,7 +793,8 @@
}
private void validateDefaultType() {
- updateMessage(CndValidator.validateDefaultType(this.childNodeBeingEdited),
this.defaultTypeError);
+ updateMessage(CndValidator.validateDefaultType(this.childNodeBeingEdited,
this.existingNamespacePrefixes),
+ this.defaultTypeError);
}
private void validateName() {
@@ -801,6 +802,7 @@
}
private void validateRequiredTypes() {
- updateMessage(CndValidator.validateRequiredTypes(this.childNodeBeingEdited),
this.requiredTypesError);
+ updateMessage(CndValidator.validateRequiredTypes(this.childNodeBeingEdited,
this.existingNamespacePrefixes),
+ this.requiredTypesError);
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -39,6 +39,7 @@
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
@@ -73,6 +74,7 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.cnd.ItemDefinition;
import org.jboss.tools.modeshape.jcr.cnd.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.cnd.NodeTypeDefinition;
import org.jboss.tools.modeshape.jcr.cnd.PropertyDefinition;
@@ -81,7 +83,6 @@
import org.jboss.tools.modeshape.ui.UiMessages;
import org.jboss.tools.modeshape.ui.UiUtils;
import org.jboss.tools.modeshape.ui.actions.DelegateAction;
-import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
import org.jboss.tools.modeshape.ui.forms.FormUtils;
import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
import org.jboss.tools.modeshape.ui.forms.MessageFormDialog;
@@ -101,6 +102,7 @@
private Button btnMixin;
private Button btnOrderable;
private Button btnQueryable;
+ private CCombo cbxPrimaryItem;
private Section childNodeSection;
private TableViewer childNodeViewer;
private IAction deleteChildNode;
@@ -115,11 +117,9 @@
private IAction editSuperType;
private QualifiedNameEditor nameEditor;
private Section namespaceSection;
- private final ErrorMessage namespacesError;
private TableViewer namespaceViewer;
private String nodeTypeNameFilterPattern;
private Section nodeTypeSection;
- private final ErrorMessage nodeTypesError;
private TableViewer nodeTypeViewer;
private Section propertiesSection;
private TableViewer propertyViewer;
@@ -132,10 +132,6 @@
*/
protected CndFormsEditorPage( final CndEditor cndEditor ) {
super(cndEditor, CND_FORMS_PAGE, CndMessages.cndEditorFormsPageTitle);
-
- // construct form messages
- this.namespacesError = new ErrorMessage();
- this.nodeTypesError = new ErrorMessage();
}
/**
@@ -234,10 +230,6 @@
// create actions
createChildNodeActions();
- // create toolbar
- FormUtils.createSectionToolBar(this.childNodeSection, toolkit, new IAction[] {
this.addChildNode, this.editChildNode,
- this.deleteChildNode });
-
// create viewer
final Composite container = toolkit.createComposite(this.childNodeSection);
container.setLayout(new GridLayout());
@@ -245,6 +237,9 @@
this.childNodeSection.setClient(container);
toolkit.paintBordersFor(container);
+ // create toolbar
+ FormUtils.createToolBar(container, toolkit, new IAction[] { this.addChildNode,
this.editChildNode, this.deleteChildNode });
+
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -284,11 +279,17 @@
final NotationType notationType = NotationType.LONG;
if (this.columnIndex == ChildNodeColumnIndexes.DEFAULT_TYPE) {
- return
childNodeDefinition.getDefaultType().toCndNotation(notationType);
+ return childNodeDefinition.getDefaultType().getDefaultType().get();
}
if (this.columnIndex == ChildNodeColumnIndexes.REQUIRED_TYPES) {
- return
childNodeDefinition.getRequiredTypesCndNotation(notationType);
+ final String[] requiredTypes =
childNodeDefinition.getRequiredPrimaryTypeNames();
+
+ if (Utils.isEmpty(requiredTypes)) {
+ return Utils.EMPTY_STRING;
+ }
+
+ return UiUtils.join(Arrays.asList(requiredTypes), null);
}
assert (this.columnIndex == ChildNodeColumnIndexes.ATTRIBUTES) :
"Unexpected child node column index"; //$NON-NLS-1$
@@ -434,7 +435,7 @@
SWT.NONE,
toolkit,
Messages.nodeTypeDefinitionName,
- getNamespacePrefixes(),
+
getCnd().getNamespacePrefixes(),
null);
((GridData)this.nameEditor.getLayoutData()).horizontalSpan = 2;
this.nameEditor.addListener(SWT.Modify, new Listener() {
@@ -526,6 +527,42 @@
});
this.btnQueryable.setToolTipText(CndMessages.queryableAttributeToolTip);
+ { // primary item
+ final Composite primaryItemContainer =
toolkit.createComposite(attributesContainer);
+ primaryItemContainer.setLayout(new GridLayout(2, false));
+ primaryItemContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true));
+ ((GridData)primaryItemContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.paintBordersFor(primaryItemContainer);
+
+ final Label lblPrimaryItem =
toolkit.createLabel(primaryItemContainer, CndMessages.primaryItemLabel, SWT.NONE);
+ lblPrimaryItem.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER,
false, false));
+
+ this.cbxPrimaryItem = new CCombo(primaryItemContainer,
Styles.COMBO_STYLE);
+ this.cbxPrimaryItem.setLayoutData(new GridData(SWT.FILL, SWT.FILL,
true, true));
+ ((GridData)this.cbxPrimaryItem.getLayoutData()).heightHint =
this.cbxPrimaryItem.getItemHeight() + 4;
+ this.cbxPrimaryItem.setToolTipText(CndMessages.primaryItemToolTip);
+ toolkit.adapt(this.cbxPrimaryItem, true, false);
+
+ this.cbxPrimaryItem.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ String newPrimaryItem = ((CCombo)e.widget).getText();
+
+ if (CndMessages.noPrimaryItemChoice.equals(newPrimaryItem))
{
+ newPrimaryItem = Utils.EMPTY_STRING;
+ }
+
+ handlePrimaryItemChanged(newPrimaryItem);
+ }
+ });
+ }
+
// fill with data from CND
refreshAttributeControls();
}
@@ -539,16 +576,29 @@
final Label label = toolkit.createLabel(rightContainer,
CndMessages.supertypesLabel);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
- ((GridData)label.getLayoutData()).horizontalSpan = 2;
+ createSuperTypesActions();
+
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.HORIZONTAL);
+ final ToolBar toolBar = toolBarManager.createControl(rightContainer);
+ toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ toolkit.adapt(toolBar);
+
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addSuperType);
+ toolBarManager.add(this.editSuperType);
+ toolBarManager.add(this.deleteSuperType);
+ toolBarManager.update(true);
+
final Table table = FormUtils.createTable(toolkit, rightContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
- ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 2;
+ ((GridData)table.getLayoutData()).horizontalSpan = 2;
+ ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 4;
table.setToolTipText(CndMessages.supertypesToolTip);
- createSuperTypesActions();
-
// table context menu
final MenuManager menuManager = new MenuManager();
menuManager.add(new DelegateAction(CndMessages.addSuperTypeMenuText,
this.addSuperType));
@@ -558,18 +608,6 @@
createSuperTypesViewer(table);
- // add toolbar buttons (add, edit, delete)
- final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.VERTICAL);
- final ToolBar toolBar = toolBarManager.createControl(rightContainer);
-
- toolkit.adapt(toolBar);
- final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- toolBar.setCursor(handCursor);
- toolBarManager.add(this.addSuperType);
- toolBarManager.add(this.editSuperType);
- toolBarManager.add(this.deleteSuperType);
- toolBarManager.update(true);
-
// fill with data from CND
refreshSuperTypes();
}
@@ -643,26 +681,26 @@
// create section
this.namespaceSection = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorNamespacesSectionTitle,
-
CndMessages.cndEditorNamespacesSectionDescription, sectionStyle, true);
+
CndMessages.cndEditorNamespacesSectionDescription, sectionStyle, false);
toolkit.paintBordersFor(this.namespaceSection);
- this.namespacesError.setControl(this.namespaceSection.getDescriptionControl());
// create actions
createNamespaceActions();
- // create toolbar
- FormUtils.createSectionToolBar(this.namespaceSection, toolkit, new IAction[] {
this.addNamespace, this.editNamespace,
- this.deleteNamespace });
-
// create viewer
final Composite container = toolkit.createComposite(this.namespaceSection);
container.setLayout(new GridLayout());
- container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ container.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
this.namespaceSection.setClient(container);
toolkit.paintBordersFor(container);
+ // create toolbar
+ FormUtils.createToolBar(container, toolkit, new IAction[] { this.addNamespace,
this.editNamespace, this.deleteNamespace });
+
final Table table = FormUtils.createTable(toolkit, container);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+ ((GridData)table.getLayoutData()).minimumHeight = table.getItemHeight() * 5;
// table context menu
final MenuManager menuManager = new MenuManager();
@@ -836,14 +874,10 @@
CndMessages.cndEditorNodeTypeSectionDescription, Styles.SECTION_STYLE
&
~ExpandableComposite.TWISTIE, false);
toolkit.paintBordersFor(this.nodeTypeSection);
- this.nodeTypesError.setControl(this.nodeTypeSection.getDescriptionControl());
// create actions
createNodeTypeActions();
- // create toolbar
- FormUtils.createSectionToolBar(this.nodeTypeSection, toolkit, new IAction[] {
this.addNodeType, this.deleteNodeType });
-
// splitter has node type table on left and node type detail, properties, and
child nodes on right
final SashForm splitter = new SashForm(this.nodeTypeSection, SWT.HORIZONTAL);
toolkit.adapt(splitter);
@@ -857,6 +891,9 @@
leftContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
toolkit.paintBordersFor(leftContainer);
+ // create toolbar
+ FormUtils.createToolBar(leftContainer, toolkit, new IAction[] { this.addNodeType,
this.deleteNodeType });
+
FILTER: {
this.txtFilter = toolkit.createText(leftContainer, Utils.EMPTY_STRING,
Styles.TEXT_STYLE | SWT.SEARCH | SWT.ICON_CANCEL);
this.txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
@@ -1110,10 +1147,6 @@
// create actions
createPropertyActions();
- // create toolbar
- FormUtils.createSectionToolBar(this.propertiesSection, toolkit, new IAction[] {
this.addProperty, this.editProperty,
- this.deleteProperty });
-
// create viewer
final Composite container = toolkit.createComposite(this.propertiesSection);
container.setLayout(new GridLayout());
@@ -1121,6 +1154,9 @@
this.propertiesSection.setClient(container);
toolkit.paintBordersFor(container);
+ // create toolbar
+ FormUtils.createToolBar(container, toolkit, new IAction[] { this.addProperty,
this.editProperty, this.deleteProperty });
+
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -1447,22 +1483,6 @@
return childNodeNames;
}
- private List<String> getNamespacePrefixes() {
- final List<NamespaceMapping> namespaces = getCnd().getNamespaceMappings();
-
- if (namespaces.isEmpty()) {
- return null;
- }
-
- final List<String> prefixes = new
ArrayList<String>(namespaces.size());
-
- for (final NamespaceMapping namespace : namespaces) {
- prefixes.add(namespace.getPrefix());
- }
-
- return prefixes;
- }
-
/**
* @return the name filter pattern (can be <code>null</code>)
*/
@@ -1589,7 +1609,7 @@
void handleAddChildNode() {
assert (getSelectedNodeType() != null) : "add child node handler called but
there is no selected node type"; //$NON-NLS-1$
- final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
getChildNodeNames(), getNamespacePrefixes());
+ final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
getChildNodeNames(), getCnd().getNamespacePrefixes());
dialog.create();
dialog.getShell().pack();
@@ -1598,7 +1618,16 @@
// add and select new child node definition
if (getSelectedNodeType().addChildNodeDefinition(newChildNodeDefinition)) {
- this.childNodeViewer.setSelection(new
StructuredSelection(newChildNodeDefinition));
+ this.childNodeViewer.setSelection(new
StructuredSelection(newChildNodeDefinition), true);
+ UiUtils.pack(this.childNodeViewer);
+
+ // make sure section is expanded
+ if (!this.childNodeSection.isExpanded()) {
+ this.childNodeSection.setExpanded(true);
+ }
+
+ // make sure table is visible
+ FormToolkit.ensureVisible(this.childNodeViewer.getTable());
} else {
MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
JcrUiUtils.getCndEditorImage(),
NLS.bind(CndMessages.errorAddingChildNode,
newChildNodeDefinition.getName()));
@@ -1614,8 +1643,18 @@
if (dialog.open() == Window.OK) {
final NamespaceMapping newNamespaceMapping = dialog.getNamespaceMapping();
+ // add and select new namespace mapping
if (getCnd().addNamespaceMapping(newNamespaceMapping)) {
- this.namespaceViewer.setSelection(new
StructuredSelection(newNamespaceMapping));
+ this.namespaceViewer.setSelection(new
StructuredSelection(newNamespaceMapping), true);
+ UiUtils.pack(this.namespaceViewer);
+
+ // make sure section is expanded
+ if (!this.namespaceSection.isExpanded()) {
+ this.namespaceSection.setExpanded(true);
+ }
+
+ // make sure table is visible
+ FormToolkit.ensureVisible(this.namespaceViewer.getTable());
} else {
MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
JcrUiUtils.getCndEditorImage(),
NLS.bind(CndMessages.errorAddingNamespaceMapping, newNamespaceMapping));
@@ -1627,7 +1666,7 @@
final QualifiedNameDialog dialog = new QualifiedNameDialog(getShell(),
CndMessages.newNodeTypeDialogTitle,
Messages.nodeTypeDefinitionName,
-
getNamespacePrefixes());
+
getCnd().getNamespacePrefixes());
dialog.setExistingQNames(getNodeTypeNames());
dialog.create();
dialog.getShell().pack();
@@ -1639,7 +1678,11 @@
// add and select new node type definition
if (getCnd().addNodeTypeDefinition(newNodeTypeDefinition)) {
- this.nodeTypeViewer.setSelection(new
StructuredSelection(newNodeTypeDefinition));
+ this.nodeTypeViewer.setSelection(new
StructuredSelection(newNodeTypeDefinition), true);
+ UiUtils.pack(this.nodeTypeViewer);
+
+ // make sure table is visible
+ FormToolkit.ensureVisible(this.nodeTypeViewer.getTable());
} else {
MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
JcrUiUtils.getCndEditorImage(),
NLS.bind(CndMessages.errorAddingNodeType,
newNodeTypeName));
@@ -1650,7 +1693,7 @@
void handleAddProperty() {
assert (getSelectedNodeType() != null) : "add property handler called but
there is no selected node type"; //$NON-NLS-1$
- final PropertyDialog dialog = new PropertyDialog(getShell(), getPropertyNames(),
getNamespacePrefixes());
+ final PropertyDialog dialog = new PropertyDialog(getShell(), getPropertyNames(),
getCnd().getNamespacePrefixes());
dialog.create();
dialog.getShell().pack();
@@ -1659,7 +1702,16 @@
// add and select new property definition
if (getSelectedNodeType().addPropertyDefinition(newPropertyDefinition)) {
- this.propertyViewer.setSelection(new
StructuredSelection(newPropertyDefinition));
+ this.propertyViewer.setSelection(new
StructuredSelection(newPropertyDefinition), true);
+ UiUtils.pack(this.propertyViewer);
+
+ // make sure section is expanded
+ if (!this.propertiesSection.isExpanded()) {
+ this.propertiesSection.setExpanded(true);
+ }
+
+ // make sure table is visible
+ FormToolkit.ensureVisible(this.propertyViewer.getTable());
} else {
MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
JcrUiUtils.getCndEditorImage(),
NLS.bind(CndMessages.errorAddingProperty,
newPropertyDefinition.getName()));
@@ -1673,7 +1725,7 @@
final QualifiedNameDialog dialog = new QualifiedNameDialog(getShell(),
CndMessages.newSuperTypeDialogTitle,
Messages.superTypeName,
-
getNamespacePrefixes());
+
getCnd().getNamespacePrefixes());
dialog.setExistingQNames(getSelectedNodeType().getSupertypes());
dialog.create();
dialog.getShell().pack();
@@ -1684,7 +1736,10 @@
// add and select new supertype
if (nodeTypeDefinition.addSuperType(newSupertype.get())) {
- this.superTypesViewer.setSelection(new
StructuredSelection(newSupertype.get()));
+ this.superTypesViewer.setSelection(new
StructuredSelection(newSupertype.get()), true);
+
+ // make sure table is visible
+ FormToolkit.ensureVisible(this.superTypesViewer.getTable());
} else {
MessageFormDialog.openError(getShell(), UiMessages.errorDialogTitle,
JcrUiUtils.getCndEditorImage(),
NLS.bind(CndMessages.errorAddingSupertype,
newSupertype));
@@ -1832,10 +1887,15 @@
assert (getSelectedNodeType() != null) : "edit child node handler called but
there is no selected node type"; //$NON-NLS-1$
assert (getSelectedChildNode() != null) : "edit child node handler has been
called when there is no child node selected"; //$NON-NLS-1$
+ // make sure section is expanded
+ if (!this.childNodeSection.isExpanded()) {
+ this.childNodeSection.setExpanded(true);
+ }
+
final ChildNodeDefinition childNodeBeingEdited = getSelectedChildNode();
final ChildNodeDialog dialog = new ChildNodeDialog(getShell(),
getChildNodeNames(),
- getNamespacePrefixes(),
+
getCnd().getNamespacePrefixes(),
childNodeBeingEdited);
dialog.create();
dialog.getShell().pack();
@@ -1906,7 +1966,7 @@
final PropertyDefinition propertyBeingEdited = getSelectedProperty();
final PropertyDialog dialog = new PropertyDialog(getShell(),
getPropertyNames(),
- getNamespacePrefixes(),
+
getCnd().getNamespacePrefixes(),
propertyBeingEdited);
dialog.create();
dialog.getShell().pack();
@@ -1942,7 +2002,7 @@
final QualifiedNameDialog dialog = new QualifiedNameDialog(getShell(),
CndMessages.editSuperTypeDialogTitle,
Messages.superTypeName,
-
getNamespacePrefixes(),
+
getCnd().getNamespacePrefixes(),
QualifiedName.parse(selectedSupertype));
dialog.setExistingQNames(getSelectedNodeType().getSupertypes());
dialog.create();
@@ -2047,6 +2107,10 @@
getSelectedNodeType().setOrderableChildNodes(newValue);
}
+ void handlePrimaryItemChanged( final String newPrimaryItem ) {
+ getSelectedNodeType().setPrimaryItemName(newPrimaryItem);
+ }
+
/**
* {@inheritDoc}
*
@@ -2068,7 +2132,9 @@
||
NodeTypeDefinition.PropertyName.ORDERABLE.toString().equals(propName)
||
NodeTypeDefinition.PropertyName.QUERYABLE.toString().equals(propName)
||
NodeTypeDefinition.PropertyName.PRIMARY_ITEM.toString().equals(propName)) {
- validateAttributes();
+ if
(NodeTypeDefinition.PropertyName.PRIMARY_ITEM.toString().equals(propName)) {
+ validateAttributes();
+ }
} else if
(NodeTypeDefinition.PropertyName.CHILD_NODES.toString().equals(propName)) {
validateChildNodes();
this.childNodeViewer.refresh();
@@ -2094,6 +2160,7 @@
if
(CompactNodeTypeDefinition.PropertyName.NAMESPACE_MAPPINGS.toString().equals(propName)) {
validateNamespaces();
refreshNamespaceControls();
+ refreshNameControls(); // need to repopulate the node type name qualifier
combo
} else if
(CompactNodeTypeDefinition.PropertyName.NODE_TYPE_DEFINITIONS.toString().equals(propName))
{
refreshNodeTypeControls();
}
@@ -2138,6 +2205,9 @@
private void populateUi() {
this.namespaceViewer.setInput(this);
+
this.namespaceViewer.getTable().setToolTipText(NLS.bind(CndMessages.namespacesTableToolTip,
getCnd().getNamespaceMappings()
+
.size()));
+
this.nodeTypeViewer.setInput(this);
// size columns to the data
@@ -2195,15 +2265,61 @@
if (nodeTypeDefinition.isAbstract()) {
notConcrete = true;
}
+
if (nodeTypeDefinition.isMixin()) {
mixin = true;
}
+
if (nodeTypeDefinition.hasOrderableChildNodes()) {
orderable = true;
}
+
if (nodeTypeDefinition.isQueryable()) {
queryable = true;
}
+
+ // set primary item choices if they have changed
+ final List<ItemDefinition> currentItems =
nodeTypeDefinition.getItemDefinitions();
+
+ // take out any items with residual names
+ for (ItemDefinition item : new ArrayList<ItemDefinition>(currentItems))
{
+ if (ItemDefinition.RESIDUAL_NAME.equals(item.getQualifiedName().get()))
{
+ currentItems.remove(item);
+ }
+ }
+
+ final String[] itemNames = new String[currentItems.size() + 1];
+ itemNames[0] = CndMessages.noPrimaryItemChoice;
+ int i = 1;
+
+ for (final ItemDefinition item : currentItems) {
+ itemNames[i++] = item.getQualifiedName().get();
+ }
+
+ // only reload primary item names if different
+ if ((this.cbxPrimaryItem.getItemCount() != itemNames.length)
+ ||
!Arrays.asList(itemNames).containsAll(Arrays.asList(this.cbxPrimaryItem.getItems()))) {
+ this.cbxPrimaryItem.setItems(itemNames);
+ }
+
+ // select the current primary item name
+ final String primaryItemName = nodeTypeDefinition.getPrimaryItemName();
+
+ if (Utils.isEmpty(primaryItemName)) {
+ this.cbxPrimaryItem.select(0); // select no primary item assigned
+ } else {
+ final int index = this.cbxPrimaryItem.indexOf(primaryItemName);
+
+ if (index == -1) {
+ // not a valid primary item but add and select
+ this.cbxPrimaryItem.add(primaryItemName);
+ this.cbxPrimaryItem.select(this.cbxPrimaryItem.getItemCount() - 1);
+ } else {
+ this.cbxPrimaryItem.select(index);
+ }
+ }
+ } else {
+ this.cbxPrimaryItem.select(0); // select no primary item assigned
}
if (this.btnAbstract.getSelection() != notConcrete) {
@@ -2239,13 +2355,15 @@
} else {
// load name editor with current namespace prefixes, current node type names,
and selected node type name
this.nameEditor.setNameBeingEdited(nodeTypeDefinition.getQualifiedName());
- this.nameEditor.setValidQualifiers(getNamespacePrefixes());
+ this.nameEditor.setValidQualifiers(getCnd().getNamespacePrefixes());
this.nameEditor.setExistingQNames(getNodeTypeNames());
}
}
private void refreshNamespaceControls() {
this.namespaceViewer.refresh();
+
this.namespaceViewer.getTable().setToolTipText(NLS.bind(CndMessages.namespacesTableToolTip,
getCnd().getNamespaceMappings()
+
.size()));
}
private void refreshNodeTypeControls() {
@@ -2326,10 +2444,10 @@
*/
@Override
protected void updateAllMessages() {
- validateChildNodes();
+ // validateChildNodes();
validateNamespaces();
validateNodeTypes();
- validateProperties();
+ // validateProperties();
}
private void updateEnabledState() {
@@ -2396,6 +2514,10 @@
this.btnQueryable.setEnabled(enableWithNodeTypeSelected);
}
+ if (this.cbxPrimaryItem.isEnabled() != enableWithNodeTypeSelected) {
+ this.cbxPrimaryItem.setEnabled(enableWithNodeTypeSelected);
+ }
+
if (this.addSuperType.isEnabled() != enableWithNodeTypeSelected) {
this.addSuperType.setEnabled(enableWithNodeTypeSelected);
}
@@ -2456,37 +2578,39 @@
}
}
+ private void processStatus( IMessageManager msgMgr,
+ final ValidationStatus status,
+ final Control c ) {
+ if (status.isOk()) {
+ return;
+ }
+
+ if (status instanceof MultiValidationStatus) {
+ final MultiValidationStatus multiStatus = (MultiValidationStatus)status;
+
+ for (final ValidationStatus embeddedStatus : multiStatus.getAll()) {
+ processStatus(msgMgr, embeddedStatus, c);
+ }
+ } else {
+ msgMgr.addMessage(status.getMessage(), status.getMessage(), null,
JcrUiUtils.getMessageType(status), c);
+ }
+ }
+
private void updateMessage( final ValidationStatus status,
- final ErrorMessage errorMessage ) {
+ final Control control ) {
final IMessageManager msgMgr = getCndEditor().getMessageManager();
msgMgr.setAutoUpdate(false);
- final Control control = errorMessage.getControl();
msgMgr.removeMessages(control);
- JcrUiUtils.setMessage(status, errorMessage);
-
- if (!errorMessage.isOk()) {
- if (status instanceof MultiValidationStatus) {
- final Object data = errorMessage.getData();
- final MultiValidationStatus multiStatus = (MultiValidationStatus)status;
-
- for (final ValidationStatus singleStatus : multiStatus.getAll()) {
- if (!singleStatus.isOk()) {
- msgMgr.addMessage(singleStatus.getMessage(),
singleStatus.getMessage(), data,
- JcrUiUtils.getMessageType(singleStatus),
control);
- }
- }
- } else {
- msgMgr.addMessage(errorMessage.getKey(), errorMessage.getMessage(),
errorMessage.getData(),
- errorMessage.getMessageType(),
errorMessage.getControl());
- }
+ if (!status.isOk()) {
+ processStatus(msgMgr, status, control);
}
msgMgr.setAutoUpdate(true);
}
private void validateAttributes() {
- // TODO primary item
+ validateNodeTypes();
}
private void validateChildNodes() {
@@ -2499,12 +2623,13 @@
private void validateNamespaces() {
final MultiValidationStatus status =
CndValidator.validateNamespaceMappings(getCnd().getNamespaceMappings());
- updateMessage(status, this.namespacesError);
+ updateMessage(status, this.namespaceSection);
}
private void validateNodeTypes() {
- final MultiValidationStatus status =
CndValidator.validateNodeTypeDefinitions(getCnd().getNodeTypeDefinitions(), true);
- updateMessage(status, this.nodeTypesError);
+ final MultiValidationStatus status =
CndValidator.validateNodeTypeDefinitions(getCnd().getNodeTypeDefinitions(),
+
getCnd().getNamespacePrefixes(), true);
+ updateMessage(status, this.nodeTypeSection);
}
private void validateProperties() {
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -819,6 +819,11 @@
public static String namespacePrefixToolTip;
/**
+ * The tool tip for a namespace mappings table.
+ */
+ public static String namespacesTableToolTip;
+
+ /**
* The column header text for a namespace URI.
*/
public static String namespaceUriHeaderText;
@@ -879,6 +884,11 @@
public static String noNameQualifierChoice;
/**
+ * The text indicating the node type definition has not assigned a primary item.
+ */
+ public static String noPrimaryItemChoice;
+
+ /**
* A name for the noQueryOrder attribute suitable for a radio or check button.
*/
public static String noQueryOrderAttribute;
@@ -909,6 +919,16 @@
public static String orderableAttributeToolTip;
/**
+ * A label for a primary item control.
+ */
+ public static String primaryItemLabel;
+
+ /**
+ * A tool tip message of the node type definition's primary item attribute.
+ */
+ public static String primaryItemToolTip;
+
+ /**
* The tool tip for the attributes of a property definition.
*/
public static String propertyAttributesToolTip;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -368,8 +368,7 @@
// select the current type
if (isEditMode()) {
- final String currentType =
OnParentVersion.findUsingJcrValue(this.propertyBeingEdited.getOnParentVersion())
- .toString();
+ final String currentType =
this.propertyBeingEdited.getType().toString();
final int index = cbxType.indexOf(currentType);
if (index == -1) {
@@ -615,17 +614,30 @@
final Label label = toolkit.createLabel(defaultValuesContainer,
CndMessages.defaultValuesLabel);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
- ((GridData)label.getLayoutData()).horizontalSpan = 2;
+ createDefaultValuesActions();
+
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.HORIZONTAL);
+ final ToolBar toolBar =
toolBarManager.createControl(defaultValuesContainer);
+ toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ toolkit.adapt(toolBar);
+
+ final Cursor handCursor = new Cursor(Display.getCurrent(),
SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addDefaultValue);
+ toolBarManager.add(this.editDefaultValue);
+ toolBarManager.add(this.deleteDefaultValue);
+ toolBarManager.update(true);
+
final Table table = FormUtils.createTable(toolkit,
defaultValuesContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() *
4;
+ ((GridData)table.getLayoutData()).horizontalSpan = 2;
table.setToolTipText(CndMessages.defaultValuesToolTip);
this.defaultValuesError.setControl(table);
- createDefaultValuesActions();
-
// table context menu
final MenuManager menuManager = new MenuManager();
menuManager.add(new DelegateAction(CndMessages.addDefaultValueMenuText,
this.addDefaultValue));
@@ -635,18 +647,6 @@
createDefaultValuesViewer(table);
- // add toolbar buttons (add, edit, delete)
- final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.VERTICAL);
- final ToolBar toolBar =
toolBarManager.createControl(defaultValuesContainer);
- toolkit.adapt(toolBar);
-
- final Cursor handCursor = new Cursor(Display.getCurrent(),
SWT.CURSOR_HAND);
- toolBar.setCursor(handCursor);
- toolBarManager.add(this.addDefaultValue);
- toolBarManager.add(this.editDefaultValue);
- toolBarManager.add(this.deleteDefaultValue);
- toolBarManager.update(true);
-
// fill with data
this.defaultValuesViewer.setInput(this);
}
@@ -659,17 +659,30 @@
final Label label = toolkit.createLabel(valueConstraintsContainer,
CndMessages.valueConstraintsLabel);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
- ((GridData)label.getLayoutData()).horizontalSpan = 2;
+ createValueConstraintsActions();
+
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.HORIZONTAL);
+ final ToolBar toolBar =
toolBarManager.createControl(valueConstraintsContainer);
+ toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
+ toolkit.adapt(toolBar);
+
+ final Cursor handCursor = new Cursor(Display.getCurrent(),
SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addValueConstraint);
+ toolBarManager.add(this.editValueConstraint);
+ toolBarManager.add(this.deleteValueConstraint);
+ toolBarManager.update(true);
+
final Table table = FormUtils.createTable(toolkit,
valueConstraintsContainer);
table.setHeaderVisible(false);
table.setLinesVisible(false);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() *
4;
+ ((GridData)table.getLayoutData()).horizontalSpan = 2;
table.setToolTipText(CndMessages.valueConstraintsToolTip);
this.valueConstraintsError.setControl(table);
- createValueConstraintsActions();
-
// table context menu
final MenuManager menuManager = new MenuManager();
menuManager.add(new
DelegateAction(CndMessages.addValueConstraintMenuText, this.addValueConstraint));
@@ -679,18 +692,6 @@
createValueConstraintsViewer(table);
- // add toolbar buttons (add, edit, delete)
- final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.VERTICAL);
- final ToolBar toolBar =
toolBarManager.createControl(valueConstraintsContainer);
- toolkit.adapt(toolBar);
-
- final Cursor handCursor = new Cursor(Display.getCurrent(),
SWT.CURSOR_HAND);
- toolBar.setCursor(handCursor);
- toolBarManager.add(this.addValueConstraint);
- toolBarManager.add(this.editValueConstraint);
- toolBarManager.add(this.deleteValueConstraint);
- toolBarManager.update(true);
-
// fill with data
this.valueConstraintsViewer.setInput(this);
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -255,7 +255,7 @@
this.cbxQualifiers.setItems(this.validQualifiers.toArray(new
String[this.validQualifiers.size()]));
}
- // select the current qualifier
+ // select the current qualifier and set the name
if (isEditMode()) {
final String currentQualifier = this.qnameBeingEdited.getQualifier();
@@ -272,14 +272,11 @@
this.cbxQualifiers.select(index);
}
}
- } else {
- this.cbxQualifiers.select(0);
- }
- if (isEditMode()) {
final String name = this.qnameBeingEdited.getUnqualifiedName();
this.txtName.setText(Utils.isEmpty(name) ? Utils.EMPTY_STRING : name);
} else {
+ this.cbxQualifiers.select(0);
this.txtName.setText(Utils.EMPTY_STRING);
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-29
20:38:25 UTC (rev 39924)
@@ -168,9 +168,10 @@
namespaceLabel = Namespace:
namespacePrefixHeaderText = Prefix
namespacePrefixLabel = Prefix:
-namespacePrefixToolTip = The prefix of the namespace mapping. Must be unique within a
CND
+namespacePrefixToolTip = The prefix of the namespace mapping. Must be unique within a
CND.
+namespacesTableToolTip = The mappings of prefixes to the namespace URIs used in a JCR
repository. The current number of mappings in this CND is {0}.
namespaceUriHeaderText = URI
-namespaceUriToolTip = The URI of the namespace mapping. Must be unique with a CND
+namespaceUriToolTip = The URI of the namespace mapping. Must be unique with a CND.
newNamespaceDialogTitle = New Namespace
newNodeTypeDialogTitle = New Node Type
newRequiredTypeDialogTitle = New Required Type
@@ -181,12 +182,15 @@
noFullTextAttribute = Not Full Text Searchable
noFullTextAttributeToolTip = Indicates if the property does not support full text search
noNameQualifierChoice = <no qualifier>
+noPrimaryItemChoice = <not assigned>
noQueryOrderAttribute = Not Query Orderable
noQueryOrderAttributeToolTip = Indicates if query results of this property cannot be
ordered
onParentVersionLabel = On Parent Version:
onParentVersionToolTip = Indicates what happens to the child node/property when the
parent is created
orderableAttribute = Orderable
orderableAttributeToolTip = Indicates if the node type definition's are ordered
+primaryItemLabel = Primary Item:
+primaryItemToolTip = The child node or property made accessible via the API without
having to know it's name
propertyAttributesToolTip = The attributes of a property definition (autocreated,
mandatory, multiple, nofulltext, noqueryorder, abstract, opv, queryops)
propertyDefaultValuesToolTip = The default values of a property definition
propertyDialogCreateTitle = Create Property
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -120,7 +120,7 @@
});
for (final IAction action : actions) {
- toolBarManager.add(action);
+ toolBarManager.add(action);
}
toolBarManager.update(true);
@@ -128,6 +128,45 @@
}
/**
+ * @param parent the parent whose toolbar is being created (cannot
<code>null</code>)
+ * @param toolkit the toolkit used to create the form objects (cannot be
<code>null</code>)
+ * @param actions the actions used to create the toolbar buttons from (cannot be
<code>null</code> or empty)
+ * @return the toolbar manager of the new toolbar (never
<code>null</code>)
+ */
+ public static IToolBarManager createToolBar( final Composite parent,
+ final FormToolkit toolkit,
+ final IAction[] actions ) {
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+ final ToolBar toolBar = toolBarManager.createControl(parent);
+ toolBar.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
+ toolkit.adapt(toolBar);
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+
+ // Cursor needs to be explicitly disposed
+ toolBar.addDisposeListener(new DisposeListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+ */
+ @Override
+ public void widgetDisposed( final DisposeEvent e ) {
+ if (!handCursor.isDisposed()) {
+ handCursor.dispose();
+ }
+ }
+ });
+
+ for (final IAction action : actions) {
+ toolBarManager.add(action);
+ }
+ toolBarManager.update(true);
+ return toolBarManager;
+ }
+
+ /**
* Table is created with header and lines visible using the default {@link
Styles#VIEWER_STYLE style}.
*
* @param toolkit the toolkit used to create the form objects (cannot be
<code>null</code>)
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/ChildNodeDefinitionTest.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -439,7 +439,7 @@
that.setOnParentVersion(this.childNodeDefinition.getOnParentVersion());
assertEquals(this.childNodeDefinition, that);
-
this.childNodeDefinition.setRequiredPrimaryTypeNames(Constants.Helper.getDefaultQualifiedNamesAsArray());
+
this.childNodeDefinition.setRequiredPrimaryTypeNames(Constants.Helper.getDefaultQualifiedNamesAsStringArray());
that.setRequiredPrimaryTypeNames(this.childNodeDefinition.getRequiredPrimaryTypeNames());
assertEquals(this.childNodeDefinition, that);
}
@@ -490,7 +490,7 @@
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
-
this.childNodeDefinition.setRequiredPrimaryTypeNames(Constants.Helper.getDefaultQualifiedNamesAsArray());
+
this.childNodeDefinition.setRequiredPrimaryTypeNames(Constants.Helper.getDefaultQualifiedNamesAsStringArray());
thatChildNodeDefinition = ChildNodeDefinition.copy(this.childNodeDefinition);
assertEquals(this.childNodeDefinition, thatChildNodeDefinition);
assertEquals(this.childNodeDefinition.hashCode(),
thatChildNodeDefinition.hashCode());
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -38,10 +38,146 @@
public static final String CND_FILE_PATH = "testdata/"; //$NON-NLS-1$
+ public static final String[] NO_DEFAULTS = {};
+ public static final String NO_PRIMARY_NAME = null;
+ public static final String[] NO_SUPERTYPES = {};
+
+ public static final String[] NO_VALUE_CONSTRAINTS = {};
+
+ //
+ // protected Name name( String name ) {
+ // return context.getValueFactories().getNameFactory().create(name);
+ // }
+
private CompactNodeTypeDefinition cnd;
+
private CndImporter importer;
+
private Collection<Throwable> problems;
+ private void assertChild( final String nodeTypeName,
+ final String childName,
+ final String requiredType,
+ final String defaultPrimaryType,
+ final OnParentVersion onParentVersioning,
+ final ChildOptions... childOptions ) {
+ assertChild(nodeTypeName, childName, new String[] { requiredType },
defaultPrimaryType, childOptions, onParentVersioning);
+ }
+
+ private void assertChild( final String nodeTypeName,
+ final String childName,
+ final String[] requiredTypes,
+ final String defaultPrimaryType,
+ final ChildOptions[] childOptions,
+ final OnParentVersion onParentVersioning ) {
+ final Set<ChildOptions> options = new HashSet<ChildOptions>();
+ for (final ChildOptions option : childOptions) {
+ options.add(option);
+ }
+
+ final NodeTypeDefinition defn = defn(nodeTypeName);
+ final NodeDefinition childDefn = childDefn(defn, childName);
+
+ assertEquals(childDefn.getName(), childName);
+ assertEquals(childDefn.getDefaultPrimaryTypeName(), defaultPrimaryType);
+ assertEquals(childDefn.isMandatory(), options.contains(ChildOptions.Mandatory));
+ assertEquals(childDefn.isAutoCreated(),
options.contains(ChildOptions.Autocreated));
+ assertEquals(childDefn.isProtected(), options.contains(ChildOptions.Protected));
+ assertEquals(childDefn.allowsSameNameSiblings(),
options.contains(ChildOptions.Sns));
+ assertEquals(childDefn.getOnParentVersion(), opv(onParentVersioning));
+ assertArrayEquals(childDefn.getRequiredPrimaryTypeNames(), requiredTypes);
+ }
+
+ private void assertNodeType( final String name,
+ final String[] superTypes,
+ final String primaryItemName,
+ final NodeOptions... nodeOptions ) {
+ final Set<NodeOptions> options = new HashSet<NodeOptions>();
+
+ for (final NodeOptions option : nodeOptions) {
+ options.add(option);
+ }
+
+ final NodeTypeDefinition defn = defn(name);
+ assertEquals(defn.getName(), name);
+ assertEquals(defn.isAbstract(), options.contains(NodeOptions.Abstract));
+ assertEquals(defn.hasOrderableChildNodes(),
options.contains(NodeOptions.Ordered));
+ assertEquals(defn.isMixin(), options.contains(NodeOptions.Mixin));
+ // assertEquals(defn.isQueryable(), options.contains(NodeOptions.Queryable)); //
defaults to variant
+ assertTrue(defn.getState(NodeTypeDefinition.PropertyName.QUERYABLE) ==
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value.VARIANT);
+ assertEquals(defn.getPrimaryItemName(), primaryItemName);
+ final String[] supertypeNames = defn.getDeclaredSupertypeNames();
+ assertArrayEquals(supertypeNames, superTypes);
+ }
+
+ //
+ // @Test(expected = ParsingException.class)
+ // public void shouldReportErrorIfTheNodeTypeNameUsesInvalidNamespace() {
+ // String cnd = "<ns = 'http://namespace.com/ns'>
[xyz:acme] abstract"; //$NON-NLS-1$
+ // this.importer.parse(cnd);
+ // }
+
+ private void assertProperty( final String nodeTypeName,
+ final String propertyName,
+ final String requiredType,
+ final String[] defaultValues,
+ final OnParentVersion onParentVersion,
+ final PropertyOptions... propertyOptions ) throws
RepositoryException {
+ assertProperty(nodeTypeName, propertyName, requiredType, defaultValues,
propertyOptions, onParentVersion);
+ }
+
+ private void assertProperty( final String nodeTypeName,
+ final String propertyName,
+ final String requiredType,
+ final String[] defaultValues,
+ final PropertyOptions... propertyOptions ) throws
RepositoryException {
+ assertProperty(nodeTypeName, propertyName, requiredType, defaultValues,
propertyOptions, null);
+ }
+
+ private void assertProperty( final String nodeTypeName,
+ final String propertyName,
+ final String requiredType,
+ final String[] defaultValues,
+ final PropertyOptions[] propertyOptions,
+ final OnParentVersion onParentVersioning,
+ final String... valueConstraints ) throws
RepositoryException {
+ final Set<PropertyOptions> options = new HashSet<PropertyOptions>();
+ for (final PropertyOptions option : propertyOptions) {
+ options.add(option);
+ }
+
+ final NodeTypeDefinition defn = defn(nodeTypeName);
+ final PropertyDefinition propDefn = propDefn(defn, propertyName);
+
+ assertEquals(propDefn.getName(), propertyName);
+ assertEquals(propDefn.getRequiredType(), jcrPropertyType(requiredType));
+ assertEquals(propDefn.isMandatory(),
options.contains(PropertyOptions.Mandatory));
+ assertEquals(propDefn.isAutoCreated(),
options.contains(PropertyOptions.Autocreated));
+ assertEquals(propDefn.isProtected(),
options.contains(PropertyOptions.Protected));
+ assertEquals(propDefn.isMultiple(), options.contains(PropertyOptions.Multiple));
+ assertEquals(propDefn.isFullTextSearchable(),
options.contains(PropertyOptions.FullTextSearchable));
+ assertEquals(propDefn.isQueryOrderable(),
options.contains(PropertyOptions.QueryOrderable));
+
+ final int opv = opv(onParentVersioning);
+ assertEquals(propDefn.getOnParentVersion(), opv);
+
+ if ((defaultValues == null) || (defaultValues.length == 0)) {
+ assertTrue(propDefn.getDefaultValues().length == 0);
+ } else {
+ int i = 0;
+
+ for (final Value defaultValue : propDefn.getDefaultValues()) {
+ assertEquals(defaultValues[i++], defaultValue.getString());
+ }
+ }
+
+ if ((valueConstraints == null) || (valueConstraints.length == 0)) {
+ assertTrue(propDefn.getValueConstraints().length == 0);
+ } else {
+ assertArrayEquals(propDefn.getValueConstraints(), valueConstraints);
+ }
+ }
+
@Before
public void beforeEach() {
this.cnd = null;
@@ -51,165 +187,286 @@
this.importer = new CndImporter(true);
}
- //
- // protected Name name( String name ) {
- // return context.getValueFactories().getNameFactory().create(name);
- // }
-
- protected void printProblems() {
- for (Throwable problem : this.problems) {
- System.out.println(problem.getLocalizedMessage());
+ private NodeDefinition childDefn( final NodeTypeDefinition nodeType,
+ final String name ) {
+ for (final NodeDefinition defn : nodeType.getDeclaredChildNodeDefinitions()) {
+ if (defn.getName().equals(name)) {
+ return defn;
+ }
}
- }
- protected InputStream openCndStream( String cndFileName ) {
- return this.getClass().getClassLoader().getResourceAsStream("cnd/" +
cndFileName); //$NON-NLS-1$
+ assertFalse("Failed to find child node definition \"" + name +
"\"", false); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
}
- protected File openCndFile( String cndFileName ) {
- File result = new File(CND_FILE_PATH + cndFileName);
- assertTrue(result.exists());
+ private NodeTypeDefinition defn( final String name ) {
+ NodeTypeDefinition result = null;
+
+ for (final NodeTypeDefinition defn : this.cnd.getNodeTypeDefinitions()) {
+ if (defn.getName().equals(name)) {
+ result = defn;
+ break;
+ }
+ }
+
+ assertNotNull("Failed to find node type definition \"" + name +
"\"", result); //$NON-NLS-1$ //$NON-NLS-2$
return result;
}
- @Test(expected = ParsingException.class)
- public void shouldReportErrorIfTheNodeTypeNameIsEmpty() {
- String content = "<ns = 'http://namespace.com/ns'> []
abstract"; //$NON-NLS-1$
- this.importer.parse(content);
+ private int jcrPropertyType( final String typeName ) {
+ final PropertyType type = PropertyType.find(typeName);
+ return type.asJcrValue();
+ // org.modeshape.jcr.value.PropertyType type =
org.modeshape.jcr.value.PropertyType.valueFor(typeName.toLowerCase());
+ // return PropertyTypeUtil.jcrPropertyTypeFor(type);
}
- @Test(expected = ParsingException.class)
- public void shouldReportErrorIfTheNodeTypeNameIsBlank() {
- String content = "<ns = 'http://namespace.com/ns'> [ ]
abstract"; //$NON-NLS-1$
- this.importer.parse(content);
+ protected File openCndFile( final String cndFileName ) {
+ final File result = new File(CND_FILE_PATH + cndFileName);
+ assertTrue(result.exists());
+ return result;
}
- @Test(expected = ParsingException.class)
- public void shouldReportErrorIfTheNodeTypeNameIsNotFollowedByClosingBracket() {
- String content = "<ns = 'http://namespace.com/ns'> [
abstract"; //$NON-NLS-1$
- this.importer.parse(content);
+ protected InputStream openCndStream( final String cndFileName ) {
+ return this.getClass().getClassLoader().getResourceAsStream("cnd/" +
cndFileName); //$NON-NLS-1$
}
//
- // @Test(expected = ParsingException.class)
- // public void shouldReportErrorIfTheNodeTypeNameUsesInvalidNamespace() {
- // String cnd = "<ns = 'http://namespace.com/ns'>
[xyz:acme] abstract"; //$NON-NLS-1$
- // this.importer.parse(cnd);
+ // @Test
+ // public void shouldImportCndThatUsesExtensions() throws RepositoryException {
+ // // this.importer.setDebug(true);
+ // String content = "<ex =
'http://namespace.com/ns'>\n" //$NON-NLS-1$
+ // + "[ex:NodeType] > ex:ParentType1, ex:ParentType2 abstract
{mode:desc 'ex:NodeType description'} orderable mixin noquery primaryitem
ex:property\n" //$NON-NLS-1$
+ // + "- ex:property (STRING) = 'default1',
'default2' mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
+ // + " queryops '=, <>, <, <=, >, >=,
LIKE' {mode:desc 'ex:property description'} {mode:altName Cool Property}
nofulltext noqueryorder < 'constraint1', 'constraint2'"
//$NON-NLS-1$
+ // + "+ ex:node (ex:reqType1, ex:reqType2) = ex:defaultType {}
mandatory autocreated protected sns version"; //$NON-NLS-1$
+ // CompactNodeTypeDefinition cnd = this.importer.importFrom(content, problems,
"string"); //$NON-NLS-1$
+ //
+ // // Check the namespace ...
+ // assertEquals(cnd.getNamespaceMappings().size(), 1);
+ // NamespaceMapping ns = cnd.getNamespaceMappings().iterator().next();
+ // assertEquals(ns.getUri(), "http://namespace.com/ns");
//$NON-NLS-1$
+ //
+ // Set<NodeTypeDefinition> defns = cnd.getNodeTypeDefinitions();
+ // assertEquals(defns.size(), 1);
+ //
+ // NodeTypeDefinition defn = defns.iterator().next();
+ // assertEquals(defn.getName(), "ex:NodeType"); //$NON-NLS-1$
+ // assertTrue(defn.isAbstract());
+ // assertTrue(defn.hasOrderableChildNodes());
+ // assertTrue(defn.isMixin());
+ // assertFalse(defn.isQueryable());
+ // assertEquals(defn.getPrimaryItemName(), "ex:property");
//$NON-NLS-1$
+ // String[] supertypeNames = defn.getDeclaredSupertypeNames();
+ // assertEquals(supertypeNames[0], "ex:ParentType1"); //$NON-NLS-1$
+ // assertEquals(supertypeNames[1], "ex:ParentType2"); //$NON-NLS-1$
+ //
+ // PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
+ // assertEquals(propDefns.length, 1);
+ // PropertyDefinition propDefn = propDefns[0];
+ // assertEquals(propDefn.getName(), "ex:property"); //$NON-NLS-1$
+ // assertEquals(propDefn.getRequiredType(), PropertyType.STRING);
+ // assertTrue(propDefn.isMandatory());
+ // assertTrue(propDefn.isAutoCreated());
+ // assertTrue(propDefn.isProtected());
+ // assertTrue(propDefn.isMultiple());
+ // assertEquals(propDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
+ // assertFalse(propDefn.isFullTextSearchable());
+ // assertFalse(propDefn.isQueryOrderable());
+ // Value[] defaultValues = propDefn.getDefaultValues();
+ // assertEquals(defaultValues[0].getString(), "default1");
//$NON-NLS-1$
+ // assertEquals(defaultValues[1].getString(), "default2");
//$NON-NLS-1$
+ // String[] queryOps = propDefn.getAvailableQueryOperators();
+ // assertEquals(queryOps[0], "="); //$NON-NLS-1$
+ // assertEquals(queryOps[1], "<>"); //$NON-NLS-1$
+ // assertEquals(queryOps[2], "<"); //$NON-NLS-1$
+ // assertEquals(queryOps[3], "<="); //$NON-NLS-1$
+ // assertEquals(queryOps[4], ">"); //$NON-NLS-1$
+ // assertEquals(queryOps[5], ">="); //$NON-NLS-1$
+ // assertEquals(queryOps[6], "LIKE"); //$NON-NLS-1$
+ // String[] constraints = propDefn.getValueConstraints();
+ // assertEquals(constraints[0], "constraint1"); //$NON-NLS-1$
+ // assertEquals(constraints[1], "constraint2"); //$NON-NLS-1$
+ //
+ // NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
+ // assertEquals(childDefns.length, 1);
+ // NodeDefinition childDefn = childDefns[0];
+ // assertEquals(childDefn.getName(), "ex:node"); //$NON-NLS-1$
+ // assertEquals(childDefn.getDefaultPrimaryTypeName(),
"ex:defaultType"); //$NON-NLS-1$
+ // assertTrue(childDefn.isMandatory());
+ // assertTrue(childDefn.isAutoCreated());
+ // assertTrue(childDefn.isProtected());
+ // assertTrue(childDefn.allowsSameNameSiblings());
+ // assertEquals(childDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
+ // String[] requiredTypeNames = childDefn.getRequiredPrimaryTypeNames();
+ // assertEquals(requiredTypeNames[0], "ex:reqType1"); //$NON-NLS-1$
+ // assertEquals(requiredTypeNames[1], "ex:reqType2"); //$NON-NLS-1$
// }
- @Test
- public void shouldParseNamespaceDeclarationWithQuotedUriAndQuotedPrefix() {
- String content = "<'ns' =
'http://namespace.com/ns'>"; //$NON-NLS-1$
- this.cnd = this.importer.parse(content);
+ protected int opv( final OnParentVersion onParentVersioning ) {
+ int opv = OnParentVersionAction.COPY;
+ if (onParentVersioning != null) {
+ switch (onParentVersioning) {
+ case Abort:
+ opv = OnParentVersionAction.ABORT;
+ break;
+ case Compute:
+ opv = OnParentVersionAction.COMPUTE;
+ break;
+ case Copy:
+ opv = OnParentVersionAction.COPY;
+ break;
+ case Ignore:
+ opv = OnParentVersionAction.IGNORE;
+ break;
+ case Initialize:
+ opv = OnParentVersionAction.INITIALIZE;
+ break;
+ case Version:
+ opv = OnParentVersionAction.VERSION;
+ break;
+ }
+ }
+ return opv;
+ }
- List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
- assertEquals(1, namespaces.size());
+ protected void printProblems() {
+ for (final Throwable problem : this.problems) {
+ System.out.println(problem.getLocalizedMessage());
+ }
+ }
- NamespaceMapping namespace = namespaces.iterator().next();
- assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
-
assertEquals("http://namespace.com/ns", namespace.getUri());
//$NON-NLS-1$
+ private PropertyDefinition propDefn( final NodeTypeDefinition nodeType,
+ final String name ) {
+ for (final PropertyDefinition defn : nodeType.getDeclaredPropertyDefinitions())
{
+ if (defn.getName().equals(name)) {
+ return defn;
+ }
+ }
+
+ assertFalse("Failed to find property type definition \"" + name +
"\"", false); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
}
@Test
- public void shouldParseNamespaceDeclarationWithUnquotedUriAndQuotedPrefix() {
- String content = "<'ns' = http_namespace.com_ns>";
//$NON-NLS-1$
- this.cnd = this.importer.parse(content);
+ public void shouldImportCndForAircraft() throws Exception {
+ this.importer.importFrom(openCndFile("aircraft.cnd"), this.problems);
//$NON-NLS-1$
- List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
- assertEquals(1, namespaces.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NamespaceMapping namespace = namespaces.iterator().next();
- assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
- assertEquals("http_namespace.com_ns", namespace.getUri());
//$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
+ //
+ // @Test
+ // public void shouldImportBuiltInNodeTypes() throws Exception {
+ // this.importer.importBuiltIns(this.problems);
+ // if (this.problems.size() != 0)
+ // printProblems();
+ // assertThat(this.problems.size(), is(0));
+ //
+ // // Verify a select few from the JCR and ModeShape builtin types ...
+ // registerImportedNamespaces();
+ // assertNodeType("nt:base", new String[] {}, NO_PRIMARY_NAME,
NodeOptions.Abstract, NodeOptions.Queryable);
+ // assertNodeType("mode:root", new String[] { "nt:base",
"mix:referenceable" }, NO_PRIMARY_NAME, NodeOptions.Queryable,
+ // NodeOptions.Ordered);
+ // }
+
@Test
- public void shouldParseNamespaceDeclarationWithQuotedUriAndUnquotedPrefix() {
- String content = "<ns = 'http://namespace.com/ns'>";
//$NON-NLS-1$
- this.cnd = this.importer.parse(content);
+ public void shouldImportCndForCars() throws Exception {
+ this.importer.importFrom(openCndFile("cars.cnd"), this.problems);
//$NON-NLS-1$
- List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
- assertEquals(1, namespaces.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NamespaceMapping namespace = namespaces.iterator().next();
- assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
-
assertEquals("http://namespace.com/ns", namespace.getUri());
//$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
@Test
- public void shouldParseNamespaceDeclarationWithUnquotedUriAndUnquotedPrefix() {
- String content = "<ns = http_namespace.com_ns>"; //$NON-NLS-1$
- this.cnd = this.importer.parse(content);
+ public void shouldImportCndForImageSequencer() throws Exception {
+ this.importer.importFrom(openCndFile("images.cnd"), this.problems);
//$NON-NLS-1$
- List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
- assertEquals(1, namespaces.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NamespaceMapping namespace = namespaces.iterator().next();
- assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
- assertEquals("http_namespace.com_ns", namespace.getUri());
//$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
@Test
- public void shouldParseMinimalNodeDefinition() {
- String content = "[nodeTypeName]"; //$NON-NLS-1$
- this.cnd = this.importer.parse(content);
+ public void shouldImportCndForJavaSequencer() throws Exception {
+ this.importer.importFrom(openCndFile("javaSource.cnd"), this.problems);
//$NON-NLS-1$
- List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
- assertEquals(1, nodeTypeDefns.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
- assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
@Test
- public void shouldParseMinimalNodeDefinitionWithSupertype() {
- String cnd = "[nodeTypeName] > supertype"; //$NON-NLS-1$
- this.cnd = this.importer.parse(cnd);
+ public void shouldImportCndForMp3Sequencer() throws Exception {
+ this.importer.importFrom(openCndFile("mp3.cnd"), this.problems);
//$NON-NLS-1$
- List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
- assertEquals(1, nodeTypeDefns.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
- assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
-
- String[] superTypes = nodeTypeDefn.getDeclaredSupertypeNames();
- assertEquals(1, superTypes.length);
- assertEquals("supertype", superTypes[0]); //$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
@Test
- public void shouldParseMinimalNodeDefinitionWithSupertypes() {
- String cnd = "[nodeTypeName] > supertype1, supertype2";
//$NON-NLS-1$
- this.cnd = this.importer.parse(cnd);
+ public void shouldImportCndForTeiidSequencer() throws Exception {
+ this.cnd = this.importer.importFrom(openCndFile("teiid.cnd"),
this.problems); //$NON-NLS-1$
- List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
- assertEquals(1, nodeTypeDefns.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
- assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
+ // registerImportedNamespaces();
+ assertEquals(0, this.problems.size());
+ assertNodeType("relational:catalog", new String[] {
"nt:unstructured", "relational:relationalEntity" }, NO_PRIMARY_NAME,
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ NodeOptions.Queryable, NodeOptions.Ordered);
+ }
- String[] superTypes = nodeTypeDefn.getDeclaredSupertypeNames();
- assertEquals(2, superTypes.length);
- assertEquals("supertype1", superTypes[0]); //$NON-NLS-1$
- assertEquals("supertype2", superTypes[1]); //$NON-NLS-1$
+ @Test
+ public void shouldImportCndThatHasNoChildren() {
+ final String cnd = "<ns = 'http://namespace.com/ns'>\n"
//$NON-NLS-1$
+ + "<ex = 'http://namespace.com/ex'>\n"
//$NON-NLS-1$
+ + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract
orderable mixin noquery primaryitem ex:property\n" //$NON-NLS-1$
+ + "- ex:property (STRING) = 'default1', 'default2'
mandatory autocreated protected multiple VERSION < 'constraint1',
'constraint2'\n" //$NON-NLS-1$
+ + " queryops '=, <>, <, <=, >, >=, LIKE'
nofulltext noqueryorder"; //$NON-NLS-1$
+ this.importer.importFrom(cnd, this.problems, "string"); //$NON-NLS-1$
}
@Test
- public void shouldParseNodeDefinitionWithNameThatIsKeyword() {
- String cnd = "[abstract] > supertype1, supertype2"; //$NON-NLS-1$
- this.cnd = this.importer.parse(cnd);
+ public void shouldImportCndThatIsEmpty() throws Exception {
+ this.importer.importFrom(openCndFile("empty.cnd"), this.problems);
//$NON-NLS-1$
- List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
- assertEquals(1, nodeTypeDefns.size());
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
- NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
- assertEquals("abstract", nodeTypeDefn.getName()); //$NON-NLS-1$
+ assertEquals(0, this.problems.size());
}
@Test
+ public void shouldImportCndThatIsOnOneLine() {
+ final String cnd = "<ns = 'http://namespace.com/ns'> "
//$NON-NLS-1$
+ + "<ex = 'http://namespace.com/ex'>\n"
//$NON-NLS-1$
+ + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract
orderable mixin noquery primaryitem ex:property " //$NON-NLS-1$
+ + "- ex:property (STRING) = 'default1', 'default2'
mandatory autocreated protected multiple VERSION < 'constraint1',
'constraint2' " //$NON-NLS-1$
+ + " queryops '=, <>, <, <=, >, >=, LIKE'
nofulltext noqueryorder " //$NON-NLS-1$
+ + "+ ns:node (ns:reqType1, ns:reqType2) = ns:defaultType mandatory
autocreated protected sns version"; //$NON-NLS-1$
+ this.importer.importFrom(cnd, this.problems, "string"); //$NON-NLS-1$
+ }
+
+ @Test
public void shouldImportCndThatUsesAllFeatures() throws RepositoryException {
// this.importer.setDebug(true);
- String content = "<ex = 'http://namespace.com/ns'>\n"
//$NON-NLS-1$
+ final String content = "<ex =
'http://namespace.com/ns'>\n" //$NON-NLS-1$
+ "[ex:NodeType] > ex:ParentType1, ex:ParentType2 abstract
orderable mixin noquery primaryitem ex:property\n" //$NON-NLS-1$
+ "- ex:property (STRING) = 'default1', 'default2'
mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
+ " queryops '=, <>, <, <=, >, >=, LIKE'
nofulltext noqueryorder < 'constraint1', 'constraint2'"
//$NON-NLS-1$
@@ -222,26 +479,26 @@
// check the namespace
assertEquals(this.cnd.getNamespaceMappings().size(), 1);
- NamespaceMapping ns = this.cnd.getNamespaceMappings().iterator().next();
+ final NamespaceMapping ns = this.cnd.getNamespaceMappings().iterator().next();
assertEquals(ns.getUri(), "http://namespace.com/ns"); //$NON-NLS-1$
- List<NodeTypeDefinition> defns = this.cnd.getNodeTypeDefinitions();
+ final List<NodeTypeDefinition> defns = this.cnd.getNodeTypeDefinitions();
assertEquals(defns.size(), 1);
- NodeTypeDefinition defn = defns.iterator().next();
+ final NodeTypeDefinition defn = defns.iterator().next();
assertEquals(defn.getName(), "ex:NodeType"); //$NON-NLS-1$
assertTrue(defn.isAbstract());
assertTrue(defn.hasOrderableChildNodes());
assertTrue(defn.isMixin());
assertFalse(defn.isQueryable());
assertEquals(defn.getPrimaryItemName(), "ex:property"); //$NON-NLS-1$
- String[] supertypeNames = defn.getDeclaredSupertypeNames();
+ final String[] supertypeNames = defn.getDeclaredSupertypeNames();
assertEquals(supertypeNames[0], "ex:ParentType1"); //$NON-NLS-1$
assertEquals(supertypeNames[1], "ex:ParentType2"); //$NON-NLS-1$
- PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
+ final PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
assertEquals(propDefns.length, 1);
- PropertyDefinition propDefn = propDefns[0];
+ final PropertyDefinition propDefn = propDefns[0];
assertEquals(propDefn.getName(), "ex:property"); //$NON-NLS-1$
assertEquals(propDefn.getRequiredType(), PropertyType.STRING.asJcrValue());
assertTrue(propDefn.isMandatory());
@@ -251,10 +508,10 @@
assertEquals(propDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
assertFalse(propDefn.isFullTextSearchable());
assertFalse(propDefn.isQueryOrderable());
- Value[] defaultValues = propDefn.getDefaultValues();
+ final Value[] defaultValues = propDefn.getDefaultValues();
assertEquals(defaultValues[0].getString(), "default1"); //$NON-NLS-1$
assertEquals(defaultValues[1].getString(), "default2"); //$NON-NLS-1$
- String[] queryOps = propDefn.getAvailableQueryOperators();
+ final String[] queryOps = propDefn.getAvailableQueryOperators();
assertEquals(queryOps[0], "="); //$NON-NLS-1$
assertEquals(queryOps[1], "<>"); //$NON-NLS-1$
assertEquals(queryOps[2], "<"); //$NON-NLS-1$
@@ -262,13 +519,13 @@
assertEquals(queryOps[4], ">"); //$NON-NLS-1$
assertEquals(queryOps[5], ">="); //$NON-NLS-1$
assertEquals(queryOps[6], "LIKE"); //$NON-NLS-1$
- String[] constraints = propDefn.getValueConstraints();
+ final String[] constraints = propDefn.getValueConstraints();
assertEquals(constraints[0], "constraint1"); //$NON-NLS-1$
assertEquals(constraints[1], "constraint2"); //$NON-NLS-1$
- NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
+ final NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
assertEquals(childDefns.length, 1);
- NodeDefinition childDefn = childDefns[0];
+ final NodeDefinition childDefn = childDefns[0];
assertEquals(childDefn.getName(), "ex:node"); //$NON-NLS-1$
assertEquals(childDefn.getDefaultPrimaryTypeName(), "ex:defaultType");
//$NON-NLS-1$
assertTrue(childDefn.isMandatory());
@@ -276,102 +533,20 @@
assertTrue(childDefn.isProtected());
assertTrue(childDefn.allowsSameNameSiblings());
assertEquals(childDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
- String[] requiredTypeNames = childDefn.getRequiredPrimaryTypeNames();
+ final String[] requiredTypeNames = childDefn.getRequiredPrimaryTypeNames();
assertEquals(requiredTypeNames[0], "ex:reqType1"); //$NON-NLS-1$
assertEquals(requiredTypeNames[1], "ex:reqType2"); //$NON-NLS-1$
}
- //
- // @Test
- // public void shouldImportCndThatUsesExtensions() throws RepositoryException {
- // // this.importer.setDebug(true);
- // String content = "<ex =
'http://namespace.com/ns'>\n" //$NON-NLS-1$
- // + "[ex:NodeType] > ex:ParentType1, ex:ParentType2 abstract
{mode:desc 'ex:NodeType description'} orderable mixin noquery primaryitem
ex:property\n" //$NON-NLS-1$
- // + "- ex:property (STRING) = 'default1',
'default2' mandatory autocreated protected multiple VERSION\n" //$NON-NLS-1$
- // + " queryops '=, <>, <, <=, >, >=,
LIKE' {mode:desc 'ex:property description'} {mode:altName Cool Property}
nofulltext noqueryorder < 'constraint1', 'constraint2'"
//$NON-NLS-1$
- // + "+ ex:node (ex:reqType1, ex:reqType2) = ex:defaultType {}
mandatory autocreated protected sns version"; //$NON-NLS-1$
- // CompactNodeTypeDefinition cnd = this.importer.importFrom(content, problems,
"string"); //$NON-NLS-1$
- //
- // // Check the namespace ...
- // assertEquals(cnd.getNamespaceMappings().size(), 1);
- // NamespaceMapping ns = cnd.getNamespaceMappings().iterator().next();
- // assertEquals(ns.getUri(), "http://namespace.com/ns");
//$NON-NLS-1$
- //
- // Set<NodeTypeDefinition> defns = cnd.getNodeTypeDefinitions();
- // assertEquals(defns.size(), 1);
- //
- // NodeTypeDefinition defn = defns.iterator().next();
- // assertEquals(defn.getName(), "ex:NodeType"); //$NON-NLS-1$
- // assertTrue(defn.isAbstract());
- // assertTrue(defn.hasOrderableChildNodes());
- // assertTrue(defn.isMixin());
- // assertFalse(defn.isQueryable());
- // assertEquals(defn.getPrimaryItemName(), "ex:property");
//$NON-NLS-1$
- // String[] supertypeNames = defn.getDeclaredSupertypeNames();
- // assertEquals(supertypeNames[0], "ex:ParentType1"); //$NON-NLS-1$
- // assertEquals(supertypeNames[1], "ex:ParentType2"); //$NON-NLS-1$
- //
- // PropertyDefinition[] propDefns = defn.getDeclaredPropertyDefinitions();
- // assertEquals(propDefns.length, 1);
- // PropertyDefinition propDefn = propDefns[0];
- // assertEquals(propDefn.getName(), "ex:property"); //$NON-NLS-1$
- // assertEquals(propDefn.getRequiredType(), PropertyType.STRING);
- // assertTrue(propDefn.isMandatory());
- // assertTrue(propDefn.isAutoCreated());
- // assertTrue(propDefn.isProtected());
- // assertTrue(propDefn.isMultiple());
- // assertEquals(propDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
- // assertFalse(propDefn.isFullTextSearchable());
- // assertFalse(propDefn.isQueryOrderable());
- // Value[] defaultValues = propDefn.getDefaultValues();
- // assertEquals(defaultValues[0].getString(), "default1");
//$NON-NLS-1$
- // assertEquals(defaultValues[1].getString(), "default2");
//$NON-NLS-1$
- // String[] queryOps = propDefn.getAvailableQueryOperators();
- // assertEquals(queryOps[0], "="); //$NON-NLS-1$
- // assertEquals(queryOps[1], "<>"); //$NON-NLS-1$
- // assertEquals(queryOps[2], "<"); //$NON-NLS-1$
- // assertEquals(queryOps[3], "<="); //$NON-NLS-1$
- // assertEquals(queryOps[4], ">"); //$NON-NLS-1$
- // assertEquals(queryOps[5], ">="); //$NON-NLS-1$
- // assertEquals(queryOps[6], "LIKE"); //$NON-NLS-1$
- // String[] constraints = propDefn.getValueConstraints();
- // assertEquals(constraints[0], "constraint1"); //$NON-NLS-1$
- // assertEquals(constraints[1], "constraint2"); //$NON-NLS-1$
- //
- // NodeDefinition[] childDefns = defn.getDeclaredChildNodeDefinitions();
- // assertEquals(childDefns.length, 1);
- // NodeDefinition childDefn = childDefns[0];
- // assertEquals(childDefn.getName(), "ex:node"); //$NON-NLS-1$
- // assertEquals(childDefn.getDefaultPrimaryTypeName(),
"ex:defaultType"); //$NON-NLS-1$
- // assertTrue(childDefn.isMandatory());
- // assertTrue(childDefn.isAutoCreated());
- // assertTrue(childDefn.isProtected());
- // assertTrue(childDefn.allowsSameNameSiblings());
- // assertEquals(childDefn.getOnParentVersion(), OnParentVersionAction.VERSION);
- // String[] requiredTypeNames = childDefn.getRequiredPrimaryTypeNames();
- // assertEquals(requiredTypeNames[0], "ex:reqType1"); //$NON-NLS-1$
- // assertEquals(requiredTypeNames[1], "ex:reqType2"); //$NON-NLS-1$
- // }
-
@Test
- public void shouldImportCndThatIsOnOneLine() {
- String cnd = "<ns = 'http://namespace.com/ns'> "
//$NON-NLS-1$
- + "<ex = 'http://namespace.com/ex'>\n"
//$NON-NLS-1$
- + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract
orderable mixin noquery primaryitem ex:property " //$NON-NLS-1$
- + "- ex:property (STRING) = 'default1', 'default2'
mandatory autocreated protected multiple VERSION < 'constraint1',
'constraint2' " //$NON-NLS-1$
- + " queryops '=, <>, <, <=, >, >=, LIKE'
nofulltext noqueryorder " //$NON-NLS-1$
- + "+ ns:node (ns:reqType1, ns:reqType2) = ns:defaultType mandatory
autocreated protected sns version"; //$NON-NLS-1$
- this.importer.importFrom(cnd, this.problems, "string"); //$NON-NLS-1$
- }
+ public void shouldImportDerbyDdlCnd() throws Exception {
+ this.importer.importFrom(openCndFile("DerbyDdl.cnd"), this.problems);
//$NON-NLS-1$
- @Test
- public void shouldImportCndThatHasNoChildren() {
- String cnd = "<ns = 'http://namespace.com/ns'>\n"
//$NON-NLS-1$
- + "<ex = 'http://namespace.com/ex'>\n"
//$NON-NLS-1$
- + "[ns:NodeType] > ns:ParentType1, ns:ParentType2 abstract
orderable mixin noquery primaryitem ex:property\n" //$NON-NLS-1$
- + "- ex:property (STRING) = 'default1', 'default2'
mandatory autocreated protected multiple VERSION < 'constraint1',
'constraint2'\n" //$NON-NLS-1$
- + " queryops '=, <>, <, <=, >, >=, LIKE'
nofulltext noqueryorder"; //$NON-NLS-1$
- this.importer.importFrom(cnd, this.problems, "string"); //$NON-NLS-1$
+ if (this.problems.size() != 0) {
+ printProblems();
+ }
+
+ assertEquals(0, this.problems.size());
}
@Test
@@ -556,23 +731,15 @@
}
//
- // @Test
- // public void shouldImportBuiltInNodeTypes() throws Exception {
- // this.importer.importBuiltIns(this.problems);
- // if (this.problems.size() != 0)
- // printProblems();
- // assertThat(this.problems.size(), is(0));
- //
- // // Verify a select few from the JCR and ModeShape builtin types ...
- // registerImportedNamespaces();
- // assertNodeType("nt:base", new String[] {}, NO_PRIMARY_NAME,
NodeOptions.Abstract, NodeOptions.Queryable);
- // assertNodeType("mode:root", new String[] { "nt:base",
"mix:referenceable" }, NO_PRIMARY_NAME, NodeOptions.Queryable,
- // NodeOptions.Ordered);
+ // protected void registerImportedNamespaces() {
+ // for (NamespaceRegistry.Namespace ns : this.importer.getNamespaces()) {
+ // context.getNamespaceRegistry().register(ns.getPrefix(), ns.getNamespaceUri());
// }
+ // }
@Test
- public void shouldImportCndThatIsEmpty() throws Exception {
- this.importer.importFrom(openCndFile("empty.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldImportOracleDdlCnd() throws Exception {
+ this.importer.importFrom(openCndFile("OracleDdl.cnd"), this.problems);
//$NON-NLS-1$
if (this.problems.size() != 0) {
printProblems();
@@ -582,8 +749,8 @@
}
@Test
- public void shouldImportCndForImageSequencer() throws Exception {
- this.importer.importFrom(openCndFile("images.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldImportPostgresDdlCnd() throws Exception {
+ this.importer.importFrom(openCndFile("PostgresDdl.cnd"),
this.problems); //$NON-NLS-1$
if (this.problems.size() != 0) {
printProblems();
@@ -593,8 +760,8 @@
}
@Test
- public void shouldImportCndForMp3Sequencer() throws Exception {
- this.importer.importFrom(openCndFile("mp3.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldImportStandardDdlCnd() throws Exception {
+ this.importer.importFrom(openCndFile("StandardDdl.cnd"),
this.problems); //$NON-NLS-1$
if (this.problems.size() != 0) {
printProblems();
@@ -604,255 +771,151 @@
}
@Test
- public void shouldImportCndForTeiidSequencer() throws Exception {
- this.cnd = this.importer.importFrom(openCndFile("teiid.cnd"),
this.problems); //$NON-NLS-1$
-
- if (this.problems.size() != 0) {
- printProblems();
- }
-
- // registerImportedNamespaces();
- assertEquals(0, this.problems.size());
- assertNodeType("relational:catalog", new String[] {
"nt:unstructured", "relational:relationalEntity" }, NO_PRIMARY_NAME,
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- NodeOptions.Queryable, NodeOptions.Ordered);
- }
-
- @Test
public void shouldNotImportFileThatIsNotAValidCnd() throws Exception {
this.importer.importFrom(openCndFile("invalid.cnd"), this.problems);
//$NON-NLS-1$
assertEquals(1, this.problems.size());
}
@Test
- public void shouldImportCndForAircraft() throws Exception {
- this.importer.importFrom(openCndFile("aircraft.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldParseMinimalNodeDefinition() {
+ final String content = "[nodeTypeName]"; //$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
- if (this.problems.size() != 0) {
- printProblems();
- }
+ final List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
+ assertEquals(1, nodeTypeDefns.size());
- assertEquals(0, this.problems.size());
+ final NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
+ assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
}
@Test
- public void shouldImportCndForCars() throws Exception {
- this.importer.importFrom(openCndFile("cars.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldParseMinimalNodeDefinitionWithSupertype() {
+ final String cnd = "[nodeTypeName] > supertype"; //$NON-NLS-1$
+ this.cnd = this.importer.parse(cnd);
- if (this.problems.size() != 0) {
- printProblems();
- }
+ final List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
+ assertEquals(1, nodeTypeDefns.size());
- assertEquals(0, this.problems.size());
+ final NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
+ assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
+
+ final String[] superTypes = nodeTypeDefn.getDeclaredSupertypeNames();
+ assertEquals(1, superTypes.length);
+ assertEquals("supertype", superTypes[0]); //$NON-NLS-1$
}
@Test
- public void shouldImportCndForJavaSequencer() throws Exception {
- this.importer.importFrom(openCndFile("javaSource.cnd"), this.problems);
//$NON-NLS-1$
+ public void shouldParseMinimalNodeDefinitionWithSupertypes() {
+ final String cnd = "[nodeTypeName] > supertype1, supertype2";
//$NON-NLS-1$
+ this.cnd = this.importer.parse(cnd);
- if (this.problems.size() != 0) {
- printProblems();
- }
+ final List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
+ assertEquals(1, nodeTypeDefns.size());
- assertEquals(0, this.problems.size());
+ final NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
+ assertEquals("nodeTypeName", nodeTypeDefn.getName()); //$NON-NLS-1$
+
+ final String[] superTypes = nodeTypeDefn.getDeclaredSupertypeNames();
+ assertEquals(2, superTypes.length);
+ assertEquals("supertype1", superTypes[0]); //$NON-NLS-1$
+ assertEquals("supertype2", superTypes[1]); //$NON-NLS-1$
}
- //
- // protected void registerImportedNamespaces() {
- // for (NamespaceRegistry.Namespace ns : this.importer.getNamespaces()) {
- // context.getNamespaceRegistry().register(ns.getPrefix(), ns.getNamespaceUri());
- // }
- // }
+ @Test
+ public void shouldParseNamespaceDeclarationWithQuotedUriAndQuotedPrefix() {
+ final String content = "<'ns' =
'http://namespace.com/ns'>"; //$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
- public static final String[] NO_DEFAULTS = {};
- public static final String[] NO_SUPERTYPES = {};
- public static final String[] NO_VALUE_CONSTRAINTS = {};
- public static final String NO_PRIMARY_NAME = null;
+ final List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
+ assertEquals(1, namespaces.size());
- public static enum PropertyOptions {
- Mandatory,
- Autocreated,
- Protected,
- Multiple,
- FullTextSearchable,
- QueryOrderable
+ final NamespaceMapping namespace = namespaces.iterator().next();
+ assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
+
assertEquals("http://namespace.com/ns", namespace.getUri());
//$NON-NLS-1$
}
- public static enum ChildOptions {
- Mandatory,
- Autocreated,
- Protected,
- Multiple,
- Sns
- }
+ @Test
+ public void shouldParseNamespaceDeclarationWithQuotedUriAndUnquotedPrefix() {
+ final String content = "<ns =
'http://namespace.com/ns'>"; //$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
- public static enum NodeOptions {
- Abstract,
- Mixin,
- Ordered,
- Queryable
- }
+ final List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
+ assertEquals(1, namespaces.size());
- public static enum OnParentVersion {
- Copy,
- Version,
- Initialize,
- Compute,
- Ignore,
- Abort
+ final NamespaceMapping namespace = namespaces.iterator().next();
+ assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
+
assertEquals("http://namespace.com/ns", namespace.getUri());
//$NON-NLS-1$
}
- protected int opv( OnParentVersion onParentVersioning ) {
- int opv = OnParentVersionAction.COPY;
- if (onParentVersioning != null) {
- switch (onParentVersioning) {
- case Abort:
- opv = OnParentVersionAction.ABORT;
- break;
- case Compute:
- opv = OnParentVersionAction.COMPUTE;
- break;
- case Copy:
- opv = OnParentVersionAction.COPY;
- break;
- case Ignore:
- opv = OnParentVersionAction.IGNORE;
- break;
- case Initialize:
- opv = OnParentVersionAction.INITIALIZE;
- break;
- case Version:
- opv = OnParentVersionAction.VERSION;
- break;
- }
- }
- return opv;
- }
+ @Test
+ public void shouldParseNamespaceDeclarationWithUnquotedUriAndQuotedPrefix() {
+ final String content = "<'ns' = http_namespace.com_ns>";
//$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
- private NodeTypeDefinition defn( String name ) {
- NodeTypeDefinition result = null;
+ final List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
+ assertEquals(1, namespaces.size());
- for (NodeTypeDefinition defn : this.cnd.getNodeTypeDefinitions()) {
- if (defn.getName().equals(name)) {
- result = defn;
- break;
- }
- }
-
- assertNotNull("Failed to find node type definition \"" + name +
"\"", result); //$NON-NLS-1$ //$NON-NLS-2$
- return result;
+ final NamespaceMapping namespace = namespaces.iterator().next();
+ assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
+ assertEquals("http_namespace.com_ns", namespace.getUri());
//$NON-NLS-1$
}
- private PropertyDefinition propDefn( NodeTypeDefinition nodeType,
- String name ) {
- for (PropertyDefinition defn : nodeType.getDeclaredPropertyDefinitions()) {
- if (defn.getName().equals(name)) {
- return defn;
- }
- }
+ @Test
+ public void shouldParseNamespaceDeclarationWithUnquotedUriAndUnquotedPrefix() {
+ final String content = "<ns = http_namespace.com_ns>";
//$NON-NLS-1$
+ this.cnd = this.importer.parse(content);
- assertFalse("Failed to find property type definition \"" + name +
"\"", false); //$NON-NLS-1$ //$NON-NLS-2$
- return null;
- }
+ final List<NamespaceMapping> namespaces = this.cnd.getNamespaceMappings();
+ assertEquals(1, namespaces.size());
- private NodeDefinition childDefn( NodeTypeDefinition nodeType,
- String name ) {
- for (NodeDefinition defn : nodeType.getDeclaredChildNodeDefinitions()) {
- if (defn.getName().equals(name)) {
- return defn;
- }
- }
-
- assertFalse("Failed to find child node definition \"" + name +
"\"", false); //$NON-NLS-1$ //$NON-NLS-2$
- return null;
+ final NamespaceMapping namespace = namespaces.iterator().next();
+ assertEquals("ns", namespace.getPrefix()); //$NON-NLS-1$
+ assertEquals("http_namespace.com_ns", namespace.getUri());
//$NON-NLS-1$
}
- private void assertNodeType( String name,
- String[] superTypes,
- String primaryItemName,
- NodeOptions... nodeOptions ) {
- Set<NodeOptions> options = new HashSet<NodeOptions>();
+ @Test
+ public void shouldParseNodeDefinitionWithNameThatIsKeyword() {
+ final String cnd = "[abstract] > supertype1, supertype2";
//$NON-NLS-1$
+ this.cnd = this.importer.parse(cnd);
- for (NodeOptions option : nodeOptions) {
- options.add(option);
- }
+ final List<NodeTypeDefinition> nodeTypeDefns =
this.cnd.getNodeTypeDefinitions();
+ assertEquals(1, nodeTypeDefns.size());
- NodeTypeDefinition defn = defn(name);
- assertEquals(defn.getName(), name);
- assertEquals(defn.isAbstract(), options.contains(NodeOptions.Abstract));
- assertEquals(defn.hasOrderableChildNodes(),
options.contains(NodeOptions.Ordered));
- assertEquals(defn.isMixin(), options.contains(NodeOptions.Mixin));
- // assertEquals(defn.isQueryable(), options.contains(NodeOptions.Queryable)); //
defaults to variant
- assertTrue(defn.getState(NodeTypeDefinition.PropertyName.QUERYABLE) ==
org.jboss.tools.modeshape.jcr.cnd.attributes.AttributeState.Value.VARIANT);
- assertEquals(defn.getPrimaryItemName(), primaryItemName);
- String[] supertypeNames = defn.getDeclaredSupertypeNames();
- assertArrayEquals(supertypeNames, superTypes);
+ final NodeTypeDefinition nodeTypeDefn = nodeTypeDefns.iterator().next();
+ assertEquals("abstract", nodeTypeDefn.getName()); //$NON-NLS-1$
}
- private void assertProperty( String nodeTypeName,
- String propertyName,
- String requiredType,
- String[] defaultValues,
- PropertyOptions... propertyOptions ) throws
RepositoryException {
- assertProperty(nodeTypeName, propertyName, requiredType, defaultValues,
propertyOptions, null);
+ @Test(expected = ParsingException.class)
+ public void shouldReportErrorIfTheNodeTypeNameIsBlank() {
+ final String content = "<ns = 'http://namespace.com/ns'> [ ]
abstract"; //$NON-NLS-1$
+ this.importer.parse(content);
}
- private void assertProperty( String nodeTypeName,
- String propertyName,
- String requiredType,
- String[] defaultValues,
- OnParentVersion onParentVersion,
- PropertyOptions... propertyOptions ) throws
RepositoryException {
- assertProperty(nodeTypeName, propertyName, requiredType, defaultValues,
propertyOptions, onParentVersion);
+ @Test(expected = ParsingException.class)
+ public void shouldReportErrorIfTheNodeTypeNameIsEmpty() {
+ final String content = "<ns = 'http://namespace.com/ns'> []
abstract"; //$NON-NLS-1$
+ this.importer.parse(content);
}
- private int jcrPropertyType( String typeName ) {
- PropertyType type = PropertyType.find(typeName);
- return type.asJcrValue();
- // org.modeshape.jcr.value.PropertyType type =
org.modeshape.jcr.value.PropertyType.valueFor(typeName.toLowerCase());
- // return PropertyTypeUtil.jcrPropertyTypeFor(type);
+ @Test(expected = ParsingException.class)
+ public void shouldReportErrorIfTheNodeTypeNameIsNotFollowedByClosingBracket() {
+ final String content = "<ns = 'http://namespace.com/ns'> [
abstract"; //$NON-NLS-1$
+ this.importer.parse(content);
}
- private void assertProperty( String nodeTypeName,
- String propertyName,
- String requiredType,
- String[] defaultValues,
- PropertyOptions[] propertyOptions,
- OnParentVersion onParentVersioning,
- String... valueConstraints ) throws RepositoryException
{
- Set<PropertyOptions> options = new HashSet<PropertyOptions>();
- for (PropertyOptions option : propertyOptions)
- options.add(option);
+ public static enum ChildOptions {
+ Autocreated,
+ Mandatory,
+ Multiple,
+ Protected,
+ Sns
+ }
- NodeTypeDefinition defn = defn(nodeTypeName);
- PropertyDefinition propDefn = propDefn(defn, propertyName);
-
- assertEquals(propDefn.getName(), propertyName);
- assertEquals(propDefn.getRequiredType(), jcrPropertyType(requiredType));
- assertEquals(propDefn.isMandatory(),
options.contains(PropertyOptions.Mandatory));
- assertEquals(propDefn.isAutoCreated(),
options.contains(PropertyOptions.Autocreated));
- assertEquals(propDefn.isProtected(),
options.contains(PropertyOptions.Protected));
- assertEquals(propDefn.isMultiple(), options.contains(PropertyOptions.Multiple));
- assertEquals(propDefn.isFullTextSearchable(),
options.contains(PropertyOptions.FullTextSearchable));
- assertEquals(propDefn.isQueryOrderable(),
options.contains(PropertyOptions.QueryOrderable));
-
- int opv = opv(onParentVersioning);
- assertEquals(propDefn.getOnParentVersion(), opv);
-
- if ((defaultValues == null) || (defaultValues.length == 0)) {
- assertTrue(propDefn.getDefaultValues().length == 0);
- } else {
- int i = 0;
-
- for (Value defaultValue : propDefn.getDefaultValues()) {
- assertEquals(defaultValues[i++], defaultValue.getString());
- }
- }
-
- if ((valueConstraints == null) || (valueConstraints.length == 0)) {
- assertTrue(propDefn.getValueConstraints().length == 0);
- } else {
- assertArrayEquals(propDefn.getValueConstraints(), valueConstraints);
- }
+ public static enum NodeOptions {
+ Abstract,
+ Mixin,
+ Ordered,
+ Queryable
}
//
@@ -865,35 +928,21 @@
// assertChild(nodeTypeName, childName, new String[] { requiredType },
defaultPrimaryType, childOptions, onParentVersioning);
// }
- private void assertChild( String nodeTypeName,
- String childName,
- String requiredType,
- String defaultPrimaryType,
- OnParentVersion onParentVersioning,
- ChildOptions... childOptions ) {
- assertChild(nodeTypeName, childName, new String[] { requiredType },
defaultPrimaryType, childOptions, onParentVersioning);
+ public static enum OnParentVersion {
+ Abort,
+ Compute,
+ Copy,
+ Ignore,
+ Initialize,
+ Version
}
- private void assertChild( String nodeTypeName,
- String childName,
- String[] requiredTypes,
- String defaultPrimaryType,
- ChildOptions[] childOptions,
- OnParentVersion onParentVersioning ) {
- Set<ChildOptions> options = new HashSet<ChildOptions>();
- for (ChildOptions option : childOptions)
- options.add(option);
-
- NodeTypeDefinition defn = defn(nodeTypeName);
- NodeDefinition childDefn = childDefn(defn, childName);
-
- assertEquals(childDefn.getName(), childName);
- assertEquals(childDefn.getDefaultPrimaryTypeName(), defaultPrimaryType);
- assertEquals(childDefn.isMandatory(), options.contains(ChildOptions.Mandatory));
- assertEquals(childDefn.isAutoCreated(),
options.contains(ChildOptions.Autocreated));
- assertEquals(childDefn.isProtected(), options.contains(ChildOptions.Protected));
- assertEquals(childDefn.allowsSameNameSiblings(),
options.contains(ChildOptions.Sns));
- assertEquals(childDefn.getOnParentVersion(), opv(onParentVersioning));
- assertArrayEquals(childDefn.getRequiredPrimaryTypeNames(), requiredTypes);
+ public static enum PropertyOptions {
+ Autocreated,
+ FullTextSearchable,
+ Mandatory,
+ Multiple,
+ Protected,
+ QueryOrderable
}
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -29,39 +29,45 @@
@Before
public void beforeEach() {
this.childNodeDefinition = new ChildNodeDefinition();
+ this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.cnd = new CompactNodeTypeDefinition();
this.namespaceMapping = new NamespaceMapping();
+
this.nodeTypeDefinition = new NodeTypeDefinition();
+ this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.propertyDefinition = new PropertyDefinition();
+ this.propertyDefinition.setName(Constants.QUALIFIED_NAME1.get());
}
@Test
public void childNodeDefinitionWithEmptyNameShouldBeAnError() {
this.childNodeDefinition.setName(null);
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null).isError());
+ assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null, null).isError());
this.childNodeDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null).isError());
+ assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null, null).isError());
}
@Test
public void childNodeDefinitionWithInvalidDefaultTypeNameShouldBeAnError() {
this.childNodeDefinition.setName("name"); //$NON-NLS-1$
this.childNodeDefinition.setDefaultPrimaryTypeName("missingName:");
//$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null).isError());
+ assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null, null).isError());
}
@Test
public void childNodeDefinitionWithInvalidNameShouldBeAnError() {
this.childNodeDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null).isError());
+ assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null, null).isError());
}
@Test
public void childNodeDefinitionWithInvalidRequiredTypeNameShouldBeAnError() {
this.childNodeDefinition.setName("name"); //$NON-NLS-1$
this.childNodeDefinition.addRequiredType("missingName:");
//$NON-NLS-1$
- assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null).isError());
+ assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition,
null, null).isError());
}
@Test
@@ -147,7 +153,7 @@
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
this.nodeTypeDefinition.addChildNodeDefinition(child2);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
true).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, true).isError());
}
@Test
@@ -162,22 +168,22 @@
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
this.nodeTypeDefinition.addPropertyDefinition(prop2);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
true).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, true).isError());
}
@Test
public void nodeTypeDefinitionWithEmptyNameShouldAnError() {
this.nodeTypeDefinition.setName(null);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isError());
this.nodeTypeDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isError());
}
@Test
public void nodeTypeDefinitionWithInvalidNameShouldBeAnError() {
this.nodeTypeDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isError());
}
@Test
@@ -185,7 +191,7 @@
this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
this.nodeTypeDefinition.setPrimaryItemName("invalid/name");
//$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isError());
}
@Test
@@ -193,13 +199,13 @@
this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
this.nodeTypeDefinition.addSuperType("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isError());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isError());
}
@Test
public void nodeTypeDefinitionWithoutPropertiesAndChildNodesShouldBeAWarning() {
this.nodeTypeDefinition.setName("name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
false).isWarning());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null,
null, false).isWarning());
}
@Test
@@ -210,10 +216,10 @@
@Test
public void propertyDefinitionWithEmptyNameShouldNotBeValid() {
this.propertyDefinition.setName(null);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition,
null).isError());
+ assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null,
null).isError());
this.propertyDefinition.setName(Utils.EMPTY_STRING);
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition,
null).isError());
+ assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null,
null).isError());
}
@Test
@@ -222,13 +228,13 @@
this.propertyDefinition.setType(PropertyType.LONG);
this.propertyDefinition.addDefaultValue("notALongValue");
//$NON-NLS-1$
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition,
null).isError());
+ assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null,
null).isError());
}
@Test
public void propertyDefinitionWithInvalidNameShouldBeAnError() {
this.propertyDefinition.setName("invalid/name"); //$NON-NLS-1$
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition,
null).isError());
+ assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null,
null).isError());
}
@Test
@@ -237,13 +243,13 @@
this.propertyDefinition.addDefaultValue("defaultValue1");
//$NON-NLS-1$
this.propertyDefinition.addDefaultValue("defaultValue2");
//$NON-NLS-1$
- assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition,
null).isError());
+ assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition, null,
null).isError());
}
@Test
public void shouldAllowChildNodeDefinitionsWithResidualNames() {
this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- assertTrue(CndValidator.validateName(this.childNodeDefinition, null).isOk());
+ assertTrue(CndValidator.validateName(this.childNodeDefinition, null,
null).isOk());
}
@Test
@@ -254,7 +260,7 @@
childNode2.setName(ItemDefinition.RESIDUAL_NAME);
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
-
assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(),
+
assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(),
null,
this.nodeTypeDefinition.getChildNodeDefinitions()).isOk());
}
@@ -266,14 +272,14 @@
propDefn2.setName(ItemDefinition.RESIDUAL_NAME);
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
-
assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(),
+
assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(),
null,
this.nodeTypeDefinition.getPropertyDefinitions()).isOk());
}
@Test
public void shouldAllowPropertyDefinitionsWithResidualNames() {
this.propertyDefinition.setName(ItemDefinition.RESIDUAL_NAME);
- assertTrue(CndValidator.validateName(this.propertyDefinition, null).isOk());
+ assertTrue(CndValidator.validateName(this.propertyDefinition, null,
null).isOk());
}
@Test
@@ -284,7 +290,7 @@
childNode2.setName(this.childNodeDefinition.getName());
this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
this.nodeTypeDefinition.addChildNodeDefinition(childNode2);
-
assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(),
+
assertTrue(CndValidator.validateChildNodeDefinitions(this.nodeTypeDefinition.getName(),
null,
this.nodeTypeDefinition.getChildNodeDefinitions()).isError());
}
@@ -316,7 +322,7 @@
propDefn2.setName(this.propertyDefinition.getName());
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
this.nodeTypeDefinition.addPropertyDefinition(propDefn2);
-
assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(),
+
assertTrue(CndValidator.validatePropertyDefinitions(this.nodeTypeDefinition.getName(),
null,
this.nodeTypeDefinition.getPropertyDefinitions()).isError());
}
@@ -326,4 +332,59 @@
assertTrue(CndValidator.validateQueryOperator(operator.toString(),
"propName").isOk()); //$NON-NLS-1$
}
}
+
+ @Test
+ public void childNodeNameWithNonMatchingQualifierShouldBeAnError() {
+
this.childNodeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateName(this.childNodeDefinition,
Constants.Helper.getDefaultNamespacePrefixes(), null)
+ .isError());
+ }
+
+ @Test
+ public void propertyNameWithNonMatchingQualifierShouldBeAnError() {
+
this.propertyDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateName(this.propertyDefinition,
Constants.Helper.getDefaultNamespacePrefixes(), null)
+ .isError());
+ }
+
+ @Test
+ public void nodeTypeNameWithNonMatchingQualifierShouldBeAnError() {
+
this.nodeTypeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateName(this.nodeTypeDefinition,
Constants.Helper.getDefaultNamespacePrefixes(), null)
+ .isError());
+ }
+
+ @Test
+ public void defaultTypeNameWithNonMatchingQualifierShouldBeAnError() {
+ this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateDefaultType(this.childNodeDefinition,
Constants.Helper.getDefaultNamespacePrefixes())
+ .isError());
+ }
+
+ @Test
+ public void primaryItemNameWithNonMatchingQualifierShouldBeAnError() {
+ this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.nodeTypeDefinition.setPrimaryItemName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition,
+
Constants.Helper.getDefaultNamespacePrefixes(), null, false).isError());
+ }
+
+ @Test
+ public void requiredTypeNameWithNonMatchingQualifierShouldBeAnError() {
+ this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.childNodeDefinition.addRequiredType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateRequiredTypes(this.childNodeDefinition,
Constants.Helper.getDefaultNamespacePrefixes())
+ .isError());
+ }
+
+ @Test
+ public void superTypeNameWithNonMatchingQualifierShouldBeAnError() {
+ this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+
this.nodeTypeDefinition.addSuperType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateSuperTypes(this.nodeTypeDefinition.getName(),
+
Constants.Helper.getDefaultNamespacePrefixes(),
+
this.nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
+
this.nodeTypeDefinition.getSupertypes()).isError());
+ }
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -7,7 +7,7 @@
*/
package org.jboss.tools.modeshape.jcr.cnd;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import javax.jcr.PropertyType;
@@ -44,27 +44,34 @@
String NAMESPACE_PREFIX1 = "NAMESPACE_PREFIX1"; //$NON-NLS-1$
String NAMESPACE_PREFIX2 = "NAMESPACE_PREFIX2"; //$NON-NLS-1$
String NAMESPACE_PREFIX3 = "NAMESPACE_PREFIX3"; //$NON-NLS-1$
+ String[] DEFAULT_NAMESPACE_PREFIXES = new String[] { NAMESPACE_PREFIX1,
NAMESPACE_PREFIX2, NAMESPACE_PREFIX3 };
String NAMESPACE_URI1 = "NAMESPACE_URI1"; //$NON-NLS-1$
String NAMESPACE_URI2 = "NAMESPACE_URI2"; //$NON-NLS-1$
String NAMESPACE_URI3 = "NAMESPACE_URI3"; //$NON-NLS-1$
+ String[] DEFAULT_NAMESPACE_URIS = new String[] { NAMESPACE_URI1, NAMESPACE_URI2,
NAMESPACE_URI3 };
NamespaceMapping NAMESPACE1 = new NamespaceMapping(NAMESPACE_PREFIX1,
NAMESPACE_URI1);
NamespaceMapping NAMESPACE2 = new NamespaceMapping(NAMESPACE_PREFIX2,
NAMESPACE_URI2);
NamespaceMapping NAMESPACE3 = new NamespaceMapping(NAMESPACE_PREFIX3,
NAMESPACE_URI3);
+ NamespaceMapping[] DEFAULT_NAMESPACE_MAPPINGS = new NamespaceMapping[] { NAMESPACE1,
NAMESPACE2, NAMESPACE3 };
- String QUALIFIER1 = "QUALIFIER1"; //$NON-NLS-1$
- String QUALIFIER2 = "QUALIFIER2"; //$NON-NLS-1$
- String QUALIFIER3 = "QUALIFIER3"; //$NON-NLS-1$
+ String QUALIFIER1 = NAMESPACE_PREFIX1;
+ String QUALIFIER2 = NAMESPACE_PREFIX2;
+ String QUALIFIER3 = NAMESPACE_PREFIX3;
+ String[] DEFAULT_QUALIFIERS = DEFAULT_NAMESPACE_PREFIXES;
String UNQUALIFIED_NAME1 = "UNQUALIFIED_NAME1"; //$NON-NLS-1$
String UNQUALIFIED_NAME2 = "UNQUALIFIED_NAME2"; //$NON-NLS-1$
String UNQUALIFIED_NAME3 = "UNQUALIFIED_NAME3"; //$NON-NLS-1$
+ String[] DEFAULT_UNQUALIFIED_NAMES = new String[] { UNQUALIFIED_NAME1,
UNQUALIFIED_NAME2, UNQUALIFIED_NAME3 };
QualifiedName QUALIFIED_NAME1 = new QualifiedName(QUALIFIER1, UNQUALIFIED_NAME1);
QualifiedName QUALIFIED_NAME2 = new QualifiedName(QUALIFIER2, UNQUALIFIED_NAME2);
QualifiedName QUALIFIED_NAME3 = new QualifiedName(QUALIFIER3, UNQUALIFIED_NAME3);
+ QualifiedName[] DEFAULT_QUALIFIED_NAMES = new QualifiedName[] { QUALIFIED_NAME1,
QUALIFIED_NAME2, QUALIFIED_NAME3 };
QualifiedName NAME_WITH_EMPTY_QUALIFIER = new QualifiedName(null,
UNQUALIFIED_NAME1);
+ QualifiedName NAME_WITH_NON_DEFAULT_QUALIFIER = new QualifiedName(QUALIFIER1 +
"changed", UNQUALIFIED_NAME1); //$NON-NLS-1$
String VARIANT = AttributeState.VARIANT_STRING;
@@ -127,9 +134,12 @@
String QUERY_OPS_VARIANT_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + VARIANT;
String QUERY_OPS_VARIANT_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + VARIANT;
String QUERY_OPS_VARIANT_LONG_FORM = QUERY_OPS_LONG_FORM + VARIANT;
+
QueryOperator OPERATOR_ONE = QueryOperator.EQUALS;
QueryOperator OPERATOR_TWO = QueryOperator.GREATER_THAN;
QueryOperator OPERATOR_THREE = QueryOperator.LESS_THAN;
+ QueryOperator[] DEFAULT_OPERATORS = new QueryOperator[] { OPERATOR_ONE, OPERATOR_TWO,
OPERATOR_THREE };
+
String QUERY_OPS_ONE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ OPERATOR_ONE.toCndNotation(NotationType.COMPACT)
@@ -221,6 +231,8 @@
String VALUE_CONSTRAINT1 = "(19|20)\\d{2}"; //$NON-NLS-1$
String VALUE_CONSTRAINT2 = "[$]\\d{1,3}[,]?\\d{3}([.]\\d{2})?";
//$NON-NLS-1$
String VALUE_CONSTRAINT3 = "[1,5]"; //$NON-NLS-1$
+ String[] DEFAULT_VALUE_CONSTRAINTS = new String[] {VALUE_CONSTRAINT1,
VALUE_CONSTRAINT2, VALUE_CONSTRAINT3};
+
String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
+ VARIANT;
String VALUE_CONSTRAINTS_ONE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX
@@ -254,44 +266,46 @@
}
public static Collection<NamespaceMapping> getDefaultNamespaces() {
- Collection<NamespaceMapping> namespaces = new
ArrayList<NamespaceMapping>();
- namespaces.add(NAMESPACE1);
- namespaces.add(NAMESPACE2);
- namespaces.add(NAMESPACE3);
- return namespaces;
+ return Arrays.asList(DEFAULT_NAMESPACE_MAPPINGS);
}
public static Collection<QualifiedName> getDefaultQualifiedNames() {
- Collection<QualifiedName> qualifiedNames = new
ArrayList<QualifiedName>();
- qualifiedNames.add(QUALIFIED_NAME1);
- qualifiedNames.add(QUALIFIED_NAME2);
- qualifiedNames.add(QUALIFIED_NAME3);
- return qualifiedNames;
+ return Arrays.asList(DEFAULT_QUALIFIED_NAMES);
}
- public static String[] getDefaultQualifiedNamesAsArray() {
- return new String[] { QUALIFIED_NAME1.get(), QUALIFIED_NAME2.get(),
QUALIFIED_NAME3.get() };
+ public static String[] getDefaultQualifiedNamesAsStringArray() {
+ String[] names = new String[DEFAULT_QUALIFIED_NAMES.length];
+ int i = 0;
+
+ for (QualifiedName qname : DEFAULT_QUALIFIED_NAMES) {
+ names[i++] = qname.get();
+ }
+
+ return names;
}
+ public static Collection<String> getDefaultNamespacePrefixes() {
+ return Arrays.asList(DEFAULT_NAMESPACE_PREFIXES);
+ }
+
public static Collection<String> getDefaultQualifiers() {
- Collection<String> qualifiers = new ArrayList<String>();
- qualifiers.add(QUALIFIER1);
- qualifiers.add(QUALIFIER2);
- qualifiers.add(QUALIFIER3);
- return qualifiers;
+ return Arrays.asList(DEFAULT_QUALIFIERS);
}
public static String[] getDefaultQueryOperators() {
- return new String[] { OPERATOR_ONE.toString(), OPERATOR_TWO.toString(),
OPERATOR_THREE.toString() };
+ String[] result = new String[DEFAULT_OPERATORS.length];
+ int i = 0;
+
+ for (QueryOperator operator : DEFAULT_OPERATORS) {
+ result[i++] = operator.toString();
+ }
+
+ return result;
}
public static javax.jcr.Value[] getDefaultStringValues() {
return new PropertyValue[] { new PropertyValue(PropertyType.STRING,
ITEM_ONE),
new PropertyValue(PropertyType.STRING, ITEM_TWO), new
PropertyValue(PropertyType.STRING, ITEM_THREE) };
}
-
- public static String[] getDefaultValueConstraints() {
- return new String[] { VALUE_CONSTRAINT1, VALUE_CONSTRAINT2, VALUE_CONSTRAINT3
};
- }
}
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/PropertyDefinitionTest.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -99,7 +99,7 @@
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
-
this.propDefn.setValueConstraints(Constants.Helper.getDefaultValueConstraints());
+ this.propDefn.setValueConstraints(Constants.DEFAULT_VALUE_CONSTRAINTS);
thatPropDefn = PropertyDefinition.copy(this.propDefn);
assertEquals(this.propDefn, thatPropDefn);
assertEquals(this.propDefn.hashCode(), thatPropDefn.hashCode());
@@ -154,7 +154,7 @@
thatPropDefn.setRequiredType(this.propDefn.getRequiredType());
assertEquals(this.propDefn, thatPropDefn);
-
this.propDefn.setValueConstraints(Constants.Helper.getDefaultValueConstraints());
+ this.propDefn.setValueConstraints(Constants.DEFAULT_VALUE_CONSTRAINTS);
thatPropDefn.setValueConstraints(this.propDefn.getValueConstraints());
assertEquals(this.propDefn, thatPropDefn);
}
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItemTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItemTest.java 2012-03-29
20:20:02 UTC (rev 39923)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/PrimaryItemTest.java 2012-03-29
20:38:25 UTC (rev 39924)
@@ -8,6 +8,7 @@
package org.jboss.tools.modeshape.jcr.cnd.attributes;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.jboss.tools.modeshape.jcr.Utils;
@@ -93,4 +94,27 @@
assertEquals(PRIMARY_ITEM_VARIANT_LONG_FORM,
this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
+ @Test
+ public void newInstancesShouldBeEqualAndHaveSameHashCode() {
+ assertEquals(this.attribute, new PrimaryItem());
+ assertEquals(this.attribute.hashCode(), new PrimaryItem().hashCode());
+ }
+
+ @Test
+ public void instancesWithSamePrimaryItemNameShouldBeEqualAndHaveSameHashCode() {
+ this.attribute.setPrimaryItem(Constants.QUALIFIED_NAME1.get());
+ PrimaryItem that = new PrimaryItem();
+ that.setPrimaryItem(this.attribute.getPrimaryItem().get());
+ assertEquals(this.attribute, that);
+ assertEquals(this.attribute.hashCode(), that.hashCode());
+ }
+
+ @Test
+ public void
instancesWithDifferentPrimaryItemNamesShouldNotBeEqualAndHaveDifferentHashCodes() {
+ this.attribute.setPrimaryItem(Constants.QUALIFIED_NAME1.get());
+ PrimaryItem that = new PrimaryItem();
+ that.setPrimaryItem(this.attribute.getPrimaryItem().get() + "changed");
//$NON-NLS-1$
+ assertFalse(this.attribute.equals(that));
+ assertFalse(this.attribute.hashCode() == that.hashCode());
+ }
}
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/DerbyDdl.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/DerbyDdl.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/DerbyDdl.cnd 2012-03-29
20:38:25 UTC (rev 39924)
@@ -0,0 +1,105 @@
+/*
+ * ModeShape (
http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+ //------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<ddl='http://www.modeshape.org/ddl/1.0'>
+<derbyddl='http://www.modeshape.org/ddl/derby/1.0'>
+
+// =============================================================================
+// OPERANDS
+// =============================================================================
+[derbyddl:functionOperand] > ddl:operand abstract
+[derbyddl:indexOperand] > ddl:operand abstract
+[derbyddl:procedureOperand] > ddl:operand abstract
+[derbyddl:roleOperand] > ddl:operand abstract
+[derbyddl:synonymOperand] > ddl:operand abstract
+[derbyddl:triggerOperand] > ddl:operand abstract
+
+[derbyddl:roleName] > derbyddl:roleOperand mixin
+
+// =============================================================================
+// COLUMN
+// =============================================================================
+[derbyddl:columnDefinition] > ddl:columnDefinition mixin
+ - derbyddl:dropDefault (boolean)
+
+[derbyddl:functionParameter] > ddl:columnDefinition mixin
+
+[derbyddl:indexColumnReference] > ddl:columnReference mixin
+ - derbyddl:order (STRING)
+
+// =============================================================================
+// CREATE STATEMENTS
+// =============================================================================
+[derbyddl:createFunctionStatement] > ddl:creatable, ddl:statement,
derbyddl:functionOperand mixin
+ - ddl:datatypeName (STRING)
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ - ddl:isTableType (boolean)
+ - derbyddl:parameterStyle (STRING)
+ + * (ddl:createTableStatement) = ddl:createTableStatement sns
+ + * (derbyddl:functionParameter) = derbyddl:functionParameter sns
+ + * (ddl:statementOption) = ddl:statementOption sns
+[derbyddl:createIndexStatement] > ddl:statement, ddl:creatable,
derbyddl:indexOperand mixin
+ - derbyddl:tableName (string) mandatory
+ - derbyddl:unique (boolean)
+ + * (derbyddl:indexColumnReference) = derbyddl:indexColumnReference sns
+[derbyddl:createProcedureStatement] > ddl:creatable, ddl:statement,
derbyddl:procedureOperand mixin
+[derbyddl:createRoleStatement] > ddl:creatable, ddl:statement,
derbyddl:roleOperand mixin
+[derbyddl:createSynonymStatement] > ddl:creatable, ddl:statement,
derbyddl:synonymOperand mixin
+ - derbyddl:tableName (string) mandatory
+[derbyddl:createTriggerStatement] > ddl:creatable, ddl:statement,
derbyddl:triggerOperand mixin
+ - derbyddl:tableName (string) mandatory
+ - ddl:sql (string) mandatory
+ + * (ddl:columnReference) = ddl:columnReference sns
+[derbyddl:declareGlobalTemporaryTableStatement] > ddl:createTableStatement mixin
+
+// =============================================================================
+// DROP STATEMENTS
+// =============================================================================
+[derbyddl:dropFunctionStatement] > ddl:droppable, derbyddl:functionOperand mixin
+[derbyddl:dropIndexStatement] > ddl:droppable, derbyddl:indexOperand mixin
+[derbyddl:dropProcedureStatement] > ddl:droppable, derbyddl:procedureOperand mixin
+[derbyddl:dropRoleStatement] > ddl:droppable, derbyddl:roleOperand mixin
+[derbyddl:dropSynonymStatement] > ddl:droppable, derbyddl:synonymOperand mixin
+[derbyddl:dropTriggerStatement] > ddl:droppable, derbyddl:triggerOperand mixin
+
+// =============================================================================
+// MISC STATEMENTS
+// =============================================================================
+[derbyddl:lockTableStatement] > ddl:statement, ddl:tableOperand mixin
+[derbyddl:renameTableStatement] > ddl:statement, ddl:renamable, ddl:tableOperand
mixin
+[derbyddl:renameIndexStatement] > ddl:statement, ddl:renamable,
derbyddl:indexOperand mixin
+
+[derbyddl:grantOnFunctionStatement] > ddl:grantStatement, derbyddl:functionOperand
mixin
+[derbyddl:grantOnProcedureStatement] > ddl:grantStatement,
derbyddl:procedureOperand mixin
+
+[derbyddl:grantRolesStatement] > ddl:grantStatement mixin
+ + ddl:name (derbyddl:roleName) = derbyddl:roleName sns
\ No newline at end of file
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/OracleDdl.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/OracleDdl.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/OracleDdl.cnd 2012-03-29
20:38:25 UTC (rev 39924)
@@ -0,0 +1,221 @@
+/*
+ * ModeShape (
http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+ //------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<ddl='http://www.modeshape.org/ddl/1.0'>
+<oracleddl='http://www.modeshape.org/ddl/oracle/1.0'>
+
+// =============================================================================
+// OPERANDS
+// =============================================================================
+[oracleddl:clusterOperand] > ddl:operand abstract
+[oracleddl:commentOperand] > ddl:operand abstract
+[oracleddl:contextOperand] > ddl:operand abstract
+[oracleddl:controlfileOperand] > ddl:operand abstract
+[oracleddl:databaseOperand] > ddl:operand abstract
+[oracleddl:dimensionOperand] > ddl:operand abstract
+[oracleddl:directoryOperand] > ddl:operand abstract
+[oracleddl:diskgroupOperand] > ddl:operand abstract
+[oracleddl:functionOperand] > ddl:operand abstract
+[oracleddl:indexOperand] > ddl:operand abstract
+[oracleddl:indextypeOperand] > ddl:operand abstract
+[oracleddl:javaOperand] > ddl:operand abstract
+[oracleddl:libraryOperand] > ddl:operand abstract
+[oracleddl:materializedOperand] > ddl:operand abstract
+[oracleddl:operatorOperand] > ddl:operand abstract
+[oracleddl:outlineOperand] > ddl:operand abstract
+[oracleddl:packageOperand] > ddl:operand abstract
+[oracleddl:parameterOperand] > ddl:operand abstract
+[oracleddl:pfileOperand] > ddl:operand abstract
+[oracleddl:procedureOperand] > ddl:operand abstract
+[oracleddl:profileOperand] > ddl:operand abstract
+[oracleddl:resourceOperand] > ddl:operand abstract
+[oracleddl:roleOperand] > ddl:operand abstract
+[oracleddl:rollbackOperand] > ddl:operand abstract
+[oracleddl:sequenceOperand] > ddl:operand abstract
+[oracleddl:sessionOperand] > ddl:operand abstract
+[oracleddl:spfileOperand] > ddl:operand abstract
+[oracleddl:systemOperand] > ddl:operand abstract
+[oracleddl:synonymOperand] > ddl:operand abstract
+[oracleddl:tablespaceOperand] > ddl:operand abstract
+[oracleddl:triggerOperand] > ddl:operand abstract
+[oracleddl:typeOperand] > ddl:operand abstract
+[oracleddl:userOperand] > ddl:operand abstract
+
+// =============================================================================
+// COLUMN
+// =============================================================================
+[oracleddl:columnDefinition] > ddl:columnDefinition
+ - oracleddl:dropDefault (boolean)
+
+//
+
+[oracleddl:functionParameter] > oracleddl:parameterOperand mixin
+ - ddl:datatypeName (STRING) mandatory
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ - oracleddl:default (STRING)
+ - oracleddl:defaultExpresssion (STRING)
+ - oracleddl:inOutNoCopy (STRING)
+
+// =============================================================================
+// ALTER STATEMENTS
+// =============================================================================
+[oracleddl:alterClusterStatement] > ddl:alterable, ddl:statement,
oracleddl:clusterOperand mixin
+[oracleddl:alterDatabaseStatement] > ddl:alterable, ddl:statement,
oracleddl:databaseOperand mixin
+[oracleddl:alterDimensionStatement] > ddl:alterable, ddl:statement,
oracleddl:dimensionOperand mixin
+[oracleddl:alterDiskgroupStatement] > ddl:alterable, ddl:statement,
oracleddl:diskgroupOperand mixin
+[oracleddl:alterFunctionStatement] > ddl:alterable, ddl:statement,
oracleddl:functionOperand mixin
+[oracleddl:alterIndexStatement] > ddl:alterable, ddl:statement,
oracleddl:indexOperand mixin
+[oracleddl:alterIndextypeStatement] > ddl:alterable, ddl:statement,
oracleddl:indextypeOperand mixin
+[oracleddl:alterJavaStatement] > ddl:alterable, ddl:statement,
oracleddl:javaOperand mixin
+[oracleddl:alterMaterializedStatement] > ddl:alterable, ddl:statement,
oracleddl:materializedOperand mixin
+[oracleddl:alterOperatorStatement] > ddl:alterable, ddl:statement,
oracleddl:operatorOperand mixin
+[oracleddl:alterOutlineStatement] > ddl:alterable, ddl:statement,
oracleddl:outlineOperand mixin
+[oracleddl:alterPackageStatement] > ddl:alterable, ddl:statement,
oracleddl:packageOperand mixin
+[oracleddl:alterProcedureStatement] > ddl:alterable, ddl:statement,
oracleddl:procedureOperand mixin
+[oracleddl:alterProfileStatement] > ddl:alterable, ddl:statement,
oracleddl:profileOperand mixin
+[oracleddl:alterResourceStatement] > ddl:alterable, ddl:statement,
oracleddl:resourceOperand mixin
+[oracleddl:alterRoleStatement] > ddl:alterable, ddl:statement,
oracleddl:roleOperand mixin
+[oracleddl:alterRollbackStatement] > ddl:alterable, ddl:statement,
oracleddl:rollbackOperand mixin
+[oracleddl:alterSequenceStatement] > ddl:alterable, ddl:statement,
oracleddl:sequenceOperand mixin
+[oracleddl:alterSessionStatement] > ddl:alterable, ddl:statement,
oracleddl:sessionOperand mixin
+[oracleddl:alterSystemStatement] > ddl:alterable, ddl:statement,
oracleddl:systemOperand mixin
+[oracleddl:alterTablespaceStatement] > ddl:alterable, ddl:statement,
oracleddl:tablespaceOperand mixin
+[oracleddl:alterTriggerStatement] > ddl:alterable, ddl:statement,
oracleddl:triggerOperand mixin
+[oracleddl:alterTypeStatement] > ddl:alterable, ddl:statement,
oracleddl:typeOperand mixin
+[oracleddl:alterUserStatement] > ddl:alterable, ddl:statement,
oracleddl:userOperand mixin
+[oracleddl:alterViewStatement] > ddl:alterable, ddl:statement,
ddl:viewOperand mixin
+
+[oracleddl:alterTableStatement] > ddl:alterTableStatement mixin
+ - oracleddl:newTableName (STRING)
+ + oracleddl:renameColumn (ddl:renamable) = ddl:renamable sns
+ + oracleddl:renameConstraint (ddl:renamable) = ddl:renamable sns
+
+// =============================================================================
+// CREATE STATEMENTS
+// =============================================================================
+
+[oracleddl:createClusterStatement] > ddl:creatable, ddl:statement,
oracleddl:clusterOperand mixin
+[oracleddl:createContextStatement] > ddl:creatable, ddl:statement,
oracleddl:contextOperand mixin
+[oracleddl:createControlfileStatement] > ddl:creatable, ddl:statement,
oracleddl:controlfileOperand mixin
+[oracleddl:createDatabaseStatement] > ddl:creatable, ddl:statement,
oracleddl:databaseOperand mixin
+[oracleddl:createDimensionStatement] > ddl:creatable, ddl:statement,
oracleddl:dimensionOperand mixin
+[oracleddl:createDirectoryStatement] > ddl:creatable, ddl:statement,
oracleddl:directoryOperand mixin
+[oracleddl:createDiskgroupStatement] > ddl:creatable, ddl:statement,
oracleddl:diskgroupOperand mixin
+[oracleddl:createFunctionStatement] > ddl:creatable, ddl:statement,
oracleddl:functionOperand mixin
+ - ddl:datatypeName (STRING) mandatory
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ + oracleddl:parameter (oracleddl:functionParameter) = oracleddl:functionParameter sns
+[oracleddl:createIndexStatement] > ddl:creatable, ddl:statement,
oracleddl:indexOperand mixin
+ - oracleddl:tableName (string)
+ - oracleddl:unique (boolean)
+ - oracleddl:bitmap (boolean)
+ + * (ddl:columnReference) = ddl:columnReference sns
+[oracleddl:createIndexTypeStatement] > ddl:creatable, ddl:statement,
oracleddl:indextypeOperand mixin
+[oracleddl:createJavaStatement] > ddl:creatable, ddl:statement,
oracleddl:javaOperand mixin
+[oracleddl:createLibraryStatement] > ddl:creatable, ddl:statement,
oracleddl:libraryOperand mixin
+[oracleddl:createMaterializedViewStatement] > ddl:creatable, ddl:statement,
oracleddl:materializedOperand mixin
+[oracleddl:createMaterializedViewLogStatement] > ddl:creatable, ddl:statement,
oracleddl:materializedOperand mixin
+[oracleddl:createOperatorStatement] > ddl:creatable, ddl:statement,
oracleddl:operatorOperand mixin
+[oracleddl:createOutlineStatement] > ddl:creatable, ddl:statement,
oracleddl:outlineOperand mixin
+[oracleddl:createPackageStatement] > ddl:creatable, ddl:statement,
oracleddl:packageOperand mixin
+[oracleddl:createPfileStatement] > ddl:creatable, ddl:statement,
oracleddl:pfileOperand mixin
+[oracleddl:createProcedureStatement] > ddl:creatable, ddl:statement,
oracleddl:procedureOperand mixin
+ + oracleddl:parameter (oracleddl:functionParameter) = oracleddl:functionParameter sns
+[oracleddl:createRoleStatement] > ddl:creatable, ddl:statement,
oracleddl:roleOperand mixin
+[oracleddl:createRollbackStatement] > ddl:creatable, ddl:statement,
oracleddl:rollbackOperand mixin
+[oracleddl:createSequenceStatement] > ddl:creatable, ddl:statement,
oracleddl:sequenceOperand mixin
+[oracleddl:createSpfileStatement] > ddl:creatable, ddl:statement,
oracleddl:spfileOperand mixin
+[oracleddl:createSynonymStatement] > ddl:creatable, ddl:statement,
oracleddl:synonymOperand mixin
+[oracleddl:createTablespaceStatement] > ddl:creatable, ddl:statement,
oracleddl:tablespaceOperand mixin
+[oracleddl:createTriggerStatement] > ddl:creatable, ddl:statement,
oracleddl:triggerOperand mixin
+[oracleddl:createTypeStatement] > ddl:creatable, ddl:statement,
oracleddl:typeOperand mixin
+[oracleddl:createUserStatement] > ddl:creatable, ddl:statement,
oracleddl:userOperand mixin
+
+// =============================================================================
+// DROP STATEMENTS
+// =============================================================================
+
+[oracleddl:dropClusterStatement] > ddl:droppable, ddl:statement,
oracleddl:clusterOperand mixin
+[oracleddl:dropContextStatement] > ddl:droppable, ddl:statement,
oracleddl:contextOperand mixin
+[oracleddl:dropDatabaseStatement] > ddl:droppable, ddl:statement,
oracleddl:databaseOperand mixin
+[oracleddl:dropDimensionStatement] > ddl:droppable, ddl:statement,
oracleddl:dimensionOperand mixin
+[oracleddl:dropDirectoryStatement] > ddl:droppable, ddl:statement,
oracleddl:directoryOperand mixin
+[oracleddl:dropDiskgroupStatement] > ddl:droppable, ddl:statement,
oracleddl:diskgroupOperand mixin
+[oracleddl:dropFunctionStatement] > ddl:droppable, ddl:statement,
oracleddl:functionOperand mixin
+[oracleddl:dropIndexStatement] > ddl:droppable, ddl:statement,
oracleddl:indexOperand mixin
+[oracleddl:dropIndextypeStatement] > ddl:droppable, ddl:statement,
oracleddl:indextypeOperand mixin
+[oracleddl:dropJavaStatement] > ddl:droppable, ddl:statement,
oracleddl:javaOperand mixin
+[oracleddl:dropLibraryStatement] > ddl:droppable, ddl:statement,
oracleddl:libraryOperand mixin
+[oracleddl:dropMaterializedStatement] > ddl:droppable, ddl:statement,
oracleddl:materializedOperand mixin
+[oracleddl:dropOperatorStatement] > ddl:droppable, ddl:statement,
oracleddl:operatorOperand mixin
+[oracleddl:dropOutlineStatement] > ddl:droppable, ddl:statement,
oracleddl:outlineOperand mixin
+[oracleddl:dropPackageStatement] > ddl:droppable, ddl:statement,
oracleddl:packageOperand mixin
+[oracleddl:dropProcedureStatement] > ddl:droppable, ddl:statement,
oracleddl:procedureOperand mixin
+[oracleddl:dropProfileStatement] > ddl:droppable, ddl:statement,
oracleddl:profileOperand mixin
+[oracleddl:dropRoleStatement] > ddl:droppable, ddl:statement,
oracleddl:roleOperand mixin
+[oracleddl:dropRollbackStatement] > ddl:droppable, ddl:statement,
oracleddl:rollbackOperand mixin
+[oracleddl:dropSequenceStatement] > ddl:droppable, ddl:statement,
oracleddl:sequenceOperand mixin
+[oracleddl:dropSynonymStatement] > ddl:droppable, ddl:statement,
oracleddl:synonymOperand mixin
+[oracleddl:dropTablespaceStatement] > ddl:droppable, ddl:statement,
oracleddl:tablespaceOperand mixin
+[oracleddl:dropTriggerStatement] > ddl:droppable, ddl:statement,
oracleddl:triggerOperand mixin
+[oracleddl:dropTypeStatement] > ddl:droppable, ddl:statement,
oracleddl:typeOperand mixin
+[oracleddl:dropUserStatement] > ddl:droppable, ddl:statement,
oracleddl:userOperand mixin
+
+// =============================================================================
+// MISC STATEMENTS
+// =============================================================================
+
+[oracleddl:analyzeStatement] > ddl:statement mixin
+[oracleddl:associateStatisticsStatement] > ddl:statement mixin
+[oracleddl:auditStatement] > ddl:statement mixin
+[oracleddl:commitStatement] > ddl:statement mixin
+[oracleddl:commentOnStatement] > ddl:statement, oracleddl:commentOperand mixin
+ - oracleddl:targetObjectType (STRING) mandatory
+ - oracleddl:targetObjectName (STRING)
+ - oracleddl:comment (STRING) mandatory
+[oracleddl:disassociateStatisticsStatement] > ddl:statement mixin
+[oracleddl:explainPlanStatement] > ddl:statement mixin
+[oracleddl:flashbackStatement] > ddl:statement mixin
+[oracleddl:lockTableStatement] > ddl:statement mixin
+[oracleddl:mergeStatement] > ddl:statement mixin
+[oracleddl:nestedTableStatement] > ddl:statement mixin
+[oracleddl:noauditStatement] > ddl:statement mixin
+[oracleddl:purgeStatement] > ddl:statement mixin
+[oracleddl:renameStatement] > ddl:statement mixin
+[oracleddl:revokeStatement] > ddl:statement mixin
+[oracleddl:rollbackStatement] > ddl:statement mixin
+[oracleddl:setConstraintsStatement] > ddl:statement, ddl:settable mixin
+[oracleddl:setRoleStatement] > ddl:statement, ddl:settable mixin
+[oracleddl:setTransactionStatement] > ddl:statement, ddl:settable mixin
+[oracleddl:truncateStatement] > ddl:statement mixin
\ No newline at end of file
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/PostgresDdl.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/PostgresDdl.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/PostgresDdl.cnd 2012-03-29
20:38:25 UTC (rev 39924)
@@ -0,0 +1,206 @@
+/*
+ * ModeShape (
http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+ //------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<ddl='http://www.modeshape.org/ddl/1.0'>
+<postgresddl='http://www.modeshape.org/ddl/postgres/1.0'>
+
+// =============================================================================
+// OPERANDS
+// =============================================================================
+[postgresddl:aggregateOperand] > ddl:operand abstract
+[postgresddl:castOperand] > ddl:operand abstract
+[postgresddl:commentOperand] > ddl:operand abstract
+[postgresddl:constraintTriggerOperand] > ddl:operand abstract
+[postgresddl:conversionOperand] > ddl:operand abstract
+[postgresddl:databaseOperand] > ddl:operand abstract
+[postgresddl:foreignDataOperand] > ddl:operand abstract
+[postgresddl:groupOperand] > ddl:operand abstract
+[postgresddl:functionOperand] > ddl:operand abstract
+[postgresddl:indexOperand] > ddl:operand abstract
+[postgresddl:languageOperand] > ddl:operand abstract
+[postgresddl:operatorOperand] > ddl:operand abstract
+[postgresddl:ownedByOperand] > ddl:operand abstract
+[postgresddl:roleOperand] > ddl:operand abstract
+[postgresddl:ruleOperand] > ddl:operand abstract
+[postgresddl:sequenceOperand] > ddl:operand abstract
+[postgresddl:serverOperand] > ddl:operand abstract
+[postgresddl:tablespaceOperand] > ddl:operand abstract
+[postgresddl:textSearchOperand] > ddl:operand abstract
+[postgresddl:triggerOperand] > ddl:operand abstract
+[postgresddl:typeOperand] > ddl:operand abstract
+[postgresddl:userOperand] > ddl:operand abstract
+[postgresddl:userMappingOperand] > ddl:operand abstract
+[postgresddl:parameterOperand] > ddl:operand abstract
+
+[postgresddl:functionParameter] > postgresddl:parameterOperand mixin
+ - ddl:datatypeName (STRING) mandatory
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ - ddl:nullable (STRING)
+ - ddl:defaultOption (STRING)
+ - postgresddl:mode (STRING)
+
+[postgresddl:role] > postgresddl:roleOperand mixin
+
+[postgresddl:renamedColumn] > ddl:renamable mixin
+
+// =============================================================================
+// ALTER STATEMENTS
+// =============================================================================
+[postgresddl:alterAggregateStatement] > ddl:alterable, ddl:statement,
postgresddl:aggregateOperand mixin
+[postgresddl:alterConversionStatement] > ddl:alterable, ddl:statement,
postgresddl:conversionOperand mixin
+[postgresddl:alterDatabaseStatement] > ddl:alterable, ddl:statement,
postgresddl:databaseOperand mixin
+[postgresddl:alterForeignDataWrapperStatement] > ddl:alterable, ddl:statement,
postgresddl:foreignDataOperand mixin
+[postgresddl:alterFunctionStatement] > ddl:alterable, ddl:statement,
postgresddl:functionOperand mixin
+[postgresddl:alterGroupStatement] > ddl:alterable, ddl:statement,
postgresddl:groupOperand mixin
+[postgresddl:alterIndexStatement] > ddl:alterable, ddl:statement,
postgresddl:indexOperand mixin
+[postgresddl:alterLanguageStatement] > ddl:alterable, ddl:statement,
postgresddl:languageOperand mixin
+[postgresddl:alterOperatorStatement] > ddl:alterable, ddl:statement,
postgresddl:operatorOperand mixin
+[postgresddl:alterRoleStatement] > ddl:alterable, ddl:statement,
postgresddl:roleOperand mixin
+[postgresddl:alterSchemaStatement] > ddl:alterable, ddl:statement,
ddl:schemaOperand mixin
+[postgresddl:alterSequenceStatement] > ddl:alterable, ddl:statement,
postgresddl:sequenceOperand mixin
+[postgresddl:alterServerStatement] > ddl:alterable, ddl:statement,
postgresddl:serverOperand mixin
+[postgresddl:alterTablespaceStatement] > ddl:alterable, ddl:statement,
postgresddl:tablespaceOperand mixin
+[postgresddl:alterTextSearchStatement] > ddl:alterable, ddl:statement,
postgresddl:textSearchOperand mixin
+[postgresddl:alterTriggerStatement] > ddl:alterable, ddl:statement,
postgresddl:triggerOperand mixin
+[postgresddl:alterTypeStatement] > ddl:alterable, ddl:statement,
postgresddl:typeOperand mixin
+[postgresddl:alterUserStatement] > ddl:alterable, ddl:statement,
postgresddl:userOperand mixin
+[postgresddl:alterUserMappingStatement] > ddl:alterable, ddl:statement,
postgresddl:userMappingOperand mixin
+[postgresddl:alterViewStatement] > ddl:alterable, ddl:statement,
ddl:viewOperand mixin
+
+[postgresddl:alterTableStatement] > ddl:alterTableStatement mixin
+ - postgresddl:newTableName (STRING)
+ - postgresddl:schemaName (STRING)
+ + postgresddl:renameColumn (postgresddl:renamedColumn) = postgresddl:renamedColumn sns
+
+
+// =============================================================================
+// CREATE STATEMENTS
+// =============================================================================
+
+[postgresddl:createAggregateStatement] > ddl:creatable, ddl:statement,
postgresddl:aggregateOperand mixin
+[postgresddl:createCastStatement] > ddl:creatable, ddl:statement,
postgresddl:castOperand mixin
+[postgresddl:createConstraintTriggerStatement] > ddl:creatable, ddl:statement,
postgresddl:constraintTriggerOperand mixin
+[postgresddl:createConversionStatement] > ddl:creatable, ddl:statement,
postgresddl:conversionOperand mixin
+[postgresddl:createDatabaseStatement] > ddl:creatable, ddl:statement,
postgresddl:databaseOperand mixin
+[postgresddl:createForeignDataWrapperStatement] > ddl:creatable, ddl:statement,
postgresddl:foreignDataOperand mixin
+[postgresddl:createFunctionStatement] > ddl:creatable, ddl:statement,
postgresddl:functionOperand mixin
+[postgresddl:createGroupStatement] > ddl:creatable, ddl:statement,
postgresddl:groupOperand mixin
+[postgresddl:createIndexStatement] > ddl:creatable, ddl:statement,
postgresddl:indexOperand mixin
+[postgresddl:createLanguageStatement] > ddl:creatable, ddl:statement,
postgresddl:languageOperand mixin
+[postgresddl:createOperatorStatement] > ddl:creatable, ddl:statement,
postgresddl:operatorOperand mixin
+[postgresddl:createRoleStatement] > ddl:creatable, ddl:statement,
postgresddl:roleOperand mixin
+[postgresddl:createRuleStatement] > ddl:creatable, ddl:statement,
postgresddl:ruleOperand mixin
+[postgresddl:createSequenceStatement] > ddl:creatable, ddl:statement,
postgresddl:sequenceOperand mixin
+[postgresddl:createServerStatement] > ddl:creatable, ddl:statement,
postgresddl:serverOperand mixin
+[postgresddl:createTablespaceStatement] > ddl:creatable, ddl:statement,
postgresddl:tablespaceOperand mixin
+[postgresddl:createTextSearchStatement] > ddl:creatable, ddl:statement,
postgresddl:textSearchOperand mixin
+[postgresddl:createTriggerStatement] > ddl:creatable, ddl:statement,
postgresddl:triggerOperand mixin
+[postgresddl:createTypeStatement] > ddl:creatable, ddl:statement,
postgresddl:typeOperand mixin
+[postgresddl:createUserStatement] > ddl:creatable, ddl:statement,
postgresddl:userOperand mixin
+[postgresddl:createUserMappingStatement] > ddl:creatable, ddl:statement,
postgresddl:userMappingOperand mixin
+
+// =============================================================================
+// DROP STATEMENTS
+// =============================================================================
+
+[postgresddl:dropAggregateStatement] > ddl:droppable, ddl:statement,
postgresddl:aggregateOperand mixin
+[postgresddl:dropCastStatement] > ddl:droppable, ddl:statement,
postgresddl:castOperand mixin
+[postgresddl:dropConstraintTriggerStatement] > ddl:droppable, ddl:statement,
postgresddl:constraintTriggerOperand mixin
+[postgresddl:dropConversionStatement] > ddl:droppable, ddl:statement,
postgresddl:conversionOperand mixin
+[postgresddl:dropDatabaseStatement] > ddl:droppable, ddl:statement,
postgresddl:databaseOperand mixin
+[postgresddl:dropForeignDataWrapperStatement] > ddl:droppable, ddl:statement,
postgresddl:foreignDataOperand mixin
+[postgresddl:dropFunctionStatement] > ddl:droppable, ddl:statement,
postgresddl:functionOperand mixin
+[postgresddl:dropGroupStatement] > ddl:droppable, ddl:statement,
postgresddl:groupOperand mixin
+[postgresddl:dropIndexStatement] > ddl:droppable, ddl:statement,
postgresddl:indexOperand mixin
+[postgresddl:dropLanguageStatement] > ddl:droppable, ddl:statement,
postgresddl:languageOperand mixin
+[postgresddl:dropOperatorStatement] > ddl:droppable, ddl:statement,
postgresddl:operatorOperand mixin
+[postgresddl:dropOwnedByStatement] > ddl:droppable, ddl:statement,
postgresddl:ownedByOperand mixin
+[postgresddl:dropRoleStatement] > ddl:droppable, ddl:statement,
postgresddl:roleOperand mixin
+[postgresddl:dropRuleStatement] > ddl:droppable, ddl:statement,
postgresddl:ruleOperand mixin
+[postgresddl:dropSequenceStatement] > ddl:droppable, ddl:statement,
postgresddl:sequenceOperand mixin
+[postgresddl:dropServerStatement] > ddl:droppable, ddl:statement,
postgresddl:serverOperand mixin
+[postgresddl:dropTablespaceStatement] > ddl:droppable, ddl:statement,
postgresddl:tablespaceOperand mixin
+[postgresddl:dropTextSearchStatement] > ddl:droppable, ddl:statement,
postgresddl:textSearchOperand mixin
+[postgresddl:dropTriggerStatement] > ddl:droppable, ddl:statement,
postgresddl:triggerOperand mixin
+[postgresddl:dropTypeStatement] > ddl:droppable, ddl:statement,
postgresddl:typeOperand mixin
+[postgresddl:dropUserStatement] > ddl:droppable, ddl:statement,
postgresddl:userOperand mixin
+[postgresddl:dropUserMappingStatement] > ddl:droppable, ddl:statement,
postgresddl:userMappingOperand mixin
+
+// =============================================================================
+// MISC STATEMENTS
+// =============================================================================
+
+[postgresddl:abortStatement] > ddl:statement mixin
+[postgresddl:analyzeStatement] > ddl:statement mixin
+[postgresddl:clusterStatement] > ddl:statement mixin
+[postgresddl:commentOnStatement] > ddl:statement, postgresddl:commentOperand
mixin
+ - postgresddl:targetObjectType (STRING) mandatory
+ - postgresddl:targetObjectName (STRING)
+ - postgresddl:comment (STRING) mandatory
+[postgresddl:copyStatement] > ddl:statement mixin
+[postgresddl:deallocateStatement] > ddl:statement mixin
+[postgresddl:declareStatement] > ddl:statement mixin
+[postgresddl:discardStatement] > ddl:statement mixin
+[postgresddl:explainStatement] > ddl:statement mixin
+[postgresddl:fetchStatement] > ddl:statement mixin
+[postgresddl:listenStatement] > ddl:statement mixin
+[postgresddl:loadStatement] > ddl:statement mixin
+[postgresddl:lockTableStatement] > ddl:statement mixin
+[postgresddl:moveStatement] > ddl:statement mixin
+[postgresddl:notifyStatement] > ddl:statement mixin
+[postgresddl:prepareStatement] > ddl:statement mixin
+[postgresddl:reassignOwnedStatement] > ddl:statement mixin
+[postgresddl:reindexStatement] > ddl:statement mixin
+[postgresddl:releaseSavepointStatement] > ddl:statement mixin
+[postgresddl:rollbackStatement] > ddl:statement mixin
+[postgresddl:selectIntoStatement] > ddl:statement mixin
+[postgresddl:showStatement] > ddl:statement mixin
+[postgresddl:truncateStatement] > ddl:statement mixin
+[postgresddl:unlistenStatement] > ddl:statement mixin
+[postgresddl:vacuumStatement] > ddl:statement mixin
+[postgresddl:commitStatement] > ddl:statement mixin
+
+// =============================================================================
+// GRANT STATEMENTS
+// =============================================================================
+[postgresddl:grantOnTableStatement] > ddl:grantStatement, ddl:tableOperand
mixin
+[postgresddl:grantOnSequenceStatement] > ddl:grantStatement,
postgresddl:sequenceOperand mixin
+[postgresddl:grantOnDatabaseStatement] > ddl:grantStatement,
postgresddl:databaseOperand mixin
+[postgresddl:grantOnForeignDataWrapperStatement] > ddl:grantStatement,
postgresddl:foreignDataOperand mixin
+[postgresddl:grantOnForeignServerStatement] > ddl:grantStatement,
postgresddl:serverOperand mixin
+[postgresddl:grantOnFunctionStatement] > ddl:grantStatement,
postgresddl:functionOperand mixin
+ + postgresddl:parameter (postgresddl:functionParameter) = postgresddl:functionParameter
sns
+[postgresddl:grantOnLanguageStatement] > ddl:grantStatement,
postgresddl:languageOperand mixin
+[postgresddl:grantOnSchemaStatement] > ddl:grantStatement, ddl:schemaOperand
mixin
+[postgresddl:grantOnTablespaceStatement] > ddl:grantStatement,
postgresddl:tablespaceOperand mixin
+[postgresddl:grantRolesStatement] > ddl:grantStatement mixin
+ + postgresddl:grantRole (postgresddl:role) = postgresddl:role sns
\ No newline at end of file
Added: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/StandardDdl.cnd
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/StandardDdl.cnd
(rev 0)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/testdata/StandardDdl.cnd 2012-03-29
20:38:25 UTC (rev 39924)
@@ -0,0 +1,299 @@
+/*
+ * ModeShape (
http://www.modeshape.org)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * ModeShape is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+ //------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<ddl='http://www.modeshape.org/ddl/1.0'>
+
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[ddl:operation] mixin abstract
+
+[ddl:operand] mixin abstract
+
+// =============================================================================
+// STATEMENT
+// =============================================================================
+[ddl:statement] mixin abstract
+ - ddl:expression (string) mandatory // The string fragment
encompassing the statement expression.
+ - ddl:originalExpression (string) // The string fragment encompassing the
original statement expression.
+ - ddl:startLineNumber (long) mandatory // The starting line number
for the statement
+ - ddl:startColumnNumber (long) mandatory // The starting column number
for the statement
+ - ddl:startCharIndex (long) mandatory // The starting content
character index for the statement
+ - ddl:length (long) mandatory // The string length
+ + ddl:problem (ddl:ddlProblem) = ddl:ddlProblem sns // Problems encountered
during parsing.
+
+// =============================================================================
+// CREATE, ALTER, DROP, INSERT, SET, GRANT, REVOKE
+// =============================================================================
+[ddl:creatable] > ddl:operation abstract
+[ddl:alterable] > ddl:operation abstract
+[ddl:droppable] > ddl:operation abstract
+ - ddl:dropBehavior (STRING)
+ + ddl:dropOption (ddl:statementOption) = ddl:statementOption sns
+[ddl:insertable] > ddl:operation abstract
+[ddl:settable] > ddl:operation abstract
+[ddl:grantable] > ddl:operation abstract
+[ddl:revokable] > ddl:operation abstract
+[ddl:renamable] > ddl:operation abstract
+ - ddl:newName (STRING)
+
+// =============================================================================
+// OPERANDS: SCHEMA, TABLE, DOMAIN, VIEW, ASSERTION, CHARACTER SET, COLLATION,
TRANSLATION
+// =============================================================================
+[ddl:schemaOperand] > ddl:operand abstract
+[ddl:tableOperand] > ddl:operand abstract
+[ddl:domainOperand] > ddl:operand abstract
+[ddl:viewOperand] > ddl:operand abstract
+[ddl:assertionOperand] > ddl:operand abstract
+[ddl:characterSetOperand] > ddl:operand abstract
+[ddl:collationOperand] > ddl:operand abstract
+[ddl:translationOperand] > ddl:operand abstract
+[ddl:columnOperand] > ddl:operand abstract
+[ddl:tableConstraintOperand] > ddl:operand abstract
+[ddl:referenceOperand] > ddl:operand abstract
+
+
+// =============================================================================
+// SIMPLE STRING PROPERTY
+// =============================================================================
+[ddl:simpleProperty] mixin
+ - ddl:propValue (STRING) mandatory
+
+[ddl:constraintAttribute] > ddl:simpleProperty mixin
+
+// =============================================================================
+// STATEMENT OPTION
+// =============================================================================
+[ddl:statementOption] mixin
+ - ddl:value (STRING) mandatory
+
+// =============================================================================
+// UNKNOWN STATEMENT
+// =============================================================================
+[ddl:unknownStatement] mixin
+
+// =============================================================================
+// DDL PROBLEM
+// =============================================================================
+[ddl:ddlProblem] mixin
+ - ddl:problemLevel (LONG) mandatory
+ - ddl:message (STRING) mandatory
+
+// =============================================================================
+// COLUMN
+// =============================================================================
+[ddl:columnDefinition] > ddl:creatable, ddl:columnOperand mixin
+ - ddl:datatypeName (STRING)
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ - ddl:nullable (STRING)
+ - ddl:defaultOption (STRING)
+ < 'LITERAL', 'DATETIME', 'USER', 'CURRENT_USER',
'SESSION_USER', 'SYSTEM_USER', 'NULL'
+ - ddl:defaultValue (STRING)
+ - ddl:defaultPrecision (LONG)
+ - ddl:collationName (STRING)
+ + ddl:dropBehavior (ddl:simpleProperty) = ddl:simpleProperty
+ + ddl:columnAttribute (ddl:simpleProperty) = ddl:simpleProperty sns
+
+// =============================================================================
+// TABLE CONSTRAINT
+// =============================================================================
+[ddl:tableConstraint] > ddl:creatable, ddl:tableConstraintOperand mixin
+ - ddl:constraintType (STRING)
+ < 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY',
'CHECK'
+ - ddl:deferrable (STRING)
+ < 'DEFERRABLE', 'NOT DEFERRABLE'
+ - ddl:checkSearchCondition (STRING)
+ < 'INITIALLY DEFERRED', 'INITIALLY IMMEDIATE'
+ + * (ddl:columnReference) = ddl:columnReference sns
+ + * (ddl:tableReference) = ddl:tableReference
+ + * (ddl:fkColumnReference) = ddl:fkColumnReference sns
+ + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute sns
+
+// =============================================================================
+// REFERENCE
+// =============================================================================
+[ddl:columnReference] > ddl:referenceOperand mixin
+[ddl:tableReference] > ddl:referenceOperand mixin
+[ddl:fkColumnReference] > ddl:referenceOperand mixin
+[ddl:grantee] > ddl:referenceOperand mixin
+
+// =============================================================================
+// CREATE SCHEMA
+// =============================================================================
+[ddl:createSchemaStatement] > ddl:statement, ddl:creatable, ddl:schemaOperand mixin
+ - ddl:defaultCharacterSetName (STRING)
+ + * (ddl:statement) = ddl:statement sns
+
+// =============================================================================
+// CREATE TABLE
+// =============================================================================
+[ddl:createTableStatement] > ddl:statement, ddl:creatable, ddl:tableOperand mixin
+ - ddl:temporary (STRING)
+ < 'GLOBAL', 'LOCAL'
+ - ddl:onCommitValue (STRING)
+ < 'DELETE ROWS', 'PRESERVE ROWS'
+ + * (ddl:columnDefinition) = ddl:columnDefinition sns
+ + * (ddl:tableConstraint) = ddl:tableConstraint sns
+ + * (ddl:statementOption) = ddl:statementOption sns
+
+// =============================================================================
+// CREATE VIEW
+// =============================================================================
+[ddl:createViewStatement] > ddl:statement, ddl:creatable, ddl:viewOperand mixin
+ - ddl:checkOption (STRING)
+ + * (ddl:columnReference) = ddl:columnReference sns
+
+// =============================================================================
+// CREATE DOMAIN
+// =============================================================================
+[ddl:createDomainStatement] > ddl:statement, ddl:creatable, ddl:domainOperand mixin
+ - ddl:datatypeName (STRING) mandatory
+ - ddl:datatypeLength (LONG)
+ - ddl:datatypePrecision (LONG)
+ - ddl:datatypeScale (LONG)
+ - ddl:defaultOption (STRING)
+ < 'LITERAL', 'DATETIME', 'USER',
'CURRENT_USER', 'SESSION_USER', 'SYSTEM_USER', 'NULL'
+ - ddl:defaultValue (STRING)
+ - ddl:defaultPrecision (LONG)
+ - ddl:collationName (STRING)
+
+// =============================================================================
+// CREATE ASSERTION
+// =============================================================================
+[ddl:createAssertionStatement] > ddl:statement, ddl:creatable,
ddl:tableConstraintOperand mixin
+ - ddl:searchCondition (STRING) mandatory
+ + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute sns
+
+// =============================================================================
+// CREATE CHARACTER SET
+// =============================================================================
+[ddl:createCharacterSetStatement] > ddl:statement, ddl:creatable,
ddl:characterSetOperand mixin
+ - ddl:existingName (STRING) mandatory
+ - ddl:collateClause (STRING) // TODO: THIS IS COMPLEX, NEED TO
BREAK DOWN
+ - ddl:limitedCollationDefinition (STRING) // TODO: THIS IS COMPLEX, NEED TO
BREAK DOWN
+
+// =============================================================================
+// CREATE COLLATION
+// =============================================================================
+[ddl:createCollationStatement] > ddl:statement, ddl:creatable, ddl:collationOperand
mixin
+ - ddl:characterSetName (STRING) mandatory
+ - ddl:collationSource (STRING) // TODO: THIS IS COMPLEX, NEED TO
BREAK DOWN
+ - ddl:padAttribute (STRING)
+ < 'NO PAD', 'PAD SPACE'
+
+// =============================================================================
+// CREATE TRANSLATION
+// =============================================================================
+[ddl:createTranslationStatement] > ddl:statement, ddl:creatable,
ddl:translationOperand mixin
+ - ddl:sourceCharacterSetName (STRING) mandatory
+ - ddl:targetCharacterSetName (STRING) mandatory
+ - ddl:translationSource (STRING) // TODO: THIS IS COMPLEX, NEED TO
BREAK DOWN
+
+// =============================================================================
+// ALTER TABLE
+// =============================================================================
+[ddl:alterTableStatement] > ddl:statement, ddl:alterable, ddl:tableOperand mixin
+ + * (ddl:addColumnDefinition) = ddl:addColumnDefinition sns
+ + * (ddl:dropColumnDefinition) = ddl:dropColumnDefinition sns
+ + * (ddl:alterColumnDefinition) = ddl:alterColumnDefinition sns
+ + * (ddl:addTableConstraintDefinition) = ddl:addTableConstraintDefinition sns
+ + * (ddl:dropTableConstraintDefinition) = ddl:dropTableConstraintDefinition sns
+ + * (ddl:statementOption) = ddl:statementOption sns
+
+// =============================================================================
+// ALTER DOMAIN
+// =============================================================================
+[ddl:alterDomainStatement] > ddl:statement, ddl:alterable, ddl:domainOperand mixin
+ - ddl:alterDomainAction (STRING) // TODO: THIS IS COMPLEX, NEED TO
BREAK DOWN
+
+// =============================================================================
+// DROP STATEMENTS
+// =============================================================================
+[ddl:dropSchemaStatement] > ddl:statement, ddl:droppable, ddl:schemaOperand
mixin
+[ddl:dropTableStatement] > ddl:statement, ddl:droppable, ddl:tableOperand
mixin
+[ddl:dropViewStatement] > ddl:statement, ddl:droppable, ddl:viewOperand
mixin
+[ddl:dropDomainStatement] > ddl:statement, ddl:droppable, ddl:domainOperand
mixin
+[ddl:dropCharacterSetStatement] > ddl:statement, ddl:droppable,
ddl:characterSetOperand mixin
+[ddl:dropCollationStatement] > ddl:statement, ddl:droppable,
ddl:collationOperand mixin
+[ddl:dropTranslationStatement] > ddl:statement, ddl:droppable,
ddl:translationOperand mixin
+[ddl:dropAssertionStatement] > ddl:statement, ddl:droppable,
ddl:assertionOperand mixin
+
+[ddl:alterColumnDefinition] > ddl:columnDefinition, ddl:alterable mixin
+[ddl:addColumnDefinition] > ddl:columnDefinition, ddl:creatable mixin
+[ddl:dropColumnDefinition] > ddl:columnDefinition, ddl:droppable mixin
+[ddl:addTableConstraintDefinition] > ddl:tableConstraint, ddl:creatable mixin
+[ddl:dropTableConstraintDefinition] > ddl:tableConstraint, ddl:droppable mixin
+
+// =============================================================================
+// MISC STATEMENTS
+// =============================================================================
+[ddl:setStatement] > ddl:statement, ddl:settable mixin
+ // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN
+
+[ddl:insertStatement] > ddl:statement, ddl:insertable mixin
+ // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN
+
+// =============================================================================
+// GRANT STATEMENTS
+// =============================================================================
+
+[ddl:grantPrivilege] mixin
+ - ddl:type (STRING) mandatory
+ + * (ddl:columnReference) = ddl:columnReference sns
+
+[ddl:grantStatement] > ddl:statement, ddl:grantable mixin
+ - ddl:allPrivileges (boolean)
+ + * (ddl:grantPrivilege) = ddl:grantPrivilege sns
+ + * (ddl:grantee) = ddl:grantee sns
+
+[ddl:grantOnTableStatement] > ddl:grantStatement, ddl:tableOperand mixin
+[ddl:grantOnDomainStatement] > ddl:grantStatement, ddl:domainOperand mixin
+[ddl:grantOnCollationStatement] > ddl:grantStatement, ddl:collationOperand mixin
+[ddl:grantOnCharacterSetStatement] > ddl:grantStatement, ddl:characterSetOperand
mixin
+[ddl:grantOnTranslationStatement] > ddl:grantStatement, ddl:translationOperand
mixin
+
+// =============================================================================
+// REVOKE STATEMENTS
+// =============================================================================
+
+[ddl:revokeStatement] > ddl:statement, ddl:revokable, ddl:droppable mixin
+ - ddl:allPrivileges (boolean)
+ + * (ddl:grantPrivilege) = ddl:grantPrivilege sns
+ + * (ddl:grantee) = ddl:grantee sns
+
+[ddl:revokeOnTableStatement] > ddl:revokeStatement, ddl:tableOperand mixin
+[ddl:revokeOnDomainStatement] > ddl:revokeStatement, ddl:domainOperand mixin
+[ddl:revokeOnCollationStatement] > ddl:revokeStatement, ddl:collationOperand
mixin
+[ddl:revokeOnCharacterSetStatement] > ddl:revokeStatement, ddl:characterSetOperand
mixin
+[ddl:revokeOnTranslationStatement] > ddl:revokeStatement, ddl:translationOperand
mixin
\ No newline at end of file