incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apope...@apache.org
Subject svn commit: r375382 - 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/ test-config/ test/org/apache/portals/graffito/jcr/mapper/
Date Mon, 06 Feb 2006 21:34:48 GMT
Author: apopescu
Date: Mon Feb  6 13:34:45 2006
New Revision: 375382

URL: http://svn.apache.org/viewcvs?rev=375382&view=rev
Log:
DTD updated:
- class-descriptor: added jcrMixinTypes attribute
- bean-descriptor: added inline, converter attributes

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testmappings.xml
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/model/BeanDescriptor.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/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.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=375382&r1=375381&r2=375382&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 Mon Feb  6 13:34:45
2006
@@ -23,13 +23,15 @@
     * className : the className
     * jcrNodeType : the primary jcr node type, it can be nt:unstructured
     * jcrSuperTypes : the jcr super types, optional
+    * jcrMixinTypes: the jcr mixin types (comma separated list) (optional)
 -->
 <!ELEMENT class-descriptor (field-descriptor*, bean-descriptor*, collection-descriptor*)>
 
 <!ATTLIST class-descriptor
 	className CDATA #REQUIRED
 	jcrNodeType CDATA #IMPLIED
-        jcrSuperTypes CDATA #IMPLIED>
+    jcrSuperTypes CDATA #IMPLIED
+    jcrMixinTypes CDATA #IMPLIED>
 
 <!--
     Field descriptor - A field descriptor maps one atomic object attribute (primitive types,
String, Long, ...)  into a JCR property
@@ -53,12 +55,12 @@
 	jcrName CDATA #IMPLIED 
 	id (true | false) "false"
 	path (true | false) "false"
-        jcrType (String | Date | Long | Double | Boolean | Binary) #IMPLIED
-        jcrAutoCreated (true | false) "false"
-        jcrMandatory (true | false) "false"
-        jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
-        jcrProtected (true | false) "false"
-        jcrMultiple (true | false) "false"
+    jcrType (String | Date | Long | Double | Boolean | Binary) #IMPLIED
+    jcrAutoCreated (true | false) "false"
+    jcrMandatory (true | false) "false"
+    jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
+    jcrProtected (true | false) "false"
+    jcrMultiple (true | false) "false"
 >
 
 <!--
@@ -66,6 +68,8 @@
     * 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.
+    * inline: persist/retrieve bean properties from the current node (if true).
+    * converter: fully qualified name of the converter class to be used (default is ObjectConverterImpl)
     * jcrNodeType: defines the child node type, optional
     * jcrAutoCreated (boolean) default is "false"
     * jcrMandatory (boolean) default is "false"
@@ -78,12 +82,14 @@
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
 	proxy (true | false) "false" 
+	inline (true | false) "false"
+	converter CDATA #IMPLIED
 	jcrNodeType CDATA #IMPLIED
-        jcrAutoCreated (true | false) "false"   
-        jcrMandatory (true | false) "false"
-        jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
-        jcrProtected (true | false) "false"
-        jcrSameNameSiblings (true | false) "false"         
+    jcrAutoCreated (true | false) "false"   
+    jcrMandatory (true | false) "false"
+    jcrOnParentVersion (COPY | VERSION | INITIALIZE | COMPUTE | IGNORE | ABORT) "COPY"
+    jcrProtected (true | false) "false"
+    jcrSameNameSiblings (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=375382&r1=375381&r2=375382&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
Mon Feb  6 13:34:45 2006
@@ -59,6 +59,7 @@
 			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", "jcrMixinTypesList");
 
 			digester.addSetNext("graffito-jcr/class-descriptor", "addClassDescriptor");
 
@@ -88,6 +89,8 @@
 			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");

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java?rev=375382&r1=375381&r2=375382&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
Mon Feb  6 13:34:45 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -15,175 +15,181 @@
  */
 package org.apache.portals.graffito.jcr.mapper.model;
 
+
+import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
+
 /**
  * BeanDescriptor is used by the mapper to read general information on a bean field
- * 
+ *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
- * 
+ * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
  */
-public class BeanDescriptor
-{
+public class BeanDescriptor {
+    private static final String DEFAULT_CONVERTER = ObjectConverterImpl.class.getName();
 
-     private String fieldName;
-     private String jcrName;
-     private boolean proxy; 
-     private String jcrNodeType;
-     private boolean jcrAutoCreated;
-     private boolean jcrMandatory;
-     private String jcrOnParentVersion;
-     private boolean jcrProtected;
-     private boolean jcrSameNameSiblings;
+    private String fieldName;
+    private String jcrName;
+    private boolean proxy;
+    private boolean inline;
+    private String converter = DEFAULT_CONVERTER;
+    private String jcrNodeType;
+    private boolean jcrAutoCreated;
+    private boolean jcrMandatory;
+    private String jcrOnParentVersion;
+    private boolean jcrProtected;
+    private boolean jcrSameNameSiblings;
 
     /**
      * @return Returns the fieldName.
      */
-    public String getFieldName()
-    {
+    public String getFieldName() {
         return fieldName;
     }
+
     /**
      * @param fieldName The fieldName to set.
      */
-    public void setFieldName(String fieldName)
-    {
+    public void setFieldName(String fieldName) {
         this.fieldName = fieldName;
     }
+
     /**
      * @return Returns the jcrName.
      */
-    public String getJcrName()
-    {
+    public String getJcrName() {
         return jcrName;
     }
+
     /**
      * @param jcrName The jcrName to set.
      */
-    public void setJcrName(String jcrName)
-    {
+    public void setJcrName(String jcrName) {
         this.jcrName = jcrName;
     }
-    
-    
+
     /**
      * @return Returns the proxy.
      */
-    public boolean isProxy()
-    {
+    public boolean isProxy() {
         return proxy;
     }
+
     /**
      * @param proxy The proxy to set.
      */
-    public void setProxy(boolean proxy)
-    {
+    public void setProxy(boolean proxy) {
         this.proxy = proxy;
     }
 
+    public boolean isInline() {
+        return this.inline;
+    }
+
+    public void setInline(boolean flag) {
+        this.inline = flag;
+    }
+
+    public String getConverter() {
+        return this.converter;
+    }
+
+    public void setConverter(String converterClass) {
+        this.converter = converterClass;
+    }
+
     /** Getter for property jcrNodeType.
-     * 
+     *
      * @return jcrNodeType
      */
-    public String getJcrNodeType()
-    {
+    public String getJcrNodeType() {
         return jcrNodeType;
     }
 
     /** Setter for property jcrNodeType.
-     * 
+     *
      * @param value jcrNodeType
      */
-    public void setJcrNodeType(String value)
-    {
+    public void setJcrNodeType(String value) {
         this.jcrNodeType = value;
     }
 
     /** Getter for property jcrAutoCreated.
-     * 
+     *
      * @return jcrAutoCreated
      */
-    public boolean isJcrAutoCreated()
-    {
+    public boolean isJcrAutoCreated() {
         return jcrAutoCreated;
     }
 
     /** Setter for property jcrAutoCreated.
-     * 
+     *
      * @param value jcrAutoCreated
      */
-    public void setJcrAutoCreated(boolean value)
-    {
+    public void setJcrAutoCreated(boolean value) {
         this.jcrAutoCreated = value;
     }
 
     /** Getter for property jcrMandatory.
-     * 
+     *
      * @return jcrMandatory
      */
-    public boolean isJcrMandatory()
-    {
+    public boolean isJcrMandatory() {
         return jcrMandatory;
     }
 
     /** Setter for property jcrMandatory.
-     * 
+     *
      * @param value jcrMandatory
      */
-    public void setJcrMandatory(boolean value)
-    {
+    public void setJcrMandatory(boolean value) {
         this.jcrMandatory = value;
     }
 
     /** Getter for property jcrOnParentVersion.
-     * 
+     *
      * @return jcrOnParentVersion
      */
-    public String getJcrOnParentVersion()
-    {
+    public String getJcrOnParentVersion() {
         return jcrOnParentVersion;
     }
 
     /** Setter for property jcrOnParentVersion.
-     * 
+     *
      * @param value jcrOnParentVersion
      */
-    public void setJcrOnParentVersion(String value)
-    {
+    public void setJcrOnParentVersion(String value) {
         this.jcrOnParentVersion = value;
     }
 
     /** Getter for property jcrProtected.
-     * 
+     *
      * @return jcrProtected
      */
-    public boolean isJcrProtected()
-    {
+    public boolean isJcrProtected() {
         return jcrProtected;
     }
 
     /** Setter for property jcrProtected.
-     * 
+     *
      * @param value jcrProtected
      */
-    public void setJcrProtected(boolean value)
-    {
+    public void setJcrProtected(boolean value) {
         this.jcrProtected = value;
     }
 
     /** Getter for property jcrSameNameSiblings.
-     * 
+     *
      * @return jcrSameNameSiblings
      */
-    public boolean isJcrSameNameSiblings()
-    {
+    public boolean isJcrSameNameSiblings() {
         return jcrSameNameSiblings;
     }
 
     /** Setter for property jcrSameNameSiblings.
-     * 
+     *
      * @param value jcrSameNameSiblings
      */
-    public void setJcrSameNameSiblings(boolean value)
-    {
+    public void setJcrSameNameSiblings(boolean value) {
         this.jcrSameNameSiblings = value;
     }
 }

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=375382&r1=375381&r2=375382&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
Mon Feb  6 13:34:45 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -15,110 +15,100 @@
  */
 package org.apache.portals.graffito.jcr.mapper.model;
 
+
 import java.util.Collection;
 import java.util.HashMap;
 
 /**
- * 
+ *
  * ClassDescriptor is used by the mapper to read general information on a class
- * 
+ *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
- * 
+ * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
  */
-public class ClassDescriptor
-{
+public class ClassDescriptor {
+    private String className;
+    private String jcrNodeType;
+    private String jcrSuperTypes;
+    private String[] jcrMixinTypes = new String[0];
+    private FieldDescriptor idFieldDescriptor;
+    private FieldDescriptor pathFieldDescriptor;
+
+    private HashMap fieldDescriptors = new HashMap();
+    private HashMap beanDescriptors = new HashMap();
+    private HashMap collectionDescriptors = new HashMap();
+    private HashMap fieldNames = new HashMap();
 
-     private String className;
-     private String jcrNodeType;
-     private String jcrSuperTypes;
-     private FieldDescriptor idFieldDescriptor;
-     private FieldDescriptor pathFieldDescriptor;
-     
-     private HashMap fieldDescriptors = new HashMap();
-     private HashMap beanDescriptors = new HashMap();
-     private HashMap collectionDescriptors = new HashMap();
-     private HashMap fieldNames = new HashMap();
-    
-    
     /**
      * @return Returns the className.
      */
-    public String getClassName()
-    {
+    public String getClassName() {
         return className;
     }
+
     /**
      * @param className The className to set.
      */
-    public void setClassName(String className)
-    {
+    public void setClassName(String className) {
         this.className = className;
     }
-    
-    
+
     /**
      * @return Returns the jcrNodeType.
      */
-    public String getJcrNodeType()
-    {
+    public String getJcrNodeType() {
         return jcrNodeType;
     }
+
     /**
      * @param jcrNodeType The jcrNodeType to set.
      */
-    public void setJcrNodeType(String jcrNodeType)
-    {
+    public void setJcrNodeType(String jcrNodeType) {
         this.jcrNodeType = jcrNodeType;
     }
-    
+
     /**
      * Add a new FielDescriptor
      * @param fieldDescriptor the new field descriptor to add
      */
-    public void addFieldDescriptor(FieldDescriptor fieldDescriptor )
-    {
+    public void addFieldDescriptor(FieldDescriptor fieldDescriptor) {
         fieldDescriptor.setClassDescriptor(this);
-        if (fieldDescriptor.isId())
-        {
-           this.idFieldDescriptor = fieldDescriptor;
+        if (fieldDescriptor.isId()) {
+            this.idFieldDescriptor = fieldDescriptor;
         }
-        
-        if (fieldDescriptor.isPath())
-        {
-        	this.pathFieldDescriptor = fieldDescriptor;
+
+        if (fieldDescriptor.isPath()) {
+            this.pathFieldDescriptor = fieldDescriptor;
         }
-        
+
         fieldDescriptors.put(fieldDescriptor.getFieldName(), fieldDescriptor);
         fieldNames.put(fieldDescriptor.getFieldName(), fieldDescriptor.getJcrName());
     }
-    
+
     /**
      * Get the FieldDescriptor to used for a specific java bean attribute
      * @param fieldName The java bean attribute name
-     * 
+     *
      * @return the {@link FieldDescriptor} found or null
      */
-    public FieldDescriptor getFieldDescriptor(String fieldName)
-    {
+    public FieldDescriptor getFieldDescriptor(String fieldName) {
         return (FieldDescriptor) fieldDescriptors.get(fieldName);
     }
-    
+
     /**
-     * 
+     *
      * @return all {@link FieldDescriptor} defined in this ClassDescriptor
      */
-    public Collection getFieldDescriptors()
-    {
-        return fieldDescriptors.values();   
+    public Collection getFieldDescriptors() {
+        return fieldDescriptors.values();
     }
-    
+
     /**
      * Add a new BeanDescriptor
      * @param beanDescriptor the new bean descriptor to add
      */
-                  
-    public void addBeanDescriptor(BeanDescriptor beanDescriptor )
-    {
+
+    public void addBeanDescriptor(BeanDescriptor beanDescriptor) {
         beanDescriptors.put(beanDescriptor.getFieldName(), beanDescriptor);
         fieldNames.put(beanDescriptor.getFieldName(), beanDescriptor.getJcrName());
     }
@@ -126,31 +116,26 @@
     /**
      * Get the BeanDescriptor to used for a specific java bean attribute
      * @param fieldName The java bean attribute name
-     * 
+     *
      * @return the {@link BeanDescriptor} found or null
      */
-    public BeanDescriptor getBeanDescriptor(String fieldName)
-    {
+    public BeanDescriptor getBeanDescriptor(String fieldName) {
         return (BeanDescriptor) beanDescriptors.get(fieldName);
     }
-    
-    
-    /**     
+
+    /**
      * @return all {@link BeanDescriptor} defined in this ClassDescriptor
      */
-    public Collection getBeanDescriptors()
-    {
-        return beanDescriptors.values();   
+    public Collection getBeanDescriptors() {
+        return beanDescriptors.values();
     }
 
-    
     /**
      * Add a new CollectionDescriptor
      * @param collectionDescriptor the new collection descriptor to add
      */
-                  
-    public void addCollectionDescriptor(CollectionDescriptor collectionDescriptor )
-    {
+
+    public void addCollectionDescriptor(CollectionDescriptor collectionDescriptor) {
         collectionDescriptor.setClassDescriptor(this);
         collectionDescriptors.put(collectionDescriptor.getFieldName(), collectionDescriptor);
         fieldNames.put(collectionDescriptor.getFieldName(), collectionDescriptor.getJcrName());
@@ -159,72 +144,88 @@
     /**
      * Get the CollectionDescriptor to used for a specific java bean attribute
      * @param fieldName The java bean attribute name
-     * 
+     *
      * @return the {@link CollectionDescriptor} found or null
      */
-    public CollectionDescriptor getCollectionDescriptor(String fieldName)
-    {
+    public CollectionDescriptor getCollectionDescriptor(String fieldName) {
         return (CollectionDescriptor) collectionDescriptors.get(fieldName);
     }
-        
+
     /**
      * @return all {@link BeanDescriptor} defined in this ClassDescriptor
      */
-    public Collection getCollectionDescriptors()
-    {
-        return collectionDescriptors.values();   
+    public Collection getCollectionDescriptors() {
+        return collectionDescriptors.values();
     }
-    
+
     /**
-     * @return the fieldDescriptor ID  
+     * @return the fieldDescriptor ID
      */
-    public FieldDescriptor getIdFieldDescriptor()
-    {
+    public FieldDescriptor getIdFieldDescriptor() {
         return idFieldDescriptor;
     }
-    
+
     /**
-     * @return the fieldDescriptor path  
+     * @return the fieldDescriptor path
      */
-    public FieldDescriptor getPathFieldDescriptor()
-    {
+    public FieldDescriptor getPathFieldDescriptor() {
         return pathFieldDescriptor;
     }
-    
+
     /**
-     * Check if this class has an ID 
+     * Check if this class has an ID
      * @return true if the class has an ID
      */
-    public boolean hasIdField()
-    {
+    public boolean hasIdField() {
         return this.idFieldDescriptor != null;
     }
-    
+
     /**
      * Get the JCR name used for one of the object attributes
      * @param fieldName the object attribute name (can be an atomic field, bean field or
a collection field)
-     * @return the JCR name found 
+     * @return the JCR name found
      */
-    public String getJcrName(String fieldName)
-    {
-    	return (String) this.fieldNames.get(fieldName);
+    public String getJcrName(String fieldName) {
+        return (String) this.fieldNames.get(fieldName);
     }
 
     /** Get the JCR node super types.
-     * 
+     *
      * @return jcrSuperTypes
      */
-    public String getJcrSuperTypes()
-    {
+    public String getJcrSuperTypes() {
         return jcrSuperTypes;
     }
 
     /** Setter for JCR super types.
-     * 
+     *
      * @param superTypes Comma separated list of JCR node super types
      */
-    public void setJcrSuperTypes(String superTypes)
-    {
+    public void setJcrSuperTypes(String superTypes) {
         this.jcrSuperTypes = superTypes;
+    }
+
+    /**
+     * Retrieve the mixin types.
+     * 
+     * @return array of mixin types
+     */
+    public String[] getJcrMixinTypes() {
+        return this.jcrMixinTypes;
+    }
+
+    /**
+     * Sets a comma separated list of mixin types.
+     *
+     * @param mixinTypes command separated list of mixins
+     */
+    public void setJcrMixinTypesList(String mixinTypes) {
+        if(null != mixinTypes) {
+            setJcrMixinTypes(mixinTypes.split(","));
+        }
+    }
+
+    public void setJcrMixinTypes(String[] mixinTypes) {
+        jcrMixinTypes = mixinTypes;
     }
 }

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testmappings.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testmappings.xml?rev=375382&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testmappings.xml (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-testmappings.xml Mon
Feb  6 13:34:45 2006
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!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.Folder" jcrNodeType="nt:unstructured">
+		<!-- Field-descriptor is used to map simple attributes to jcr property -->
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="name" jcrName="name" />
+		<field-descriptor fieldName="description" jcrName="description" />
+		<field-descriptor fieldName="title" jcrName="title" />
+		<field-descriptor fieldName="creationDate" jcrName="creationDate" />
+		<field-descriptor fieldName="lastModified" jcrName="lastModified" />
+
+	</class-descriptor>
+
+	<!--
+		The following classes are used to test object associations
+		A has an assocition (1..1) with B (field b) => B is mapped as subnode in A
+		A has a collection of C (field "collection" ) => there are n subnodes used to map the
"C" collection 
+		
+	-->
+	<class-descriptor
+		className="org.apache.portals.graffito.jcr.testmodel.A"
+		jcrNodeType="nt:unstructured"
+		jcrMixinTypes="mixin:a,mixin:b">
+		<!-- Field-descriptor is used to map simple attributes to jcr property -->
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="a1" jcrName="a1" />
+		<field-descriptor fieldName="a2" jcrName="a2" />
+
+		<!-- bean-descriptor is used to map a bean into subnode
+			* The definition of the associated class has to be defined in this mapping file 
+			* proxy="true" => use lazy laoding for this attribute b when retrieving A
+		-->
+		<bean-descriptor fieldName="b" 
+						 jcrName="b" 
+						 proxy="false" 
+						 inline="true"
+						 jcrNodeType="nt:unstructured"
+        				 jcrAutoCreated="false" 
+        				 jcrMandatory="false" 
+        				 jcrOnParentVersion="IGNORE"
+        				 jcrProtected="false" 
+        				 jcrSameNameSiblings="false" />
+
+		<!-- 
+			Use the default collection mapping stategy and the default collection type (can be a Vector,
an ArrayList, a Collection or a List) 
+			The default collection mapping strategy map a collection under an extra JCR node (specify
by the jcrName).
+			
+		-->
+		<collection-descriptor fieldName="collection" jcrName="collection" proxy="false"
+        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C"
+        jcrAutoCreated="false" jcrMandatory="false" jcrOnParentVersion="IGNORE"
+        jcrProtected="false" jcrSameNameSiblings="false"/>
+        
+		<collection-descriptor fieldName="emptyCollection" jcrName="emptyCollection" proxy="false"
+        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" />
+		
+	</class-descriptor>
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured"
jcrSuperTypes="nt:base">
+		<!-- Field-descriptor is used to map simple attributes to jcr property -->
+
+		<field-descriptor fieldName="b1" jcrName="b1" jcrType="String" jcrAutoCreated="false"
jcrMandatory="false"
+        jcrOnParentVersion="IGNORE" jcrProtected="false" jcrMultiple="false" />
+		
+        <field-descriptor fieldName="b2" jcrName="b2" jcrType="String" jcrAutoCreated="true"
jcrMandatory="true"
+        jcrOnParentVersion="COPY" jcrProtected="true" jcrMultiple="true" />
+
+	</class-descriptor>
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C">
+		<!-- 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">
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="title" jcrName="graffito:title" />
+		<collection-descriptor fieldName="paragraphs" proxy="false" 
+		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.Paragraph"

+		                       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">
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="text" jcrName="graffito:text"/>
+	</class-descriptor>
+
+
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Main"
jcrNodeType="nt:unstructured">
+		<field-descriptor fieldName="path" path="true" />
+		<field-descriptor fieldName="text" jcrName="text" />
+		<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">
+		<field-descriptor fieldName="id" jcrName="graffito:id"  />
+		<field-descriptor fieldName="text" jcrName="graffito:text" />
+	</class-descriptor>
+</graffito-jcr>
+ 
\ No newline at end of file

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java?rev=375382&r1=375381&r2=375382&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
Mon Feb  6 13:34:45 2006
@@ -26,6 +26,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.objectconverter.impl.ObjectConverterImpl;
 import org.apache.portals.graffito.jcr.testmodel.A;
 import org.apache.portals.graffito.jcr.testmodel.B;
 
@@ -36,8 +37,6 @@
  */
 public class DigesterMapperImplTest extends TestCase
 {
-
-    
     /**
      * <p>Defines the test case name for junit.</p>
      * @param testName The test case name.
@@ -77,13 +76,14 @@
     {
         try
         {
-            DigesterMapperImpl mapper = new DigesterMapperImpl("./src/test-config/jcrmapping.xml");
+            DigesterMapperImpl mapper = new DigesterMapperImpl("./src/test-config/jcrmapping-testmappings.xml");
             assertNotNull("Mapper is null", mapper);
             
             ClassDescriptor classDescriptor = mapper.getClassDescriptor(A.class);
             assertNotNull("ClassDescriptor is null", classDescriptor);
             assertTrue("Invalid classname", classDescriptor.getClassName().equals(A.class.getName()));
             assertTrue("Invalid path field", classDescriptor.getPathFieldDescriptor().getFieldName().equals("path"));
+            assertEquals("Invalid mixins", "mixin:a", classDescriptor.getJcrMixinTypes()[0]
);
             
             FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor("a1");
             assertNotNull("FieldDescriptor is null", fieldDescriptor);
@@ -92,6 +92,10 @@
             BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor("b");
             assertNotNull("BeanDescriptor is null", beanDescriptor);
             assertTrue("Invalid jcrName for field b", beanDescriptor.getJcrName().equals("b"));
+            assertEquals("Invalid bean-descriptor inline", true, beanDescriptor.isInline());
+            assertEquals("Invalid bean default descriptor", 
+                         ObjectConverterImpl.class.getName(),
+                         beanDescriptor.getConverter());
             
             CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor("collection");
             assertNotNull("CollectionDescriptor is null", collectionDescriptor);



Mime
View raw message