incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r307132 [1/2] - in /incubator/graffito/trunk/jcr-mapping/src: java/org/apache/portals/graffito/jcr/exception/ java/org/apache/portals/graffito/jcr/persistence/ java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/ java/org/a...
Date Fri, 07 Oct 2005 14:30:19 GMT
Author: clombart
Date: Fri Oct  7 07:29:44 2005
New Revision: 307132

URL: http://svn.apache.org/viewcvs?rev=307132&view=rev
Log:
* review pck structure
* Add interfaces for ObjectConverter and AtomicTypeConverter (& drop unused methods)
* Add more unit test (search) 
* Add method getObjectIterator (in the PersistenceManager)

Added:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/test-config/repository-old.xml
    incubator/graffito/trunk/jcr-mapping/src/test/log4j.properties
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerBeanQueryTest.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java
Removed:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AbstarctAtomicTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/BinaryTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/BooleanTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/ByteArrayTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/CalendarTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/DoubleTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/IntTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/LongTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/StringTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/TimestampTypeConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/UtilDateTypeConverter.java
Modified:
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/Filter.java
    incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
    incubator/graffito/trunk/jcr-mapping/src/test-config/jcrmapping.xml
    incubator/graffito/trunk/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java
    incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/exception/IncorrectAtomicTypeException.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.exception;
+
+/**
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public class IncorrectAtomicTypeException extends JcrMappingException
+{
+
+	public IncorrectAtomicTypeException()
+	{
+		super();
+		
+	}
+
+	public IncorrectAtomicTypeException(String message, Throwable nested)
+	{
+		super(message, nested);
+		
+	}
+
+	public IncorrectAtomicTypeException(String message)
+	{
+		super(message);
+		
+	}
+
+	public IncorrectAtomicTypeException(Throwable nested)
+	{
+		super(nested);
+		
+	}
+
+
+
+}

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java?rev=307132&r1=307131&r2=307132&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/PersistenceManager.java Fri Oct  7 07:29:44 2005
@@ -16,6 +16,7 @@
 package org.apache.portals.graffito.jcr.persistence;
 
 import java.util.Collection;
+import java.util.Iterator;
 
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
 import org.apache.portals.graffito.jcr.query.Query;
@@ -79,6 +80,16 @@
      * 
      */
     public Collection getObjects(Query query) throws JcrMappingException;
+    
+    
+    /**
+     * Retrieve some pojo objects matching to a query. 
+     *  
+     * @param query The Graffito Query object used to seach the objects
+     * @return an iterator of objects found
+     * @throws JcrMappingException
+     */
+    public Iterator getObjectIterator (Query query) throws JcrMappingException;
     
     /**
      * Close the JCR session    

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/AtomicTypeConverter.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * AtomicTypeConverter interface.
+ * 
+ * The Object converter used atomic type converters to map atomic fields to JCR Value object.
+ * Amotic fields are primitive java types and their wrapper classes.
+ * 
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ *
+ */
+public interface AtomicTypeConverter
+{
+
+	/**
+	 * Convert an object into a JCR value.
+	 * 
+	 * @param propValue The object to convert
+	 * @return the matching JCR value
+	 * @throws IncorrectAtomicTypeException when the object is not a correct atomic type 
+	 */
+	public Value getValue(Object object) throws IncorrectAtomicTypeException;
+
+	/**
+	 * Convert a jcr property into an object
+	 * 
+	 * @param node The jcr node 
+	 * @param jcrPropName the node property name
+	 * @return the matching object
+	 * @throws IncorrectAtomicTypeException when it is not possible to convert the JCR property
+	 */
+	public Object getObject(Node node, String jcrPropName)  throws IncorrectAtomicTypeException;
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/AbstractAtomicTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
+
+/**
+ * Abstract implementation for {@link org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter}
+ *  
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public abstract class AbstractAtomicTypeConverterImpl implements AtomicTypeConverter
+{
+
+	private ValueFactory valueFactory;
+
+	public AbstractAtomicTypeConverterImpl(ValueFactory factory)
+	{
+		super();
+		valueFactory = factory;
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public abstract Value getValue(Object propValue)  throws IncorrectAtomicTypeException;
+
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public abstract Object getObject(Node node, String jcrPropName)  throws IncorrectAtomicTypeException;
+
+	/**
+	 * Set the JCR value factory
+	 * 
+	 * @param valueFactory The value factory to set
+	 */
+	void setValueFactory(ValueFactory valueFactory)
+	{
+		this.valueFactory = valueFactory;
+	}
+
+	/**	
+	 * @return the JCR value factory 
+	 */
+	public ValueFactory getValueFactory()
+	{
+		return this.valueFactory;
+	}
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BinaryTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import java.io.InputStream;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * Binary Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class BinaryTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+	
+	public BinaryTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+		
+	}
+
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+    public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+    {
+        if (propValue == null)
+        {
+            return null;
+        }
+        return this.getValueFactory().createValue((InputStream) propValue);
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+     */
+    public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+    {
+    	
+        try
+		{
+        	
+			if (node.hasProperty(jcrPropName) == true)
+			{
+			    return node.getProperty(jcrPropName).getStream();
+			}
+			else
+			{
+			    return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName , e);
+		}
+    }
+
+
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/BooleanTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * Boolean Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class BooleanTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public BooleanTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		boolean value = ((Boolean) propValue).booleanValue();
+		return this.getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				boolean aBoolean = node.getProperty(jcrPropName).getBoolean();
+				return new Boolean(aBoolean);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/ByteArrayTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * Byte Array Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class ByteArrayTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public ByteArrayTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		String value = new String((byte[]) propValue);
+		return getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				byte[] value = node.getProperty(jcrPropName).getString().getBytes();
+				return value;
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/CalendarTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import java.util.Calendar;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * Calendar Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class CalendarTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public CalendarTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		return this.getValueFactory().createValue(((Calendar) propValue).getTimeInMillis());
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName)  throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				Calendar calendar = Calendar.getInstance();
+				calendar.setTimeInMillis(node.getProperty(jcrPropName).getLong());
+				return calendar;
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/DoubleTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * Double Type Converter 
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class DoubleTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public DoubleTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		double value = ((Double) propValue).doubleValue();
+		return this.getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				double beanPropValue = node.getProperty(jcrPropName).getDouble();
+				return new Double(beanPropValue);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/IntTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * Int Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class IntTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public IntTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		long value = ((Integer) propValue).intValue();
+		return this.getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node,
+	 *      java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				int beanPropValue = (int) node.getProperty(jcrPropName).getLong();
+				return new Integer(beanPropValue);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/LongTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * Long Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class LongTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public LongTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+
+		long value = ((Long) propValue).longValue();
+		return this.getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				long beanPropValue = node.getProperty(jcrPropName).getLong();
+				return new Long(beanPropValue);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/StringTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * String Type Converter 
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class StringTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public StringTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		return this.getValueFactory().createValue((String) propValue);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				return node.getProperty(jcrPropName).getString();
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+
+	}
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/TimestampTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import java.sql.Timestamp;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * 
+ * Timestamp Type Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class TimestampTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public TimestampTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue) throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+			return null;
+		long value = ((Timestamp) propValue).getTime();
+		return this.getValueFactory().createValue(value);
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName) throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				long beanPropValue = node.getProperty(jcrPropName).getLong();
+				return new Timestamp(beanPropValue);
+			}
+			else
+			{
+				return null;
+			}
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+	}
+
+}

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/atomictypeconverter/impl/UtilDateTypeConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.atomictypeconverter.impl;
+
+import java.util.Date;
+
+import javax.jcr.Node;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+
+import org.apache.portals.graffito.jcr.exception.IncorrectAtomicTypeException;
+
+/**
+ * Util Date Converter
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ * 
+ */
+public class UtilDateTypeConverterImpl extends AbstractAtomicTypeConverterImpl
+{
+
+	public UtilDateTypeConverterImpl(ValueFactory factory)
+	{
+		super(factory);
+
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getValue(java.lang.Object)
+	 */
+	public Value getValue(Object propValue)  throws IncorrectAtomicTypeException
+	{
+		if (propValue == null)
+		{
+			return null;
+		}
+		return this.getValueFactory().createValue(((java.util.Date) propValue).getTime());
+	}
+
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter#getObject(javax.jcr.Node, java.lang.String)
+	 */
+	public Object getObject(Node node, String jcrPropName)  throws IncorrectAtomicTypeException
+	{
+		try
+		{
+			if (node.hasProperty(jcrPropName) == true)
+			{
+				long time = node.getProperty(jcrPropName).getLong();
+				Date date = new Date(time);
+
+				return date;
+			}
+			else
+			{
+				return null;
+			}
+
+		}
+		catch (Exception e)
+		{
+			throw new IncorrectAtomicTypeException("Impossible to convert the property : " + jcrPropName, e);
+		}
+
+	}
+
+}

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=307132&r1=307131&r2=307132&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -123,7 +123,7 @@
                     elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
                 }
 
-                objectConverter.insertNode(session, collectionNode, elementJcrName, item);
+                objectConverter.insert(session, collectionNode, elementJcrName, item);
             }
         }
         catch (Exception e)
@@ -192,12 +192,12 @@
                     // Update existing JCR Nodes
                     if (collectionNode.hasNode(elementJcrName))
                     {
-                        objectConverter.updateNode(session, collectionNode, elementJcrName, item);
+                        objectConverter.update(session, collectionNode, elementJcrName, item);
                     }
                     else
                     {
                         // Add new collection elements
-                        objectConverter.insertNode(session, collectionNode, elementJcrName, item);
+                        objectConverter.insert(session, collectionNode, elementJcrName, item);
                     }
                     
                     updatedItems.put(elementJcrName, item);
@@ -208,7 +208,7 @@
 
                     elementCollectionCount++;
                     elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
-                    objectConverter.insertNode(session, collectionNode, elementJcrName, item);
+                    objectConverter.insert(session, collectionNode, elementJcrName, item);
                 }
 
             }

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java?rev=307132&r1=307131&r2=307132&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java Fri Oct  7 07:29:44 2005
@@ -113,7 +113,7 @@
                     elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
                 }
 
-                objectConverter.insertNode(session, parentNode, elementJcrName, item);
+                objectConverter.insert(session, parentNode, elementJcrName, item);
             }
         }
         catch (Exception e)
@@ -167,12 +167,12 @@
                     // Update existing JCR Nodes
                     if (parentNode.hasNode(elementJcrName))
                     {
-                        objectConverter.updateNode(session, parentNode, elementJcrName, item);
+                        objectConverter.update(session, parentNode, elementJcrName, item);
                     }
                     else
                     {
                         // Add new collection elements
-                        objectConverter.insertNode(session, parentNode, elementJcrName, item);
+                        objectConverter.insert(session, parentNode, elementJcrName, item);
                     }
                     
                     updatedItems.put(elementJcrName, item);
@@ -182,7 +182,7 @@
                 {
                     
                     elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
-                    objectConverter.insertNode(session, parentNode, elementJcrName, item);
+                    objectConverter.insert(session, parentNode, elementJcrName, item);
                 }
 
             }

Added: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java?rev=307132&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/ObjectIterator.java Fri Oct  7 07:29:44 2005
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * 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.impl;
+
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Session;
+
+import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
+
+
+/**
+ * ObjectIterator is a wrapper class for NodeIterator
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class ObjectIterator implements Iterator
+{
+
+	private NodeIterator nodeIterator;
+
+	private Class objectClass;
+
+	private Session session;
+
+	private ObjectConverter objectConverter;
+
+	
+	
+	public ObjectIterator(NodeIterator iterator, Class class1, ObjectConverter converter, Session session)
+	{
+		nodeIterator = iterator;
+		objectClass = class1;
+		objectConverter = converter;
+		this.session = session;
+	}
+
+	public boolean hasNext()
+	{
+		return nodeIterator.hasNext();
+	}
+
+	public Object next() 
+	{
+
+		try
+		{
+			Node node = nodeIterator.nextNode();
+			return objectConverter.getObject(session, objectClass, node.getPath());
+		}
+		catch (Exception e)
+		{
+           return null;			
+		}
+
+	}
+
+	public void remove()
+	{
+		nodeIterator.remove();
+	}
+
+}

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?rev=307132&r1=307131&r2=307132&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java Fri Oct  7 07:29:44 2005
@@ -17,6 +17,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
 
 import javax.jcr.Item;
@@ -32,6 +33,7 @@
 import org.apache.portals.graffito.jcr.mapper.Mapper;
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
 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.Query;
 
 /** Interface that specifies howto interact with a jcr repository (JCR broker).
@@ -75,7 +77,7 @@
 		try
 		{
 			this.session = session;
-			this.objectConverter = new ObjectConverter(mapper, atomicTypeConverters);
+			this.objectConverter = new ObjectConverterImpl(mapper, atomicTypeConverters);
 			this.queryManager = queryManager;
 		}
 		catch (Exception e)
@@ -193,8 +195,7 @@
 
 			String jcrExpression = this.queryManager.buildJCRExpression(query);
 			log.debug("Get Object with expression : " + jcrExpression);
-			
-				
+						
 			javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(jcrExpression, javax.jcr.query.Query.XPATH);
 			QueryResult queryResult = jcrQuery.execute();
 			NodeIterator nodeIterator = queryResult.getNodes();
@@ -203,6 +204,7 @@
 			while (nodeIterator.hasNext())
 			{
 				Node node = nodeIterator.nextNode();
+				log.debug("Node found : " + node.getPath());
 				result.add(objectConverter.getObject(session, query.getFilter().getFilterClass(), node.getPath()));
 			}
 
@@ -214,6 +216,30 @@
 		}
 	}
 
+	/**
+	 * 
+	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObjectIterator(org.apache.portals.graffito.jcr.query.Query)
+	 */
+	public Iterator getObjectIterator(Query query) throws JcrMappingException
+	{
+		try
+		{
+
+			String jcrExpression = this.queryManager.buildJCRExpression(query);
+			log.debug("Get Object with expression : " + jcrExpression);
+						
+			javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(jcrExpression, javax.jcr.query.Query.XPATH);
+			QueryResult queryResult = jcrQuery.execute();
+			NodeIterator nodeIterator = queryResult.getNodes();
+			return new ObjectIterator(nodeIterator, query.getFilter().getFilterClass(), this.objectConverter, this.session);
+			
+		}
+		catch (RepositoryException e)
+		{
+			throw new JcrMappingException("Impossible to get the object collection", e);
+		}
+	}	
+	
 	/**
 	 * 
 	 * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#logout()

Modified: incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java?rev=307132&r1=307131&r2=307132&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java (original)
+++ incubator/graffito/trunk/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/ObjectConverter.java Fri Oct  7 07:29:44 2005
@@ -15,455 +15,72 @@
  */
 package org.apache.portals.graffito.jcr.persistence.objectconverter;
 
-import java.lang.reflect.InvocationTargetException;
-import java.util.Iterator;
-import java.util.Map;
-
 import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-import javax.jcr.nodetype.PropertyDefinition;
 
-import org.apache.commons.beanutils.ConstructorUtils;
-import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.portals.graffito.jcr.exception.JcrMappingException;
-import org.apache.portals.graffito.jcr.mapper.Mapper;
-import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
-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.atomictypeconverter.AbstarctAtomicTypeConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
-import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.DefaultCollectionConverterImpl;
-import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
+
 
 /**
- * Convert any kind of bean by using the xml mapping file
+ * Convert any kind of bean into JCR nodes & properties
  * 
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
  * @version $Id: Exp $
  */
-public class ObjectConverter
+public interface ObjectConverter
 {
-    private Mapper mapper;
-    private Map atomicTypeConverters;
-
-    public ObjectConverter(Mapper mapper, Map atomicTypeConverters)
-    {
-        this.mapper = mapper;
-        this.atomicTypeConverters = atomicTypeConverters;
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.converter.Converter#insert(javax.jcr.Session, java.lang.String, java.lang.Object)
-     */
-    public void insert(Session session, String path, Object object) throws JcrMappingException
-    {
-        try
-        {
-            String parentPath = RepositoryUtil.getParentPath(path);
-            String nodeName = RepositoryUtil.getNodeName(path);
-            Node parentNode = (Node) session.getItem(parentPath);
-            this.insertNode(session, parentNode, nodeName, object);            
-            parentNode.save();
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the object at " + path, e);
-        }
-
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.converter.Converter#update(javax.jcr.Session, java.lang.String, java.lang.Object)
-     */
-    public void update(Session session, String path, Object object) throws JcrMappingException
-    {
-        try
-        {
-            String parentPath = RepositoryUtil.getParentPath(path);
-            String nodeName = RepositoryUtil.getNodeName(path);
-            Node parentNode = (Node) session.getItem(parentPath);
-            this.updateNode(session, parentNode, nodeName, object);
-            parentNode.save();
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the object at " + path, e);
-        }
-    }
-
-    /**
-     * 
-     * @see org.apache.portals.graffito.jcr.converter.Converter#getObject(javax.jcr.Session, java.lang.Class, java.lang.String)
-     */
-    public Object getObject(Session session, Class clazz, String path) throws JcrMappingException
-    {
-
-        try
-        {
-            
-            if (! session.itemExists(path))
-            {
-                return null;
-            }
-            
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(clazz);
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + clazz.getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-
-            Node node = (Node) session.getItem(path);
-            Object object = clazz.newInstance();
-
-            retrieveSimpleFields(classDescriptor, node, object);
-            retrieveBeanFields(session, path, classDescriptor, object);
-            retrieveCollectionFields(session, classDescriptor, node, object);
-            
-            return object;
-
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to get the object at " + path, e);
-        }
-    }
-
-    /**
-     * @param classDescriptor
-     * @param node
-     * @param object
-     * @throws PathNotFoundException
-     * @throws RepositoryException
-     * @throws ValueFormatException
-     * @throws JcrMappingException
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
-     */
-    private void retrieveSimpleFields(ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, ValueFormatException, JcrMappingException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
-    {
-        Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
-        
-        while (fieldDescriptorIterator.hasNext())
-        {
-            FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-            String fieldName = fieldDescriptor.getFieldName();
-            String propertyName = fieldDescriptor.getJcrName();
-            
-            AbstarctAtomicTypeConverter converter = (AbstarctAtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
-            Object fieldValue = converter.getJavaObjectFromJcr(node, propertyName);
-            
-            PropertyUtils.setNestedProperty(object, fieldName, fieldValue);
-        }        
-    }    
-    
+	/**
+	 * Insert the object 
+	 * 
+	 * @param session the JCR session 
+	 * @param path the JCR path 
+	 * @param object the object to insert
+	 * @throws JcrMappingException when it is not possible to insert the object
+	 */
+    public void insert(Session session, String path, Object object) throws JcrMappingException;
+    
+	/**
+	 * Update the object 
+	 * 
+	 * @param session the JCR session 
+	 * @param path the JCR path 
+	 * @param object the object to update
+	 * @throws JcrMappingException when it is not possible to update the object
+	 */    
+    public void update(Session session, String path, Object object) throws JcrMappingException;
     
     /**
-     * @param session
-     * @param path
-     * @param classDescriptor
-     * @param object
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
-     * @throws JcrMappingException
-     */
-    private void retrieveBeanFields(Session session, String path, ClassDescriptor classDescriptor, Object object) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, JcrMappingException
-    {
-        Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-        while (beanDescriptorIterator.hasNext())
-        {
-            BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-            String beanName = beanDescriptor.getFieldName();
-            Class beanClass = PropertyUtils.getPropertyDescriptor(object, beanName).getPropertyType();
-            Object bean = this.getObject(session, beanClass, path + "/" + beanDescriptor.getJcrName());
-            PropertyUtils.setNestedProperty(object, beanName, bean);
-        }
-    }
-
-    
-    /**
-     * @param session
-     * @param classDescriptor
-     * @param node
-     * @param object
-     * @throws PathNotFoundException
-     * @throws RepositoryException
+     * Retrieve an object from the JCR repo
+     * 
+     * @param session The JCR session 
+     * @param clazz The class assigned to the object to retrieve
+     * @param path the JCR path
+     * @return The object found
      * @throws JcrMappingException
-     * @throws ClassNotFoundException
-     * @throws IllegalAccessException
-     * @throws InvocationTargetException
-     * @throws NoSuchMethodException
      */
-    private void retrieveCollectionFields(Session session, ClassDescriptor classDescriptor, Node node, Object object) throws PathNotFoundException, RepositoryException, JcrMappingException, ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
-    {
-        Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-        while(collectionDescriptorIterator.hasNext())
-        {
-            CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-            CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-            Class collectionFieldClass = PropertyUtils.getPropertyDescriptor(object, collectionDescriptor.getFieldName()).getPropertyType();
-            ManageableCollection collection = collectionConverter.getCollection(session, node, collectionDescriptor, collectionFieldClass );
-            PropertyUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), collection);
-        }
-    }
-
-    public void insertNode(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException
-    {
-        try
-        {
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-            String jcrNodeType = classDescriptor.getJcrNodeType();
-            if (jcrNodeType == null || jcrNodeType.equals(""))
-            {
-                throw new JcrMappingException("Undefined node type for  " + parentNode);
-            }
-
-            Node objectNode = null;
-            objectNode = parentNode.addNode(nodeName, jcrNodeType);
-
-            storeSimpleFields(object, classDescriptor, objectNode);
-            insertBeanFields(session, object, classDescriptor, objectNode);            
-            insertCollectionFields(session, object, classDescriptor, objectNode);
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to add the node : " + parentNode, e);
-        }
-
-    }
-
-    public void updateNode(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException
-    {
-        try
-        {
-            ClassDescriptor classDescriptor = mapper.getClassDescriptor(object.getClass());
-            if (classDescriptor == null) 
-            {
-                throw new JcrMappingException("Class of type: " + object.getClass().getName() + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing" );
-            }
-            
-            String jcrNodeType = classDescriptor.getJcrNodeType();
-            if (jcrNodeType == null || jcrNodeType.equals(""))
-            {
-                throw new JcrMappingException("Undefined node type for  " + parentNode);
-            }
-
-            Node objectNode = null;
-            objectNode = parentNode.getNode(nodeName);
-
-            storeSimpleFields(object, classDescriptor, objectNode);
-            updateBeanFields(session, object, classDescriptor, objectNode);            
-            updateCollectionFields(session, object, classDescriptor, objectNode);
-            
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to add the node : " + parentNode, e);
-        }
-
-    }    
+    public Object getObject(Session session, Class clazz, String path) throws JcrMappingException;
     
-    private void insertBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-            while (beanDescriptorIterator.hasNext())
-            {
-                BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-                String jcrName = beanDescriptor.getJcrName();
-                Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
-                if (bean != null)
-                {
-                    this.insertNode(session, objectNode, jcrName, bean);
-                }
-
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }
     
-    private void updateBeanFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
-            while (beanDescriptorIterator.hasNext())
-            {
-                BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
-                String jcrName = beanDescriptor.getJcrName();
-                Object bean = PropertyUtils.getNestedProperty(object, beanDescriptor.getFieldName());
-                
-                // if the bean is null, remove existing node
-                if ((bean == null))
-                {
-                   if (objectNode.hasNode(jcrName))
-                   {
-                       objectNode.getNode(jcrName).remove();
-                   }
-                }
-                else
-                {
-                   this.updateNode(session, objectNode, jcrName, bean);
-                }
+	/**
+	 * Insert the object 
+	 * 
+	 * @param session the JCR session 
+	 * @param parentNode The parent node used to store the new JCR element (object) 
+	 * @param nodeName The node name used to store the object
+	 * @param object the object to insert
+	 * @throws JcrMappingException when it is not possible to insert the object
+	 */
+    public void insert(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException;
+    
+	/**
+	 * Update the object 
+	 * 
+	 * @param session the JCR session 
+	 * @param parentNode The parent node used to store the new JCR element (object) 
+	 * @param nodeName The node name used to store the object
+	 * @param object the object to update
+	 * @throws JcrMappingException when it is not possible to update the object
+	 */    
+    public void update(Session session, Node parentNode, String nodeName, Object object) throws JcrMappingException;
 
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }    
-    
-    private void insertCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-            while (collectionDescriptorIterator.hasNext())
-            {
-                CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-                CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-                Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
-                ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
-                collectionConverter.insertCollection(session, objectNode, collectionDescriptor, manageableCollection);
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the collection fields", e);
-        }
-        
-    }    
-    
-    private void updateCollectionFields(Session session, Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
-            while (collectionDescriptorIterator.hasNext())
-            {
-                CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
-                CollectionConverter collectionConverter = this.getCollectionConverter(collectionDescriptor);
-                Object collection = PropertyUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
-                ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
-                collectionConverter.updateCollection(session, objectNode, collectionDescriptor, manageableCollection);
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-        
-    }      
-
-    private void storeSimpleFields(Object object, ClassDescriptor classDescriptor, Node objectNode) throws JcrMappingException
-    {
-        try
-        {
-            Iterator fieldDescriptorIterator = classDescriptor.getFieldDescriptors().iterator();
-            while (fieldDescriptorIterator.hasNext())
-            {
-                FieldDescriptor fieldDescriptor = (FieldDescriptor) fieldDescriptorIterator.next();
-                String fieldName = fieldDescriptor.getFieldName();
-                String jcrName = fieldDescriptor.getJcrName();                
-                
-                // Check if the node property is "autocreated"
-                boolean autoCreated = false;
-                
-                if (objectNode.hasProperty(jcrName))
-                {
-                      autoCreated = objectNode.getProperty(jcrName).getDefinition().isAutoCreated();
-                }
-                
-               // All auto created JCR properties are ignored
-                if (! autoCreated)
-                {
-                   Object fieldValue = PropertyUtils.getNestedProperty(object, fieldName);                
-                                   
-                   AbstarctAtomicTypeConverter converter = (AbstarctAtomicTypeConverter) atomicTypeConverters.get(PropertyUtils.getPropertyType(object, fieldName));
-                   Value value = converter.getJcrValueFromJavaObject(fieldValue);
-                   // Check if mandatory property are not null
-                   this.checkMandatoryProperty(objectNode, fieldDescriptor, value);
-                   
-                   objectNode.setProperty(jcrName, value);
-                }
-                
-                                               
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to store the bean fields", e);
-        }
-    }
-    
-    private CollectionConverter getCollectionConverter(CollectionDescriptor collectionDescriptor) throws JcrMappingException
-    {
-        
-         try
-        {
-            String className = collectionDescriptor.getCollectionConverterClassName();
-             if (className == null)
-             {
-                 return new DefaultCollectionConverterImpl(this, this.mapper);
-             }
-             else
-             {
-                 Class converterClass = Class.forName(className);
-                 Object[] param  = {this, this.mapper};
-                 return (CollectionConverter) ConstructorUtils.invokeConstructor(converterClass, param);
-             }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to get the collection descriptor for " + collectionDescriptor.getCollectionConverterClassName(), e); 
-        }
-       
-    }
-    
-    private void checkMandatoryProperty(Node objectNode, FieldDescriptor fieldDescriptor, Value value ) throws JcrMappingException
-    {
-        try
-        {
-            PropertyDefinition[] propertyDefinitions = objectNode.getPrimaryNodeType().getDeclaredPropertyDefinitions();
-            for (int i = 0; i < propertyDefinitions.length; i++)
-            {
-                PropertyDefinition definition = propertyDefinitions[i];
-                if (definition.getName().equals(fieldDescriptor.getJcrName()) && definition.isMandatory()
-                        && definition.isAutoCreated() == false && value == null)
-                {
-                    throw new JcrMappingException("Class of type:" + fieldDescriptor.getClassDescriptor().getClassName()
-                            + " has property: " + fieldDescriptor.getFieldName() + " declared as JCR property: "
-                            + fieldDescriptor.getJcrName() + " This property is mandatory but property in bean has value null");
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            throw new JcrMappingException("Impossible to check mandatory property" , e);
-        }
-    }
 }



Mime
View raw message