incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r387951 - in /incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr: mapper/model/ClassDescriptor.java query/impl/FilterImpl.java query/impl/QueryManagerImpl.java
Date Wed, 22 Mar 2006 21:31:47 GMT
Author: clombart
Date: Wed Mar 22 13:31:45 2006
New Revision: 387951

URL: http://svn.apache.org/viewcvs?rev=387951&view=rev
Log:
Code clean-up

Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java?rev=387951&r1=387950&r2=387951&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/mapper/model/ClassDescriptor.java
Wed Mar 22 13:31:45 2006
@@ -348,14 +348,6 @@
 
 
     private void lookupInheritanceSettings() {
-//        if (null != this.superClassDescriptor) {
-//            if (this.jcrNodeType.equals(this.superClassDescriptor.jcrNodeType)) {
-//                this.extendsStrategy = NODETYPE_PER_HIERARCHY;
-//            }
-//            else {
-//                this.extendsStrategy = NODETYPE_PER_CONCRETECLASS;
-//            }
-//        }
     	     if ((null != this.superClassDescriptor) || (this.hasDescendants() ))
     	     {
     	    	       if (this.hasDiscriminatorField())

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java?rev=387951&r1=387950&r2=387951&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/FilterImpl.java
Wed Mar 22 13:31:45 2006
@@ -18,10 +18,7 @@
 package org.apache.portals.graffito.jcr.query.impl;
 
 
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java?rev=387951&r1=387950&r2=387951&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/query/impl/QueryManagerImpl.java
Wed Mar 22 13:31:45 2006
@@ -58,37 +58,7 @@
 		ClassDescriptor classDescriptor = mapper.getClassDescriptor(filter.getFilterClass()); 
 		if (classDescriptor.hasDiscriminatorField())
 		{
-			Filter discrininatorFilter = this.createFilter(query.getFilter().getFilterClass());
-			if ( ! classDescriptor.isAbstract())
-			{
-			    FieldDescriptor fieldDescriptor = classDescriptor.getDiscriminatorFieldDescriptor();
-		        discrininatorFilter.addEqualTo(fieldDescriptor.getFieldName(), filter.getFilterClass().getName());
-			}
-			
-			if (classDescriptor.hasDescendants())
-			{
-				
-			    	
-				Iterator  descendantDescriptorIterator = classDescriptor.getDescendantClassDescriptors().iterator();
-				ClassDescriptor descendantClassDescriptor = (ClassDescriptor)descendantDescriptorIterator.next();
-				FieldDescriptor fieldDescriptor = descendantClassDescriptor.getDiscriminatorFieldDescriptor();
-				 Filter descendantFilter = this.createFilter(query.getFilter().getFilterClass());			
 
-				 descendantFilter.addEqualTo(fieldDescriptor.getFieldName(), descendantClassDescriptor.getClassName());
-				 discrininatorFilter = discrininatorFilter.addOrFilter(descendantFilter);
-				 
-				while (descendantDescriptorIterator.hasNext())
-				{
-					 descendantFilter = this.createFilter(query.getFilter().getFilterClass());
-					
-					 descendantClassDescriptor = (ClassDescriptor)descendantDescriptorIterator.next();
-					  fieldDescriptor = descendantClassDescriptor.getDiscriminatorFieldDescriptor();
-					 descendantFilter.addEqualTo(fieldDescriptor.getFieldName(), descendantClassDescriptor.getClassName());
-					 discrininatorFilter =  discrininatorFilter.addOrFilter(descendantFilter);
-				}
-				
-			}
-			
-			
+			Filter discrininatorFilter = buildDiscriminatorFilter(query,  classDescriptor);
 			 filter = filter.addAndFilter(discrininatorFilter);
 		}
 		
@@ -121,6 +91,28 @@
 		
 		return jcrExp;
 		 
+	}
+
+	private Filter buildDiscriminatorFilter(Query query, ClassDescriptor classDescriptor) {
+		Filter discrininatorFilter = this.createFilter(query.getFilter().getFilterClass());
+		if ( ! classDescriptor.isAbstract())
+		{
+		    FieldDescriptor fieldDescriptor = classDescriptor.getDiscriminatorFieldDescriptor();
+		    discrininatorFilter.addEqualTo(fieldDescriptor.getFieldName(), classDescriptor.getClassName());
+		}
+		
+		if (classDescriptor.hasDescendants())
+		{
+			Iterator  descendantDescriptorIterator = classDescriptor.getDescendantClassDescriptors().iterator();
+			while (descendantDescriptorIterator.hasNext())
+			{
+				 ClassDescriptor descendantClassDescriptor = (ClassDescriptor)descendantDescriptorIterator.next();
+				 //Add subdescendant discriminator value
+				 discrininatorFilter =  discrininatorFilter.addOrFilter( this.buildDiscriminatorFilter(query,
descendantClassDescriptor));
+			}
+			
+		}
+		return discrininatorFilter;
 	}
 	
 	private String getNodeType(Filter filter)



Mime
View raw message