cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r647073 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/DbLoader.java main/java/org/apache/cayenne/map/DbEntity.java test/java/org/apache/cayenne/access/DbLoaderTest.java
Date Fri, 11 Apr 2008 08:01:32 GMT
Author: aadamchik
Date: Fri Apr 11 01:01:17 2008
New Revision: 647073

URL: http://svn.apache.org/viewvc?rev=647073&view=rev
Log:
ridding DbLoader of (unneeded) Ashwood dependency

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java?rev=647073&r1=647072&r2=647073&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoader.java
Fri Apr 11 01:01:17 2008
@@ -52,7 +52,6 @@
 import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.objectstyle.ashwood.dbutil.Table;
 
 /**
  * Utility class that does reverse engineering of the database. It can create DataMaps
@@ -230,26 +229,27 @@
     }
 
     /**
-     * Returns all table names for given combination of the criteria.
+     * Returns all tables for given combination of the criteria. Tables returned as
+     * DbEntities without any attributes or relationships.
      * 
-     * @param catalog The name of the catalog, may be null.
+     * @param catalogPattern The name of the catalog, may be null.
      * @param schemaPattern The pattern for schema name, use "%" for wildcard.
      * @param tableNamePattern The pattern for table names, % for wildcard, if null or ""
      *            defaults to "%".
      * @param types The types of table names to retrieve, null returns all types.
      * @return List of TableInfo objects, empty array if nothing found.
      */
-    public List<Table> getTables(
-            String catalog,
+    public List<DbEntity> getTables(
+            String catalogPattern,
             String schemaPattern,
             String tableNamePattern,
             String[] types) throws SQLException {
 
-        List<Table> tables = new ArrayList<Table>();
+        List<DbEntity> tables = new ArrayList<DbEntity>();
 
         if (logObj.isDebugEnabled()) {
             logObj.debug("Read tables: catalog="
-                    + catalog
+                    + catalogPattern
                     + ", schema="
                     + schemaPattern
                     + ", tableNames="
@@ -263,14 +263,14 @@
         }
 
         ResultSet rs = getMetaData().getTables(
-                catalog,
+                catalogPattern,
                 schemaPattern,
                 tableNamePattern,
                 types);
 
         try {
             while (rs.next()) {
-                String cat = rs.getString("TABLE_CAT");
+                String catalog = rs.getString("TABLE_CAT");
                 String schema = rs.getString("TABLE_SCHEM");
                 String name = rs.getString("TABLE_NAME");
 
@@ -285,8 +285,10 @@
                     continue;
                 }
 
-                Table info = new Table(cat, schema, name);
-                tables.add(info);
+                DbEntity table = new DbEntity(name);
+                table.setCatalog(catalog);
+                table.setSchema(schema);
+                tables.add(table);
             }
         }
         finally {
@@ -303,14 +305,14 @@
      *            DbEntities must be created.
      * @return false if loading must be immediately aborted.
      */
-    public boolean loadDbEntities(DataMap map, List<? extends Table> tables) throws
SQLException {
+    public boolean loadDbEntities(DataMap map, List<? extends DbEntity> tables) throws
SQLException {
         this.dbEntityList = new ArrayList<DbEntity>();
 
-        for (final Table table : tables) {
+        for (DbEntity dbEntity : tables) {
 
             // Check if there already is a DbEntity under such name
             // if so, consult the delegate what to do
-            DbEntity oldEnt = map.getDbEntity(table.getName());
+            DbEntity oldEnt = map.getDbEntity(dbEntity.getName());
             if (oldEnt != null) {
                 if (delegate == null) {
                     // no delegate, don't know what to do, cancel import
@@ -340,16 +342,12 @@
                 }
             }
 
-            DbEntity dbEntity = new DbEntity();
-            dbEntity.setName(table.getName());
-            dbEntity.setSchema(table.getSchema());
-            dbEntity.setCatalog(table.getCatalog());
 
             // Create DbAttributes from column information --
             ResultSet rs = getMetaData().getColumns(
-                    table.getCatalog(),
-                    table.getSchema(),
-                    table.getName(),
+                    dbEntity.getCatalog(),
+                    dbEntity.getSchema(),
+                    dbEntity.getName(),
                     "%");
 
             try {
@@ -409,9 +407,8 @@
             }
 
             // delegate might have thrown this entity out... so check if it is still
-            // around
-            // before continuing processing
-            if (map.getDbEntity(table.getName()) == dbEntity) {
+            // around  before continuing processing
+            if (map.getDbEntity(dbEntity.getName()) == dbEntity) {
                 this.dbEntityList.add(dbEntity);
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=647073&r1=647072&r2=647073&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
Fri Apr 11 01:01:17 2008
@@ -395,7 +395,7 @@
                     for (ObjEntity oe : map.getMappedEntities(ent)) {
                         for (ObjAttribute attr : oe.getAttributes()) {
                             if (attr.getDbAttribute() == dbAttribute) {
-                                attr.setDbAttributeName(newName);
+                                attr.setDbAttributePath(newName);
                             }
                         }
                     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java?rev=647073&r1=647072&r2=647073&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbLoaderTest.java
Fri Apr 11 01:01:17 2008
@@ -32,7 +32,6 @@
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.unit.CayenneCase;
-import org.objectstyle.ashwood.dbutil.Table;
 
 public class DbLoaderTest extends CayenneCase {
 
@@ -75,16 +74,15 @@
 
             String tableLabel = getNode().getAdapter().tableTypeForTable();
 
-            List tables = loader.getTables(null, null, "%", new String[] {
+            List<DbEntity> tables = loader.getTables(null, null, "%", new String[]
{
                 tableLabel
             });
 
             assertNotNull(tables);
 
-            Iterator it = tables.iterator();
             boolean foundArtist = false;
-            while (it.hasNext()) {
-                Table table = (Table) it.next();
+
+            for (DbEntity table : tables) {
                 if ("ARTIST".equalsIgnoreCase(table.getName())) {
                     foundArtist = true;
                     break;
@@ -312,13 +310,10 @@
     }
 
     public void checkAllDBEntities(DataMap map) {
-        Iterator entIt = originalMap().getDbEntities().iterator();
-        while (entIt.hasNext()) {
-            DbEntity origEnt = (DbEntity) entIt.next();
+
+        for (DbEntity origEnt : originalMap().getDbEntities()) {
             DbEntity newEnt = map.getDbEntity(origEnt.getName());
-            Iterator it = origEnt.getAttributes().iterator();
-            while (it.hasNext()) {
-                DbAttribute origAttr = (DbAttribute) it.next();
+            for (DbAttribute origAttr : origEnt.getAttributes()) {
                 DbAttribute newAttr = (DbAttribute) newEnt.getAttribute(origAttr
                         .getName());
                 assertNotNull(



Mime
View raw message