cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1358360 - in /cayenne/main/trunk: framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/ modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modele...
Date Fri, 06 Jul 2012 19:13:07 GMT
Author: aadamchik
Date: Fri Jul  6 19:13:06 2012
New Revision: 1358360

URL: http://svn.apache.org/viewvc?rev=1358360&view=rev
Log:
CAY-1718 Remove everything deprecated in 3.1

in progress

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
    cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java?rev=1358360&r1=1358359&r2=1358360&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbGenerator.java
Fri Jul  6 19:13:06 2012
@@ -41,7 +41,6 @@ import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.PkGenerator;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.log.JdbcEventLogger;
-import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -93,31 +92,6 @@ public class DbGenerator {
     protected ValidationResult failures;
 
     /**
-     * Creates and initializes new DbGenerator.
-     * 
-     * @deprecated since 3.1 use {@link #DbGenerator(DbAdapter, DataMap, JdbcEventLogger)}
-     */
-    @Deprecated
-    public DbGenerator(DbAdapter adapter, DataMap map) {
-        this(adapter, map, Collections.<DbEntity> emptyList());
-    }
-
-    /**
-     * Creates and initializes new DbGenerator instance.
-     * 
-     * @param adapter DbAdapter corresponding to the database
-     * @param map DataMap whose entities will be used in schema generation
-     * @param excludedEntities entities that should be ignored during schema generation
-     * @deprecated since 3.1 use
-     *             {@link #DbGenerator(DbAdapter, DataMap, Collection, DataDomain, JdbcEventLogger)}
-     */
-    @Deprecated
-    public DbGenerator(DbAdapter adapter, DataMap map,
-            Collection<DbEntity> excludedEntities) {
-        this(adapter, map, excludedEntities, null, NoopJdbcEventLogger.getInstance());
-    }
-
-    /**
      * @since 3.1
      */
     public DbGenerator(DbAdapter adapter, DataMap map, JdbcEventLogger logger) {
@@ -281,8 +255,11 @@ public class DbGenerator {
         }
 
         Driver driver = (Driver) Class.forName(dsi.getJdbcDriver()).newInstance();
-        DataSource dataSource = new DriverDataSource(driver, dsi.getDataSourceUrl(), dsi
-                .getUserName(), dsi.getPassword());
+        DataSource dataSource = new DriverDataSource(
+                driver,
+                dsi.getDataSourceUrl(),
+                dsi.getUserName(),
+                dsi.getPassword());
 
         runGenerator(dataSource);
     }
@@ -570,8 +547,8 @@ public class DbGenerator {
 
             // create a copy of the original PK list,
             // since the list will be modified locally
-            List<DbAttribute> pkAttributes = new ArrayList<DbAttribute>(nextEntity
-                    .getPrimaryKeys());
+            List<DbAttribute> pkAttributes = new ArrayList<DbAttribute>(
+                    nextEntity.getPrimaryKeys());
             while (pkAttributes.size() > 0 && relationships.hasNext()) {
                 DbRelationship nextRelationship = relationships.next();
                 if (!nextRelationship.isToMasterPK()) {

Modified: cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java?rev=1358360&r1=1358359&r2=1358360&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
(original)
+++ cayenne/main/trunk/framework/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbGeneratorTask.java
Fri Jul  6 19:13:06 2012
@@ -19,6 +19,9 @@
 
 package org.apache.cayenne.tools;
 
+import java.sql.Driver;
+import java.util.Collections;
+
 import org.apache.cayenne.access.DbGenerator;
 import org.apache.cayenne.configuration.ToolModule;
 import org.apache.cayenne.conn.DriverDataSource;
@@ -27,13 +30,13 @@ import org.apache.cayenne.dba.JdbcAdapte
 import org.apache.cayenne.di.AdhocObjectFactory;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
+import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.util.Util;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
-import java.sql.Driver;
-
 /**
  * An Ant Task that is a frontend to Cayenne DbGenerator allowing schema generation from
  * DataMap using Ant.
@@ -53,30 +56,49 @@ public class DbGeneratorTask extends Cay
 
     @Override
     public void execute() {
-        
+
         Injector injector = DIBootstrap.createInjector(new ToolModule());
         AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);
 
         // prepare defaults
         if (adapter == null) {
-            adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());
-        }
-        
-        log(String.format("connection settings - [driver: %s, url: %s, username: %s]", driver,
url, userName), Project.MSG_VERBOSE);
-
-        log(String.format("generator options - [dropTables: %s, dropPK: %s, createTables:
%s, createPK: %s, createFK: %s]",
-                dropTables, dropPK, createTables, createPK, createFK), Project.MSG_VERBOSE);
+            adapter = objectFactory.newInstance(
+                    DbAdapter.class,
+                    JdbcAdapter.class.getName());
+        }
+
+        log(String.format(
+                "connection settings - [driver: %s, url: %s, username: %s]",
+                driver,
+                url,
+                userName), Project.MSG_VERBOSE);
+
+        log(
+                String.format(
+                        "generator options - [dropTables: %s, dropPK: %s, createTables: %s,
createPK: %s, createFK: %s]",
+                        dropTables,
+                        dropPK,
+                        createTables,
+                        createPK,
+                        createFK),
+                Project.MSG_VERBOSE);
 
         validateAttributes();
-        
+
         ClassLoader loader = null;
         try {
             loader = Thread.currentThread().getContextClassLoader();
-            Thread.currentThread().setContextClassLoader(DbGeneratorTask.class.getClassLoader());
+            Thread.currentThread().setContextClassLoader(
+                    DbGeneratorTask.class.getClassLoader());
 
             // Load the data map and run the db generator.
             DataMap dataMap = loadDataMap();
-            DbGenerator generator = new DbGenerator(adapter, dataMap);
+            DbGenerator generator = new DbGenerator(
+                    adapter,
+                    dataMap,
+                    Collections.<DbEntity> emptyList(),
+                    null,
+                    NoopJdbcEventLogger.getInstance());
             generator.setShouldCreateFKConstraints(createFK);
             generator.setShouldCreatePKSupport(createPK);
             generator.setShouldCreateTables(createTables);
@@ -101,7 +123,7 @@ public class DbGeneratorTask extends Cay
             log(message, Project.MSG_ERR);
             throw new BuildException(message, th);
         }
-        finally{
+        finally {
             Thread.currentThread().setContextClassLoader(loader);
         }
     }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java?rev=1358360&r1=1358359&r2=1358360&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DBGeneratorOptions.java
Fri Jul  6 19:13:06 2012
@@ -36,6 +36,7 @@ import javax.swing.event.ChangeListener;
 
 import org.apache.cayenne.access.DbGenerator;
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.log.NoopJdbcEventLogger;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ValidationResultBrowser;
@@ -64,8 +65,7 @@ public class DBGeneratorOptions extends 
 
     protected TableSelectorController tables;
 
-    public DBGeneratorOptions(ProjectController parent, String title,
-            DataMap dataMap) {
+    public DBGeneratorOptions(ProjectController parent, String title, DataMap dataMap) {
         super(parent);
 
         this.dataMap = dataMap;
@@ -78,7 +78,7 @@ public class DBGeneratorOptions extends 
 
         this.view.setTitle(title);
         initController();
-        connectionInfo.setDbAdapter((String)view.getAdapters().getSelectedItem());
+        connectionInfo.setDbAdapter((String) view.getAdapters().getSelectedItem());
 
         tables.updateTables(dataMap);
         prepareGenerator();
@@ -101,19 +101,19 @@ public class DBGeneratorOptions extends 
 
     protected void initController() {
 
-        DefaultComboBoxModel adapterModel = new DefaultComboBoxModel(DbAdapterInfo
-                .getStandardAdapters());
+        DefaultComboBoxModel adapterModel = new DefaultComboBoxModel(
+                DbAdapterInfo.getStandardAdapters());
         view.getAdapters().setModel(adapterModel);
         view.getAdapters().setSelectedIndex(0);
-        
+
         BindingBuilder builder = new BindingBuilder(
                 getApplication().getBindingFactory(),
                 this);
 
         sqlBinding = builder.bindToTextArea(view.getSql(), "textForSQL");
         adapterBinding = builder.bindToComboSelection(
-                view.getAdapters(), 
-                "connectionInfo.dbAdapter", 
+                view.getAdapters(),
+                "connectionInfo.dbAdapter",
                 "refreshSQLAction()",
                 "org.apache.cayenne.dba.JdbcAdapter");
 
@@ -163,7 +163,12 @@ public class DBGeneratorOptions extends 
         try {
             DbAdapter adapter = connectionInfo.makeAdapter(getApplication()
                     .getClassLoadingService());
-            this.generator = new DbGenerator(adapter, dataMap, tables.getExcludedTables());
+            this.generator = new DbGenerator(
+                    adapter,
+                    dataMap,
+                    tables.getExcludedTables(),
+                    null,
+                    NoopJdbcEventLogger.getInstance());
         }
         catch (Exception ex) {
             reportError("Error loading adapter", ex);
@@ -176,7 +181,7 @@ public class DBGeneratorOptions extends 
     protected void createSQL() {
         // convert them to string representation for display
         StringBuffer buf = new StringBuffer();
-        Iterator it = generator.configuredStatements().iterator();
+        Iterator<String> it = generator.configuredStatements().iterator();
         String batchTerminator = generator.getAdapter().getBatchTerminator();
 
         String lineEnd = (batchTerminator != null)
@@ -227,7 +232,7 @@ public class DBGeneratorOptions extends 
     public void refreshSQLAction() {
         // sync generator with defaults, make SQL, then sync the view...
         adapterBinding.updateView();
-        connectionInfo.setDbAdapter((String)view.getAdapters().getSelectedItem());
+        connectionInfo.setDbAdapter((String) view.getAdapters().getSelectedItem());
         prepareGenerator();
         generatorDefaults.configureGenerator(generator);
         createSQL();
@@ -238,7 +243,7 @@ public class DBGeneratorOptions extends 
      * Performs configured schema operations via DbGenerator.
      */
     public void generateSchemaAction() {
-        
+
         DataSourceWizard connectWizard = new DataSourceWizard(
                 this.getParent(),
                 "Generate DB Schema: Connect to Database",
@@ -249,9 +254,9 @@ public class DBGeneratorOptions extends 
             // canceled
             return;
         }
-        
+
         this.connectionInfo = connectWizard.getConnectionInfo();
-        
+
         refreshGeneratorAction();
 
         // sanity check...
@@ -261,7 +266,7 @@ public class DBGeneratorOptions extends 
         }
 
         try {
-            
+
             DataSource dataSource = connectionInfo.makeDataSource(getApplication()
                     .getClassLoadingService());
             generator.runGenerator(dataSource);
@@ -322,11 +327,11 @@ public class DBGeneratorOptions extends 
     public void closeAction() {
         view.dispose();
     }
-    
+
     public DBConnectionInfo getConnectionInfo() {
         return this.connectionInfo;
     }
-    
+
     public void setConnectionInfo(DBConnectionInfo connectionInfo) {
         this.connectionInfo = connectionInfo;
         refreshView();



Mime
View raw message