jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r574864 - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src: main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ test/java/org/apache/jackrabbit/ocm/ test/java/org/apache/jackrabbit/ocm/manager/atomic/ test/j...
Date Wed, 12 Sep 2007 09:47:41 GMT
Author: fmeschbe
Date: Wed Sep 12 02:47:40 2007
New Revision: 574864

URL: http://svn.apache.org/viewvc?rev=574864&view=rev
Log:
JCR-1119 SimpleFieldsHelper emits a lot warnings

Added:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/atomic/DefaultValueTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Default.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/jcrmapping-default.xml
Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/TestBase.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/nodetypes/custom_nodetypes.xml

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java?rev=574864&r1=574863&r2=574864&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/SimpleFieldsHelper.java
Wed Sep 12 02:47:40 2007
@@ -33,7 +33,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.exception.JcrMappingException;
 import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
 import org.apache.jackrabbit.ocm.manager.ManagerConstant;
 import org.apache.jackrabbit.ocm.manager.atomictypeconverter.AtomicTypeConverter;
@@ -134,25 +133,51 @@
 
 	private Object retrieveSimpleField(ClassDescriptor classDescriptor, Node node, Object initializedBean,
FieldDescriptor fieldDescriptor, String fieldName, String propertyName) throws RepositoryException,
ValueFormatException, PathNotFoundException {
 
+	    Value propValue;
 		if (node.hasProperty(propertyName)) 
 		{
-			Value propValue = node.getProperty(propertyName).getValue();
-			// HINT: lazy initialize target bean - The bean can be null when it is inline
-			if (null != propValue && null == initializedBean) 
-			{
-				initializedBean = ReflectionUtils.newInstance(classDescriptor.getClassName());
-			}
-
-			AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, initializedBean,
fieldName);
-			Object fieldValue = converter.getObject(propValue);
-			ReflectionUtils.setNestedProperty(initializedBean, fieldName, fieldValue);
+			propValue = node.getProperty(propertyName).getValue();
 			
 		} 
-		else 
+		else if (fieldDescriptor.getJcrDefaultValue() != null)
 		{
-			log.warn("Class '" + classDescriptor.getClassName() + "' has an unmapped property : "
	+ propertyName);
+		    ValueFactory vf = node.getSession().getValueFactory();
+		    propValue = vf.createValue(fieldDescriptor.getJcrDefaultValue());
 		}
-		return initializedBean;
+		else
+		{
+		    PropertyDefinition propDef = getPropertyDefinition(node, propertyName);
+		    
+		    if (propDef != null && propDef.getDefaultValues() != null && propDef.getDefaultValues().length
== 1)
+		    {
+                log.debug("retrieveSimpleField: Use default value from property definition
for missing mapped property " + propertyName + " of class '" + classDescriptor.getClassName()
+ "'");
+		        propValue = propDef.getDefaultValues()[0];
+		    } else
+		    {
+                log.debug("retrieveSimpleField: No default value available for missing mapped
property " + propertyName + " of class '" + classDescriptor.getClassName() + "'");
+		        propValue = null;
+		    }
+		}
+		
+        // HINT: lazy initialize target bean - The bean can be null when it is inline
+		if (initializedBean == null)
+		{
+		    
+		    // if we do not have a value, we do nothing at all and just return null
+		    if (propValue == null)
+		    {
+		        return null;
+		    }
+		    
+		    // otherwise create the bean to set the value
+		    initializedBean = ReflectionUtils.newInstance(classDescriptor.getClassName());
+		}
+
+        AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, initializedBean,
fieldName);
+        Object fieldValue = (propValue != null) ? converter.getObject(propValue) : null;
+        ReflectionUtils.setNestedProperty(initializedBean, fieldName, fieldValue);
+
+        return initializedBean;
 	}
 	
 	public void storeSimpleFields(Session session, Object object, ClassDescriptor classDescriptor,
Node objectNode) {
@@ -225,46 +250,39 @@
 
 		// Check if the property is defined as protected in the JCR repo
 		
-		// 1. Check in the primary node type
-		PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getPropertyDefinitions();
-		for (int i = 0; i < propertyDefinitions.length; i++) {
-			PropertyDefinition definition = propertyDefinitions[i];
-			if (definition.getName().equals(fieldDescriptor.getJcrName()))
-			{
-			    return definition.isProtected();
-			}
+		// 1. Check if the property already exists and may be queried
+		if (objectNode.hasProperty(jcrName))
+		{
+		    return objectNode.getProperty(jcrName).getDefinition().isProtected();
 		}
-		
-		// 2. Check in the secondary node types
-		NodeType[] nodeTypes =  objectNode.getMixinNodeTypes();
-		for(int nodeTypeIndex = 0; nodeTypeIndex < nodeTypes.length; nodeTypeIndex++)
+		    
+		// 2. Find a definition for the property and checks its protected status
+		PropertyDefinition definition = getPropertyDefinition(objectNode, jcrName);
+		if (definition != null)
 		{
-			propertyDefinitions = nodeTypes[nodeTypeIndex].getPropertyDefinitions();
-			for (int propDefIndex = 0; propDefIndex < propertyDefinitions.length; propDefIndex++)
{
-				PropertyDefinition definition = propertyDefinitions[propDefIndex];
-				if (definition.getName().equals(fieldDescriptor.getJcrName()))
-				{
-				    return definition.isProtected();
-				}
-			}
+		    return definition.isProtected();
 		}
 		
         // This property is not defined in one of the node types
-		return false;
-		
+		return false;		
 	}
 	
 	private void checkProperty(Node objectNode, FieldDescriptor fieldDescriptor, Value value)
throws RepositoryException {
-		PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getPropertyDefinitions();
-		for (int i = 0; i < propertyDefinitions.length; i++) {
-			PropertyDefinition definition = propertyDefinitions[i];
-			if (definition.getName().equals(fieldDescriptor.getJcrName()) && definition.isMandatory()
&& (value == null)) {
-				throw new ObjectContentManagerException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName()
-						+ " has property: " + fieldDescriptor.getFieldName() + " declared as JCR property:
"
-						+ fieldDescriptor.getJcrName() + " This property is mandatory but property in bean
has value null");
-			}
-		}
+	    if (value == null)
+	    {
+	        PropertyDefinition definition = getPropertyDefinition(objectNode, fieldDescriptor.getJcrName());
+	        if (definition != null)
+	        {
+	            if (definition.isMandatory() && !definition.isAutoCreated())
+	            {
+	                throw new ObjectContentManagerException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName()
+                        + " has property: " + fieldDescriptor.getFieldName() + " declared
as JCR property: "
+                        + fieldDescriptor.getJcrName() + " This property is mandatory but
property in bean has value null");
+	            }
+	        }
+	    }
 	}	
+	
 	private AtomicTypeConverter getAtomicTypeConverter(FieldDescriptor fd, Object object, String
fieldName) {
 		Class fieldTypeClass = null;
 		// Check if an atomic converter is assigned to the field converter
@@ -288,5 +306,108 @@
 			
 		}
 	}
+	
+	/**
+	 * Returns the <code>PropertyDefinition</code> for the name property in
+	 * the given node type. If the node type has no matching node type
+	 * definition <code>null</code> is returned.
+	 * <p>
+	 * This method scans as follows: If a PropertyDefinition with the exact
+	 * name is found which is single-valued, this property definition is
+	 * returned. Otherwise the first residual property definition which is
+	 * single-valued is returned. Otherwise <code>null</code> is returned.
+	 * 
+	 * @param nodeType The <code>NodeType</code> to search for matching node
+	 *         type definitions for the given property.
+	 * @param propertyName The name of the property for which the
+	 *         <code>PropertyDefinition</code> is requested.
+	 *         
+	 * @return The <code>PropertyDefinition</code> for the given property or
+	 *         <code>null</code> if none can be found in the type.
+	 */
+	private PropertyDefinition getPropertyDefinition(NodeType nodeType, String propertyName)
{
+        PropertyDefinition[] pd = nodeType.getPropertyDefinitions();
+        PropertyDefinition candidate = null;
+        for (int i=0; i < pd.length; i++)
+        {
+            // ignore multi-value properties
+            if (pd[i].isMultiple())
+            {
+                continue;
+            }
+            
+            // if we have an exact match, use this and return
+            if (propertyName.equals(pd[i].getName()))
+            {
+                return pd[i];
+            }
+            
+            // if we have a residual property definition consider as candidate
+            if (pd[i].getName() == null && candidate == null)
+            {
+                candidate = pd[i];
+            }
+        }
+        
+        // return the potential residal candidate definition
+        return candidate;
+	}
+
+	
+	/**
+	 * Returns a <code>PropertyDefinition</code> for the given property name.
+	 * This method first looks for a matching property definition in the
+	 * primary node type and then in the list of mixin node types of the node.
+	 * Only single-valued property definitions are considered by this method.
+	 * If a definition whose name is the same as the <code>propertyName</code>
+	 * is found, this definition is returned. Otherwise a residual property
+	 * definition may be returned.
+	 * 
+	 * @param node The <code>Node</code> whose primary and mixin node types are
+	 *         to be scanned for a single-valued property definition.
+	 * @param propertyName The name of the property for which the property
+	 *         definition is to be returned.
+	 *         
+	 * @return The <code>PropertyDefinition</code> for the named property or
+	 *         <code>null</code> if no single-valued exact or residual property
+	 *         definintion may be found in the node's primary or mixin node
+	 *         types.
+	 *         
+	 * @throws RepositoryException If an error occurrs accessing the primary or
+	 *         mixin node types of the node.
+	 */
+	private PropertyDefinition getPropertyDefinition(Node node, String propertyName) throws
RepositoryException {
+	    
+	    // try to find the definition in the primary node type
+        NodeType nt = node.getPrimaryNodeType();
+        PropertyDefinition propDef = getPropertyDefinition(nt, propertyName);
+        
+        // return the definition if it is not residual
+        if (propDef != null && propDef.getName() != null)
+        {
+            return propDef;
+        }
+        
+        // otherwise look it up in any of the mixin node types
+        NodeType[] mixins = node.getMixinNodeTypes();
+        for (int i = 0; mixins != null && i < mixins.length; i++)
+        {
+            PropertyDefinition candidate = getPropertyDefinition(mixins[i], propertyName);
+            
+            // use this property definition if not residual
+            if (candidate != null && candidate.getName() != null)
+            {
+                return propDef;
+            }
+            
+            // otherwise use this if we do not have a candidate yet
+            if (propDef == null)
+            {
+                propDef = candidate;
+            }
+        }
 
+        // nothing found
+        return propDef;
+	}
 }

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/TestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/TestBase.java?rev=574864&r1=574863&r2=574864&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/TestBase.java
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/TestBase.java
Wed Sep 12 02:47:40 2007
@@ -171,7 +171,8 @@
 		Repository repository = RepositoryUtil.getRepository("repositoryTest");
 		String[] files = { "./src/test/test-config/jcrmapping.xml", 
 						   "./src/test/test-config/jcrmapping-proxy.xml",
-                           "./src/test/test-config/jcrmapping-atomic.xml",
+						   "./src/test/test-config/jcrmapping-atomic.xml",
+                           "./src/test/test-config/jcrmapping-default.xml",
                            "./src/test/test-config/jcrmapping-beandescriptor.xml",
                            "./src/test/test-config/jcrmapping-inheritance.xml",
                            "./src/test/test-config/jcrmapping-jcrnodetypes.xml", 

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/atomic/DefaultValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/atomic/DefaultValueTest.java?rev=574864&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/atomic/DefaultValueTest.java
(added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/atomic/DefaultValueTest.java
Wed Sep 12 02:47:40 2007
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.atomic;
+
+import javax.jcr.Node;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.TestBase;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.testmodel.Default;
+
+/**
+ * Test Default value assignement
+ */
+public class DefaultValueTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(DefaultValueTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public DefaultValueTest(String testName) throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new RepositoryLifecycleTestSetup(new TestSuite(DefaultValueTest.class));
+    }
+
+
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+    
+	public void testDefaultValues()
+	{
+	    try
+	    {
+	        ObjectContentManager ocm = getObjectContentManager();
+	        
+	        // --------------------------------------------------------------------------------
+	        // Create and store an object graph in the repository
+	        // --------------------------------------------------------------------------------
+	        Default a = new Default();
+	        a.setPath("/testDefault");
+	        a.setP1("p1Value");
+	        // do not set p2, p3, p4, p5
+	        
+	        ocm.insert(a);
+	        ocm.save();
+	        
+	        
+	        // --------------------------------------------------------------------------------
+	        // Get the object
+	        // --------------------------------------------------------------------------------
+	        a = null;
+	        a = (Default) ocm.getObject( "/testDefault" );
+	        assertNotNull("a is null", a);
+	        
+	        assertEquals("p1Value", a.getP1());
+	        assertNull(a.getP2());
+	        assertEquals("p3DescriptorDefaultValue", a.getP3());
+	        assertEquals("p4DefaultValue", a.getP4());
+	        assertEquals("p5DefaultValue", a.getP5());
+	        
+	    }
+	    catch (Exception e)
+	    {
+	        e.printStackTrace();
+	        fail("Exception occurs during the unit test : " + e);
+	    }
+	    
+	}
+	
+	
+    public void testDefaultValuesRead()
+    {
+        try
+        {
+        	ObjectContentManager ocm = getObjectContentManager();
+
+        	// --------------------------------------------------------------------------------
+            // Manually create a node
+        	// we need this test as SimpleFieldsHelper.storeSimpleField sets the
+        	// property value if the field is not set but a jcrDefaultValue
+        	// is set. But we want to test, that SimpleFieldsHelper.retrieveSimpleField
+        	// sets the default value from the jcrDefaultValue
+            // --------------------------------------------------------------------------------
+        	Node nodeA = ocm.getSession().getRootNode().addNode("testDefault", "ocm:DefTestPrimary");
+        	nodeA.setProperty("ocm:p1", "p1Value");
+        	ocm.getSession().save();
+        	
+             
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
+            Default a = (Default) ocm.getObject( "/testDefault" );
+            assertNotNull("a is null", a);
+            
+            assertEquals("p1Value", a.getP1());
+            assertNull(a.getP2());
+            assertEquals("p3DescriptorDefaultValue", a.getP3());
+            assertEquals("p4DefaultValue", a.getP4());
+            assertEquals("p5DefaultValue", a.getP5());
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+}
\ No newline at end of file

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Default.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Default.java?rev=574864&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Default.java
(added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Default.java
Wed Sep 12 02:47:40 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.testmodel;
+
+
+/**
+ * Simple object used to test default value assignement
+ */
+public class Default {
+    private String path;
+
+    private String p1;
+
+    private String p2;
+
+    private String p3;
+
+    private String p4;
+
+    private String p5;
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    /**
+     * @return the p1
+     */
+    public String getP1() {
+        return p1;
+    }
+
+    /**
+     * @param p1 the p1 to set
+     */
+    public void setP1(String p1) {
+        this.p1 = p1;
+    }
+
+    /**
+     * @return the p2
+     */
+    public String getP2() {
+        return p2;
+    }
+
+    /**
+     * @param p2 the p2 to set
+     */
+    public void setP2(String p2) {
+        this.p2 = p2;
+    }
+
+    /**
+     * @return the p3
+     */
+    public String getP3() {
+        return p3;
+    }
+
+    /**
+     * @param p3 the p3 to set
+     */
+    public void setP3(String p3) {
+        this.p3 = p3;
+    }
+
+    /**
+     * @return the p4
+     */
+    public String getP4() {
+        return p4;
+    }
+
+    /**
+     * @param p4 the p4 to set
+     */
+    public void setP4(String p4) {
+        this.p4 = p4;
+    }
+
+    /**
+     * @return the p5
+     */
+    public String getP5() {
+        return p5;
+    }
+
+    /**
+     * @param p5 the p5 to set
+     */
+    public void setP5(String p5) {
+        this.p5 = p5;
+    }
+
+}

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/jcrmapping-default.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/jcrmapping-default.xml?rev=574864&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/jcrmapping-default.xml
(added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/jcrmapping-default.xml
Wed Sep 12 02:47:40 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jackrabbit-ocm PUBLIC "-//The Apache Software Foundation//DTD Repository//EN"
"./src/dtd/jackrabbit-ocm.dtd">
+<jackrabbit-ocm>
+    <class-descriptor
+		className="org.apache.jackrabbit.ocm.testmodel.Default" jcrType="ocm:DefTestPrimary" discriminator="false"
>
+		<field-descriptor fieldName="path" path="true" />
+        
+        <!-- no default value, assigned in test -->
+		<field-descriptor fieldName="p1" jcrName="ocm:p1" />
+        
+        <!-- no default value, expected null in test -->
+		<field-descriptor fieldName="p2" jcrName="ocm:p2" />
+        
+        <!-- default value in descriptor -->
+		<field-descriptor fieldName="p3" jcrName="ocm:p3" jcrDefaultValue="p3DescriptorDefaultValue"
/>
+        
+        <!-- default value from PropertyDefinition in primary type -->
+		<field-descriptor fieldName="p4" jcrName="ocm:p4" />
+        
+        <!-- default value from PropertyDefinition in mixin type -->
+		<field-descriptor fieldName="p5" jcrName="ocm:p5" />
+	</class-descriptor>
+</jackrabbit-ocm>
+ 

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/nodetypes/custom_nodetypes.xml?rev=574864&r1=574863&r2=574864&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/nodetypes/custom_nodetypes.xml
(original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/test-config/nodetypes/custom_nodetypes.xml
Wed Sep 12 02:47:40 2007
@@ -242,5 +242,30 @@
     </childNodeDefinition>    
   </nodeType>
    
+  <!-- START Node Types for testing default simple values -->
+  <!-- Mixin Node Type -->
+  <nodeType name="ocm:DefTestMixin" isMixin="true">
+    <propertyDefinition name="ocm:p5" requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false">
+      <defaultValues>
+        <defaultValue>p5DefaultValue</defaultValue>
+      </defaultValues>
+    </propertyDefinition>    
+  </nodeType>    
+  <!-- Primary Node Type -->
+  <nodeType name="ocm:DefTestPrimary" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+      <supertype>ocm:DefTestMixin</supertype>
+    </supertypes>
+    <propertyDefinition name="ocm:p1" requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDefinition name="ocm:p2" requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDefinition name="ocm:p3" requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false" />
+    <propertyDefinition name="ocm:p4" requiredType="String" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false">
+      <defaultValues>
+        <defaultValue>p4DefaultValue</defaultValue>
+      </defaultValues>
+    </propertyDefinition>    
+  </nodeType>
+  <!-- END Node Types for testing default simple values -->
 </nodeTypes>
 



Mime
View raw message