db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/jdo ExtentImpl.java PersistenceManagerImpl.java QueryImpl.java TransactionImpl.java
Date Wed, 14 Apr 2004 13:12:04 GMT
brianm      2004/04/14 06:12:04

  Modified:    src/java/org/apache/ojb/jdo ExtentImpl.java
                        PersistenceManagerImpl.java QueryImpl.java
                        TransactionImpl.java
  Log:
  More incremental improvements on JDO client API
  
  Revision  Changes    Path
  1.8       +8 -4      db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java
  
  Index: ExtentImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/ExtentImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ExtentImpl.java	9 Apr 2004 01:06:00 -0000	1.7
  +++ ExtentImpl.java	14 Apr 2004 13:12:04 -0000	1.8
  @@ -33,22 +33,27 @@
   
   /**
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  + * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
    */
  +
   public class ExtentImpl implements Extent
   {
   	private Class m_clazz;
   	private OTMConnection m_conn;
   	private PersistenceManager m_pm;
       private HashSet m_iterators = new HashSet();
  +    private Criteria m_criteria;
   
  -	/**
  +    /**
   	 * Constructor for ExtentImpl.
  +     * @param subclasses is ignored
   	 */
  -	public ExtentImpl(Class pClazz, OTMConnection conn, PersistenceManager pm)
  +	public ExtentImpl(Class pClazz, OTMConnection conn, PersistenceManager pm, boolean subclasses)
   	{
   		m_clazz = pClazz;
   		m_conn = conn;
   		m_pm = pm;
  +        m_criteria = new Criteria();
   	}
   
       Class ojbGetClass()
  @@ -61,8 +66,7 @@
        */
   	public Iterator iterator()
   	{
  -        Criteria null_crit = null;
  -        QueryByCriteria q = QueryFactory.newQuery(m_clazz, null_crit);
  +        QueryByCriteria q = QueryFactory.newQuery(m_clazz, m_criteria);
           ExtentIterator itty = new ExtentIterator((OJBIterator) m_conn.getIteratorByQuery(q));
           m_iterators.add(itty);
   		return itty;
  
  
  
  1.11      +6 -5      db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java
  
  Index: PersistenceManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/PersistenceManagerImpl.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- PersistenceManagerImpl.java	12 Apr 2004 16:32:40 -0000	1.10
  +++ PersistenceManagerImpl.java	14 Apr 2004 13:12:04 -0000	1.11
  @@ -33,7 +33,8 @@
   import java.util.Iterator;
   
   /**
  - * @author Matthew Baird, Brian McCallister
  + * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  + * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
    */
   
   public class PersistenceManagerImpl implements PersistenceManager
  @@ -389,18 +390,18 @@
   
       /**
        * @param aClass top level class
  -     * @param b      include subclasses
  +     * @param include_extent      include subclasses, presently ignored
        * @return
        * @todo figure out how to implement, may have to query all and filter objects
        */
  -    public Extent getExtent(Class aClass, boolean b)
  +    public Extent getExtent(Class aClass, boolean include_extent)
       {
  -        if (!b) throw new UnsupportedOperationException("Not yet implemented!");
  +        if (!include_extent) throw new UnsupportedOperationException("Not yet implemented!");
           if (isClosed())
           {
               throw new JDOFatalUserException(generateIsClosedErrorMessage("getExtent(Class,
boolean)"));
           }
  -        return new ExtentImpl(aClass, m_conn, this);
  +        return new ExtentImpl(aClass, m_conn, this, include_extent);
       }
   
       public Object getObjectById(Object o, boolean validate)
  
  
  
  1.7       +63 -19    db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java
  
  Index: QueryImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/QueryImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- QueryImpl.java	9 Apr 2004 01:06:00 -0000	1.6
  +++ QueryImpl.java	14 Apr 2004 13:12:04 -0000	1.7
  @@ -14,54 +14,82 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +import org.apache.commons.collections.CollectionUtils;
   import org.apache.ojb.broker.query.Criteria;
  -import org.apache.ojb.broker.query.QueryFactory;
   import org.apache.ojb.broker.query.QueryByCriteria;
  +import org.apache.ojb.broker.query.QueryFactory;
   import org.apache.ojb.otm.OTMConnection;
  -import org.apache.commons.collections.CollectionUtils;
  -import org.odmg.DList;
   
  -import javax.jdo.Query;
   import javax.jdo.Extent;
   import javax.jdo.PersistenceManager;
  +import javax.jdo.Query;
   import java.util.Collection;
  -import java.util.Map;
  -import java.util.Iterator;
   import java.util.HashSet;
  +import java.util.Map;
  +
  +/**
  +
  + */
   
   /**
  + * Not Really Functional Yet:
  + * <p>
  + * Consider making this a front end for a State system where the
  + * compiled query is a different State The big list of args should/could
  + * be collected into something that knows how to compile and and
  + * apply the arguments passed at execute time.
  + * <p>
  + * Consider also, if do above, clone returns compiled query. Compiled
  + * probably needs to be able to uncompile itself if this the case,
  + * so continuing to return uncompiled may be best
  + *
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  + * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
    */
   
   public class QueryImpl implements Query
   {
  -
       private PersistenceManager m_pm;
       private OTMConnection m_conn;
       private Criteria m_criteria;
       private Class m_searchClass;
       private Collection m_candidates;
  +    private String m_filter;
  +    private String m_imports;
  +    private String m_parameters;
  +    private String m_ordering;
  +    private String m_variables;
  +    private boolean m_ignoreCache;
  +    private boolean m_compiled = false;
  +
   
       QueryImpl(PersistenceManager pm, OTMConnection conn)
       {
           this.m_pm = pm;
           this.m_conn = conn;
  -        this.m_criteria = new Criteria();
           this.m_candidates = null;
       }
   
  +    /**
  +     * @return uncompiled clone of this query
  +     */
       QueryImpl ojbClone()
       {
           QueryImpl query = new QueryImpl(m_pm, m_conn);
           query.m_candidates = m_candidates;
           query.m_searchClass = m_searchClass;
  -        query.m_criteria = m_criteria;
  +        query.m_filter = m_filter;
  +        query.m_imports = m_imports;
  +        query.m_parameters = m_parameters;
  +        query.m_ordering = m_ordering;
  +        query.m_variables = m_variables;
           return query;
       }
   
   	public void setClass(Class aClass)
   	{
           this.m_searchClass = aClass;
  +        this.m_compiled = false;
   	}
   
       /**
  @@ -70,56 +98,71 @@
   	public void setCandidates(Extent extent)
   	{
           this.m_searchClass = ((ExtentImpl)extent).ojbGetClass();
  +        this.m_compiled = false;
   	}
   
   	public void setCandidates(Collection collection)
   	{
           if (m_candidates == null) m_candidates = new HashSet();
           this.m_candidates.addAll(collection);
  +        this.m_compiled = false;
   	}
   
   	public void setFilter(String s)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        this.m_filter = s;
  +        this.m_compiled = false;
   	}
   
   	public void declareImports(String s)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        this.m_imports = s;
  +        this.m_compiled = false;
   	}
   
   	public void declareParameters(String s)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        this.m_parameters = s;
  +        this.m_compiled = false;
   	}
   
   	public void declareVariables(String s)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        this.m_variables = s;
  +        this.m_compiled = false;
   	}
   
   	public void setOrdering(String s)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        this.m_ordering = s;
  +        this.m_compiled = false;
   	}
   
  +    /**
  +     * @todo presently ignored
  +     */
   	public void setIgnoreCache(boolean b)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
  +        m_ignoreCache = b;
  +        this.m_compiled = false;
   	}
   
   	public boolean getIgnoreCache()
   	{
  -		throw new UnsupportedOperationException("Not yet implemented!");
  +		return m_ignoreCache;
   	}
   
  +    /**
  +     * @todo verify correctness of all the Strings
  +     */
   	public void compile()
   	{
  -        // Do Nothing
  +        m_criteria = new Criteria();
   	}
   
   	public Object execute()
   	{
  +        if (!m_compiled) this.compile();
           QueryByCriteria query = QueryFactory.newQuery(m_searchClass, this.m_criteria);
   		Collection results =  (Collection) m_conn.getCollectionByQuery(query);
           if (m_candidates != null) return CollectionUtils.intersection(results, this.m_candidates);
  @@ -156,13 +199,14 @@
   		return m_pm;
   	}
   
  +    /**
  +     * @param o is a Collection returned from execute()
  +     */
   	public void close(Object o)
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   
   	public void closeAll()
   	{
  -        throw new UnsupportedOperationException("Not yet implemented!");
   	}
   }
  
  
  
  1.6       +1 -0      db-ojb/src/java/org/apache/ojb/jdo/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/jdo/TransactionImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TransactionImpl.java	9 Apr 2004 01:06:00 -0000	1.5
  +++ TransactionImpl.java	14 Apr 2004 13:12:04 -0000	1.6
  @@ -25,6 +25,7 @@
   
   /**
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
  + * @author <a href="mailto:brianm@apache.org">Brian McCallister</a>
    */
   
   public class TransactionImpl implements Transaction
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message