incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r279632 - in /incubator/graffito/trunk/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/impl/ java/org/apache/portals/graffito/jcr/mapper/model/
Date Thu, 08 Sep 2005 21:27:06 GMT
Author: clombart
Date: Thu Sep  8 14:26:58 2005
New Revision: 279632

URL: http://svn.apache.org/viewcvs?rev=279632&view=rev
Log:
Review mapping model

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/DisgesterDescriptorReader.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

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=279632&r1=279631&r2=279632&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 Thu Sep  8 14:26:58
2005
@@ -20,7 +20,7 @@
 <!ELEMENT graffito-jcr (class-descriptor*)>
 <!--
     Class descriptor - Each class descriptor describes the mapping strategy used for one
a java class
-    *className : the className
+    * className : the className
     * jcrNodeType : the primary jcr node type, it can be nt:unstructured
 -->
 <!ELEMENT class-descriptor (field-descriptor*, bean-descriptor*, collection-descriptor*)>
@@ -33,16 +33,18 @@
     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 column is an id column. Id is optional. If the class contains
an id field, some process can run faster
 -->
 
 <!ELEMENT field-descriptor EMPTY>
 <!ATTLIST field-descriptor
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
+	id (true | false) "false"
 >
 
 <!--
-    Bean descriptor - A bean descriptor maps one object attribute (primitive types, String,
Long, ...)  into a JCR node.
+    Bean descriptor - A bean descriptor maps one "complex" object attribute into a JCR node.
     * 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.
@@ -56,10 +58,16 @@
 >
 
 <!--
-    Collection descriptor - A collection descriptor maps one object attribute based on a
collection (or a map)  into a series of JCR nodes.
-    * fieldName : the field/attribute name
+    Collection descriptor - A collection descriptor maps one object attribute based on a
collection (or a map) into a series of JCR nodes.
+    * fieldName : the field/attribute name (matching to the collection attribute)
     * jcrName : the jcr property 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 retrieve. it will be loaded when the get method is called.
+    * elementClassName : contains a fully qualified class name.	This class is the Object
type of the persistent collection elements.
+    * collectionClassName : contains a fully qualified class name. This class must be the
Java type of the Collection attribute. 	
+                            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)                             
     
 -->
 
@@ -68,5 +76,7 @@
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
 	proxy (true | false) "false"
-	clasName CDATA #REQUIRED
+	elementClassName CDATA #REQUIRED
+	collectionClassName CDATA #IMPLIED
+	collectionConverter CDATA #IMPLIED	
 >

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DisgesterDescriptorReader.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DisgesterDescriptorReader.java?rev=279632&r1=279631&r2=279632&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DisgesterDescriptorReader.java
(original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DisgesterDescriptorReader.java
Thu Sep  8 14:26:58 2005
@@ -47,7 +47,7 @@
         try
         {
             Digester digester = new Digester();
-            digester.setValidating(false); // TODO : validate - add DTD
+            digester.setValidating(true);
 
             digester.addObjectCreate("graffito-jcr", MappingDescriptor.class);
 
@@ -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.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");
 
             // --------------------------------------------------------------------------------
@@ -67,6 +68,7 @@
             digester.addObjectCreate("graffito-jcr/class-descriptor/field-descriptor", FieldDescriptor.class);
             digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "fieldName",
"fieldName");
             digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "jcrName",
"jcrName");
+            digester.addSetProperties("graffito-jcr/class-descriptor/field-descriptor", "id",
"id");
             digester.addSetNext("graffito-jcr/class-descriptor/field-descriptor", "addFieldDescriptor");
             
             // --------------------------------------------------------------------------------
@@ -86,10 +88,10 @@
             digester.addObjectCreate("graffito-jcr/class-descriptor/collection-descriptor",
CollectionDescriptor.class);
             digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"fieldName", "fieldName");
             digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"jcrName", "jcrName");
-            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"proxy", "proxy");
-            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"fieldId", "fieldId");
-            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"className", "className");
+            digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor",
"proxy", "proxy");            
+            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.addSetNext("graffito-jcr/class-descriptor/collection-descriptor", "addCollectionDescriptor");
             
             
@@ -98,7 +100,7 @@
             return mappingDescriptor;
         }
         catch (Exception e)
-        {
+        {            
             throw new JcrMappingException("Impossible to read the xml mapping file", e);
         }
     }

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=279632&r1=279631&r2=279632&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
Thu Sep  8 14:26:58 2005
@@ -30,6 +30,7 @@
 
      private String className;
      private String jcrNodeType;
+     private FieldDescriptor idFieldDescriptor;
      
      HashMap fieldDescriptors = new HashMap();
      HashMap beanDescriptors = new HashMap();
@@ -74,6 +75,11 @@
     public void addFieldDescriptor(FieldDescriptor fieldDescriptor )
     {
         fieldDescriptor.setClassDescriptor(this);
+        if (fieldDescriptor.isId())
+        {
+           this.idFieldDescriptor = fieldDescriptor;
+        }
+        
         fieldDescriptors.put(fieldDescriptor.getFieldName(), fieldDescriptor);
     }
     
@@ -136,6 +142,7 @@
                   
     public void addCollectionDescriptor(CollectionDescriptor collectionDescriptor )
     {
+        collectionDescriptor.setClassDescriptor(this);
         collectionDescriptors.put(collectionDescriptor.getFieldName(), collectionDescriptor);
     }
 
@@ -159,4 +166,13 @@
         return collectionDescriptors.values();   
     }
     
+    public FieldDescriptor getIdFieldDescriptor()
+    {
+        return idFieldDescriptor;
+    }
+    
+    public boolean hasIdField()
+    {
+        return this.idFieldDescriptor != null;
+    }
 }

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=279632&r1=279631&r2=279632&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
Thu Sep  8 14:26:58 2005
@@ -27,11 +27,13 @@
 {
 
      private String fieldName;
-     private String jcrName;
-     private String fieldId;
-     private String className; 
+     private String jcrName;     
+     private String elementClassName; 
      private String collectionConverterClassName;
+     private String collectionClassName;
      private boolean proxy; 
+     
+     private ClassDescriptor classDescriptor;
     
     /**
      * @return Returns the fieldName.
@@ -64,33 +66,20 @@
     
     
     /**
-     * @return Returns the className.
+     * @return Returns the elementClassName.
      */
-    public String getClassName()
+    public String getElementClassName()
     {
-        return className;
+        return elementClassName;
     }
     /**
-     * @param className The className to set.
+     * @param elementClassName The elementClassName to set.
      */
-    public void setClassName(String className)
+    public void setElementClassName(String className)
     {
-        this.className = className;
-    }
-    /**
-     * @return Returns the fieldId.
-     */
-    public String getFieldId()
-    {
-        return fieldId;
-    }
-    /**
-     * @param fieldId The fieldId to set.
-     */
-    public void setFieldId(String fieldId)
-    {
-        this.fieldId = fieldId;
+        this.elementClassName = className;
     }
+
     /**
      * @return Returns the proxy.
      */
@@ -114,6 +103,23 @@
     public void setCollectionConverterClassName(String collectionConverterClassName)
     {
         this.collectionConverterClassName = collectionConverterClassName;
+    }
+    
+    public String getCollectionClassName()
+    {
+        return collectionClassName;
+    }
+    public void setCollectionClassName(String managableCollectionClassName)
+    {
+        this.collectionClassName = managableCollectionClassName;
+    }
+    public ClassDescriptor getClassDescriptor()
+    {
+        return classDescriptor;
+    }
+    public void setClassDescriptor(ClassDescriptor classDescriptor)
+    {
+        this.classDescriptor = classDescriptor;
     }
     
     

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=279632&r1=279631&r2=279632&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
Thu Sep  8 14:26:58 2005
@@ -29,6 +29,7 @@
      private String fieldName;
      private String jcrName;
      private ClassDescriptor classDescriptor;
+     private boolean id;
     
     
     /**
@@ -68,6 +69,14 @@
     public void setClassDescriptor(ClassDescriptor classDescriptor)
     {
         this.classDescriptor = classDescriptor;
+    }
+    public boolean isId()
+    {
+        return id;
+    }
+    public void setId(boolean id)
+    {
+        this.id = id;
     }
     
     



Mime
View raw message