incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From okiess...@apache.org
Subject svn commit: r348952 - in /incubator/graffito/trunk/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/impl/ java/org/apache/portals/graffito/jcr/mapper/model/ test-config/ test/org/apache/portals/graffito/jcr/mapper/
Date Fri, 25 Nov 2005 13:44:39 GMT
Author: okiessler
Date: Fri Nov 25 05:44:27 2005
New Revision: 348952

URL: http://svn.apache.org/viewcvs?rev=348952&view=rev
Log:
Issue: GRFT-78

Modified:
    incubator/graffito/trunk/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
    incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java

Modified: incubator/graffito/trunk/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd (original)
+++ incubator/graffito/trunk/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd Fri Nov 25 05:44:27
2005
@@ -22,27 +22,41 @@
     Class descriptor - Each class descriptor describes the mapping strategy used for one
a java class
     * className : the className
     * jcrNodeType : the primary jcr node type, it can be nt:unstructured
+    * jcrSuperTypes : the jcr super types, optional
 -->
 <!ELEMENT class-descriptor (field-descriptor*, bean-descriptor*, collection-descriptor*)>
 
 <!ATTLIST class-descriptor
 	className CDATA #REQUIRED
-	jcrNodeType CDATA #IMPLIED >
+	jcrNodeType CDATA #IMPLIED
+        jcrSuperTypes CDATA #IMPLIED>
 
 <!--
     Field descriptor - A field descriptor maps one atomic object attribute (primitive types,
String, Long, ...)  into a JCR property
     * fieldName : the field/attribute name
     * jcrName : the jcr property name (optional). If it is not defined, fieldname is used
to specify the jcr property name
-    * id : specifies if the field is an id. Id is optional. If the class contains an id field,
some process can run faster
+    * id : specifies if the field is an id. Id is optional. If the class contains an id field,
some process can run faster
     * path : specified if the fiels is the object path
+    * jcrType: specifies the JCR property type (supported jcr property types: STRING, DATE,
LONG, DOUBLE, BOOLEAN), optional
+    * jcrAutoCreated: specifies if this JCR property will be autocreated (true/false / default
is false), optional
+    * jcrMandatory: specifies if this JCR property is mandatory (true/false / default is
false), optional
+    * jcrOnParentVersion: specifies how this JCR property acts on inherited versioned node
properties (default is IGNORE), optional
+    * jcrProtected: specifies if this JCR node property is protected (true/false / default
is false), optional
+    * jcrMultiple: specifies if this JCR node property is a multivalued property (true/false
/ default is false), optional
 -->
 
 <!ELEMENT field-descriptor EMPTY>
 <!ATTLIST field-descriptor
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
-	id (true | false) "false"
+	id (true | false) "false"
 	path (true | false) "false"
+        jcrType (STRING | DATE | LONG | DOUBLE | BOOLEAN) #IMPLIED
+        jcrAutoCreated (true | false) "false"
+        jcrMandatory (true | false) "false"
+        jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "IGNORE"
+        jcrProtected (true | false) "false"
+        jcrMultiple (true | false) "false"
 >
 
 <!--
@@ -50,13 +64,24 @@
     * fieldName : the field/attribute name
     * jcrName : the jcr node name (optional). If it is not defined, fieldname is used to
specify the jcr node name
     * proxy : Use lazy loading or not. if true, this attributes is not loaded when the main
object is retrieved. it will be loaded when the get method is called.
-    
+    * jcrNodeType: defines the child node type, optional
+    * jcrAutoCreated (boolean) default is "false"
+    * jcrMandatory (boolean) default is "false"
+    * jcrOnParentVersion default is "IGNORE"
+    * jcrProtected (boolean) default is "false"
+    * jcrSameNameSiblings (boolean) default is "false"   
 -->
 <!ELEMENT bean-descriptor EMPTY>
 <!ATTLIST bean-descriptor
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
-	proxy (true | false) "false"
+	proxy (true | false) "false" 
+	jcrNodeType CDATA #IMPLIED
+        jcrAutoCreated (true | false) "false"   
+        jcrMandatory (true | false) "false"
+        jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "IGNORE"
+        jcrProtected (true | false) "false"
+        jcrSameNameSiblings (true | false) "false"         
 >
 
 <!--
@@ -69,8 +94,13 @@
                             This attribute must only specified if the attribute type is not
a java.util.Collection (or subclass). 
                             The declared class must implement ManageableCollection to let
the persistence engine handles this type of collection.
     * collectionConverter : The class name converter. This is the collection mapping strategy
to used. 
-                            If this attribute is not specify, the default collection mapping
strategy is used (DefaultCollectionConverterImpl)                             
-    
+                            If this attribute is not specify, the default collection mapping
strategy is used (DefaultCollectionConverterImpl)
+    * jcrNodeType: defines the child node type, optional
+    * jcrAutoCreated (boolean) default is "false"
+    * jcrMandatory (boolean) default is "false"
+    * jcrOnParentVersion default is "IGNORE"
+    * jcrProtected (boolean) default is "false"
+    * jcrSameNameSiblings (boolean) default is "false"
 -->
 
 <!ELEMENT collection-descriptor EMPTY>
@@ -80,5 +110,11 @@
 	proxy (true | false) "false"
 	elementClassName CDATA #REQUIRED
 	collectionClassName CDATA #IMPLIED
-	collectionConverter CDATA #IMPLIED	
+	collectionConverter CDATA #IMPLIED
+	jcrNodeType CDATA #IMPLIED
+        jcrAutoCreated (true | false) "false"   
+        jcrMandatory (true | false) "false"
+        jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "IGNORE"
+        jcrProtected (true | false) "false"
+        jcrSameNameSiblings (true | false) "false"	
 >

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
Fri Nov 25 05:44:27 2005
@@ -58,6 +58,7 @@
 			digester.addObjectCreate("graffito-jcr/class-descriptor", ClassDescriptor.class);
 			digester.addSetProperties("graffito-jcr/class-descriptor", "className", "className");
 			digester.addSetProperties("graffito-jcr/class-descriptor", "jcrNodeType", "jcrNodeType");
+            digester.addSetProperties("graffito-jcr/class-descriptor", "jcrSuperTypes", "jcrSuperTypes");
 
 			digester.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");
 
@@ -70,6 +71,12 @@
 			digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrName",
"jcrName");
 			digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "id", "id");
 			digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "path", "path");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrType",
"jcrType");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrAutoCreated",
"jcrAutoCreated");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrMandatory",
"jcrMandatory");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrOnParentVersion",
"jcrOnParentVersion");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrProtected",
"jcrProtected");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrMultiple",
"jcrMultiple");
 			digester.addSetNext("graffito-jcr/class-descriptor/field-descriptor", "addFieldDescriptor");
 
 			// --------------------------------------------------------------------------------
@@ -80,6 +87,12 @@
 			digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "fieldName",
"fieldName");
 			digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrName",
"jcrName");
 			digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "proxy", "proxy");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrNodeType",
"jcrNodeType");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrAutoCreated",
"jcrAutoCreated");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrMandatory",
"jcrMandatory");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrOnParentVersion",
"jcrOnParentVersion");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrProtected",
"jcrProtected");
+            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "jcrSameNameSiblings",
"jcrSameNameSiblings");
 			digester.addSetNext("graffito-jcr/class-descriptor/bean-descriptor", "addBeanDescriptor");
 
 			// --------------------------------------------------------------------------------
@@ -93,6 +106,12 @@
 			digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "elementClassName",
"elementClassName");
 			digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "collectionConverter",
"collectionConverterClassName");
 			digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor", "collectionClassName",
"collectionClassName");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrNodeType", "jcrNodeType");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrAutoCreated", "jcrAutoCreated");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrMandatory", "jcrMandatory");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrOnParentVersion", "jcrOnParentVersion");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrProtected", "jcrProtected");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrSameNameSiblings", "jcrSameNameSiblings");            
 			digester.addSetNext("graffito-jcr/class-descriptor/collection-descriptor", "addCollectionDescriptor");
 
 			MappingDescriptor mappingDescriptor = (MappingDescriptor) digester.parse(stream);

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
Fri Nov 25 05:44:27 2005
@@ -27,7 +27,13 @@
      private String fieldName;
      private String jcrName;
      private boolean proxy; 
-    
+     private String jcrNodeType;
+     private boolean jcrAutoCreated;
+     private boolean jcrMandatory;
+     private String jcrOnParentVersion;
+     private boolean jcrProtected;
+     private boolean jcrSameNameSiblings;
+
     /**
      * @return Returns the fieldName.
      */
@@ -71,5 +77,113 @@
     public void setProxy(boolean proxy)
     {
         this.proxy = proxy;
+    }
+
+    /** Getter for property jcrNodeType.
+     * 
+     * @return jcrNodeType
+     */
+    public String getJcrNodeType()
+    {
+        return jcrNodeType;
+    }
+
+    /** Setter for property jcrNodeType.
+     * 
+     * @param value jcrNodeType
+     */
+    public void setJcrNodeType(String value)
+    {
+        this.jcrNodeType = value;
+    }
+
+    /** Getter for property jcrAutoCreated.
+     * 
+     * @return jcrAutoCreated
+     */
+    public boolean isJcrAutoCreated()
+    {
+        return jcrAutoCreated;
+    }
+
+    /** Setter for property jcrAutoCreated.
+     * 
+     * @param value jcrAutoCreated
+     */
+    public void setJcrAutoCreated(boolean value)
+    {
+        this.jcrAutoCreated = value;
+    }
+
+    /** Getter for property jcrMandatory.
+     * 
+     * @return jcrMandatory
+     */
+    public boolean isJcrMandatory()
+    {
+        return jcrMandatory;
+    }
+
+    /** Setter for property jcrMandatory.
+     * 
+     * @param value jcrMandatory
+     */
+    public void setJcrMandatory(boolean value)
+    {
+        this.jcrMandatory = value;
+    }
+
+    /** Getter for property jcrOnParentVersion.
+     * 
+     * @return jcrOnParentVersion
+     */
+    public String getJcrOnParentVersion()
+    {
+        return jcrOnParentVersion;
+    }
+
+    /** Setter for property jcrOnParentVersion.
+     * 
+     * @param value jcrOnParentVersion
+     */
+    public void setJcrOnParentVersion(String value)
+    {
+        this.jcrOnParentVersion = value;
+    }
+
+    /** Getter for property jcrProtected.
+     * 
+     * @return jcrProtected
+     */
+    public boolean isJcrProtected()
+    {
+        return jcrProtected;
+    }
+
+    /** Setter for property jcrProtected.
+     * 
+     * @param value jcrProtected
+     */
+    public void setJcrProtected(boolean value)
+    {
+        this.jcrProtected = value;
+    }
+
+    /** Getter for property jcrSameNameSiblings.
+     * 
+     * @return jcrSameNameSiblings
+     */
+    public boolean isJcrSameNameSiblings()
+    {
+        return jcrSameNameSiblings;
+    }
+
+    /** Setter for property jcrSameNameSiblings.
+     * 
+     * @param value jcrSameNameSiblings
+     */
+    public void setJcrSameNameSiblings(boolean value)
+    {
+        this.jcrSameNameSiblings = value;
     }
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
Fri Nov 25 05:44:27 2005
@@ -30,6 +30,7 @@
 
      private String className;
      private String jcrNodeType;
+     private String jcrSuperTypes;
      private FieldDescriptor idFieldDescriptor;
      private FieldDescriptor pathFieldDescriptor;
      
@@ -207,5 +208,23 @@
     public String getJcrName(String fieldName)
     {
     	return (String) this.fieldNames.get(fieldName);
+    }
+
+    /** Get the JCR node super types.
+     * 
+     * @return jcrSuperTypes
+     */
+    public String getJcrSuperTypes()
+    {
+        return jcrSuperTypes;
+    }
+
+    /** Setter for JCR super types.
+     * 
+     * @param superTypes Comma separated list of JCR node super types
+     */
+    public void setJcrSuperTypes(String superTypes)
+    {
+        this.jcrSuperTypes = superTypes;
     }
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
Fri Nov 25 05:44:27 2005
@@ -30,7 +30,13 @@
      private String elementClassName; 
      private String collectionConverterClassName;
      private String collectionClassName;
-     private boolean proxy; 
+     private boolean proxy;
+     private String jcrNodeType;
+     private boolean jcrAutoCreated;
+     private boolean jcrMandatory;
+     private String jcrOnParentVersion;
+     private boolean jcrProtected;
+     private boolean jcrSameNameSiblings;     
      
      private ClassDescriptor classDescriptor;
     
@@ -150,5 +156,111 @@
         this.classDescriptor = classDescriptor;
     }
     
-    
+    /** Getter for property jcrNodeType.
+     * 
+     * @return jcrNodeType
+     */
+    public String getJcrNodeType()
+    {
+        return jcrNodeType;
+    }
+
+    /** Setter for property jcrNodeType.
+     * 
+     * @param value jcrNodeType
+     */
+    public void setJcrNodeType(String value)
+    {
+        this.jcrNodeType = value;
+    }
+
+    /** Getter for property jcrAutoCreated.
+     * 
+     * @return jcrAutoCreated
+     */
+    public boolean isJcrAutoCreated()
+    {
+        return jcrAutoCreated;
+    }
+
+    /** Setter for property jcrAutoCreated.
+     * 
+     * @param value jcrAutoCreated
+     */
+    public void setJcrAutoCreated(boolean value)
+    {
+        this.jcrAutoCreated = value;
+    }
+
+    /** Getter for property jcrMandatory.
+     * 
+     * @return jcrMandatory
+     */
+    public boolean isJcrMandatory()
+    {
+        return jcrMandatory;
+    }
+
+    /** Setter for property jcrMandatory.
+     * 
+     * @param value jcrMandatory
+     */
+    public void setJcrMandatory(boolean value)
+    {
+        this.jcrMandatory = value;
+    }
+
+    /** Getter for property jcrOnParentVersion.
+     * 
+     * @return jcrOnParentVersion
+     */
+    public String getJcrOnParentVersion()
+    {
+        return jcrOnParentVersion;
+    }
+
+    /** Setter for property jcrOnParentVersion.
+     * 
+     * @param value jcrOnParentVersion
+     */
+    public void setJcrOnParentVersion(String value)
+    {
+        this.jcrOnParentVersion = value;
+    }
+
+    /** Getter for property jcrProtected.
+     * 
+     * @return jcrProtected
+     */
+    public boolean isJcrProtected()
+    {
+        return jcrProtected;
+    }
+
+    /** Setter for property jcrProtected.
+     * 
+     * @param value jcrProtected
+     */
+    public void setJcrProtected(boolean value)
+    {
+        this.jcrProtected = value;
+    }
+
+    /** Getter for property jcrSameNameSiblings.
+     * 
+     * @return jcrSameNameSiblings
+     */
+    public boolean isJcrSameNameSiblings()
+    {
+        return jcrSameNameSiblings;
+    }
+
+    /** Setter for property jcrSameNameSiblings.
+     * 
+     * @param value jcrSameNameSiblings
+     */
+    public void setJcrSameNameSiblings(boolean value)
+    {
+        this.jcrSameNameSiblings = value;
+    }    
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
Fri Nov 25 05:44:27 2005
@@ -25,15 +25,18 @@
  */
 public class FieldDescriptor
 {
-
      private String fieldName;
      private String jcrName;
+     private String jcrType;
+     private boolean jcrAutoCreated;
+     private boolean jcrMandatory;
+     private String jcrOnParentVersion;
+     private boolean jcrProtected;
+     private boolean jcrMultiple;
      private ClassDescriptor classDescriptor;
      private boolean id;
      private boolean path;
      
-    
-    
     /**
      * @return Returns the fieldName.
      */
@@ -41,6 +44,7 @@
     {
         return fieldName;
     }
+
     /**
      * @param fieldName The fieldName to set.
      */
@@ -48,6 +52,7 @@
     {
         this.fieldName = fieldName;
     }
+
     /**
      * @return Returns the jcrName.
      */
@@ -55,6 +60,7 @@
     {
         return jcrName;
     }
+
     /**
      * @param jcrName The jcrName to set.
      */
@@ -97,6 +103,7 @@
     {
         this.id = id;
     }
+
 	/**
 	 * @return Returns true if the field is the object JCR path.
 	 */
@@ -104,6 +111,7 @@
 	{
 		return path;
 	}
+
 	/**
 	 * @param path The path to set.
 	 */
@@ -111,7 +119,112 @@
 	{
 		this.path = path;
 	}
-    
-    
-    
+
+    /** Getter for property jcrType.
+     * 
+     * @return jcrType
+     */
+    public String getJcrType()
+    {
+        return jcrType;
+    }
+
+    /** Setter for property jcrType.
+     * 
+     * @param value jcrType
+     */
+    public void setJcrType(String value)
+    {
+        this.jcrType = value;
+    }
+
+    /** Getter for propery jcrAutoCreated.
+     * 
+     * @return jcrAutoCreated
+     */
+    public boolean isJcrAutoCreated()
+    {
+        return jcrAutoCreated;
+    }
+
+    /** Setter for property jcrAutoCreated.
+     * 
+     * @param value jcrAutoCreated
+     */
+    public void setJcrAutoCreated(boolean value)
+    {
+        this.jcrAutoCreated = value;
+    }
+
+    /** Getter for property jcrMandatory.
+     * 
+     * @return jcrMandatory
+     */
+    public boolean isJcrMandatory()
+    {
+        return jcrMandatory;
+    }
+
+    /** Setter for property jcrMandatory.
+     * 
+     * @param value jcrMandatory
+     */
+    public void setJcrMandatory(boolean value)
+    {
+        this.jcrMandatory = value;
+    }
+
+    /** Getter for property jcrOnParentVersion.
+     * 
+     * @return jcrOnParentVersion
+     */
+    public String getJcrOnParentVersion()
+    {
+        return jcrOnParentVersion;
+    }
+
+    /** Setter for property jcrOnParentVersion.
+     * 
+     * @param value jcrOnParentVersion
+     */
+    public void setJcrOnParentVersion(String value)
+    {
+        this.jcrOnParentVersion = value;
+    }
+
+    /** Getter for property jcrProtected.
+     * 
+     * @return jcrProtected
+     */
+    public boolean isJcrProtected()
+    {
+        return jcrProtected;
+    }
+
+    /** Setter for property jcrProtected.
+     * 
+     * @param value jcrProtected
+     */
+    public void setJcrProtected(boolean value)
+    {
+        this.jcrProtected = value;
+    }
+
+    /** Getter for property jcrMultiple.
+     * 
+     * @return jcrMultiple
+     */
+    public boolean isJcrMultiple()
+    {
+        return jcrMultiple;
+    }
+
+    /** Setter for property jcrMultiple.
+     * 
+     * @param value jcrMultiple
+     */
+    public void setJcrMultiple(boolean value)
+    {
+        this.jcrMultiple = value;
+    }
 }

Modified: incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml (original)
+++ incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml Fri Nov 25 05:44:27
2005
@@ -6,7 +6,7 @@
   
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Folder" jcrNodeType="nt:unstructured">
 		<!-- Field-descriptor is used to map simple attributes to jcr property -->
-		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="name" jcrName="name" />
 		<field-descriptor fieldName="description" jcrName="description" />
 		<field-descriptor fieldName="title" jcrName="title" />
@@ -24,7 +24,7 @@
 	<class-descriptor
 		className="org.apache.portals.graffito.jcr.testmodel.A"
 		jcrNodeType="nt:unstructured">
-		<!-- Field-descriptor is used to map simple attributes to jcr property -->
+		<!-- Field-descriptor is used to map simple attributes to jcr property -->
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="a1" jcrName="a1" />
 		<field-descriptor fieldName="a2" jcrName="a2" />
@@ -33,24 +33,33 @@
 			* The definition of the associated class has to be defined in this mapping file 
 			* proxy="true" => use lazy laoding for this attribute b when retrieving A
 		-->
-		<bean-descriptor fieldName="b" jcrName="b" proxy="false" />
-
+		<bean-descriptor fieldName="b" jcrName="b" proxy="false" jcrNodeType="nt:unstructured"
+        jcrAutoCreated="false" jcrMandatory="false" jcrOnParentVersion="IGNORE"
+        jcrProtected="false" jcrSameNameSiblings="false" />
 
 		<!-- 
 			Use the default collection mapping stategy and the default collection type (can be a Vector,
an ArrayList, a Collection or a List) 
 			The default collection mapping strategy map a collection under an extra JCR node (specify
by the jcrName).
 			
 		-->
-		<collection-descriptor fieldName="collection" jcrName="collection" proxy="false" elementClassName="org.apache.portals.graffito.jcr.testmodel.C"
/>
-		<collection-descriptor fieldName="emptyCollection" jcrName="emptyCollection" proxy="false"
elementClassName="org.apache.portals.graffito.jcr.testmodel.C" />
+		<collection-descriptor fieldName="collection" jcrName="collection" proxy="false"
+        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C"
+        jcrAutoCreated="false" jcrMandatory="false" jcrOnParentVersion="IGNORE"
+        jcrProtected="false" jcrSameNameSiblings="false"/>
+        
+		<collection-descriptor fieldName="emptyCollection" jcrName="emptyCollection" proxy="false"
+        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" />
 		
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured"
jcrSuperTypes="nt:base">
 		<!-- Field-descriptor is used to map simple attributes to jcr property -->
-
-		<field-descriptor fieldName="b1" jcrName="b1" />
-		<field-descriptor fieldName="b2" jcrName="b2" />
+
+		<field-descriptor fieldName="b1" jcrName="b1" jcrType="STRING" jcrAutoCreated="false"
jcrMandatory="false"
+        jcrOnParentVersion="IGNORE" jcrProtected="false" jcrMultiple="false" />
+		
+        <field-descriptor fieldName="b2" jcrName="b2" jcrType="STRING" jcrAutoCreated="true"
jcrMandatory="true"
+        jcrOnParentVersion="COPY" jcrProtected="true" jcrMultiple="true" />
 
 	</class-descriptor>
 
@@ -62,7 +71,7 @@
 
 
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Page" jcrNodeType="graffito:page">
-		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="title" jcrName="graffito:title" />
 		<collection-descriptor fieldName="paragraphs" proxy="false" 
 		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.Paragraph"

@@ -70,13 +79,13 @@
 	</class-descriptor>
 
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Paragraph" jcrNodeType="graffito:paragraph">
-		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="text" jcrName="graffito:text"/>
 	</class-descriptor>
 
 
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Main"
jcrNodeType="nt:unstructured">
-		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="text" jcrName="text" />
 		<collection-descriptor fieldName="elements" proxy="false" 
 		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.Element"


Modified: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java?rev=348952&r1=348951&r2=348952&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
Fri Nov 25 05:44:27 2005
@@ -27,6 +27,7 @@
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
 import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.B;
 
 /**
  * Test Mapper
@@ -95,8 +96,72 @@
             CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor("collection");
             assertNotNull("CollectionDescriptor is null", collectionDescriptor);
             assertTrue("Invalid jcrName for field collection", collectionDescriptor.getJcrName().equals("collection"));
+        }
+        catch (JcrMappingException e)
+        {
+              e.printStackTrace();
+              fail("Impossible to retrieve the converter " + e);
+        }
+    }
+    
+    /**
+     * Test for getConverter
+     *
+     */
+    public void testMapperOptionalProperties()    
+    {
+        try
+        {
+            DigesterMapperImpl mapper = new DigesterMapperImpl("./src/test-config/jcrmapping.xml");
+            assertNotNull("Mapper is null", mapper);
             
+            ClassDescriptor classDescriptor = mapper.getClassDescriptor(B.class);
+            assertNotNull("ClassDescriptor is null", classDescriptor);
+            assertTrue("Invalid classname", classDescriptor.getClassName().equals(B.class.getName()));
+            assertEquals(classDescriptor.getJcrSuperTypes(), "nt:base");
             
+            FieldDescriptor b1Field = classDescriptor.getFieldDescriptor("b1");
+            assertNotNull("FieldDescriptor is null", b1Field);
+            assertEquals(b1Field.getFieldName(), "b1");
+            assertEquals(b1Field.getJcrType(), "STRING");
+            assertFalse(b1Field.isJcrAutoCreated());
+            assertFalse(b1Field.isJcrMandatory());
+            assertFalse(b1Field.isJcrProtected());
+            assertFalse(b1Field.isJcrMultiple());
+            assertEquals(b1Field.getJcrOnParentVersion(), "IGNORE");
+            
+            FieldDescriptor b2Field = classDescriptor.getFieldDescriptor("b2");
+            assertNotNull("FieldDescriptor is null", b2Field);
+            assertEquals(b2Field.getFieldName(), "b2");
+            assertEquals(b2Field.getJcrType(), "STRING");
+            assertTrue(b2Field.isJcrAutoCreated());
+            assertTrue(b2Field.isJcrMandatory());
+            assertTrue(b2Field.isJcrProtected());
+            assertTrue(b2Field.isJcrMultiple());
+            assertEquals(b2Field.getJcrOnParentVersion(), "COPY");
+            
+            ClassDescriptor classDescriptor2 = mapper.getClassDescriptor(A.class);
+            assertNotNull("ClassDescriptor is null", classDescriptor2);
+            assertTrue("Invalid classname", classDescriptor2.getClassName().equals(A.class.getName()));
+            
+            BeanDescriptor beanDescriptor = classDescriptor2.getBeanDescriptor("b");
+            assertNotNull(beanDescriptor);
+            assertEquals(beanDescriptor.getFieldName(), "b");
+            assertEquals(beanDescriptor.getJcrNodeType(), "nt:unstructured");
+            assertFalse(beanDescriptor.isJcrAutoCreated());
+            assertFalse(beanDescriptor.isJcrMandatory());
+            assertFalse(beanDescriptor.isJcrProtected());
+            assertFalse(beanDescriptor.isJcrSameNameSiblings());
+            assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");
+            
+            CollectionDescriptor collectionDescriptor = classDescriptor2.getCollectionDescriptor("collection");
+            assertNotNull(collectionDescriptor);
+            assertEquals(collectionDescriptor.getJcrNodeType(), "graffito:C");
+            assertFalse(collectionDescriptor.isJcrAutoCreated());
+            assertFalse(collectionDescriptor.isJcrMandatory());
+            assertFalse(collectionDescriptor.isJcrProtected());
+            assertFalse(collectionDescriptor.isJcrSameNameSiblings());
+            assertEquals(collectionDescriptor.getJcrOnParentVersion(), "IGNORE");
         }
         catch (JcrMappingException e)
         {
@@ -104,5 +169,4 @@
               fail("Impossible to retrieve the converter " + e);
         }
     }
-
 }



Mime
View raw message