wam         2003/01/14 08:23:14

  Modified:    src/stores/org/apache/slide/search/basic/sample
                        BasicExpressionSample.java
  Log:
  remove dependency to webdav component
  
  Revision  Changes    Path
  1.2       +37 -35    
jakarta-slide/src/stores/org/apache/slide/search/basic/sample/BasicExpressionSample.java
  
  Index: BasicExpressionSample.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/search/basic/sample/BasicExpressionSample.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicExpressionSample.java        13 Jan 2003 10:29:54 -0000      1.1
  +++ BasicExpressionSample.java        14 Jan 2003 16:23:14 -0000      1.2
  @@ -65,20 +65,16 @@
   
   package org.apache.slide.search.basic.sample;
   
  +import org.apache.slide.search.basic.*;
  +
   import java.util.Collection;
  -import java.util.Hashtable;
   import java.util.Iterator;
  -import org.apache.slide.content.NodeRevisionDescriptor;
  -import org.apache.slide.content.NodeRevisionDescriptors;
  -import org.apache.slide.content.NodeRevisionNumber;
  +import org.apache.slide.common.SlideException;
   import org.apache.slide.search.BadQueryException;
   import org.apache.slide.search.RequestedResource;
   import org.apache.slide.search.SearchException;
  -import org.apache.slide.search.basic.BasicResultSetImpl;
  -import org.apache.slide.search.basic.IBasicExpression;
  -import org.apache.slide.search.basic.IBasicExpressionFactory;
  -import org.apache.slide.search.basic.IBasicResultSet;
  -import org.apache.slide.webdav.util.ResourceWithProvidedProperties;
  +import org.apache.slide.structure.ObjectNode;
  +import org.apache.slide.structure.SubjectNode;
   
   /**
    * A very basic sample for a store specific Expression. Depending on the
  @@ -90,14 +86,14 @@
    * @version $Revision$
    */
   public class BasicExpressionSample implements IBasicExpression {
  -    
  -    
  +
  +
       /** an example for an executable command */
       String theExecutableCommand;
  -    
  +
       /** backptr to the factory */
       IBasicExpressionFactory factory;
  -    
  +
       /**
        * constructor for a compare expression like gt, eq, ...
        * For your concrete implementation you are free, which parameters have to
  @@ -107,31 +103,31 @@
           theExecutableCommand = command;
           this.factory = factory;
       }
  -    
  +
       /**
        * contructor for a merge expression
        */
       BasicExpressionSample (String mergeOperator,
  -                      Collection children,
  -                      IBasicExpressionFactory factory)
  +                           Collection children,
  +                           IBasicExpressionFactory factory)
           throws BadQueryException
       {
           this.factory = factory;
           Iterator it = children.iterator();
           BasicExpressionSample firstChild = (BasicExpressionSample)it.next();
  -        
  +
           if (firstChild == null)
               throw new BadQueryException (mergeOperator + " needs at least one 
nested element");
  -        
  +
           theExecutableCommand = firstChild.theExecutableCommand;
  -        
  +
           // create the executable command
           while (it.hasNext()) {
               BasicExpressionSample exp = (BasicExpressionSample)it.next();
               theExecutableCommand += " " + mergeOperator + " " + 
exp.theExecutableCommand;
           }
       }
  -    
  +
       /**
        * fake executer. The executable command is printed and a fake result is 
created.
        *
  @@ -141,26 +137,32 @@
        *
        */
       public IBasicResultSet execute() throws SearchException {
  -        
  +
           IBasicResultSet result = new BasicResultSetImpl (true);
  -        
  -        // here the miracle happens. The command is executed, and slide objects
  +
  +        // here the miracle happens. The command is executed, and ObjectNodes
           // are created from all results, that match the query.
           System.out.println("now execute: " + theExecutableCommand);
  -        
  +
  +        //
           // fake one result
  -        NodeRevisionDescriptors nrds =
  -            new NodeRevisionDescriptors (
  -            "/", new NodeRevisionNumber (1,0),
  -            new Hashtable(), new Hashtable(), new Hashtable(), false);
  -        
  -        NodeRevisionDescriptor nrd = new NodeRevisionDescriptor ();
  -        
  -        RequestedResource resource = new ResourceWithProvidedProperties
  -            (nrds, nrd, factory.getPropertyProvider());
  -        
  +        //
  +        ObjectNode node = new SubjectNode("/"); // this will return the root folder
  +        RequestedResource resource = null;
  +        IBasicQuery query = factory.getQuery();
  +
  +        try {
  +            resource = new ComparableResourceImpl
  +                (node, query.getSearchToken(), query.getScope(),
  +                 factory.getPropertyProvider());
  +        }
  +        catch (SlideException e) {
  +            throw new SearchException (e);
  +        }
  +
           result.add (resource);
  -        
  +
  +
           return  result;
       }
   }
  
  
  

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

Reply via email to