db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/metadata ClassDescriptor.java DescriptorRepository.java
Date Wed, 05 Nov 2003 20:33:11 GMT
brj         2003/11/05 12:33:11

  Modified:    src/java/org/apache/ojb/broker/core
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/accesslayer/sql
                        SqlQueryStatement.java
               src/java/org/apache/ojb/broker/metadata ClassDescriptor.java
                        DescriptorRepository.java
  Log:
  moved getAllConcreteSubclassesOf to DescriptorRepository
  
  Revision  Changes    Path
  1.46      +8 -9      db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/core/PersistenceBrokerImpl.java,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- PersistenceBrokerImpl.java	2 Nov 2003 13:21:08 -0000	1.45
  +++ PersistenceBrokerImpl.java	5 Nov 2003 20:33:10 -0000	1.46
  @@ -502,11 +502,11 @@
               String lastUsedTable = cld.getFullTableName();
               if (cld.isExtent())
               {
  -                Iterator extentClasses = cld.getAllConcreteExtentClasses().iterator();
  +                Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
   
  -                while (extentClasses.hasNext())
  +                while (extents.hasNext())
                   {
  -                    Class ec = (Class) extentClasses.next();
  +                    Class ec = (Class) extents.next();
                       ClassDescriptor extCld = getClassDescriptor(ec);
   
                       // read same table only once
  @@ -1765,7 +1765,7 @@
           // we can lookup all tables of the extent classes:
           if (newObj == null && cld.isExtent())
           {
  -            Iterator extents = cld.getAllConcreteExtentClasses().iterator();
  +            Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
               
               while (extents.hasNext())
               {
  @@ -2521,11 +2521,10 @@
               chainingIter.addIterator(factory.createRsIterator(query, cld, this));
           }
   
  -        Iterator extentClasses = cld.getAllConcreteExtentClasses().iterator();
  -
  -        while (extentClasses.hasNext())
  +        Iterator extents = getDescriptorRepository().getAllConcreteSubclassesOf(cld).iterator();
  +        while (extents.hasNext())
           {
  -            Class ec = (Class) extentClasses.next();
  +            Class ec = (Class) extents.next();
               ClassDescriptor extCld = getClassDescriptor(ec);
   
               // read same table only once
  
  
  
  1.57      +2 -2      db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
  
  Index: SqlQueryStatement.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- SqlQueryStatement.java	19 Sep 2003 19:34:05 -0000	1.56
  +++ SqlQueryStatement.java	5 Nov 2003 20:33:11 -0000	1.57
  @@ -1694,7 +1694,7 @@
               // BRJ : build alias for extents, only one per Table
   			if (lookForExtents)
   			{
  -				List extClasses = aCld.getRepository().getConcreteSubclassesOf(aCld.getClassOfObject());
  +				List extClasses = aCld.getRepository().getAllConcreteSubclassesOf(aCld);
   				ClassDescriptor extCd;
   				String extTable;
   				Map extMap = new HashMap(); // only one Alias per Table
  
  
  
  1.71      +1 -47     db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java
  
  Index: ClassDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ClassDescriptor.java,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- ClassDescriptor.java	1 Nov 2003 21:08:57 -0000	1.70
  +++ ClassDescriptor.java	5 Nov 2003 20:33:11 -0000	1.71
  @@ -586,52 +586,6 @@
   
   
       /**
  -     * Return all concrete extent classes of the hierarchy recursively
  -     * @return Collection
  -     */
  -    public Collection getAllConcreteExtentClasses()
  -    {
  -        Set result = new HashSet();
  -        Vector extents = getExtentClasses();
  -        
  -        for (int i = 0; i < extents.size(); i++)
  -        {
  -            Class ext = (Class)extents.elementAt(i);
  -            ClassDescriptor extCld = getRepository().getDescriptorFor(ext);
  -            
  -            if (!extCld.isInterface())
  -            {    
  -                result.add(ext);
  -            }
  -            result.addAll(extCld.getAllConcreteExtentClasses());
  -        }
  -        
  -        return result;
  -    }
  -
  -    /**
  -     * Return all extent classes of the hierarchy recursively
  -     * @return Collection
  -     */
  -    public Collection getAllExtentClasses()
  -    {
  -        Set result = new HashSet();
  -        Vector extents = getExtentClasses();
  -        
  -        for (int i = 0; i < extents.size(); i++)
  -        {
  -            Class ext = (Class)extents.elementAt(i);
  -            ClassDescriptor extCld = getRepository().getDescriptorFor(ext);
  -            
  -            result.add(ext);
  -            result.addAll(extCld.getAllExtentClasses());
  -        }
  -        
  -        return result;
  -    }
  -
  -    
  -    /**
        * Return the names of all classes in this extent
        * @return java.util.Vector a Vector containing the fully qualified names
        * of all classes in this extent
  
  
  
  1.38      +18 -26    db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java
  
  Index: DescriptorRepository.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/DescriptorRepository.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- DescriptorRepository.java	11 Jul 2003 07:42:04 -0000	1.37
  +++ DescriptorRepository.java	5 Nov 2003 20:33:11 -0000	1.38
  @@ -54,22 +54,15 @@
    * <http://www.apache.org/>.
    */
   
  +import java.io.Serializable;
  +import java.util.*;
  +
   import org.apache.commons.lang.SystemUtils;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.builder.ToStringStyle;
   import org.apache.ojb.broker.OJBRuntimeException;
   import org.apache.ojb.broker.PersistenceBrokerException;
   
  -import java.io.Serializable;
  -import java.util.ArrayList;
  -import java.util.Enumeration;
  -import java.util.HashMap;
  -import java.util.Hashtable;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Map;
  -import java.util.Vector;
  -
   /**
    * The repository containing all object mapping and manipulation information of
    * all used persistent objects.
  @@ -258,29 +251,28 @@
        *
        * @return a List of Class objects
        */
  -    public List getConcreteSubclassesOf(Class superClass)
  +    public List getAllConcreteSubclassesOf(ClassDescriptor aCld)
       {
  -        //logger.debug("-- -- -- Looking for concrete subclasses of ["+superClass.getName()+"]");
  -        List concreteSubclasses = new ArrayList();
  -        ClassDescriptor cld = getDescriptorFor(superClass);
  -        Vector extent = cld.getExtentClasses();
  -        Iterator it = extent.iterator();
  -        while (it.hasNext())
  +        // BRJ: set to prevent duplicates
  +        Set concreteSubclasses = new HashSet();
  +        Iterator iter = aCld.getExtentClasses().iterator();
  +
  +        while (iter.hasNext())
           {
  -            Class extentClass = (Class) it.next();
  -            //logger.debug("-- -- -- Extent class for ["+superClass.getName()+"] ->
["+extentClass+"]");
  -            ClassDescriptor extentClassCld = getDescriptorFor(extentClass);
  -            if (!extentClassCld.isAbstract())
  +            Class extentClass = (Class) iter.next();
  +            ClassDescriptor extCld = getDescriptorFor(extentClass);
  +            if (!extCld.isInterface())
               {
                   concreteSubclasses.add(extentClass);
               }
  -            // recurse
  -            concreteSubclasses.addAll(getConcreteSubclassesOf(extentClass));
   
  +            // recurse
  +            concreteSubclasses.addAll(getAllConcreteSubclassesOf(extCld));
           }
  -        return concreteSubclasses;
  +        
  +        return new ArrayList(concreteSubclasses);
       }
  -
  +    
       /**
        * Checks if repository contains given class.
        */
  
  
  

---------------------------------------------------------------------
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