You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2007/08/22 04:58:08 UTC
svn commit: r568386 - in
/ibatis/trunk/java/mapper/mapper2/tools/abator/core: build/ doc/ htmldoc/
src/org/apache/ibatis/abator/ant/ src/org/apache/ibatis/abator/api/
src/org/apache/ibatis/abator/config/
src/org/apache/ibatis/abator/internal/util/messa...
Author: jgbutler
Date: Tue Aug 21 19:58:07 2007
New Revision: 568386
URL: http://svn.apache.org/viewvc?rev=568386&view=rev
Log:
Add ability to specify contexts and/or table names from any or the command line
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties Tue Aug 21 19:58:07 2007
@@ -1,4 +1,4 @@
#Abator build version info
-#Tue Jun 05 21:25:26 CDT 2007
-version=1.0.1
-buildNum=363
+#Tue Aug 21 21:49:49 CDT 2007
+version=1.1.0
+buildNum=365
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/doc/ReleaseNotes.txt Tue Aug 21 19:58:07 2007
@@ -29,7 +29,11 @@
columns.
9. API change to allow generating with selected contexts rather than
the entire config file.
-10. IBATIS-414 - make the Example and Criteria classes extendable
+10. API change to allow generating with selected tables rather than
+ the entire config file.
+11. Exposed new support for selecting tables and/or contexts to the
+ command line and the Ant task
+12. IBATIS-414 - make the Example and Criteria classes extendable
-------------------------------------------------------------------------------
Version 1.0.0:
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/htmldoc/running.html Tue Aug 21 19:58:07 2007
@@ -37,21 +37,58 @@
<p>Abator can be run directly from the command line. The JAR manifest includes the
name of the default class (<code>org.apache.ibatis.abator.api.AbatorRunner</code>)
or you can specify it yourself. The <code>AbatorRunner</code>
- class takes two arguments: the name of the configuration file,
- and a flag (<code>true</code> or <code>false</code>) specifying whether existing Java files
- should be overwritten. If the flag is <code>false</code>, and an Java file already exists
- with the same name as a newly generated file, then Abator will write the
- newly generated Java file to the proper directory with a unique name
- (e.g. MyClass.java.1, MyClass.java.2, etc.).
- <b>Important: Abator will always merge and overwrite XML files.</b></p>
+ class accepts several arguments as detailed below:</p>
+<table border="1" cellspacing="0" cellpadding="5">
+<tr>
+ <th>Argument</th>
+ <th>Value</th>
+</tr>
+<tr>
+ <td>-configfile (required)</td>
+ <td>Specifies the name of the configuration file.</td>
+</tr>
+<tr>
+ <td>-overwrite (optional)</td>
+ <td>If specified, then existing Java files will be overwritten if an existing Java
+ file if found with the same nae as a generated file. If not specified, and a
+ Java file already exists with the same name as a generated file, then Abator
+ will write the newly generated Java file to the proper directory with a
+ unique name (e.g. MyClass.java.1, MyClass.java.2, etc.).
+ <b>Important: Abator will always merge and overwrite XML files.</b></td>
+</tr>
+<tr>
+ <td>-contextids (optional)</td>
+ <td>If specified, then this is a comma delimited list of contexts to use in
+ the current run of Abator. Any id specified in the list must exactly
+ match the value of the <code>id</code> attribute of an
+ <abatorContext> configuration element. Only ids specified
+ in this list will be active for this run of Abator. If this argument
+ is not specified, then all contexts will be active.</td>
+</tr>
+<tr>
+ <td>-tables (optional)</td>
+ <td>If specified, then this is a comma delimited list of tables to use in
+ the current run of Abator. Any table specified in the list must exactly
+ match the fully qualified table name specified in a
+ <table> configuration element. Only tables specified
+ in this list will be active for this run of Abator. If this argument
+ is not specified, then all tables will be active.
+ Specify table names as: <br/><br/>
+ <code>table</code><br/>
+ <code>schema.table</code><br/>
+ <code>catalog..table</code><br/>
+ etc.</td>
+</tr>
+</table>
+
<p>You must still create an Abator XML configuration file. If the file is
named "abatorConfig.xml", then any of the following command lines will run
Abator:</p>
<pre>
- java -jar abator.jar abatorConfig.xml false
- java -jar abator.jar abatorConfig.xml true
- java -cp abator.jar org.apache.ibatis.abator.api.AbatorRunner abatorConfig.xml false
- java -cp abator.jar org.apache.ibatis.abator.api.AbatorRunner abatorConfig.xml true
+ java -jar abator.jar -configfile abatorConfig.xml
+ java -jar abator.jar -configfile abatorConfig.xml -overwrite
+ java -cp abator.jar org.apache.ibatis.abator.api.AbatorRunner -configfile abatorConfig.xml
+ java -cp abator.jar org.apache.ibatis.abator.api.AbatorRunner -configfile abatorConfig.xml -overwrite
</pre>
<h2>Running Abator from Ant</h2>
@@ -74,6 +111,56 @@
</target>
</project>
</pre>
+
+<p>Abator task attributes are as follows:</p>
+<table border="1" cellspacing="0" cellpadding="5">
+<tr>
+ <th>Attribute</th>
+ <th>Value</th>
+</tr>
+<tr>
+ <td>configfile (required)</td>
+ <td>Specifies the name of the configuration file.</td>
+</tr>
+<tr>
+ <td>overwrite (optional)</td>
+ <td>If "true", "yes", etc., then existing Java files will be overwritten if an existing Java
+ file if found with the same nae as a generated file. If "false", "no", etc., and a
+ Java file already exists with the same name as a generated file, then Abator
+ will write the newly generated Java file to the proper directory with a
+ unique name (e.g. MyClass.java.1, MyClass.java.2, etc.).
+ <b>Important: Abator will always merge and overwrite XML files.</b></td>
+</tr>
+<tr>
+ <td>contextids (optional)</td>
+ <td>If specified, then this is a comma delimited list of contexts to use in
+ the current run of Abator. Any id specified in the list must exactly
+ match the value of the <code>id</code> attribute of an
+ <abatorContext> configuration element. Only ids specified
+ in this list will be active for this run of Abator. If this argument
+ is not specified, then all contexts will be active.</td>
+</tr>
+<tr>
+ <td>tables (optional)</td>
+ <td>If specified, then this is a comma delimited list of tables to use in
+ the current run of Abator. Any table specified in the list must exactly
+ match the fully qualified table name specified in a
+ <table> configuration element. Only tables specified
+ in this list will be active for this run of Abator. If this argument
+ is not specified, then all tables will be active.
+ Specify table names as: <br/><br/>
+ <code>table</code><br/>
+ <code>schema.table</code><br/>
+ <code>catalog..table</code><br/>
+ etc.</td>
+</tr>
+<tr>
+ <td>verbose (optional)</td>
+ <td>If "true", "yes", etc., then Abator will log progress messages to the
+ ant console. The default is "false".</td>
+</tr>
+</table>
+
<p>Notes:</p>
<ul>
<li>The classpath on the <taskdef> is used to tell Ant where the implementing
@@ -81,15 +168,6 @@
of the other ways described in the Ant manual</li>
<li>The name of the task can be anything you desire, "abator" is
simply an example</li>
- <li>The "overwrite" attribute is optional. If "true", "yes", etc. then Abator
- will overwrite any existing Java files. If "false", "no", etc. then
- Abator will not touch existing Java files - the newly generated Java file
- will be saved with a unique filename instead. The default is "false".
- <b>Important: Abator will always merge and overwrite XML files.</b></li>
- <li>The "configfile" attribute is required - it must specify a valid Abator
- configuration XML file.</li>
- <li>The "verbose" attribute is optional. If "true", "yes", etc then the task will
- log Abator progress messages to the Ant console. The default is "false".</li>
<li>The task supports an optional nested <code><propertyset></code> element which
is the standard Ant property set type. This can be used to pass parameters into
a configuration file. For example, the above property
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AbatorAntTask.java Tue Aug 21 19:58:07 2007
@@ -19,9 +19,12 @@
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.ibatis.abator.api.Abator;
import org.apache.ibatis.abator.config.AbatorConfiguration;
@@ -56,6 +59,15 @@
* </project>
* </pre>
*
+ * The task also supports these optional attributes:
+ * <ul>
+ * <li>"contextIds" - a comma delimited list of contaxtIds to use
+ * for this run</li>
+ * <li>"fullyQualifiedTableNames" - a comma delimited list of
+ * fully qualified table names to use for this run</li>
+ * </ul>
+ *
+ *
* @author Jeff Butler
*/
public class AbatorAntTask extends Task {
@@ -64,6 +76,8 @@
private boolean overwrite;
private PropertySet propertyset;
private boolean verbose;
+ private String contextIds;
+ private String fullyQualifiedTableNames;
/**
*
@@ -87,6 +101,28 @@
throw new BuildException(Messages.getString("RuntimeError.1", configfile)); //$NON-NLS-1$
}
+ Set fullyqualifiedTables = new HashSet();
+ if (StringUtility.stringHasValue(fullyQualifiedTableNames)) {
+ StringTokenizer st = new StringTokenizer(fullyQualifiedTableNames, ",");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ fullyqualifiedTables.add(s);
+ }
+ }
+ }
+
+ List contexts = new ArrayList();
+ if (StringUtility.stringHasValue(contextIds)) {
+ StringTokenizer st = new StringTokenizer(contextIds, ",");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ contexts.add(s);
+ }
+ }
+ }
+
try {
Properties p = propertyset == null ? null : propertyset.getProperties();
@@ -98,7 +134,7 @@
Abator abator = new Abator(config, callback, warnings);
- abator.generate(new AntProgressCallback(this, verbose));
+ abator.generate(new AntProgressCallback(this, verbose), contexts, fullyqualifiedTables);
} catch (XMLParserException e) {
Iterator errors = e.getErrors().iterator();
@@ -173,5 +209,21 @@
public void setVerbose(boolean verbose) {
this.verbose = verbose;
+ }
+
+ public String getContextIds() {
+ return contextIds;
+ }
+
+ public void setContextIds(String contextIds) {
+ this.contextIds = contextIds;
+ }
+
+ public String getFullyQualifiedTableNames() {
+ return fullyQualifiedTableNames;
+ }
+
+ public void setFullyQualifiedTableNames(String fullyQualifiedTableNames) {
+ this.fullyQualifiedTableNames = fullyQualifiedTableNames;
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/Abator.java Tue Aug 21 19:58:07 2007
@@ -44,7 +44,7 @@
* be the result of a parsing the XML configuration file, or it can be created
* solely in Java.</li>
* <li>Create an Abator object</li>
- * <li>Call the generate() method</li>
+ * <li>Call one of the generate() methods</li>
* </ol>
*
* @see org.apache.ibatis.abator.config.xml.AbatorConfigurationParser
@@ -121,7 +121,7 @@
*/
public void generate(ProgressCallback callback)
throws SQLException, IOException, InterruptedException {
- generate(callback, null);
+ generate(callback, null, null);
}
/**
@@ -141,6 +141,32 @@
*/
public void generate(ProgressCallback callback, List contextIds)
throws SQLException, IOException, InterruptedException {
+ generate(callback, contextIds, null);
+ }
+
+ /**
+ * This is the main method for generating code. This method is long running, but
+ * progress can be provided and the method can be cancelled through the ProgressCallback
+ * interface.
+ *
+ * @param callback an instance of the ProgressCallback interface, or <code>null</code>
+ * if you do not require progress information
+ * @param contextIds a list of Strings containing context ids to run. Only the
+ * contexts with an id specified in this list will be run. If the list is
+ * null or empty, than all contexts are run.
+ * @param fullyQualifiedTableNames a set of table names to generate. The elements
+ * of the set must be Strings that exactly match what's specified in the configuration.
+ * For example, if table name = "foo" and schema = "bar", then the fully qualified
+ * table name is "foo.bar".
+ * If the Set is null or empty, then all tables in the configuration will be
+ * used for code generation.
+ * @throws InvalidConfigurationException
+ * @throws SQLException
+ * @throws IOException
+ * @throws InterruptedException if the method is cancelled through the ProgressCallback
+ */
+ public void generate(ProgressCallback callback, List contextIds, Set fullyQualifiedTableNames)
+ throws SQLException, IOException, InterruptedException {
if (callback == null) {
callback = new NullProgressCallback();
@@ -180,7 +206,7 @@
AbatorContext abatorContext = (AbatorContext) iter.next();
abatorContext.generateFiles(callback, generatedJavaFiles,
- generatedXmlFiles, warnings);
+ generatedXmlFiles, warnings, fullyQualifiedTableNames);
}
iter = generatedXmlFiles.iterator();
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/api/AbatorRunner.java Tue Aug 21 19:58:07 2007
@@ -19,8 +19,13 @@
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
import org.apache.ibatis.abator.config.AbatorConfiguration;
import org.apache.ibatis.abator.config.xml.AbatorConfigurationParser;
@@ -35,34 +40,56 @@
* @author Jeff Butler
*/
public class AbatorRunner {
+ private static final String ARGUMENT_PREFIX = "-"; //$NON-NLS-1$
+ private static final String CONFIG_FILE = "-configfile"; //$NON-NLS-1$
+ private static final String OVERWRITE = "-overwrite"; //$NON-NLS-1$
+ private static final String CONTEXT_IDS = "-contextids"; //$NON-NLS-1$
+ private static final String TABLES = "-tables"; //$NON-NLS-1$
public static void main(String[] args) {
- if (args.length != 2) {
- usage();
- return;
- }
-
- String configfile = args[0];
- boolean overwrite = "true".equalsIgnoreCase(args[1]); //$NON-NLS-1$
-
- List warnings = new ArrayList();
+ Map arguments = parseCommandLine(args);
+ List warnings = new ArrayList();
+
+ String configfile = (String) arguments.get(CONFIG_FILE);
File configurationFile = new File(configfile);
if (!configurationFile.exists()) {
writeLine(Messages.getString("RuntimeError.1", configfile)); //$NON-NLS-1$
return;
}
+ Set fullyqualifiedTables = new HashSet();
+ if (arguments.containsKey(TABLES)) {
+ StringTokenizer st = new StringTokenizer((String)arguments.get(TABLES), ",");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ fullyqualifiedTables.add(s);
+ }
+ }
+ }
+
+ List contexts = new ArrayList();
+ if (arguments.containsKey(CONTEXT_IDS)) {
+ StringTokenizer st = new StringTokenizer((String)arguments.get(CONTEXT_IDS), ",");
+ while (st.hasMoreTokens()) {
+ String s = st.nextToken().trim();
+ if (s.length() > 0) {
+ contexts.add(s);
+ }
+ }
+ }
+
try {
AbatorConfigurationParser cp = new AbatorConfigurationParser(
warnings);
AbatorConfiguration config = cp.parseAbatorConfiguration(configurationFile);
- DefaultShellCallback callback = new DefaultShellCallback(overwrite);
+ DefaultShellCallback callback = new DefaultShellCallback(arguments.containsKey(OVERWRITE));
Abator abator = new Abator(config, callback, warnings);
- abator.generate(null);
+ abator.generate(null, contexts, fullyqualifiedTables);
} catch (XMLParserException e) {
writeLine(Messages.getString("Progress.3")); //$NON-NLS-1$
@@ -102,12 +129,12 @@
}
private static void usage() {
- writeLine(Messages.getString("Usage.0")); //$NON-NLS-1$
- writeLine(Messages.getString("Usage.1")); //$NON-NLS-1$
- writeLine(Messages.getString("Usage.2")); //$NON-NLS-1$
- writeLine(Messages.getString("Usage.3")); //$NON-NLS-1$
- writeLine(Messages.getString("Usage.4")); //$NON-NLS-1$
- writeLine(Messages.getString("Usage.5")); //$NON-NLS-1$
+ String lines = Messages.getString("Usage.Lines"); //$NON-NLS-1$
+ int iLines = Integer.parseInt(lines);
+ for (int i = 0; i < iLines; i++) {
+ String key = "Usage." + i; //$NON-NLS-1$
+ writeLine(Messages.getString(key));
+ }
}
private static void writeLine(String message) {
@@ -117,4 +144,74 @@
private static void writeLine() {
System.out.println();
}
+
+ private static Map parseCommandLine(String[] args) {
+ if (args.length == 0) {
+ usage();
+ System.exit(0);
+ return null; // only to satisfy compiler, never returns
+ } else if (args.length == 2) {
+ if (args[0].startsWith(ARGUMENT_PREFIX)) {
+ return parseNewCommandLine(args);
+ } else {
+ return parseOldCommandLine(args);
+ }
+ } else {
+ return parseNewCommandLine(args);
+ }
+ }
+
+ private static Map parseOldCommandLine(String[] args) {
+ Map arguments = new HashMap();
+ arguments.put(CONFIG_FILE, args[0]);
+ if ("true".equalsIgnoreCase(args[1])) { //$NON-NLS-1$
+ arguments.put(OVERWRITE, "Y"); //$NON-NLS-1$
+ }
+
+ return arguments;
+ }
+
+ private static Map parseNewCommandLine(String[] args) {
+ List errors = new ArrayList();
+ Map arguments = new HashMap();
+
+ for (int i = 0; i < args.length; i++) {
+ if (CONFIG_FILE.equalsIgnoreCase(args[i])) {
+ if ((i + 1) < args.length) {
+ arguments.put(CONFIG_FILE, args[i + 1]);
+ } else {
+ errors.add(Messages.getString("RuntimeError.19", CONFIG_FILE)); //$NON-NLS-1$
+ }
+ i++;
+ } else if (OVERWRITE.equalsIgnoreCase(args[i])) {
+ arguments.put(OVERWRITE, "Y"); //$NON-NLS-1$
+ } else if (CONTEXT_IDS.equalsIgnoreCase(args[i])) {
+ if ((i + 1) < args.length) {
+ arguments.put(CONTEXT_IDS, args[i + 1]);
+ } else {
+ errors.add(Messages.getString("RuntimeError.19", CONTEXT_IDS)); //$NON-NLS-1$
+ }
+ i++;
+ } else if (TABLES.equalsIgnoreCase(args[i])) {
+ if ((i + 1) < args.length) {
+ arguments.put(TABLES, args[i + 1]);
+ } else {
+ errors.add(Messages.getString("RuntimeError.19", TABLES)); //$NON-NLS-1$
+ }
+ i++;
+ } else {
+ errors.add(Messages.getString("RuntimeError.20", args[i])); //$NON-NLS-1$
+ }
+ }
+
+ if (!errors.isEmpty()) {
+ for (int i = 0; i < errors.size(); i++) {
+ writeLine((String) errors.get(i));
+ }
+
+ System.exit(-1);
+ }
+
+ return arguments;
+ }
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/AbatorContext.java Tue Aug 21 19:58:07 2007
@@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.apache.ibatis.abator.api.DAOGenerator;
import org.apache.ibatis.abator.api.IntrospectedTable;
@@ -243,13 +244,20 @@
* The objects will be of type GeneratedXMLFile.
* @param warnings any warning generated from this method will be added to the List. Warnings
* are always Strings.
+ * @param fullyQualifiedTableNames a set of table names to generate. The elements
+ * of the set must be Strings that exactly match what's specified in the configuration.
+ * For example, if table name = "foo" and schema = "bar", then the fully qualified
+ * table name is "foo.bar".
+ * If the Set is null or empty, then all tables in the configuration will be
+ * used for code generation.
*
* @throws SQLException if some error arrises while introspecting the specified
* database tables.
*
* @throws InterruptedException if the progress callback reports a cancel
*/
- public void generateFiles(ProgressCallback callback, List generatedJavaFiles, List generatedXmlFiles, List warnings)
+ public void generateFiles(ProgressCallback callback, List generatedJavaFiles, List generatedXmlFiles, List warnings,
+ Set fullyQualifiedTableNames)
throws SQLException, InterruptedException {
if (callback == null) {
@@ -275,6 +283,13 @@
TableConfiguration tc = (TableConfiguration) iter.next();
String tableName = StringUtility.composeFullyQualifiedTableName(
tc.getCatalog(), tc.getSchema(), tc.getTableName(), '.');
+
+ if (fullyQualifiedTableNames != null
+ && fullyQualifiedTableNames.size() > 0) {
+ if (!fullyQualifiedTableNames.contains(tableName)) {
+ continue;
+ }
+ }
if (!tc.areAnyStatementsEnabled()) {
warnings.add(Messages.getString("Warning.0", tableName)); //$NON-NLS-1$
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties?rev=568386&r1=568385&r2=568386&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/messages.properties Tue Aug 21 19:58:07 2007
@@ -31,6 +31,8 @@
RuntimeError.16=Cannot load properties from <properties> resource {0}
RuntimeError.17=Cannot load properties from <properties> url {0}
RuntimeError.18=Unsupported XML Node Type {0} in XML File Merger
+RuntimeError.19=Value missing after {0}
+RuntimeError.20=Unknown argument: {0}
Warning.0=There are no statements enabled for table {0}, this table will be ignored.
Warning.1=Table {0} does not exist, this table will be ignored
@@ -68,9 +70,26 @@
Progress.12=Generating SQL Map for table {0}
Progress.13=Found SQL Statement: {0}
+Usage.Lines=20
Usage.0=Abator code generator for iBATIS. Usage:
-Usage.1=\ java -jar abator.jar configfile overwrite
-Usage.2=
-Usage.3=Where:
-Usage.4=\ configfile: the name of the abator XML configuration file
-Usage.5=\ overwrite: true if exsting Java files should be overwritten
+Usage.1=\ java -jar abator.jar -configfile file_name
+Usage.2=\ [-overwrite]
+Usage.3=\ [-contextids ids]
+Usage.4=\ [-tables tableName]
+Usage.5=
+Usage.6=Where:
+Usage.7=\ -configfile: Specifies the name of the abator XML configuration file (required)
+Usage.8=
+Usage.9=\ -overwrite: If specified then exsting Java files will be overwritten.
+Usage.10=\ If not specified, then Abator will not overwrite existing
+Usage.11=\ Java files (will save results in uniqely named files)
+Usage.12=
+Usage.13=\ -contextids: Used to specify a comma delimited list of contexts to use in this
+Usage.14=\ run of Abator. If not specified, all contexts will be used.
+Usage.15=
+Usage.16=\ -tables: Used to specify a comma delimited list of tables to use in this
+Usage.17=\ run of Abator. If not specified, all tables will be used. Table
+Usage.18=\ names must be fully qualified (e.g. schema.tablename). Table names
+Usage.19=\ must exactly match the case specified in the configuration file.
+
+