incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r407358 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/ java/org/apache/portals/graffito/jcr/mapper/impl/ java/org/apache/portals/graffito/jcr/mapper/model/
Date Wed, 17 May 2006 19:51:31 GMT
Author: clombart
Date: Wed May 17 12:51:29 2006
New Revision: 407358

URL: http://svn.apache.org/viewvc?rev=407358&view=rev
Log:
* Add ParentFolderBeanConverter
* Review inheritance, interface support, ...
* Add new method on the persistence manager : getObject (without class ref). 

Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd?rev=407358&r1=407357&r2=407358&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd Wed May 17 12:51:29
2006
@@ -44,6 +44,10 @@
 	discriminator (true|false) "true"
 >
 
+<!--
+   Implement descriptor - This descriptor matches to one java  interface implemented by the
class descriptor
+   interfaceName : the full interface name
+-->
 <!ELEMENT implement-descriptor EMPTY>
 
 <!ATTLIST implement-descriptor

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java?rev=407358&r1=407357&r2=407358&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/Mapper.java
Wed May 17 12:51:29 2006
@@ -30,5 +30,12 @@
      * @param clazz The java bean class
      * @return The mapping class found for the desired java bean class 
      */
-    public abstract ClassDescriptor getClassDescriptor(Class clazz);
+    public abstract ClassDescriptor getClassDescriptorByClass(Class clazz);
+    
+    /**
+     * Get the mapping defition to be used for a specific JCR node type
+     * @param jcrNodeType the jcr node type
+     * @return The mapping class found for the desired java bean class 
+     */
+    public abstract ClassDescriptor getClassDescriptorByNodeType(String jcrNodeType);   

 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java?rev=407358&r1=407357&r2=407358&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
Wed May 17 12:51:29 2006
@@ -134,7 +134,9 @@
             for (int i = 1; i < this.mappingFiles.length; i++) {
                 log.info("Read the xml mapping file : " +  this.mappingFiles[i]);
                 MappingDescriptor anotherMappingDescriptor = this.descriptorReader.loadClassDescriptors(this.mappingFiles[i]);
-                this.mappingDescriptor.getClassDescriptors().putAll(anotherMappingDescriptor.getClassDescriptors());
+                this.mappingDescriptor.getClassDescriptorsByClassName().putAll(anotherMappingDescriptor.getClassDescriptorsByClassName());
+                this.mappingDescriptor.getClassDescriptorsByNodeType().putAll(anotherMappingDescriptor.getClassDescriptorsByNodeType());
+                
             }
         }
         else if (this.mappingStreams != null && this.mappingStreams.length > 0)
{
@@ -145,7 +147,8 @@
             for (int i = 1; i < this.mappingStreams.length; i++) {
                 log.info("Read the stream mapping file : " +  this.mappingStreams[i].toString());
                 MappingDescriptor anotherMappingDescriptor = this.descriptorReader.loadClassDescriptors(this.mappingStreams[i]);
-                this.mappingDescriptor.getClassDescriptors().putAll(anotherMappingDescriptor.getClassDescriptors());
+                this.mappingDescriptor.getClassDescriptorsByClassName().putAll(anotherMappingDescriptor.getClassDescriptorsByClassName());
+                this.mappingDescriptor.getClassDescriptorsByNodeType().putAll(anotherMappingDescriptor.getClassDescriptorsByNodeType());
             }
         }
         if (null != this.mappingDescriptor) {
@@ -166,13 +169,13 @@
     }
 
     private List solveReferences(List errors) {
-        for(Iterator it = this.mappingDescriptor.getClassDescriptors().entrySet().iterator();
it.hasNext(); ) {
+        for(Iterator it = this.mappingDescriptor.getClassDescriptorsByClassName().entrySet().iterator();
it.hasNext(); ) {
             Map.Entry entry = (Map.Entry) it.next();
             ClassDescriptor cd = (ClassDescriptor) entry.getValue();
 
             if (null != cd.getExtend() && !"".equals(cd.getExtend())) 
             {
-                ClassDescriptor superClassDescriptor = this.mappingDescriptor.getClassDescriptor(cd.getExtend());
+                ClassDescriptor superClassDescriptor = this.mappingDescriptor.getClassDescriptorByName(cd.getExtend());
 
                 if (null == superClassDescriptor) 
                 {
@@ -198,7 +201,7 @@
             	      for (Iterator iterator = interfaces.iterator(); iterator.hasNext();)
             	      {
             	    	          String interfaceName= (String) iterator.next();
-                          ClassDescriptor interfaceClassDescriptor = this.mappingDescriptor.getClassDescriptor(interfaceName);
+                          ClassDescriptor interfaceClassDescriptor = this.mappingDescriptor.getClassDescriptorByName(interfaceName);
 
                           if (null == interfaceClassDescriptor) 
                           {
@@ -259,9 +262,17 @@
     
     /**
     *
-    * @see org.apache.portals.graffito.jcr.mapper.Mapper#getClassDescriptor(java.lang.Class)
+    * @see org.apache.portals.graffito.jcr.mapper.Mapper#getClassDescriptorByClass(java.lang.Class)
     */
-   public ClassDescriptor getClassDescriptor(Class clazz) {
-       return mappingDescriptor.getClassDescriptor(clazz.getName());
-   }      
+   public ClassDescriptor getClassDescriptorByClass(Class clazz) {
+       return mappingDescriptor.getClassDescriptorByName(clazz.getName());
+   }
+   
+   /**
+   * @see org.apache.portals.graffito.jcr.mapper.Mapper#getClassDescriptorByNodeType(String)
+   */
+  public ClassDescriptor getClassDescriptorByNodeType(String jcrNodeType) {
+      return mappingDescriptor.getClassDescriptorByNodeType(jcrNodeType);
+  }
+   
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java?rev=407358&r1=407357&r2=407358&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
Wed May 17 12:51:29 2006
@@ -122,13 +122,6 @@
         this.converter = converterClass;
     }
 
-    public BeanConverter getBeanConverter() {
-        if(null == this.beanConverter && null != this.converter) {
-            this.beanConverter = (BeanConverter) ReflectionUtils.newInstance(this.converter);
-        }
-        
-        return this.beanConverter;
-    }
     
     /** Getter for property jcrNodeType.
      *

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java?rev=407358&r1=407357&r2=407358&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
Wed May 17 12:51:29 2006
@@ -23,6 +23,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl;
+import org.apache.portals.graffito.jcr.persistence.PersistenceConstant;
 
 /**
  * This class match to the complete xml mapping files.
@@ -34,7 +35,8 @@
 public class MappingDescriptor {
 	
 	private static final Log log = LogFactory.getLog(MappingDescriptor.class);
-    private HashMap classDescriptors = new HashMap();
+    private HashMap classDescriptorsByClassName = new HashMap();
+    private HashMap classDescriptorsByNodeType = new HashMap();
 
     private Mapper mapper;
 
@@ -60,7 +62,13 @@
             }
         }
 
-        classDescriptors.put(classDescriptor.getClassName(), classDescriptor);
+        classDescriptorsByClassName.put(classDescriptor.getClassName(), classDescriptor);
+        
+        if (null != classDescriptor.getJcrNodeType() && !  "".equals(classDescriptor.getJcrNodeType())
&& 
+        		 ! PersistenceConstant.NT_UNSTRUCTURED.equals(classDescriptor.getJcrNodeType()))
+        	 {
+             classDescriptorsByNodeType.put(classDescriptor.getJcrNodeType(), classDescriptor);

+        	 }
         classDescriptor.setMappingDescriptor(this);
     }
 
@@ -69,18 +77,29 @@
      * @param className the class name
      * @return the class descriptor found or null
      */
-    public ClassDescriptor getClassDescriptor(String className) {
-        return (ClassDescriptor) classDescriptors.get(className);
+    public ClassDescriptor getClassDescriptorByName(String className) {
+        return (ClassDescriptor) classDescriptorsByClassName.get(className);
+    }
+    
+    public ClassDescriptor getClassDescriptorByNodeType(String nodeType)
+    {
+        return (ClassDescriptor) classDescriptorsByNodeType.get(nodeType);	
     }
 
     /**
-     * Get all class descriptors
+     * Get all class descriptors by class name
      * @return all class descriptors found
      */
-    public Map getClassDescriptors() {
-        return classDescriptors;
+    public Map getClassDescriptorsByClassName() {
+        return classDescriptorsByClassName;
+    }
+    /**
+     * Get all class descriptors by class name
+     * @return all class descriptors found
+     */
+    public Map getClassDescriptorsByNodeType() {
+        return classDescriptorsByNodeType;
     }
-
     public Mapper getMapper() {
         return this.mapper;
     }



Mime
View raw message