luetzkendorf    2004/11/01 09:58:02

  Modified:    src/share/org/apache/slide/search/basic
                        BasicQueryEnvelope.java BasicQueryScope.java
                        QueryTree.java
               src/share/org/apache/slide/search/basic/expression
                        CompareExpression.java
  Log:
  fixes for a bub that makes wome of the DASL\functional\orderby\DAV\twoStores*
  testcases fail
  
  Revision  Changes    Path
  1.12      +30 -25    
jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryEnvelope.java
  
  Index: BasicQueryEnvelope.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryEnvelope.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- BasicQueryEnvelope.java   28 Jul 2004 09:35:02 -0000      1.11
  +++ BasicQueryEnvelope.java   1 Nov 2004 17:58:02 -0000       1.12
  @@ -42,15 +42,13 @@
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.store.AbstractStore ;
   
  +import java.util.Collections;
   import java.util.HashSet;
   import java.util.Set;
   import java.util.HashMap;
   import java.util.Map;
  -//import java.util.ArrayList;
  -//import java.util.List;
   import java.util.Iterator;
   import java.util.Enumeration;
  -import java.util.StringTokenizer;
   
   
   /**
  @@ -235,10 +233,11 @@
       private QueryScope calculateSubQueryScope (Scope scope) {
           int relDepth = queryTree.relativeDepth (scope);
           int subQueryDepth;
  -        if (queryTree.hasChildren (scope)) {
  -            subQueryDepth = 1;
  -        }
  -        else if (queryDepth == QueryScope.DEPTH_INFINITY) {
  +//        if (queryTree.hasChildren (scope)) {
  +//            subQueryDepth = 1;
  +//        }
  +//        else 
  +        if (queryDepth == QueryScope.DEPTH_INFINITY) {
               subQueryDepth = QueryScope.DEPTH_INFINITY;
           }
           else {
  @@ -250,25 +249,31 @@
           Set inclSet = topLevelQueryScope.getIncludeSet();
           Set exclSet = topLevelQueryScope.getExcludeSet();
           
  -        QueryScope queryScope = new BasicQueryScope
  -            (contextPath, subQueryDepth, inclSet, exclSet);
  +        QueryScope queryScope;
  +        if (queryTree.hasChildren (scope)) {
  +            queryScope = new BasicQueryScope(contextPath, subQueryDepth, 
  +                    inclSet, exclSet, queryTree.getChildren(scope));
  +        } else {
  +            queryScope = new BasicQueryScope(contextPath, subQueryDepth, 
  +                    inclSet, exclSet, Collections.EMPTY_SET);
  +        }
           
           return queryScope;
       }
       
       
  -    /**
  -     * Method getDepthOfHRef
  -     *
  -     * @param    href                a  String
  -     *
  -     * @return   an int
  -     *
  -     */
  -    private int getDepthOfHRef (String href) {
  -        StringTokenizer st = new StringTokenizer (href, "/");
  -        return st.countTokens();
  -    }
  +//    /**
  +//     * Method getDepthOfHRef
  +//     *
  +//     * @param    href                a  String
  +//     *
  +//     * @return   an int
  +//     *
  +//     */
  +//    private int getDepthOfHRef (String href) {
  +//        StringTokenizer st = new StringTokenizer (href, "/");
  +//        return st.countTokens();
  +//    }
       
       
       /**
  
  
  
  1.14      +27 -11    
jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryScope.java
  
  Index: BasicQueryScope.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQueryScope.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BasicQueryScope.java      28 Jul 2004 09:35:02 -0000      1.13
  +++ BasicQueryScope.java      1 Nov 2004 17:58:02 -0000       1.14
  @@ -24,6 +24,7 @@
   package org.apache.slide.search.basic;
   
   import java.net.URL;
  +import java.util.Collections;
   import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Set;
  @@ -55,12 +56,14 @@
       /** indicates if this scope is a collection */
       private boolean isCollection = true;
       
  -    /** holds hrefs, that shall be excluded from search. */
  -    private Set excludedScopes = new HashSet ();
  -    
  +    /** 
  +     * holds [EMAIL PROTECTED] org.apache.slide.common.Scope}s, that shall be 
excluded 
  +     * from search. 
  +     */
  +    private Set excludedScopes = null;
       
  -    private Set includeSet = new HashSet ();
  -    private Set excludeSet = new HashSet ();
  +    private Set includeSet = null;
  +    private Set excludeSet = null;
       
       /**
        * Constructs a scope
  @@ -76,11 +79,12 @@
        *
        * @param      propertyName the name of the property
        */
  -    public BasicQueryScope (String href, int depth, Set includeSet, Set excludeSet) 
{
  +    public BasicQueryScope (String href, int depth, Set includeSet, Set excludeSet, 
Set excludedScopes) {
           this.href  = href;
           this.depth = depth;
           this.includeSet = includeSet;
           this.excludeSet = excludeSet;
  +        this.excludedScopes = excludedScopes;
       }
       
       /**
  @@ -109,7 +113,7 @@
           href  = scope.getChildTextTrim (Literals.HREF, namespace);
           
           try {
  -            URL url = new URL (href);
  +            new URL (href);
               throw new BadGatewayException (href + ": Bad Gateway (no server 
redirection allowed)");
           }
           // must not be a valid URL (server redirection not implemented)
  @@ -128,6 +132,7 @@
           }
           
           Iterator it = scope.getChildren (Literals.EXCLUDE, 
slideNamespace).iterator();
  +        if (it.hasNext()) excludedScopes = new HashSet();
           while (it.hasNext()) {
               Element excluded = (Element)it.next();
               String href = excluded.getText();
  @@ -135,6 +140,7 @@
           }
   
           it = scope.getChildren (Literals.INCLUDE_LASTPATHSEGEMENT, 
namespace).iterator();
  +        if (it.hasNext()) includeSet = new HashSet();
           while (it.hasNext()) {
               Element incl = (Element)it.next();
               String pattern = incl.getText();
  @@ -142,6 +148,7 @@
           }
           
           it = scope.getChildren (Literals.EXCLUDE_LASTPATHSEGEMENT, 
namespace).iterator();
  +        if (it.hasNext()) excludeSet = new HashSet();
           while (it.hasNext()) {
               Element incl = (Element)it.next();
               String pattern = incl.getText();
  @@ -221,6 +228,9 @@
        *
        */
       public Set getExcludedScopes() {
  +        if (excludedScopes == null) {
  +            return Collections.EMPTY_SET;
  +        }
           return excludedScopes;
       }
       
  @@ -230,6 +240,9 @@
        * @return   a  Set
        */
       public Set getIncludeSet() {
  +        if (includeSet == null) {
  +            return Collections.EMPTY_SET;
  +        }
           return includeSet;
       }
       
  @@ -239,6 +252,9 @@
        * @return   a  Set
        */
       public Set getExcludeSet() {
  +        if (excludeSet == null) {
  +            return Collections.EMPTY_SET;
  +        }
           return excludeSet;
       }
       
  
  
  
  1.5       +30 -6     
jakarta-slide/src/share/org/apache/slide/search/basic/QueryTree.java
  
  Index: QueryTree.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/QueryTree.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- QueryTree.java    28 Jul 2004 09:35:01 -0000      1.4
  +++ QueryTree.java    1 Nov 2004 17:58:02 -0000       1.5
  @@ -24,9 +24,12 @@
   package org.apache.slide.search.basic;
   
   import java.util.ArrayList;
  +import java.util.Collections;
   import java.util.Enumeration;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
  +import java.util.Set;
   import java.util.StringTokenizer;
   
   import org.apache.slide.common.Scope;
  @@ -84,7 +87,6 @@
        *
        */
       public boolean hasChildren (Scope scopeToBeChecked) {
  -        boolean result = false;
           TokenizedScope tScopeToBeChecked = new TokenizedScope (scopeToBeChecked);
           Iterator it = allQueryTreeNodes.iterator();
           while (it.hasNext()) {
  @@ -94,6 +96,28 @@
           }
           
           return false;
  +    }
  +    
  +    /**
  +     * Returns a set of all scopes in the query that are children of 
  +     * the <code>scopeToBeChecked</code>.
  +     * @param scopeToBeChecked
  +     */
  +    public Set getChildren(Scope scopeToBeChecked) {
  +        Set result = null;
  +        
  +        TokenizedScope tScopeToBeChecked = new TokenizedScope (scopeToBeChecked);
  +        Iterator it = allQueryTreeNodes.iterator();
  +        while (it.hasNext()) {
  +            Scope scope = (Scope)it.next();
  +            TokenizedScope ts = new TokenizedScope(scope);
  +            if (ts.isChildOf (tScopeToBeChecked)) {
  +                if (result == null) result = new HashSet();
  +                result.add(scope);
  +            }
  +        }
  +        
  +        return result != null ? result : Collections.EMPTY_SET;
       }
       
       /**
  
  
  
  1.5       +8 -4      
jakarta-slide/src/share/org/apache/slide/search/basic/expression/CompareExpression.java
  
  Index: CompareExpression.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/expression/CompareExpression.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CompareExpression.java    28 Jul 2004 09:34:50 -0000      1.4
  +++ CompareExpression.java    1 Nov 2004 17:58:02 -0000       1.5
  @@ -92,6 +92,10 @@
       public ComparableResourcesPool getRequestedResourcePool() {
           return requestedResourcesPool;
       }
  +    
  +    public void setRequestedResourcePool(ComparableResourcesPool pool) {
  +        this.requestedResourcesPool = pool;
  +    }
   
       /**
        * The concrete CompareExpression must overwrite this.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to