incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r407628 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: dtd/ java/org/apache/portals/graffito/jcr/mapper/model/ java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/ java/org/apache/portals/graffito/jcr/persistence/...
Date Thu, 18 May 2006 20:21:53 GMT
Author: clombart
Date: Thu May 18 13:21:52 2006
New Revision: 407628

URL: http://svn.apache.org/viewvc?rev=407628&view=rev
Log:
* Review the collection converter : the index used to build the node name was not necessary
* Starting the implementation of autoRetrieve, autoUpdate and autoInsert

Removed:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerQueryInheritanceConcreteClassTest.java
Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/dtd/graffito-jcr-mapping.dtd?rev=407628&r1=407627&r2=407628&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 Thu May 18 13:21:52
2006
@@ -89,6 +89,9 @@
     * 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.
+    * autoRetrieve : If false, the bean associated to this descriptor is not retrieved when
the main ojbect is retrieved
+    * autoUpdate : If false, the bean associated to this descriptor is not updated when the
main ojbect is updated
+    * autoInsert : If false, the bean associated to this descriptor is not inserted  when
the main ojbect is inserted    
     * 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
@@ -103,6 +106,9 @@
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
 	proxy (true | false) "false" 
+	autoRetrieve (true|false) "true"
+	autoUpdate (true|false) "true"
+	autoInsert (true|false) "true"	
 	inline (true | false) "false"
 	converter CDATA #IMPLIED
 	jcrNodeType CDATA #IMPLIED
@@ -118,12 +124,15 @@
     * fieldName : the field/attribute name (matching to the collection attribute)
     * jcrName : the jcr property name (optional). If it is not defined, fieldname is used
to specify the jcr node name
     * proxy : Use lazy loading or not. if true, this attributes is not loaded when the main
object is retrieve. it will be loaded when the get method is called.
+    * autoRetrieve : If false, the collection associated to this descriptor is not retrieved
when the main ojbect is retrieved
+    * autoUpdate : If false, the collection associated to this descriptor is not updated
when the main ojbect is updated
+    * autoInsert : If false, the collection associated to this descriptor is not inserted
 when the main ojbect is inserted    
     * elementClassName : contains a fully qualified class name.	This class is the Object
type of the persistent collection elements.
     * collectionClassName : contains a fully qualified class name. This class must be the
Java type of the Collection attribute. 	
                             This attribute must only specified if the attribute type is not
a java.util.Collection (or subclass). 
                             The declared class must implement ManageableCollection to let
the persistence engine handles this type of collection.
     * collectionConverter : The class name converter. This is the collection mapping strategy
to used. 
-                            If this attribute is not specify, the default collection mapping
strategy is used (DefaultCollectionConverterImpl)
+                            If this attribute is not specify, the default collection mapping
strategy is used (DefaultCollectionConverterImpl)                            
     * jcrNodeType: defines the child node type, optional
     * jcrAutoCreated (boolean) default is "false"
     * jcrMandatory (boolean) default is "false"
@@ -137,6 +146,9 @@
 	fieldName CDATA #REQUIRED
 	jcrName CDATA #IMPLIED 
 	proxy (true | false) "false"
+	autoRetrieve (true|false) "true"
+	autoUpdate (true|false) "true"
+	autoInsert (true|false) "true"	
 	elementClassName CDATA #REQUIRED
 	collectionClassName CDATA #IMPLIED
 	collectionConverter CDATA #IMPLIED

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/BeanDescriptor.java?rev=407628&r1=407627&r2=407628&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
Thu May 18 13:21:52 2006
@@ -32,6 +32,9 @@
     private String fieldName;
     private String jcrName;
     private boolean proxy;
+    private boolean autoRetrieve = true;
+    private boolean autoUpdate = true;
+    private boolean autoInsert = true;
     private boolean inline;
     private String converter;
     private BeanConverter beanConverter;
@@ -83,8 +86,33 @@
     public void setProxy(boolean proxy) {
         this.proxy = proxy;
     }
+       
+    
+    public boolean isAutoInsert() {
+		return autoInsert;
+	}
+
+	public void setAutoInsert(boolean autoInsert) {
+		this.autoInsert = autoInsert;
+	}
+
+	public boolean isAutoRetrieve() {
+		return autoRetrieve;
+	}
+
+	public void setAutoRetrieve(boolean autoRetrieve) {
+		this.autoRetrieve = autoRetrieve;
+	}
+
+	public boolean isAutoUpdate() {
+		return autoUpdate;
+	}
+
+	public void setAutoUpdate(boolean autoUpdate) {
+		this.autoUpdate = autoUpdate;
+	}
 
-    /**
+	/**
      * Are the current bean properties inlined in the parent
      * 
      * @return <tt>true</tt> if bean's properties are inlined in the parent node

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/CollectionDescriptor.java
Thu May 18 13:21:52 2006
@@ -31,6 +31,9 @@
      private String collectionConverterClassName;
      private String collectionClassName;
      private boolean proxy;
+     private boolean autoRetrieve = true;
+     private boolean autoUpdate = true;
+     private boolean autoInsert = true;     
      private String jcrNodeType;
      private boolean jcrAutoCreated;
      private boolean jcrMandatory;
@@ -101,7 +104,27 @@
         this.proxy = proxy;
     }
     
-    /**
+    
+    
+    public boolean isAutoInsert() {
+		return autoInsert;
+	}
+	public void setAutoInsert(boolean autoInsert) {
+		this.autoInsert = autoInsert;
+	}
+	public boolean isAutoRetrieve() {
+		return autoRetrieve;
+	}
+	public void setAutoRetrieve(boolean autoRetrieve) {
+		this.autoRetrieve = autoRetrieve;
+	}
+	public boolean isAutoUpdate() {
+		return autoUpdate;
+	}
+	public void setAutoUpdate(boolean autoUpdate) {
+		this.autoUpdate = autoUpdate;
+	}
+	/**
      * 
      * @return The collection converter class name 
      */

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImpl.java
Thu May 18 13:21:52 2006
@@ -50,10 +50,10 @@
  * Example - without an id attribute:
  *   /test (Main object containing the collection field )
  *     /mycollection (extra node used to store the entire collection)
- *          /collection-element1 (node used to store the first collection element)
+ *          /collection-element (node used to store the first collection element)
  *                /item-prop
  *                ....
- *          /collection-element2 (node used to store the second collection element)
+ *          /collection-element (node used to store the second collection element)
  *          ...
  *
  * Example - with an id attribute:
@@ -107,8 +107,7 @@
         
         ClassDescriptor elementClassDescriptor = mapper.getClassDescriptorByClass( ReflectionUtils.forName(collectionDescriptor.getElementClassName()));

 
-        Iterator collectionIterator = collection.getIterator();
-        int elementCollectionCount = 0;
+        Iterator collectionIterator = collection.getIterator();        
         while (collectionIterator.hasNext()) {
             Object item = collectionIterator.next();
             String elementJcrName = null;
@@ -119,9 +118,8 @@
                                                            .getFieldName();
                 elementJcrName = ReflectionUtils.getNestedProperty(item, idFieldName).toString();
             }
-            else {
-                elementCollectionCount++;
-                elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
+            else {                
+                elementJcrName = COLLECTION_ELEMENT_NAME;
             }
 
             objectConverter.insert(session, collectionNode, elementJcrName, item);
@@ -157,13 +155,11 @@
         }
 
         Iterator collectionIterator = collection.getIterator();
-        int elementCollectionCount = 0;
 
         Map updatedItems = new HashMap();
         while (collectionIterator.hasNext()) {
             Object item = collectionIterator.next();
 
-            elementCollectionCount++;
             String elementJcrName = null;
 
             if (elementClassDescriptor.hasIdField()) {
@@ -183,8 +179,7 @@
                 updatedItems.put(elementJcrName, item);
             }
             else {
-                elementCollectionCount++;
-                elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
+                elementJcrName = COLLECTION_ELEMENT_NAME ;
                 objectConverter.insert(session, collectionNode, elementJcrName, item);
             }
         }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImpl.java
Thu May 18 13:21:52 2006
@@ -51,14 +51,14 @@
  *
  *
  * If the collection element class contains an id (see the FieldDescriptor definition), this
id value is used to build the collection element node.
- * Otherwise, the element node name is a simple indexed constant.
+ * Otherwise, the element node name is a simple constant (collection-element)
  *
  * Example - without an id attribute:
  *   /test (Main object containing the collection field )
- *          /collection-element1 (node used to store the first collection element)
+ *          /collection-element (node used to store the first collection element)
  *                /item-prop
  *                ....
- *          /collection-element2 (node used to store the second collection element)
+ *          /collection-element (node used to store the second collection element)
  *          ...
  *
  * Example - with an id attribute:
@@ -104,8 +104,7 @@
         
         ClassDescriptor elementClassDescriptor = mapper.getClassDescriptorByClass( ReflectionUtils.forName(collectionDescriptor.getElementClassName()));
 
-        Iterator collectionIterator = collection.getIterator();
-        int elementCollectionCount = 0;
+        Iterator collectionIterator = collection.getIterator();        
         while (collectionIterator.hasNext()) {
             Object item = collectionIterator.next();
             String elementJcrName = null;
@@ -115,9 +114,8 @@
                 String idFieldName = elementClassDescriptor.getIdFieldDescriptor().getFieldName();
                 elementJcrName = ReflectionUtils.getNestedProperty(item, idFieldName).toString();
             }
-            else {
-                elementCollectionCount++;
-                elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
+            else {                
+                elementJcrName = COLLECTION_ELEMENT_NAME;
             }
 
             objectConverter.insert(session, parentNode, elementJcrName, item);
@@ -147,13 +145,10 @@
         }
 
         Iterator collectionIterator = collection.getIterator();
-        int elementCollectionCount = 0;
-
         Map updatedItems = new HashMap();
         while (collectionIterator.hasNext()) {
             Object item = collectionIterator.next();
-
-            elementCollectionCount++;
+        
             String elementJcrName = null;
 
             if (elementClassDescriptor.hasIdField()) {
@@ -172,7 +167,7 @@
                 updatedItems.put(elementJcrName, item);
             }
             else {
-                elementJcrName = COLLECTION_ELEMENT_NAME + elementCollectionCount;
+                elementJcrName = COLLECTION_ELEMENT_NAME;
                 objectConverter.insert(session, parentNode, elementJcrName, item);
             }
         }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
Thu May 18 13:21:52 2006
@@ -563,6 +563,11 @@
 		Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
 		while (beanDescriptorIterator.hasNext()) {
 			BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+			if  (! beanDescriptor.isAutoRetrieve())
+			{
+				continue;
+			}
+			
 			String beanName = beanDescriptor.getFieldName();
 			Class beanClass = ReflectionUtils.getPropertyType(object, beanName);
 			Object bean = null;
@@ -592,6 +597,11 @@
 		Iterator collectionDescriptorIterator = classDescriptor.getCollectionDescriptors().iterator();
 		while (collectionDescriptorIterator.hasNext()) {
 			CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+			if  (! collectionDescriptor.isAutoRetrieve())
+			{
+				continue;
+			}
+			
 			CollectionConverter collectionConverter = this.getCollectionConverter(session, collectionDescriptor);
 			Class collectionFieldClass = ReflectionUtils.getPropertyType(object, collectionDescriptor.getFieldName());
 			ManageableCollection collection = null;
@@ -615,6 +625,12 @@
 		Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
 		while (beanDescriptorIterator.hasNext()) {
 			BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+			
+			if  (! beanDescriptor.isAutoInsert())
+			{
+				continue;
+			}
+			
 			String jcrName = beanDescriptor.getJcrName();
 			Object bean = ReflectionUtils.getNestedProperty(object, beanDescriptor.getFieldName());
 			if (bean != null) {
@@ -641,6 +657,11 @@
 			Iterator beanDescriptorIterator = classDescriptor.getBeanDescriptors().iterator();
 			while (beanDescriptorIterator.hasNext()) {
 				BeanDescriptor beanDescriptor = (BeanDescriptor) beanDescriptorIterator.next();
+				if  (! beanDescriptor.isAutoUpdate())
+				{
+					continue;
+				}
+				
 				jcrName = beanDescriptor.getJcrName();
 				Object bean = ReflectionUtils.getNestedProperty(object, beanDescriptor.getFieldName());
 
@@ -688,6 +709,12 @@
 
 		while (collectionDescriptorIterator.hasNext()) {
 			CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+			
+			if  (! collectionDescriptor.isAutoInsert())
+			{
+				continue;
+			}
+			
 			CollectionConverter collectionConverter = this.getCollectionConverter(session, collectionDescriptor);
 			Object collection = ReflectionUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
 			ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);
@@ -701,6 +728,11 @@
 
 		while (collectionDescriptorIterator.hasNext()) {
 			CollectionDescriptor collectionDescriptor = (CollectionDescriptor) collectionDescriptorIterator.next();
+			if  (! collectionDescriptor.isAutoUpdate())
+			{
+				continue;
+			}
+			
 			CollectionConverter collectionConverter = this.getCollectionConverter(session, collectionDescriptor);
 			Object collection = ReflectionUtils.getNestedProperty(object, collectionDescriptor.getFieldName());
 			ManageableCollection manageableCollection = ManageableCollectionUtil.getManageableCollection(collection);

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml Thu
May 18 13:21:52 2006
@@ -56,7 +56,7 @@
 		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject"
/>	  	                                    
 		
 		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="name" jcrName="graffito:name" id="true" />
+		<field-descriptor fieldName="name" jcrName="graffito:name"  id="true" />
 		<bean-descriptor  fieldName="parentFolder" 						 
 						  converter="org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ParentBeanConverterImpl"
/>
 

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/repository/repository/nodetypes/custom_nodetypes.xml
Thu May 18 13:21:52 2006
@@ -49,7 +49,7 @@
     </supertypes>
     <propertyDefinition name="*" requiredType="undefined" autoCreated="false" mandatory="false"
onParentVersion="COPY" protected="false" multiple="false" />
     <propertyDefinition name="graffito:title" requiredType="String" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="false" multiple="false" />
-    <childNodeDefinition name="*" defaultPrimaryType="graffito:paragraph" autoCreated="false"
mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
+    <childNodeDefinition name="*" defaultPrimaryType="graffito:paragraph" autoCreated="false"
mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="true">
       <requiredPrimaryTypes>
         <requiredPrimaryType>graffito:paragraph</requiredPrimaryType>
       </requiredPrimaryTypes>

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
Thu May 18 13:21:52 2006
@@ -40,8 +40,7 @@
         suite.addTestSuite(PersistenceManagerBasicVersionningTest.class);
         suite.addTestSuite(PersistenceManagerInheritanceConcreteClassTest.class);
         suite.addTestSuite(PersistenceManagerInheritanceHierarchyTest.class);
-        suite.addTestSuite(PersistenceManagerInterfaceConcreteClassTest.class);
-        suite.addTestSuite(PersistenceManagerQueryInheritanceConcreteClassTest.class);
+        suite.addTestSuite(PersistenceManagerInterfaceConcreteClassTest.class);        
         suite.addTestSuite(PersistenceManagerInterfaceHierarchyTest.class);        
         suite.addTestSuite(PersistenceManagerIteratorQueryTest.class);
         suite.addTestSuite(PersistenceManagerMultiValueQueryTest.class);       

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
Thu May 18 13:21:52 2006
@@ -350,5 +350,96 @@
      }
 }
 
+public void testAdvancedQuery() {
+
+	try {
+		PersistenceManager persistenceManager = this.getPersistenceManager();
+
+		//---------------------------------------------------------------------------------------------------------
+		// Insert cmsobjects
+		//---------------------------------------------------------------------------------------------------------
		
+	    DocumentImpl document = new DocumentImpl();
+	    document.setPath("/document1");
+	    document.setName("document name 1");
+	    document.setContentType("plain/text"); 
+	    DocumentStream documentStream = new DocumentStream();
+	    documentStream.setEncoding("utf-8");
+	    documentStream.setContent("Test Content".getBytes());
+	    document.setDocumentStream(documentStream);        
+	    persistenceManager.insert(document);
+	    
+	    document = new DocumentImpl();
+	    document.setPath("/document2");        
+	    document.setName("document name 2");
+	    document.setContentType("plain/text"); 
+	    documentStream = new DocumentStream();
+	    documentStream.setEncoding("utf-8");
+	    documentStream.setContent("Test Content".getBytes());
+	    document.setDocumentStream(documentStream);       
+	    persistenceManager.insert(document);
+
+	    document = new DocumentImpl();
+	    document.setPath("/document3");        
+	    document.setName("document 3");
+	    document.setContentType("plain/text"); 
+	    documentStream = new DocumentStream();
+	    documentStream.setEncoding("utf-8");
+	    documentStream.setContent("Test Content 3".getBytes());
+	    document.setDocumentStream(documentStream);       
+	    persistenceManager.insert(document);
+	    
+	    FolderImpl folder = new FolderImpl();
+	    folder.setPath("/folder1");
+	    folder.setName("folder1");
+	    persistenceManager.insert(folder);
+
+
+	    document = new DocumentImpl();        
+	    document.setName("document4");
+	    document.setContentType("plain/text"); 
+	    documentStream = new DocumentStream();
+	    documentStream.setEncoding("utf-8");
+	    documentStream.setContent("Test Content 4".getBytes());
+	    document.setDocumentStream(documentStream);       
+
+	    FolderImpl subFolder = new FolderImpl();
+	    subFolder.setName("subfolder");
+	    
+	    folder = new FolderImpl();
+	    folder.setPath("/folder2");
+	    folder.setName("folder2");        
+	    folder.addChild(document);
+	    folder.addChild(subFolder);
+	    persistenceManager.insert(folder);               		
+
+	    
+		Atomic a = new Atomic();
+		a.setPath("/atomic");
+		a.setBooleanPrimitive(true);
+		persistenceManager.insert(a);
+
+		persistenceManager.save();
+
+		//---------------------------------------------------------------------------------------------------------

+		// Retrieve Folders found on the root level
+		//---------------------------------------------------------------------------------------------------------
		
+		QueryManager queryManager = persistenceManager.getQueryManager();
+		Filter filter = queryManager.createFilter(Folder.class);
+		//filter.addJCRExpression("")
+		Query query = queryManager.createQuery(filter);
+		filter.setScope("/");
+		Collection result = persistenceManager.getObjects(query);
+		assertEquals("Invalid number of folders found", result.size(), 2);
+		assertTrue("Invalid item in the collection", this.contains(result, "/folder1",FolderImpl.class));
+		assertTrue("Invalid item in the collection", this.contains(result, "/folder2", FolderImpl.class));
	
+		
+		
+	} catch (Exception e) {
+		e.printStackTrace();
+		fail();
+	}
+
+}
+
 	
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java?rev=407628&r1=407627&r2=407628&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java
Thu May 18 13:21:52 2006
@@ -127,34 +127,34 @@
 
 	}
 
-	public void testUnsupportedSameNameSiblings()
-	{
-		     PersistenceManager persistenceManager = getPersistenceManager();
-             try
-             {
-            	 
-            	 Page page = new Page();
-            	 page.setPath("/page");
-            	 page.setTitle("Page Title");            	 
-            	 persistenceManager.insert(page);
-            	 persistenceManager.save();
-            	 
-            	 Paragraph p1 = new Paragraph("para1");
-            	 p1.setPath("/page/paragraph");
-            	 persistenceManager.insert(p1);
-            	 
-            	 Paragraph p2 = new Paragraph("para1");
-            	 p2.setPath("/page/paragraph");
-            	 persistenceManager.insert(p2);
-                 fail();            	 
-            	 
-             }
-             catch(Exception e)
-             {
-    		            	 persistenceManager.remove("/page");
-            	 persistenceManager.save();
-             }
-	}
+//	public void testUnsupportedSameNameSiblings()
+//	{
+//		     PersistenceManager persistenceManager = getPersistenceManager();
+//             try
+//             {
+//            	 
+//            	 Page page = new Page();
+//            	 page.setPath("/page");
+//            	 page.setTitle("Page Title");            	 
+//            	 persistenceManager.insert(page);
+//            	 persistenceManager.save();
+//            	 
+//            	 Paragraph p1 = new Paragraph("para1");
+//            	 p1.setPath("/page/paragraph");
+//            	 persistenceManager.insert(p1);
+//            	 
+//            	 Paragraph p2 = new Paragraph("para1");
+//            	 p2.setPath("/page/paragraph");
+//            	 persistenceManager.insert(p2);
+//             fail();            	 
+//            	 
+//             }
+//             catch(Exception e)
+//             {
+//    		            	 persistenceManager.remove("/page");
+//            	 persistenceManager.save();
+//             }
+//	}
 	
 	
 	private void importData(Date date)



Mime
View raw message