incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r406118 [1/2] - in /incubator/graffito/trunk/jcr/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/impl/ java/org/apache/portals/graffito/jcr/mapper/model/ java/org/apache/portals/graffito/jcr/persistence/ java/org/apache/po...
Date Sat, 13 May 2006 15:08:06 GMT
Author: clombart
Date: Sat May 13 08:08:04 2006
New Revision: 406118

URL: http://svn.apache.org/viewcvs?rev=406118&view=rev
Log:
Add several modifications : 

* jcrNodeType is not mandatory.If not present the default value is "nt:unstructured".
* discriminator field descriptor was removed. Only the flag discriminator is defined on the class descriptor. 
	If this flag is true, a mixin node type "graffito:discriminator" is added to the node. 
	This type contains one property to store the java classname (graffito:classname).
    With this implementation, the discriminator field is not necessary. So, the persistence mechanism is still transparent for the jaba beans.

* Interface support : like the inheritance support, there are 2 differents strategies : node type per concrete class or per complete hierarchy. The hierarchy strategy requires a discriminator node type.

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ImplementDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceConstant.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInheritanceConcreteClassTest.java
      - copied, changed from r393615, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerNtConcreteClassTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInheritanceHierarchyTest.java
      - copied, changed from r388968, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerNtHierarchyTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceHierarchyTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/CmsObjectImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/ContentImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/DocumentImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/DocumentStream.java
      - copied, changed from r390238, incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/DocumentStream.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/impl/FolderImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/AnotherInterface.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/Content.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/Document.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/Folder.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/Interface.java
Removed:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerNtConcreteClassTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerNtHierarchyTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/CmsObject.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/Content.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/Document.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/DocumentStream.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/Folder.java
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/impl/DigesterDescriptorReader.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/ClassDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-atomic.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-proxy.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/AnotherDescendant.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/inheritance/Descendant.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd?rev=406118&r1=406117&r2=406118&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 Sat May 13 08:08:04 2006
@@ -28,21 +28,26 @@
     * jcrSuperTypes : the jcr super types, optional
     * jcrMixinTypes: the jcr mixin types (comma separated list) (optional)
     * extends: name of super class (optional)
-    * extends-strategy:
-    * polymorphism: specify the behavior of this class in queries; default implicit
     * abstract: true if this class is abstract and it is used in hierarchy mappings
-    * discriminator-value: use only when extends-strategy="concreteclass" and abstract="false"
+    * discriminator true if the mapped node  requires  an graffito:discriminator node type. This type contains a classname property.
 -->
-<!ELEMENT class-descriptor (field-descriptor*, bean-descriptor*, collection-descriptor*)>
+<!ELEMENT class-descriptor (implement-descriptor*, field-descriptor*, bean-descriptor*, collection-descriptor*)>
 
 <!ATTLIST class-descriptor
 	className CDATA #REQUIRED
 	jcrNodeType CDATA #IMPLIED
     jcrSuperTypes CDATA #IMPLIED
     jcrMixinTypes CDATA #IMPLIED
-    extends CDATA #IMPLIED
+    extend CDATA #IMPLIED
 	abstract (true|false) "false"
-	discriminatorValue CDATA #IMPLIED
+	interface (true|false) "false"
+	discriminator (true|false) "true"
+>
+
+<!ELEMENT implement-descriptor EMPTY>
+
+<!ATTLIST implement-descriptor
+	interfaceName CDATA #REQUIRED
 >
 
 <!--
@@ -67,7 +72,6 @@
 	jcrName CDATA #IMPLIED 
 	id (true | false) "false"
 	path (true | false) "false"
-	discriminator (true | false) "false"
     jcrType (String | Date | Long | Double | Boolean | Binary) #IMPLIED
     jcrAutoCreated (true | false) "false"
     jcrMandatory (true | false) "false"

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterDescriptorReader.java Sat May 13 08:08:04 2006
@@ -26,7 +26,9 @@
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.ImplementDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.MappingDescriptor;
+import org.xml.sax.SAXParseException;
 
 /**
  * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
@@ -68,80 +70,47 @@
                 digester.register("-//The Apache Software Foundation//DTD Repository//EN",
                                   this.dtdResolver.toString());
             }
-            
-			digester.addObjectCreate("graffito-jcr", MappingDescriptor.class);
-            digester.addSetProperties("graffito-jcr", "package", "package");
+			
+	        MappingDescriptor mappingDescriptor = new MappingDescriptor();
+	        digester.push(mappingDescriptor);
+			
+	       // TODO : activater the following line wich cause some bugs when loading the xml stream  
+           //digester.addSetProperties("graffito-jcr", package, pa);
 
 			// --------------------------------------------------------------------------------
 			// Rules used for the class-descriptor element
-			// --------------------------------------------------------------------------------
-
+			// --------------------------------------------------------------------------------	                        
 			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.addSetProperties("graffito-jcr/class-descriptor", "jcrMixinTypes", "jcrMixinTypes");
-            digester.addSetProperties("graffito-jcr/class-descriptor", "extends", "superClass");
-            digester.addSetProperties("graffito-jcr/class-descriptor", "abstract", "abstract");
-			digester.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");
+			digester.addSetProperties("graffito-jcr/class-descriptor");
+			digester.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");		
 
 			// --------------------------------------------------------------------------------
 			// Rules used for the field-descriptor element
 			// --------------------------------------------------------------------------------
-
+			digester.addObjectCreate("graffito-jcr/class-descriptor/implement-descriptor", ImplementDescriptor.class);
+			digester.addSetProperties("graffito-jcr/class-descriptor/implement-descriptor");
+            digester.addSetNext("graffito-jcr/class-descriptor/implement-descriptor", "addImplementDescriptor");
+			
+			// --------------------------------------------------------------------------------
+			// Rules used for the field-descriptor element
+			// --------------------------------------------------------------------------------
 			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", "fieldType", "fieldType");
-			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", "discriminator", "discriminator");
-            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.addSetProperties("graffito-jcr/class-descriptor/field-descriptor");
             digester.addSetNext("graffito-jcr/class-descriptor/field-descriptor", "addFieldDescriptor");
 
 			// --------------------------------------------------------------------------------
 			// Rules used for the bean-descriptor element
 			// --------------------------------------------------------------------------------
-
 			digester.addObjectCreate("graffito-jcr/class-descriptor/bean-descriptor", BeanDescriptor.class);
-			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", "inline", "inline");
-            digester.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor", "converter", "converter");
-            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.addSetProperties("graffito-jcr/class-descriptor/bean-descriptor");
             digester.addSetNext("graffito-jcr/class-descriptor/bean-descriptor", "addBeanDescriptor");
 
 			// --------------------------------------------------------------------------------
 			// Rules used for the collection-descriptor element
 			// --------------------------------------------------------------------------------
-
 			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", "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");
+			digester.addSetProperties("graffito-jcr/class-descriptor/collection-descriptor");
+            digester.addSetNext("graffito-jcr/class-descriptor/collection-descriptor", "addCollectionDescriptor");			
 
             return (MappingDescriptor) digester.parse(stream);
 		}
@@ -164,9 +133,10 @@
 		{
 			return loadClassDescriptors(new FileInputStream(xmlFile));
 		}
+		
 		catch (FileNotFoundException e)
 		{
-			throw new InitMapperException(e);
+			throw new InitMapperException("Mapping file not found : " + xmlFile,e);
 		}
 	}
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/impl/DigesterMapperImpl.java?rev=406118&r1=406117&r2=406118&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 Sat May 13 08:08:04 2006
@@ -170,23 +170,53 @@
             Map.Entry entry = (Map.Entry) it.next();
             ClassDescriptor cd = (ClassDescriptor) entry.getValue();
 
-            if (null != cd.getSuperClass() && !"".equals(cd.getSuperClass())) {
-                ClassDescriptor superClassDescriptor = this.mappingDescriptor.getClassDescriptor(cd.getSuperClass());
+            if (null != cd.getExtend() && !"".equals(cd.getExtend())) 
+            {
+                ClassDescriptor superClassDescriptor = this.mappingDescriptor.getClassDescriptor(cd.getExtend());
 
-                if (null == superClassDescriptor) {
+                if (null == superClassDescriptor) 
+                {
                     errors.add("Cannot find mapping for class "
-                            + cd.getSuperClass()
+                            + cd.getExtend()
                             + " referenced as extends from "
                             + cd.getClassName());
                 }
-                else {
-            	    log.debug("Class " +cd.getClassName() +  " extends " + cd.getSuperClass());
+                else 
+                {
+            	       log.debug("Class " +cd.getClassName() +  " extends " + cd.getExtend());
                     cd.setSuperClassDescriptor(superClassDescriptor);
                 }
             }
-            else {
-                rootClassDescriptors.add(cd);	
+            else
+            {
+                   rootClassDescriptors.add(cd);
             }
+            
+            Collection interfaces = cd.getImplements();
+            if (interfaces.size() > 0) 
+            {	
+            	      for (Iterator iterator = interfaces.iterator(); iterator.hasNext();)
+            	      {
+            	    	          String interfaceName= (String) iterator.next();
+                          ClassDescriptor interfaceClassDescriptor = this.mappingDescriptor.getClassDescriptor(interfaceName);
+
+                          if (null == interfaceClassDescriptor) 
+                          {
+                              errors.add("Cannot find mapping for interface "
+                                      + interfaceName
+                                      + " referenced as implements from "
+                                      + cd.getClassName());
+                          }
+                          else 
+                          {
+                      	       log.debug("Class " +cd.getClassName() +  " implements " + interfaceName);
+                              //cd.setSuperClassDescriptor(interfaceClassDescriptor);
+                      	      interfaceClassDescriptor.addDescendantClassDescriptor(cd); 
+                          }
+            	    	      
+            	      }
+            }
+            
         }
 
         return errors;

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java Sat May 13 08:08:04 2006
@@ -20,6 +20,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -51,7 +52,6 @@
     private String[] jcrMixinTypes = new String[0];
     private FieldDescriptor idFieldDescriptor;
     private FieldDescriptor pathFieldDescriptor;
-    private FieldDescriptor discriminatorFieldDescriptor;
 
     private Map fieldDescriptors = new HashMap();    
     private Map beanDescriptors = new HashMap();        
@@ -60,19 +60,45 @@
     private Map fieldNames = new HashMap();
 
     private String superClassName;
-    private String extendsStrategy;
-    private boolean abstractClass = false;
+    private String extendsStrategy;    
+    private boolean isAbstract = false;    
     private boolean hasDescendant = false;
+    private boolean hasDiscriminator = true; 
    
+       
+    private boolean isInterface=false;
+    private List interfaces = new ArrayList();
     
     public void setAbstract(boolean flag) {
-        this.abstractClass = flag;
+        this.isAbstract = flag;
     }
 
     public boolean isAbstract() {
-        return this.abstractClass;
+        return this.isAbstract;
     }
 
+    public void setInterface(boolean flag) {
+    	   this.isInterface = flag;
+    }
+       
+    public boolean isInterface() {
+    	    return isInterface;
+    }
+    
+    public boolean hasInterfaces()
+    {
+    	   return this.interfaces.size() > 0;
+    }
+
+    public void setDiscriminator(boolean flag)
+    {
+        this.hasDiscriminator = flag;	
+    }
+    
+    public boolean hasDiscriminator() {        
+ 	   return this.hasDiscriminator;
+ }    
+    
     public boolean usesNodeTypePerHierarchyStrategy() {
         return NODETYPE_PER_HIERARCHY.equals(this.extendsStrategy);
     }
@@ -120,14 +146,16 @@
         if (fieldDescriptor.isPath()) {
             this.pathFieldDescriptor = fieldDescriptor;
         }
-        if (fieldDescriptor.isDiscriminator()) {
-            this.discriminatorFieldDescriptor = fieldDescriptor;
-        }
 
         fieldDescriptors.put(fieldDescriptor.getFieldName(), fieldDescriptor);
         fieldNames.put(fieldDescriptor.getFieldName(), fieldDescriptor.getJcrName());
     }
 
+    public void addImplementDescriptor(ImplementDescriptor implementDescriptor)
+    {
+        interfaces.add(implementDescriptor.getInterfaceName());	
+    }
+    
     /**
      * Get the FieldDescriptor to used for a specific java bean attribute
      * @param fieldName The java bean attribute name
@@ -224,28 +252,13 @@
         return null;
     }
 
-    public FieldDescriptor getDiscriminatorFieldDescriptor() {       
-        if (null != this.discriminatorFieldDescriptor) {
-            return this.discriminatorFieldDescriptor;
-        }
-
-        if (null != this.superClassDescriptor) {
-            return this.superClassDescriptor.getDiscriminatorFieldDescriptor();
-        }
-
-        return null;        
-    }
-
-    public boolean hasDiscriminatorField() {
-        return this.getDiscriminatorFieldDescriptor() != null;
-    }
 
     /**
      * Check if this class has an ID
      * @return true if the class has an ID
      */
-    public boolean hasIdField() {
-        return this.idFieldDescriptor != null;
+    public boolean hasIdField() {        
+        return (this.idFieldDescriptor != null && ! this.idFieldDescriptor.equals(""));
     }
 
     /**
@@ -254,7 +267,31 @@
      * @return the JCR name found
      */
     public String getJcrName(String fieldName) {
-        return (String) this.fieldNames.get(fieldName);
+        String jcrName =  (String) this.fieldNames.get(fieldName);
+        if (this.isInterface && jcrName == null)
+        {
+            return this.getJcrNameFromDescendants(this, fieldName);          
+        }
+        
+        return jcrName;
+    }
+    
+    private String getJcrNameFromDescendants(ClassDescriptor classDescriptor, String fieldName )
+    {
+        Iterator  descendants = classDescriptor.getDescendantClassDescriptors().iterator();
+        while (descendants.hasNext())
+        {
+        	    ClassDescriptor descendant = (ClassDescriptor) descendants.next();
+        	    String jcrName =  (String) descendant.fieldNames.get(fieldName);
+        	    if(jcrName != null)
+        	    {
+        	    	   return jcrName;
+        	    }
+        	    return this.getJcrNameFromDescendants(descendant, fieldName);
+        }
+        return null;
+
+    	
     }
     
     public Map getFieldNames() {
@@ -319,7 +356,7 @@
         validateBeanFields();
         lookupSuperDescriptor();
         lookupInheritanceSettings();
-        validateInheritanceSettings();
+//        validateInheritanceSettings();
     }
 
 	private void validateClassName() {
@@ -346,16 +383,21 @@
 	
 	private void lookupSuperDescriptor() {
         if (null != superClassDescriptor) {
-            this.fieldDescriptors = mergeFields(this.fieldDescriptors, this.superClassDescriptor.getFieldDescriptors());
-            this.beanDescriptors = mergeBeans(this.beanDescriptors, this.superClassDescriptor.getBeanDescriptors());
-            this.collectionDescriptors = mergeCollections(this.collectionDescriptors, this.superClassDescriptor.getCollectionDescriptors());
-            this.fieldNames.putAll(this.superClassDescriptor.getFieldNames());
+            this.hasDiscriminator = superClassDescriptor.hasDiscriminator();
+            if (! this.isInterface)
+            {
+                this.fieldDescriptors = mergeFields(this.fieldDescriptors, this.superClassDescriptor.getFieldDescriptors());
+                this.beanDescriptors = mergeBeans(this.beanDescriptors, this.superClassDescriptor.getBeanDescriptors());
+                this.collectionDescriptors = mergeCollections(this.collectionDescriptors, this.superClassDescriptor.getCollectionDescriptors());            
+                this.fieldNames.putAll(this.superClassDescriptor.getFieldNames());
+            }
+        
         }
     }
 
     private void lookupInheritanceSettings() {
-        if ((null != this.superClassDescriptor) || (this.hasDescendants() )) {
-            if (this.hasDiscriminatorField()) {
+        if ((null != this.superClassDescriptor) || (this.hasDescendants()) || this.hasInterfaces()) {
+            if (this.hasDiscriminator()) {
                 this.extendsStrategy = NODETYPE_PER_HIERARCHY;
             }
             else {
@@ -364,36 +406,19 @@
         }
     }
 	
-    private void validateInheritanceSettings() {
-        if (NODETYPE_PER_CONCRETECLASS.equals(this.extendsStrategy)) {
-            this.discriminatorFieldDescriptor = getDiscriminatorFieldDescriptor();
-
-            if (null != this.discriminatorFieldDescriptor) {
-                throw new JcrMappingException("Discriminator specify for  the class : " + className + " but it is a node type per concrete class hierarchy");
-            }
-        }
-        else if (NODETYPE_PER_HIERARCHY.equals(this.extendsStrategy)) {
-            this.discriminatorFieldDescriptor = getDiscriminatorFieldDescriptor();
-
-            if (null == this.discriminatorFieldDescriptor) {
-                throw new JcrMappingException("No discriminator specify for the class : " + className);
-            }
-        }
-    }
-
 
     /**
      * @return return the super class name if defined in mapping, or
      * <tt>null</tt> if not set
      */
-    public String getSuperClass() {
+    public String getExtend() {
         return this.superClassName;
     }
 
     /**
      * @param className
      */
-    public void setSuperClass(String className) {
+    public void setExtend(String className) {
         this.superClassName = className;
     }
 
@@ -452,7 +477,13 @@
         this.superClassDescriptor= superClassDescriptor;
         superClassDescriptor.addDescendantClassDescriptor(this);
     }
+   
 
+    public Collection getImplements()
+    {
+    	    return interfaces;
+    }
+    
     private Map mergeFields(Map existing, Collection superSource) {
         if (null == superSource) {
             return existing;
@@ -464,9 +495,9 @@
             if (!merged.containsKey(fieldDescriptor.getFieldName())) {
                 merged.put(fieldDescriptor.getFieldName(), fieldDescriptor);
             }
-            else {
-                log.warn("Field name conflict in " + this.className + " - field : " +fieldDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getSuperClass());
-            }
+//            else {
+//                log.warn("Field name conflict in " + this.className + " - field : " +fieldDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getExtend());
+//            }
         }
 
         return merged;
@@ -484,9 +515,9 @@
             if (!merged.containsKey(beanDescriptor.getFieldName())) {
                 merged.put(beanDescriptor.getFieldName(), beanDescriptor);
             }
-            else {
-                log.warn("Bean name conflict in " + this.className + " - field : " +beanDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getSuperClass());
-            }
+//            else {
+//                log.warn("Bean name conflict in " + this.className + " - field : " +beanDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getExtend());
+//            }
         }
 
         return merged;
@@ -503,13 +534,33 @@
             if (!merged.containsKey(collectionDescriptor.getFieldName())) {
                 merged.put(collectionDescriptor.getFieldName(), collectionDescriptor);
             }
-            else {
-                log.warn("Collection name conflict in " + this.className + " - field : " +collectionDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getSuperClass());
-            }
+//            else {
+//                log.warn("Collection name conflict in " + this.className + " - field : " +collectionDescriptor.getFieldName() + " -  this  field name is also defined  in the ancestor class : " + this.getExtend());
+//            }
         }
 
         return merged;
     }    
+    
+    
+//    private List mergeInterfaces(List  existing, Collection superSource) {
+//        if (null == superSource) {
+//            return existing;
+//        }
+//
+//        ArrayList merged = new ArrayList(existing);
+//        for (Iterator it = superSource.iterator(); it.hasNext();)
+//        {
+//             String interfaceName = (String) it.next();
+//             if (! merged.contains(interfaceName))
+//             {
+//            	     merged.add(interfaceName);
+//             }            	 
+//        }
+//        
+//        return merged;
+//    }    
+    
     
 	public String toString() {
 		return "Class Descriptor : " +  this.getClassName();

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java Sat May 13 08:08:04 2006
@@ -105,7 +105,7 @@
      * 
      * @return The collection converter class name 
      */
-    public String getCollectionConverterClassName()
+    public String getCollectionConverter()
     {
         return collectionConverterClassName;
     }
@@ -114,7 +114,7 @@
      * Set the collection converter class name
      * @param collectionConverterClassName The converter to set
      */
-    public void setCollectionConverterClassName(String collectionConverterClassName)
+    public void setCollectionConverter(String collectionConverterClassName)
     {
         this.collectionConverterClassName = collectionConverterClassName;
     }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/FieldDescriptor.java Sat May 13 08:08:04 2006
@@ -38,7 +38,7 @@
     private ClassDescriptor classDescriptor;
     private boolean id;
     private boolean path;
-    private boolean discriminator;
+   
 
     /**
      * @return Returns the fieldName.
@@ -241,14 +241,6 @@
      */
     public void setJcrMultiple(boolean value) {
         this.jcrMultiple = value;
-    }
-
-    public void setDiscriminator(boolean value) {
-        this.discriminator = value;
-    }
-
-    public boolean isDiscriminator() {
-        return this.discriminator;
     }
 
     /**

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ImplementDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ImplementDescriptor.java?rev=406118&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ImplementDescriptor.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ImplementDescriptor.java Sat May 13 08:08:04 2006
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.portals.graffito.jcr.mapper.model;
+
+
+/**
+ *
+ *
+ * ImplementDescriptor is used by the mapper to read general information on a implemented interface
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ *
+ */
+public class ImplementDescriptor {
+    private String interfaceName;
+
+	public String getInterfaceName() {
+		return interfaceName;
+	}
+
+	public void setInterfaceName(String interfaceName) {
+		this.interfaceName = interfaceName;
+	}
+
+	public String toString() {
+		
+		return "Field Descriptor : " +  this.interfaceName;
+	}    
+}

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/MappingDescriptor.java?rev=406118&r1=406117&r2=406118&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 Sat May 13 08:08:04 2006
@@ -55,8 +55,8 @@
         if (null != this.packageName && !"".equals(this.packageName)) {
             classDescriptor.setClassName(this.packageName + "." + classDescriptor.getClassName());
 
-            if (null != classDescriptor.getSuperClass() && !"".equals(classDescriptor.getSuperClass())) {
-                classDescriptor.setSuperClass(this.packageName + "." + classDescriptor.getSuperClass());
+            if (null != classDescriptor.getExtend() && !"".equals(classDescriptor.getExtend())) {
+                classDescriptor.setExtend(this.packageName + "." + classDescriptor.getExtend());
             }
         }
 

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceConstant.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceConstant.java?rev=406118&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceConstant.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceConstant.java Sat May 13 08:08:04 2006
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.portals.graffito.jcr.persistence;
+
+
+
+/**
+ *  
+ * General Persistence Constants use in several classes
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * 
+ */
+public interface PersistenceConstant
+{
+	public static final String NT_UNSTRUCTURED = "nt:unstructured";    
+	public static final String DISCRIMINATOR_NODE_TYPE = "graffito:discriminator";
+	public static final String DISCRIMINATOR_PROPERTY_NAME = "graffito:classname"; 
+	
+        
+}
\ No newline at end of file

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java Sat May 13 08:08:04 2006
@@ -100,7 +100,7 @@
         if (jcrName == null) {
             throw new JcrMappingException(
                     "The JcrName attribute is not defined for the CollectionDescriptor : "
-                    + collectionDescriptor.getFieldName());
+                    + collectionDescriptor.getFieldName() + " for the classdescriptor : " + collectionDescriptor.getClassDescriptor().getClassName());
         }
 
         Node collectionNode = parentNode.addNode(jcrName);

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java Sat May 13 08:08:04 2006
@@ -42,6 +42,7 @@
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
+import org.apache.portals.graffito.jcr.persistence.PersistenceConstant;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverterProvider;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.NullTypeConverterImpl;
@@ -53,11 +54,12 @@
 import org.apache.portals.graffito.jcr.reflection.ReflectionUtils;
 import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
 
+import sun.reflect.misc.ReflectUtil;
+
 /**
  * Default implementation for {@link ObjectConverterImpl}
  * 
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart
- *         Christophe </a>
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart  Christophe </a>
  * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
  */
 public class ObjectConverterImpl implements ObjectConverter {
@@ -143,7 +145,7 @@
 
 		String jcrNodeType = classDescriptor.getJcrNodeType();
 		if ((jcrNodeType == null) || jcrNodeType.equals("")) {
-			throw new JcrMappingException("Undefined node type for  " + parentNode);
+			jcrNodeType= PersistenceConstant.NT_UNSTRUCTURED;
 		}
 
 		Node objectNode = null;
@@ -157,20 +159,45 @@
 					+ object.getClass(), re);
 		}
 
-		if (null != classDescriptor.getJcrMixinTypes()) {
-			String[] mixinTypes = classDescriptor.getJcrMixinTypes();
-			for (int i = 0; i < mixinTypes.length; i++) {
-				try {
-					objectNode.addMixin(mixinTypes[i].trim());
-				} catch (NoSuchNodeTypeException nsnte) {
-					throw new JcrMappingException("Unknown mixin type " + mixinTypes[i].trim() + " for mapped class "
-							+ object.getClass(), nsnte);
-				} catch (RepositoryException re) {
-					throw new PersistenceException("Cannot create new node of type " + jcrNodeType + " from mapped class "
-							+ object.getClass(), re);
+		String[] mixinTypes = classDescriptor.getJcrMixinTypes();
+		String mixinTypeName = null;
+		try {						
+			
+			// Add mixin types
+			if (null != classDescriptor.getJcrMixinTypes()) {
+				for (int i = 0; i < mixinTypes.length; i++) {
+					mixinTypeName = mixinTypes[i].trim();
+					objectNode.addMixin(mixinTypeName);
 				}
 			}
+			
+			// Add mixin types defined in the associated interfaces 
+			if (! classDescriptor.hasDiscriminator() && classDescriptor.hasInterfaces())
+			{
+				Iterator  interfacesIterator = classDescriptor.getImplements().iterator();
+				while (interfacesIterator.hasNext())
+				{
+					String interfaceName = (String)  interfacesIterator.next();
+					ClassDescriptor interfaceDescriptor =  mapper.getClassDescriptor(ReflectionUtils.forName(interfaceName));
+					objectNode.addMixin(interfaceDescriptor.getJcrNodeType().trim());
+				}			    
+			}
+			
+			// If required, add the discriminator node type 
+			if (classDescriptor.hasDiscriminator())
+			{
+				mixinTypeName = PersistenceConstant.DISCRIMINATOR_NODE_TYPE;
+				objectNode.addMixin(mixinTypeName);
+				objectNode.setProperty(PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME, ReflectionUtils.getBeanClass(object).getName());
+			}
+		} catch (NoSuchNodeTypeException nsnte) {
+			throw new JcrMappingException(
+					"Unknown mixin type " + mixinTypeName + " for mapped class " + object.getClass(), nsnte);
+		} catch (RepositoryException re) {
+			throw new PersistenceException("Cannot create new node of type " + jcrNodeType + " from mapped class "
+					+ object.getClass(), re);
 		}
+		
 
 		storeSimpleFields(session, object, classDescriptor, objectNode);
 		insertBeanFields(session, object, classDescriptor, objectNode);
@@ -207,7 +234,8 @@
 			Node objectNode = parentNode.getNode(nodeName);
 
 			checkNodeType(session, classDescriptor);
-			checkCompatibleNodeTypes(session, objectNode, classDescriptor, false);
+			
+			checkCompatiblePrimaryNodeTypes(session, objectNode, classDescriptor, false);
 
 			storeSimpleFields(session, object, classDescriptor, objectNode);
 			updateBeanFields(session, object, classDescriptor, objectNode);
@@ -235,18 +263,19 @@
 			checkNodeType(session, classDescriptor);
 
 			Node node = (Node) session.getItem(path);
-
-			checkCompatibleNodeTypes(session, node, classDescriptor, true);
+            if (! classDescriptor.isInterface())
+            {
+			    checkCompatiblePrimaryNodeTypes(session, node, classDescriptor, true);
+            }
+            
 			Object object = null;
-			if (classDescriptor.usesNodeTypePerHierarchyStrategy()) {
-				String discriminatorProperty = classDescriptor.getDiscriminatorFieldDescriptor().getJcrName();
-
-				if (!node.hasProperty(discriminatorProperty)) {
+			if (classDescriptor.usesNodeTypePerHierarchyStrategy()) {				
+				if (!node.hasProperty(PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME)) {
 					throw new PersistenceException("Cannot fetch object of type '" + clazz.getName()
 							+ "' using NODETYPE_PER_HIERARCHY. Discriminator property is not present.");
 				}
 
-				String className = node.getProperty(discriminatorProperty).getValue().getString();
+				String className = node.getProperty(PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME).getValue().getString();
 				classDescriptor = getClassDescriptor(Class.forName(className));
 				object = ReflectionUtils.newInstance(className);
 			} else {
@@ -288,11 +317,31 @@
 	 *             thrown if an error occured in the underlying repository
 	 */
 	private void checkNodeType(Session session, ClassDescriptor classDescriptor) {
+		String jcrTypeName = null;
 		try {
-			session.getWorkspace().getNodeTypeManager().getNodeType(classDescriptor.getJcrNodeType());
+			
+			
+			//Don't check the primary node type for interfaces. They are only associated to mixin node type
+			if ( classDescriptor.isInterface())
+			{
+				String[] mixinTypes = classDescriptor.getJcrMixinTypes();
+				for (int i=0; i<mixinTypes.length; i++)
+				{
+					jcrTypeName = mixinTypes[i];
+				     session.getWorkspace().getNodeTypeManager().getNodeType(jcrTypeName);
+				}
+			}
+			else
+			{
+				jcrTypeName = classDescriptor.getJcrNodeType();
+				if(jcrTypeName != null && !  jcrTypeName.equals(""))
+				{
+				    session.getWorkspace().getNodeTypeManager().getNodeType(jcrTypeName);
+				}
+			}
 		} catch (NoSuchNodeTypeException nsnte) {
-			throw new JcrMappingException("Mapping for class '" + classDescriptor.getClassName() + "' use unknown node type '"
-					+ classDescriptor.getJcrNodeType() + "'");
+			throw new JcrMappingException("Mapping for class '" + classDescriptor.getClassName() + "' use unknown primary or mixin node type '"
+					+  jcrTypeName  + "'");
 		} catch (RepositoryException re) {
 			throw new org.apache.portals.graffito.jcr.exception.RepositoryException(re);
 		}
@@ -318,7 +367,7 @@
 	 * @throws org.apache.portals.graffito.jcr.exception.RepositoryException
 	 *             thrown if an error occured in the underlying repository
 	 */
-	private void checkCompatibleNodeTypes(Session session, Node node, ClassDescriptor classDescriptor, boolean checkVersionNode) {
+	private void checkCompatiblePrimaryNodeTypes(Session session, Node node, ClassDescriptor classDescriptor, boolean checkVersionNode) {
 		try {
 			NodeType nodeType = node.getPrimaryNodeType();
 
@@ -352,6 +401,13 @@
 	 *         <tt>false</tt> otherwise
 	 */
 	private boolean checkCompatibleNodeTypes(NodeType nodeType, ClassDescriptor descriptor) {
+		
+		//return true if node type is not used
+		if (descriptor.getJcrNodeType() == null ||descriptor.getJcrNodeType().equals("") )
+		{
+			return true;
+		}
+		
 		if (nodeType.getName().equals(descriptor.getJcrNodeType())) {
 			return true;
 		}
@@ -412,14 +468,13 @@
 
 					ReflectionUtils.setNestedProperty(initializedBean, fieldName, node.getPath());
 
-				} else if (classDescriptor.usesNodeTypePerHierarchyStrategy() && fieldDescriptor.isDiscriminator()) {
+				} else if (classDescriptor.usesNodeTypePerHierarchyStrategy() && classDescriptor.hasDiscriminator()) {
 
-					if (node.hasProperty(classDescriptor.getDiscriminatorFieldDescriptor().getJcrName())) {
+					if (node.hasProperty(PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME)) {
 						if (null == initializedBean) {
 							initializedBean = ReflectionUtils.newInstance(classDescriptor.getClassName());
 						}
-						String value = node.getProperty(classDescriptor.getDiscriminatorFieldDescriptor().getJcrName())
-								.getValue().getString();
+						String value = node.getProperty(propertyName).getValue().getString();
 						ReflectionUtils.setNestedProperty(initializedBean, fieldName, value);
 					} else {
 						throw new PersistenceException("Class '" + classDescriptor.getClassName()
@@ -610,19 +665,13 @@
 					continue;
 				}
 
-				if (classDescriptor.usesNodeTypePerHierarchyStrategy() && fieldDescriptor.isDiscriminator()) {
-					objectNode.setProperty(fieldDescriptor.getJcrName(), classDescriptor.getClassName());
-					continue;
-				}
-
 				boolean protectedProperty = fieldDescriptor.isJcrProtected();
 
 				if (objectNode.hasProperty(jcrName)) {
 					protectedProperty = objectNode.getProperty(jcrName).getDefinition().isProtected();
 				}
 
-				if (!protectedProperty) { // DO NOT TRY TO WRITE PROTECTED
-											// PROPERTIES
+				if (!protectedProperty) { // DO NOT TRY TO WRITE PROTECTED  PROPERTIES
 					Object fieldValue = ReflectionUtils.getNestedProperty(object, fieldName);
 					AtomicTypeConverter converter = getAtomicTypeConverter(fieldDescriptor, object, fieldName);
 					Value value = converter.getValue(valueFactory, fieldValue);
@@ -657,7 +706,7 @@
 	}
 
 	private CollectionConverter getCollectionConverter(Session session, CollectionDescriptor collectionDescriptor) {
-		String className = collectionDescriptor.getCollectionConverterClassName();
+		String className = collectionDescriptor.getCollectionConverter();
 		Map atomicTypeConverters = this.atomicTypeConverterProvider.getAtomicTypeConverters();
 		if (className == null) {
 			return new DefaultCollectionConverterImpl(atomicTypeConverters, this, this.mapper);

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java Sat May 13 08:08:04 2006
@@ -23,13 +23,14 @@
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
+import org.apache.portals.graffito.jcr.persistence.PersistenceConstant;
 import org.apache.portals.graffito.jcr.query.Filter;
 import org.apache.portals.graffito.jcr.query.Query;
 import org.apache.portals.graffito.jcr.query.QueryManager;
 
 public class QueryManagerImpl implements QueryManager {
-
-    private Mapper mapper;
+    
+	private Mapper mapper;
     private Map atomicTypeConverters;
 
     public QueryManagerImpl(Mapper mapper, Map atomicTypeConverters) {
@@ -53,7 +54,7 @@
 
         // Check if the class has  an inheritance discriminator field
         ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
-        if (classDescriptor.hasDiscriminatorField()) {
+        if (classDescriptor.hasDiscriminator()) {
             Filter discrininatorFilter = buildDiscriminatorFilter(query, classDescriptor);
             filter = filter.addAndFilter(discrininatorFilter);
         }
@@ -88,10 +89,8 @@
 
     private Filter buildDiscriminatorFilter(Query query, ClassDescriptor classDescriptor) {
         Filter discriminatorFilter = this.createFilter(query.getFilter().getFilterClass());
-        if (!classDescriptor.isAbstract()) {
-            FieldDescriptor fieldDescriptor = classDescriptor.getDiscriminatorFieldDescriptor();
-            discriminatorFilter.addEqualTo(fieldDescriptor.getFieldName(),
-                                           classDescriptor.getClassName());
+        if (!classDescriptor.isAbstract() && (! classDescriptor.isInterface()) ) {        
+            discriminatorFilter.addJCRExpression("@" + PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME + "='" +    classDescriptor.getClassName() + "'");
         }
 
         if (classDescriptor.hasDescendants()) {
@@ -113,7 +112,15 @@
     private String getNodeType(Filter filter) {
         ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass());
 
-        return classDescriptor.getJcrNodeType();
+        String jcrNodeType = classDescriptor.getJcrNodeType();
+        if (jcrNodeType == null || jcrNodeType.equals(""))
+        	{
+           return PersistenceConstant.NT_UNSTRUCTURED;	
+        	}
+        else
+        {
+           return jcrNodeType;	
+        }
     }
 
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-atomic.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-atomic.xml?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-atomic.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-atomic.xml Sat May 13 08:08:04 2006
@@ -3,7 +3,7 @@
 <!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/dtd/graffito-jcr-mapping.dtd">
 <graffito-jcr>
     <class-descriptor
-		className="org.apache.portals.graffito.jcr.testmodel.Atomic" jcrNodeType="nt:unstructured">
+		className="org.apache.portals.graffito.jcr.testmodel.Atomic" jcrNodeType="nt:unstructured" discriminator="false" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="string" jcrName="string" />
 		<field-descriptor fieldName="booleanObject" jcrName="booleanObject" />
@@ -20,7 +20,7 @@
 	</class-descriptor>
 
     <class-descriptor
-		className="org.apache.portals.graffito.jcr.testmodel.MultiValue" jcrNodeType="nt:unstructured">
+		className="org.apache.portals.graffito.jcr.testmodel.MultiValue" jcrNodeType="nt:unstructured" discriminator="false" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="name" jcrName="name" />
 		<collection-descriptor fieldName="multiValues" jcrName="multiValue" proxy="false" 

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml Sat May 13 08:08:04 2006
@@ -3,34 +3,58 @@
 <!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/dtd/graffito-jcr-mapping.dtd">
 <graffito-jcr>    
 
-     <!--  MAPPING USED TO TEST NODE TYPE PER HIERARCHY  -->
-     
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor" jcrNodeType="nt:unstructured"  abstract="true" >
+     <!--MAPPING USED TO TEST INTERFACES WITHOUT NODE TYPE   -->	
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.Interface"  interface="true"  />
+	
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.AnotherInterface"  interface="true" />
+
+     <!--MAPPING USED TO TEST INTERFACES WITH NODE TYPE   -->	
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject"  interface="true" discriminator="false"
+	                                   jcrNodeType="graffito:cmsobject" />
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.Folder"  interface="true" discriminator="false" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject"  jcrNodeType="graffito:folder" />
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.Content"  interface="true" discriminator="false" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject"  jcrNodeType="graffito:content"  />
+	                                   
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.Document"  interface="true" discriminator="false" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.interfaces.Content"  jcrNodeType="graffito:document"  />
+	                                   
+	                                   
+     <!--  MAPPING USED TO TEST NODE TYPE PER HIERARCHY  -->	
+     
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor"  abstract="true" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="ancestorField" jcrName="ancestorField" />
-		<field-descriptor fieldName="discriminator" jcrName="discriminator" discriminator="true"  />
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Descendant" jcrNodeType="nt:unstructured" 
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor" >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Descendant" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor">
+	    <implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.AnotherInterface" />
 		<field-descriptor fieldName="descendantField" jcrName="descendantField" />  
 	</class-descriptor >
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.AnotherDescendant" jcrNodeType="nt:unstructured" 
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor"  >                               
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.AnotherDescendant" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.inheritance.Ancestor"  >
+	    <implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.Interface" />	                                   
 		<field-descriptor fieldName="anotherDescendantField" jcrName="anotherDescendantField" />  
 
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.SubDescendant" jcrNodeType="nt:unstructured" 
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.Descendant"  >                               
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.SubDescendant" 
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.inheritance.Descendant"  >                               
 		<field-descriptor fieldName="subDescendantField" jcrName="subDescendantField" />  
 
 	</class-descriptor>
 	
      <!--  MAPPING USED TO TEST NODE TYPE PER CONCRETE CLASS  -->	
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.CmsObject" jcrNodeType="graffito:cmsobject"  abstract="true" >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl" jcrNodeType="graffito:cmsobjectimpl"  
+	                                   discriminator="false" abstract="true" >
+		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject" />	  	                                    
+		
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="name" jcrName="graffito:name" id="true" />
 		<!--  bean-descriptor  fieldName="parentFolder" 						 
@@ -38,25 +62,28 @@
 
 	</class-descriptor>     
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Folder" jcrNodeType="graffito:folder" 
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.CmsObject" >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.FolderImpl" jcrNodeType="graffito:folderimpl" 
+	                                    extend="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl" >
+		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.Folder" />	  		                                    
 		<collection-descriptor fieldName="children" proxy="true" 
-		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.inheritance.CmsObject" 
+		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl" 
 		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl" />
 	</class-descriptor >	
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Content" jcrNodeType="graffito:content" abstract="true"
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.CmsObject" >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.ContentImpl" jcrNodeType="graffito:contentimpl" abstract="true"
+	                                   extend="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl" >
+       		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.Content" />	  		                                    
 	</class-descriptor>	
 		
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.Document" jcrNodeType="graffito:document" 
-	                                   extends="org.apache.portals.graffito.jcr.testmodel.inheritance.Content" >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentImpl" jcrNodeType="graffito:documentimpl" 
+	                                    extend="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.ContentImpl" >
+		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.Document" />	  		                                    	                                    
 		<field-descriptor fieldName="contentType" jcrName="graffito:contenttype" />  
 		<field-descriptor fieldName="size" jcrName="graffito:size" />  	
 		<bean-descriptor fieldName="documentStream" jcrName="graffito:documentstream" proxy="true"  />			
 	</class-descriptor >	
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.DocumentStream" jcrNodeType="graffito:documentstream"  >
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentStream" jcrNodeType="graffito:documentstream"  >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="encoding" jcrName="graffito:encoding" />
 		<field-descriptor fieldName="content" jcrName="graffito:binarycontent" />

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-proxy.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-proxy.xml?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-proxy.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-proxy.xml Sat May 13 08:08:04 2006
@@ -3,7 +3,7 @@
 <!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/dtd/graffito-jcr-mapping.dtd">
 <graffito-jcr>
     
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.proxy.Main" 	jcrNodeType="nt:unstructured">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.proxy.Main" 	jcrNodeType="nt:unstructured"  >
 		<!-- Field-descriptor is used to map simple attributes to jcr property -->
 		<field-descriptor fieldName="path" path="true" />
 		<bean-descriptor fieldName="proxyDetail" jcrName="proxydetail" proxy="true" jcrNodeType="nt:unstructured" />		
@@ -16,7 +16,7 @@
                                                   elementClassName="org.apache.portals.graffito.jcr.testmodel.proxy.Detail" jcrNodeType="nt:unstructured"/>                                                  		
 	</class-descriptor>
 
-	<class-descriptor 	className="org.apache.portals.graffito.jcr.testmodel.proxy.Detail" jcrNodeType="nt:unstructured">		
+	<class-descriptor 	className="org.apache.portals.graffito.jcr.testmodel.proxy.Detail" jcrNodeType="nt:unstructured" >		
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="field" jcrName="field" />
 	</class-descriptor>

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml Sat May 13 08:08:04 2006
@@ -53,14 +53,14 @@
 
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C" discriminator="false" >
 		<!-- Field-descriptor is used to map simple attributes to jcr property -->
 		<field-descriptor fieldName="id" jcrName="graffito:id" 	id="true" />
 		<field-descriptor fieldName="name" jcrName="graffito:name" />
 	</class-descriptor>
 
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Page" jcrNodeType="graffito:page">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Page" jcrNodeType="graffito:page" discriminator="false" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="title" jcrName="graffito:title" />
 		<collection-descriptor fieldName="paragraphs" proxy="false" 
@@ -68,23 +68,23 @@
 		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl" />
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Paragraph" jcrNodeType="graffito:paragraph">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Paragraph" jcrNodeType="graffito:paragraph" discriminator="false" >
 		<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">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Main" jcrNodeType="nt:unstructured" discriminator="false" >
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="text" jcrName="text" />
-		<collection-descriptor fieldName="elements" proxy="false" 
+		<collection-descriptor fieldName="elements"  proxy="false" 
 		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.Element" 
 		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl" 
 		                       collectionClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.HashMapElement" />
 		                       
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Element" jcrNodeType="graffito:element">
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Element" jcrNodeType="graffito:element" discriminator="false" >
 		<field-descriptor fieldName="id" jcrName="graffito:id"  />
 		<field-descriptor fieldName="text" jcrName="graffito:text" />
 	</class-descriptor>

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml Sat May 13 08:08:04 2006
@@ -66,7 +66,7 @@
     <propertyDefinition name="graffito:text" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />    
   </nodeType>
   
-   <nodeType name="graffito:cmsobject" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+   <nodeType name="graffito:cmsobjectimpl" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
     <supertypes>
       <supertype>nt:base</supertype>
     </supertypes>
@@ -75,16 +75,16 @@
 
   </nodeType>
 
-   <nodeType name="graffito:content" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+   <nodeType name="graffito:contentimpl" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
     <supertypes>
-      <supertype>graffito:cmsobject</supertype>
+      <supertype>graffito:cmsobjectimpl</supertype>
     </supertypes>
   </nodeType>
 
 
-   <nodeType name="graffito:document" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+   <nodeType name="graffito:documentimpl" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
     <supertypes>
-      <supertype>graffito:content</supertype>
+      <supertype>graffito:contentimpl</supertype>
     </supertypes>    
     <propertyDefinition name="graffito:contenttype" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />
     <propertyDefinition name="graffito:size" requiredType="Long" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />    
@@ -95,13 +95,13 @@
     </childNodeDefinition>        
   </nodeType>
   
-  <nodeType name="graffito:folder" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
+  <nodeType name="graffito:folderimpl" isMixin="false" hasOrderableChildNodes="false" primaryItemName="">
     <supertypes>
-      <supertype>graffito:cmsobject</supertype>       
+      <supertype>graffito:cmsobjectimpl</supertype>       
     </supertypes>    
-    <childNodeDefinition name="*" defaultPrimaryType="graffito:cmsobject" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="true">
+    <childNodeDefinition name="*" defaultPrimaryType="graffito:cmsobjectimpl" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="true">
       <requiredPrimaryTypes>
-        <requiredPrimaryType>graffito:cmsobject</requiredPrimaryType>         
+        <requiredPrimaryType>graffito:cmsobjectimpl</requiredPrimaryType>         
       </requiredPrimaryTypes>
     </childNodeDefinition>        
   </nodeType>
@@ -116,6 +116,37 @@
     <propertyDefinition name="graffito:binarycontent" requiredType="Binary" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />    
   </nodeType>
 
-    
+   <nodeType name="graffito:discriminator" isMixin="true">
+    <supertypes>
+      <supertype>nt:base</supertype>
+    </supertypes>
+    <propertyDefinition name="graffito:classname" requiredType="String" autoCreated="false" mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />    
+  </nodeType>
+   
+
+   <nodeType name="graffito:cmsobject" isMixin="true">
+    <supertypes>
+      <supertype>nt:base</supertype>
+    </supertypes>
+  </nodeType>    
+
+   <nodeType name="graffito:folder" isMixin="true">
+    <supertypes>
+      <supertype>graffito:cmsobject</supertype>
+    </supertypes>
+  </nodeType>    
+
+   <nodeType name="graffito:content" isMixin="true">
+    <supertypes>
+      <supertype>graffito:cmsobject</supertype>
+    </supertypes>
+  </nodeType>    
+
+   <nodeType name="graffito:document" isMixin="true">
+    <supertypes>
+      <supertype>graffito:content</supertype>
+    </supertypes>
+  </nodeType>    
+
 </nodeTypes>
 

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java?rev=406118&r1=406117&r2=406118&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java Sat May 13 08:08:04 2006
@@ -66,7 +66,7 @@
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.TimestampTypeConverterImpl;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.UtilDateTypeConverterImpl;
 import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
-import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerNtHierarchyTest;
+import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerInheritanceHierarchyTest;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
 import org.apache.portals.graffito.jcr.query.QueryManager;
@@ -268,7 +268,8 @@
             while (iterator.hasNext())
             {
                 Object  object = iterator.next();
-                if (ReflectionUtils.getNestedProperty(object, "path").equals(path))
+                String itemPath = (String)  ReflectionUtils.getNestedProperty(object, "path");
+                if (itemPath.equals(path))
                 {
                     if (object.getClass() == objectClass)
                     {



Mime
View raw message