cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2218 unify cdbimport and cdbgen parameters - move cdbgen connection properties to <dataSource> tag - update cdbgen documentation
Date Fri, 03 Feb 2017 10:24:07 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master ce3ea4291 -> fa85eb60f


CAY-2218 unify cdbimport and cdbgen parameters
 - move cdbgen connection properties to <dataSource> tag
 - update cdbgen documentation


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/fa85eb60
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/fa85eb60
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/fa85eb60

Branch: refs/heads/master
Commit: fa85eb60f6f6510bfc4d4f2bcd86192615a8a64b
Parents: ce3ea42
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Fri Feb 3 13:22:44 2017 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Fri Feb 3 13:22:44 2017 +0300

----------------------------------------------------------------------
 .../src/docbkx/including-cayenne-in-project.xml | 98 ++++++++++++++------
 .../apache/cayenne/tools/DbGeneratorMojo.java   | 55 +++++------
 .../apache/cayenne/tools/DbImporterMojo.java    | 12 ++-
 3 files changed, 103 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/fa85eb60/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml
----------------------------------------------------------------------
diff --git a/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml b/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml
index d4c0942..5ecc16f 100644
--- a/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml
+++ b/docs/docbook/cayenne-guide/src/docbkx/including-cayenne-in-project.xml
@@ -28,7 +28,7 @@
                 </listitem>
                 <listitem>
                     <para>cayenne-client-<?eval ${project.version}?>.jar - a
subset of cayenne-server.jar trimmed for use on
-                        the client in an ROP application.</para>
+                        the client in an <link linkend="introduction-to-rop">ROP application</link>.</para>
                 </listitem>
                 <listitem>
                     <para>Other cayenne-* jars - various Cayenne extensions.</para>
@@ -83,8 +83,8 @@
                 <table frame="void">
                     <caption>cgen required parameters</caption>
                     <col width="14%"/>
-                    <col width="6%"/>
-                    <col width="80%"/>
+                    <col width="7%"/>
+                    <col width="79%"/>
                     <thead>
                         <tr>
                             <th>Name</th>
@@ -105,9 +105,9 @@
                 </table>
                 <table frame="void">
                     <caption>cgen optional parameters</caption>
-                    <col width="33%"/>
-                    <col width="8%"/>
-                    <col width="59%"/>
+                    <col width="14%"/>
+                    <col width="7%"/>
+                    <col width="79%"/>
                     <thead>
                         <tr>
                             <th>Name</th>
@@ -258,8 +258,8 @@
 				<table frame="void">
 					<caption>cdbgen required parameters</caption>
 					<col width="14%"/>
-					<col width="8%"/>
-					<col width="78%"/>
+					<col width="7%"/>
+					<col width="79%"/>
 					<thead>
 						<tr>
 							<th>Name</th>
@@ -276,24 +276,64 @@
 								generation. E.g.
 									<code>${project.basedir}/src/main/resources/my.map.xml</code></td>
 						</tr>
-						<tr>
-							<td><code>driver</code></td>
-							<td>String</td>
-							<td>A class of JDBC driver to use for the target database.</td>
-						</tr>
-						<tr>
-							<td><code>url</code></td>
-							<td>String</td>
-							<td>JDBC connection URL of a target database.</td>
-						</tr>
+                        <tr>
+                            <td><code>dataSource</code>
+                            </td>
+                            <td>XML</td>
+                            <td>An object that contains Data Source parameters</td>
+                        </tr>
 					</tbody>
-				</table></para>
+				</table>
+            </para>
+            <para>
+                <table frame="void">
+                    <caption>&lt;dataSource> parameters</caption>
+                    <col width="14%"/>
+                    <col width="7%"/>
+                    <col width="7%"/>
+                    <col width="72%"/>
+                    <thead>
+                        <tr>
+                            <th>Name</th>
+                            <th>Type</th>
+                            <th>Required</th>
+                            <th>Description</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <tr>
+                            <td><code>driver</code></td>
+                            <td>String</td>
+                            <td>Yes</td>
+                            <td>A class of JDBC driver to use for the target database.</td>
+                        </tr>
+                        <tr>
+                            <td><code>url</code></td>
+                            <td>String</td>
+                            <td>Yes</td>
+                            <td>JDBC URL of a target database.</td>
+                        </tr>
+                        <tr>
+                            <td><code>username</code></td>
+                            <td>String</td>
+                            <td>No</td>
+                            <td>Database user name.</td>
+                        </tr>
+                        <tr>
+                            <td><code>password</code></td>
+                            <td>String</td>
+                            <td>No</td>
+                            <td>Database user password.</td>
+                        </tr>
+                    </tbody>
+                </table>
+            </para>
 			<para>
 				<table frame="void">
 					<caption>cdbgen optional parameters</caption>
-					<col width="18%"/>
-					<col width="8%"/>
-					<col width="74%"/>
+					<col width="14%"/>
+					<col width="7%"/>
+					<col width="79%"/>
 					<thead>
 						<tr>
 							<th>Name</th>
@@ -361,10 +401,12 @@
         &lt;execution>
             &lt;configuration>
                 &lt;map>${project.basedir}/src/main/resources/my.map.xml&lt;/map>
-                &lt;url>jdbc:hsqldb:hsql://localhost/testdb&lt;/url>
                 &lt;adapter>org.apache.cayenne.dba.hsqldb.HSQLDBAdapter&lt;/adapter>
-                &lt;driver>org.hsqldb.jdbcDriver&lt;/driver>
-                &lt;username>sa&lt;/username>
+                &lt;dataSource>
+                    &lt;url>jdbc:hsqldb:hsql://localhost/testdb&lt;/url>
+                    &lt;driver>org.hsqldb.jdbcDriver&lt;/driver>
+                    &lt;username>sa&lt;/username>
+                &lt;/dataSource>
             &lt;/configuration>
             &lt;goals>
                 &lt;goal>cdbgen&lt;/goal>
@@ -484,9 +526,9 @@
 			<para>
 				<table frame="void">
 					<caption>&lt;dbimport> parameters</caption>
-					<col width="18%"/>
-					<col width="8%"/>
-					<col width="73%"/>
+					<col width="14%"/>
+					<col width="7%"/>
+					<col width="79%"/>
 					<thead>
 						<tr>
 							<th>Name</th>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fa85eb60/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
index 0ef8a1c..6125b9c 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbGeneratorMojo.java
@@ -68,28 +68,13 @@ public class DbGeneratorMojo extends AbstractMojo {
     private String adapter;
 
     /**
-     * A class of JDBC driver to use for the target database.
+     * Connection properties.
+     *
+     * @see DbImportDataSourceConfig
+     * @since 4.0
      */
     @Parameter(required = true)
-    private String driver;
-
-    /**
-     * JDBC connection URL of a target database.
-     */
-    @Parameter(required = true)
-    private String url;
-
-    /**
-     * Database user name.
-     */
-    @Parameter
-    private String username;
-
-    /**
-     * Database user password.
-     */
-    @Parameter
-    private String password;
+    private DbImportDataSourceConfig dataSource = new DbImportDataSourceConfig();
 
     /**
      * Defines whether cdbgen should drop the tables before attempting to create
@@ -126,21 +111,29 @@ public class DbGeneratorMojo extends AbstractMojo {
     @Parameter(defaultValue = "true")
     private boolean createFK;
 
+    /**
+     * @deprecated use {@code <dataSource>} tag to set connection properties
+     */
+    @Deprecated @Parameter(name = "driver", property = "driver")
+    private final String oldDriver = "";             // TODO remove in 4.0.BETA
+
     public void execute() throws MojoExecutionException, MojoFailureException {
 
         Log logger = new MavenLogger(this);
         Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger));
         AdhocObjectFactory objectFactory = injector.getInstance(AdhocObjectFactory.class);
 
-        logger.info(String.format("connection settings - [driver: %s, url: %s, username:
%s]", driver, url, username));
+        logger.info(String.format("connection settings - [driver: %s, url: %s, username:
%s]",
+                dataSource.getDriver(), dataSource.getUrl(), dataSource.getUsername()));
 
         logger.info(String.format(
                 "generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK:
%s, createFK: %s]",
                 dropTables, dropPK, createTables, createPK, createFK));
 
         try {
-            final DbAdapter adapterInst = (adapter == null) ? (DbAdapter) objectFactory.newInstance(DbAdapter.class,
-                    JdbcAdapter.class.getName()) : (DbAdapter) objectFactory.newInstance(DbAdapter.class,
adapter);
+            final DbAdapter adapterInst = (adapter == null) ?
+                    objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName())
:
+                    objectFactory.newInstance(DbAdapter.class, adapter);
 
             // Load the data map and run the db generator.
             DataMap dataMap = loadDataMap();
@@ -152,28 +145,30 @@ public class DbGeneratorMojo extends AbstractMojo {
             generator.setShouldDropTables(dropTables);
 
             // load driver taking custom CLASSPATH into account...
-            DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(),
url,
-                    username, password);
+            DriverDataSource driverDataSource = new DriverDataSource((Driver) Class.forName(dataSource.getDriver()).newInstance(),
+                    dataSource.getUrl(), dataSource.getUsername(), dataSource.getPassword());
 
-            generator.runGenerator(dataSource);
+            generator.runGenerator(driverDataSource);
         } catch (Exception ex) {
             Throwable th = Util.unwindException(ex);
-
             String message = "Error generating database";
-
             if (th.getLocalizedMessage() != null) {
                 message += ": " + th.getLocalizedMessage();
             }
-
             logger.error(message);
             throw new MojoExecutionException(message, th);
         }
     }
 
     /** Loads and returns DataMap based on <code>map</code> attribute. */
-    protected DataMap loadDataMap() throws Exception {
+    private DataMap loadDataMap() throws Exception {
         InputSource in = new InputSource(map.getCanonicalPath());
         return new MapLoader().loadDataMap(in);
     }
 
+    @Deprecated
+    public void setDriver(String driver) {
+        throw new UnsupportedOperationException("Connection properties were replaced with
<dataSource> tag since 4.0.M5.\n" +
+                "\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/fa85eb60/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
----------------------------------------------------------------------
diff --git a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
index 2d2d761..e9bb38a 100644
--- a/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
+++ b/maven-plugins/cayenne-maven-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
@@ -191,22 +191,26 @@ public class DbImporterMojo extends AbstractMojo {
     // TODO ⬇⬇⬇ All following setters should be removed in 4.0.BETA ⬇⬇⬇
     @Deprecated
     public void setUrl(String url) {
-        throw new UnsupportedOperationException("Connection properties were replaced with
<dataSource> tag since 4.0.M5.\n\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
+        throw new UnsupportedOperationException("Connection properties were replaced with
<dataSource> tag since 4.0.M5.\n" +
+                "\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
     }
 
     @Deprecated
     public void setDriver(String driver) {
-        throw new UnsupportedOperationException("Connection properties were replaced with
<dataSource> tag since 4.0.M5.\n\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
+        throw new UnsupportedOperationException("Connection properties were replaced with
<dataSource> tag since 4.0.M5.\n" +
+                "\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
     }
 
     @Deprecated
     public void setMeaningfulPkTables(String meaningfulPkTables) {
-        throw new UnsupportedOperationException("meaningfulPkTables property has been moved
to <dbimport> tag since 4.0.M5.\n\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
+        throw new UnsupportedOperationException("meaningfulPkTables property has been moved
to <dbimport> tag since 4.0.M5.\n" +
+                "\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
     }
 
     @Deprecated
     public void setDefaultPackage(String defaultPackage) {
-        throw new UnsupportedOperationException("defaultPackage property has been moved to
<dbimport> tag since 4.0.M5.\n\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
+        throw new UnsupportedOperationException("defaultPackage property has been moved to
<dbimport> tag since 4.0.M5.\n" +
+                "\tFor additional information see http://cayenne.apache.org/docs/4.0/cayenne-guide/including-cayenne-in-project.html#maven-projects");
     }
 }
 


Mime
View raw message