cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1407604 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ cayenne-tools/src/main/java/org/apache/cayenne/access/ cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ cayenne-tools/s...
Date Fri, 09 Nov 2012 19:52:22 GMT
Author: aadamchik
Date: Fri Nov  9 19:52:20 2012
New Revision: 1407604

URL: http://svn.apache.org/viewvc?rev=1407604&view=rev
Log:
CAY-1758 cdbimport improvements

taking a step back to refactor the tools infrastructure
* moving access package in tools to dbimport
* renaming AbstractDbLoaderDelegate to non-abstract ImportDbLoaderDelegate

Added:
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegate.java
      - copied, changed from r1407603, cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/access/AbstractDbLoaderDelegate.java
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegateTest.java
      - copied, changed from r1407603, cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/access/AbstractDbLoaderDelegateTest.java
Removed:
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/access/
    cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/access/
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
    cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
    cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
    cayenne/main/trunk/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java?rev=1407604&r1=1407603&r2=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
Fri Nov  9 19:52:20 2012
@@ -24,25 +24,24 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjEntity;
 
 /**
- * DbLoaderDelegate defines API that allows to control the behavior of DbLoader during the
- * database reverse-engineering. Delegate is also notified of the progress of
- * reverse-engineering.
- * 
+ * DbLoaderDelegate defines API that allows to control the behavior of DbLoader
+ * during the database reverse-engineering. Delegate is also notified of the
+ * progress of reverse-engineering.
  */
 public interface DbLoaderDelegate {
 
     /**
-     * Returns true to tell DbLoader that it is OK to overwrite DbEntity that already
-     * exists in the model. If loading process should be stopped immediately, an exception
-     * is thrown.
+     * Returns true to tell DbLoader that it is OK to overwrite DbEntity that
+     * already exists in the model. If loading process should be stopped
+     * immediately, an exception is thrown.
      */
-    public boolean overwriteDbEntity(DbEntity ent) throws CayenneException;
+    public boolean overwriteDbEntity(DbEntity entity) throws CayenneException;
 
-    public void dbEntityAdded(DbEntity ent);
+    public void dbEntityAdded(DbEntity entity);
 
-    public void dbEntityRemoved(DbEntity ent);
+    public void dbEntityRemoved(DbEntity entity);
 
-    public void objEntityAdded(ObjEntity ent);
+    public void objEntityAdded(ObjEntity entity);
 
-    public void objEntityRemoved(ObjEntity ent);
+    public void objEntityRemoved(ObjEntity entity);
 }

Copied: cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegate.java
(from r1407603, cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/access/AbstractDbLoaderDelegate.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegate.java?p2=cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegate.java&p1=cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/access/AbstractDbLoaderDelegate.java&r1=1407603&r2=1407604&rev=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/access/AbstractDbLoaderDelegate.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegate.java
Fri Nov  9 19:52:20 2012
@@ -17,24 +17,36 @@
  *  under the License.
  ****************************************************************/
 
-package org.apache.cayenne.access;
-
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.CayenneException;
+package org.apache.cayenne.dbimport;
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Collections;
+import java.util.List;
 
-public abstract class AbstractDbLoaderDelegate implements DbLoaderDelegate {
+import org.apache.cayenne.CayenneException;
+import org.apache.cayenne.access.DbLoaderDelegate;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.ObjEntity;
 
-    private List<DbEntity> addedDbEntities = new ArrayList<DbEntity>();
-    private List<DbEntity> removedDbEntities = new ArrayList<DbEntity>();
-    private List<ObjEntity> addedObjEntities = new ArrayList<ObjEntity>();
-    private List<ObjEntity> removedObjEntities = new ArrayList<ObjEntity>();
+/**
+ * @since 3.2
+ */
+public class ImportDbLoaderDelegate implements DbLoaderDelegate {
+
+    private List<DbEntity> addedDbEntities;
+    private List<DbEntity> removedDbEntities;
+    private List<ObjEntity> addedObjEntities;
+    private List<ObjEntity> removedObjEntities;
+
+    public ImportDbLoaderDelegate() {
+        addedDbEntities = new ArrayList<DbEntity>();
+        removedDbEntities = new ArrayList<DbEntity>();
+        addedObjEntities = new ArrayList<ObjEntity>();
+        removedObjEntities = new ArrayList<ObjEntity>();
+    }
 
-    public boolean overwriteDbEntity(final DbEntity ent) throws CayenneException {
+    public boolean overwriteDbEntity(final DbEntity ent)
+            throws CayenneException {
         return false;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java?rev=1407604&r1=1407603&r2=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
Fri Nov  9 19:52:20 2012
@@ -23,10 +23,10 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.sql.Driver;
 
-import org.apache.cayenne.access.AbstractDbLoaderDelegate;
 import org.apache.cayenne.access.DbLoader;
 import org.apache.cayenne.conn.DriverDataSource;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dbimport.ImportDbLoaderDelegate;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.MapLoader;
@@ -91,8 +91,7 @@ public class DbImporterTask extends Caye
             DbAdapter adapter = getAdapter(injector, dataSource);
 
             // Load the data map and run the db importer.
-            AbstractDbLoaderDelegate loaderDelegate = new AbstractDbLoaderDelegate() {
-            };
+            ImportDbLoaderDelegate loaderDelegate = new ImportDbLoaderDelegate();
             DbLoader loader = new DbLoader(dataSource.getConnection(), adapter,
                     loaderDelegate);
             loader.setCreatingMeaningfulPK(meaningfulPk);

Copied: cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegateTest.java
(from r1407603, cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/access/AbstractDbLoaderDelegateTest.java)
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegateTest.java?p2=cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegateTest.java&p1=cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/access/AbstractDbLoaderDelegateTest.java&r1=1407603&r2=1407604&rev=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/access/AbstractDbLoaderDelegateTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/test/java/org/apache/cayenne/dbimport/ImportDbLoaderDelegateTest.java
Fri Nov  9 19:52:20 2012
@@ -17,34 +17,33 @@
  *  under the License.
  ****************************************************************/
 
-package org.apache.cayenne.access;
-
-import junit.framework.TestCase;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.CayenneException;
+package org.apache.cayenne.dbimport;
 
 import java.util.Arrays;
 import java.util.List;
 
-public class AbstractDbLoaderDelegateTest extends TestCase {
+import junit.framework.TestCase;
+
+import org.apache.cayenne.CayenneException;
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.ObjEntity;
 
-    final class TestDbLoaderDelegate extends AbstractDbLoaderDelegate {}
+public class ImportDbLoaderDelegateTest extends TestCase {
 
-    private AbstractDbLoaderDelegate delegate;
+    private ImportDbLoaderDelegate delegate;
     private DataMap dataMap;
     private DbEntity dbEntity;
     private ObjEntity objEntity;
 
     @Override
     public void setUp() {
-        delegate = new TestDbLoaderDelegate();
+        delegate = new ImportDbLoaderDelegate();
         dataMap = new DataMap();
 
         dbEntity = new DbEntity("TestDbEntity");
         dbEntity.setDataMap(dataMap);
-        
+
         objEntity = new ObjEntity("TestObjEntity");
         objEntity.setDataMap(dataMap);
     }
@@ -60,7 +59,7 @@ public class AbstractDbLoaderDelegateTes
 
         assertEquals(1, dataMap.getDbEntities().size());
         assertTrue(dataMap.getDbEntities().containsAll(entities));
-        
+
         assertEquals(entities, delegate.getAddedDbEntities());
     }
 

Modified: cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java?rev=1407604&r1=1407603&r2=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
(original)
+++ cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
Fri Nov  9 19:52:20 2012
@@ -23,7 +23,6 @@ import java.io.File;
 import java.sql.Driver;
 
 import org.apache.cayenne.access.DbGenerator;
-import org.apache.cayenne.configuration.ToolModule;
 import org.apache.cayenne.conn.DriverDataSource;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
@@ -33,6 +32,7 @@ import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.MapLoader;
+import org.apache.cayenne.tools.configuration.ToolsModule;
 import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.maven.plugin.AbstractMojo;
@@ -137,7 +137,7 @@ public class DbGeneratorMojo extends Abs
 
     public void execute() throws MojoExecutionException, MojoFailureException {
     	
-    	Injector injector = DIBootstrap.createInjector(new ToolModule());
+    	Injector injector = DIBootstrap.createInjector(new ToolsModule());
     	AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);
 
 		Log logger = new MavenLogger(this);

Modified: cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java?rev=1407604&r1=1407603&r2=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
(original)
+++ cayenne/main/trunk/framework/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
Fri Nov  9 19:52:20 2012
@@ -26,19 +26,19 @@ import java.sql.Driver;
 
 import javax.sql.DataSource;
 
-import org.apache.cayenne.access.AbstractDbLoaderDelegate;
 import org.apache.cayenne.access.DbLoader;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.configuration.ToolModule;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.conn.DriverDataSource;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dbimport.ImportDbLoaderDelegate;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.MapLoader;
 import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.naming.NamingStrategy;
+import org.apache.cayenne.tools.configuration.ToolsModule;
 import org.apache.cayenne.util.DeleteRuleUpdater;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.util.XMLEncoder;
@@ -233,7 +233,7 @@ public class DbImporterMojo extends Abst
 
         String schema = getSchema();
 
-        Injector injector = DIBootstrap.createInjector(new ToolModule());
+        Injector injector = DIBootstrap.createInjector(new ToolsModule());
 
         // load driver taking custom CLASSPATH into account...
         DriverDataSource dataSource = new DriverDataSource((Driver) Class
@@ -242,8 +242,7 @@ public class DbImporterMojo extends Abst
         DbAdapter adapter = getAdapter(injector, dataSource);
 
         // Load the data map and run the db importer.
-        AbstractDbLoaderDelegate loaderDelegate = new AbstractDbLoaderDelegate() {
-        };
+        ImportDbLoaderDelegate loaderDelegate = new ImportDbLoaderDelegate();
         DbLoader loader = new DbLoader(dataSource.getConnection(), adapter,
                 loaderDelegate);
         loader.setCreatingMeaningfulPK(meaningfulPk);

Modified: cayenne/main/trunk/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java?rev=1407604&r1=1407603&r2=1407604&view=diff
==============================================================================
--- cayenne/main/trunk/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
(original)
+++ cayenne/main/trunk/framework/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoTest.java
Fri Nov  9 19:52:20 2012
@@ -26,12 +26,12 @@ import javax.sql.DataSource;
 
 import junit.framework.TestCase;
 
-import org.apache.cayenne.configuration.ToolModule;
 import org.apache.cayenne.dba.AutoAdapter;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.mysql.MySQLAdapter;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.tools.configuration.ToolsModule;
 
 public class DbImporterMojoTest extends TestCase {
 
@@ -40,7 +40,7 @@ public class DbImporterMojoTest extends 
         DbImporterMojo mojo = new DbImporterMojo();
 
         DataSource ds = mock(DataSource.class);
-        Injector injector = DIBootstrap.createInjector(new ToolModule());
+        Injector injector = DIBootstrap.createInjector(new ToolsModule());
         DbAdapter adapter = mojo.getAdapter(injector, ds);
         assertNotNull(adapter);
         assertTrue(adapter instanceof AutoAdapter);



Mime
View raw message