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 2006/08/16 04:32:12 UTC
svn commit: r431771 [1/11] - in
/ibatis/trunk/java/mapper/mapper2/tools/abator/core: build/ devlib/
src/org/apache/ibatis/abator/ant/ src/org/apache/ibatis/abator/api/
src/org/apache/ibatis/abator/config/xml/
src/org/apache/ibatis/abator/exception/ src...
Author: jgbutler
Date: Tue Aug 15 19:32:09 2006
New Revision: 431771
URL: http://svn.apache.org/viewvc?rev=431771&view=rev
Log:
Many tests for IBATIS-328: generate a flat domain model. Also, enhancements to the Ant task to make Abator testable.
Added:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/README.txt
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/hsqldb.jar (with props)
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-common-2.jar (with props)
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-dao-2.jar (with props)
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-sqlmap-2.jar (with props)
ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/junit.jar (with props)
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AntProgressCallback.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/README.txt
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/BaseTest.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/CreateDB.sql
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/abatorConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java2/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java2/ConditionalJava2Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java2/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java2/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java5/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java5/ConditionalJava5Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java5/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/java5/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/legacy/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/legacy/ConditionalLegacyTests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/legacy/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/conditional/legacy/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java2/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java2/FlatJava2Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java2/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java2/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java5/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java5/FlatJava5Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java5/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/java5/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/legacy/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/legacy/FlatLegacyTests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/legacy/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/flat/legacy/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java2/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java2/HierarchicalJava2Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java2/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java2/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java5/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java5/HierarchicalJava5Tests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java5/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/java5/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/legacy/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/legacy/HierarchicalLegacyTests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/legacy/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/hierarchical/legacy/dao.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/BaseClass.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/BaseInterface.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/FirstName.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/FirstNameTypeHandler.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/MiscellaneousTests.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/MyTime.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/MyTimeTypeHandler.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/SqlMapConfig.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/execute/miscellaneous/dao.xml
Modified:
ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/build.xml
ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/version.properties
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/config/xml/AbatorConfigurationParser.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/exception/XMLParserException.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ConnectionFactory.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java
ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/Messages.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/build.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/build.xml?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/build.xml (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/build/build.xml Tue Aug 15 19:32:09 2006
@@ -1,6 +1,24 @@
<project name="Abator for iBATIS" default="buildAbator" basedir=".">
- <!-- Note: to update the version of Abator, change the
+ <!--
+ This is the build file for Abator. To run the build,
+ execute this command:
+
+ ant -lib ../devlib
+
+ (This will execute the default build target of buildAbator)
+
+ It is required to add the -lib parameter, the tests will not run
+ properly without it.
+
+ You can also delete the generated artifacts with:
+
+ ant clean
+
+ Important: the build requires a JSE 5.0 or greater compiler!!!
+ Abator itself is compiled for JSE 1.4, but the tests require 5.0.
+
+ Note: to update the version of Abator, change the
version.properties file (the "version" property).
-->
@@ -12,13 +30,19 @@
<property name="work.dir" value="${basedir}/work" />
<property name="work.classes" value="${work.dir}/bin" />
<property name="work.javadoc" value="${work.dir}/javadoc" />
+ <property name="test.src.dir" value="${work.dir}/test/src" />
+ <property name="generated.source.dir" value="${work.dir}/src" />
+ <property name="reports.dir" value="${basedir}/reports" />
+ <property name="reports.junit" value="${reports.dir}/junit" />
- <target name="clean">
+ <target name="clean" unless="${TSTAMP}">
+ <tstamp/>
<delete dir="${work.dir}" />
<delete dir="${deploy.dir}" />
+ <delete dir="${reports.dir}" />
</target>
- <target name="prepare" depends="clean">
+ <target name="build.prepare" depends="clean">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${work.dir}"/>
<mkdir dir="${work.classes}"/>
@@ -40,17 +64,23 @@
</propertyfile>
</target>
- <target name="buildAbatorJar" depends="prepare">
+ <target name="build.compile" depends="build.prepare">
<javac srcdir="${src.dir}"
destdir="${work.classes}"
deprecation="true"
debug="true"
+ source="1.4"
+ target="1.4"
classpath="../devlib/ant.jar"/>
+ </target>
+
+ <target name="build.abator.jar" depends="build.compile">
<!-- copy non-compilable resources -->
<copy todir="${work.classes}">
<fileset dir="${src.dir}" >
<exclude name="**/*.java"/>
+ <exclude name="**/.*/**"/> <!-- exclude any . files (SVN) -->
</fileset>
</copy>
@@ -66,7 +96,7 @@
</jar>
</target>
- <target name="abatorJavadoc">
+ <target name="build.abator.javadoc">
<javadoc destdir="${work.javadoc}" use="true" defaultexcludes="false" verbose="false">
<packageset dir="${src.dir}">
<include name="org/apache/ibatis/abator/**"/>
@@ -76,16 +106,87 @@
<zip destfile="${deploy.files}/abator-javadoc.zip" basedir="${work.javadoc}" />
</target>
- <target name="zipAbatorSource">
+ <target name="build.zip.abator.source">
<zip destfile="${deploy.files}/abator-src.zip" basedir="${src.dir}" />
</target>
- <target name="assemble.zipfile" depends="buildAbatorJar, abatorJavadoc, zipAbatorSource">
+ <target name="assemble.zipfile" depends="build.abator.jar, build.abator.javadoc, build.zip.abator.source">
<property file="version.properties"/>
<zip destfile="${deploy.dir}/abator-${version}-${buildNum}.zip" basedir="${deploy.files}" />
</target>
- <target name="buildAbator" depends="assemble.zipfile" />
+ <target name="buildAbator" depends="assemble.zipfile, test.report" >
+ <fail if="testsFailed" message="The tests did not pass"/>
+ </target>
+ <target name="test.prepare" depends="build.compile">
+ <mkdir dir="${generated.source.dir}"/>
+ <mkdir dir="${reports.dir}"/>
+ <mkdir dir="${reports.junit}"/>
+
+ <copy todir="${generated.source.dir}">
+ <fileset dir="${basedir}/../test" />
+ </copy>
+ </target>
+
+ <target name="test.generate.test.code" depends="test.prepare">
+ <taskdef name="abator"
+ classname="org.apache.ibatis.abator.ant.AbatorAntTask">
+ <classpath>
+ <pathelement location="${work.classes}"/>
+ </classpath>
+ </taskdef>
+
+ <!-- create the test database -->
+ <sql driver="org.hsqldb.jdbcDriver"
+ url="jdbc:hsqldb:mem:aname"
+ userid="sa"
+ password=""
+ src="${generated.source.dir}/abatortest/CreateDB.sql"/>
+
+ <abator configfile="${generated.source.dir}/abatortest/abatorConfig.xml" >
+ <propertyset>
+ <propertyref name="generated.source.dir"/>
+ </propertyset>
+ </abator>
+ </target>
+
+ <target name="test.compile.test.code" depends="test.generate.test.code">
+ <javac srcdir="${generated.source.dir}"
+ deprecation="true"
+ debug="true"
+ source="1.5"
+ target="1.5">
+ </javac>
+ </target>
+
+ <target name="test.run" depends="test.compile.test.code">
+ <junit printsummary="true" showoutput="true">
+ <formatter type="xml"/>
+ <batchtest todir="${reports.junit}" fork="yes" haltonerror="no" failureproperty="testsFailed">
+ <fileset dir="${generated.source.dir}">
+ <exclude name="**/AllExecuteTests.class"/>
+ <include name="**/*Tests.class"/>
+ </fileset>
+ </batchtest>
+ <classpath>
+ <pathelement location="${generated.source.dir}"/>
+ <pathelement location="${basedir}/../devlib/ibatis-common-2.jar" />
+ <pathelement location="${basedir}/../devlib/ibatis-dao-2.jar" />
+ <pathelement location="${basedir}/../devlib/ibatis-sqlmap-2.jar" />
+ <pathelement location="${basedir}/../devlib/hsqldb.jar" />
+ </classpath>
+ </junit>
+ </target>
+
+ <target name="test.report" depends="test.run" >
+ <junitreport todir="${reports.junit}">
+ <fileset dir="${reports.junit}">
+ <include name="TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="${reports.junit}"/>
+ </junitreport>
+ </target>
+
</project>
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=431771&r1=431770&r2=431771&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 15 19:32:09 2006
@@ -1,4 +1,4 @@
#Abator build version info
-#Thu Jul 20 22:14:11 CDT 2006
+#Tue Aug 15 21:24:31 CDT 2006
version=0.7.0
-buildNum=142
+buildNum=178
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/README.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/README.txt?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/README.txt (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/README.txt Tue Aug 15 19:32:09 2006
@@ -0,0 +1,4 @@
+The iBATIS JAR files are locally generated (unreleased). They include the nested iterate fixes that
+are required for the tests to run properly.
+
+The iBATIS files should be replaced once 2.2.0 is released.
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/hsqldb.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/hsqldb.jar?rev=431771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/hsqldb.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-common-2.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-common-2.jar?rev=431771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-common-2.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-dao-2.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-dao-2.jar?rev=431771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-dao-2.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-sqlmap-2.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-sqlmap-2.jar?rev=431771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/ibatis-sqlmap-2.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/junit.jar
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/junit.jar?rev=431771&view=auto
==============================================================================
Binary file - no diff available.
Propchange: ibatis/trunk/java/mapper/mapper2/tools/abator/core/devlib/junit.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
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=431771&r1=431770&r2=431771&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 15 19:32:09 2006
@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import org.apache.ibatis.abator.api.Abator;
import org.apache.ibatis.abator.config.AbatorConfiguration;
@@ -31,7 +32,9 @@
import org.apache.ibatis.abator.internal.util.StringUtility;
import org.apache.ibatis.abator.internal.util.messages.Messages;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.PropertySet;
/**
* This is an Ant task that will run Abator. The following is a sample Ant
@@ -54,6 +57,7 @@
private String configfile;
private boolean overwrite;
+ private PropertySet propertyset;
/**
*
@@ -76,9 +80,11 @@
if (!configurationFile.exists()) {
throw new BuildException(Messages.getString("RuntimeError.1", configfile)); //$NON-NLS-1$
}
-
+
try {
- AbatorConfigurationParser cp = new AbatorConfigurationParser(
+ Properties p = propertyset == null ? null : propertyset.getProperties();
+
+ AbatorConfigurationParser cp = new AbatorConfigurationParser(p,
warnings);
AbatorConfiguration config = cp.parseAbatorConfiguration(configurationFile);
@@ -86,7 +92,7 @@
Abator abator = new Abator(config, callback, warnings);
- abator.generate(null);
+ abator.generate(new AntProgressCallback(this));
} catch (XMLParserException e) {
List errors = e.getErrors();
@@ -109,7 +115,7 @@
Iterator iter = warnings.iterator();
while (iter.hasNext()) {
- log((String) iter.next());
+ log((String) iter.next(), Project.MSG_WARN);
}
}
@@ -139,5 +145,13 @@
*/
public void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
+ }
+
+ public PropertySet createPropertyset() {
+ if (propertyset == null) {
+ propertyset = new PropertySet();
+ }
+
+ return propertyset;
}
}
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AntProgressCallback.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AntProgressCallback.java?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AntProgressCallback.java (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/ant/AntProgressCallback.java Tue Aug 15 19:32:09 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ibatis.abator.ant;
+
+import org.apache.ibatis.abator.api.ProgressCallback;
+import org.apache.tools.ant.Task;
+
+/**
+ * This callback logs progress messages with the Ant logger
+ *
+ * @author Jeff Butler
+ *
+ */
+public class AntProgressCallback implements ProgressCallback {
+
+ private Task task;
+
+ /**
+ *
+ */
+ public AntProgressCallback(Task task) {
+ super();
+ this.task = task;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ibatis.abator.api.ProgressCallback#setNumberOfSubTasks(int)
+ */
+ public void setNumberOfSubTasks(int totalSubTasks) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ibatis.abator.api.ProgressCallback#startSubTask(java.lang.String)
+ */
+ public void startSubTask(String subTaskName) {
+ task.log(subTaskName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ibatis.abator.api.ProgressCallback#finished()
+ */
+ public void finished() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.ibatis.abator.api.ProgressCallback#checkCancel()
+ */
+ public void checkCancel() throws InterruptedException {
+ }
+}
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=431771&r1=431770&r2=431771&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 15 19:32:09 2006
@@ -149,7 +149,7 @@
abatorContext.generateFiles(callback, generatedJavaFiles,
generatedXmlFiles, warnings);
}
-
+
iter = generatedXmlFiles.iterator();
while (iter.hasNext()) {
GeneratedXmlFile gxf = (GeneratedXmlFile) iter.next();
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/AbatorConfigurationParser.java Tue Aug 15 19:32:09 2006
@@ -20,8 +20,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -40,6 +42,8 @@
import org.apache.ibatis.abator.config.SqlMapGeneratorConfiguration;
import org.apache.ibatis.abator.config.TableConfiguration;
import org.apache.ibatis.abator.exception.XMLParserException;
+import org.apache.ibatis.abator.internal.util.StringUtility;
+import org.apache.ibatis.abator.internal.util.messages.Messages;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -56,20 +60,37 @@
private List parseErrors;
+ private Properties properties;
+
/**
*
*/
public AbatorConfigurationParser(List warnings) {
+ this(null, warnings);
+ }
+
+ public AbatorConfigurationParser(Properties properties, List warnings) {
super();
- this.warnings = warnings;
+ if (properties == null) {
+ this.properties = new Properties();
+ } else {
+ this.properties = properties;
+ }
+
+ if (warnings == null) {
+ this.warnings = new ArrayList();
+ } else {
+ this.warnings = warnings;
+ }
+
parseErrors = new ArrayList();
}
-
+
public AbatorConfiguration parseAbatorConfiguration(File inputFile)
throws IOException, XMLParserException {
FileReader fr = new FileReader(inputFile);
-
+
return parseAbatorConfiguration(fr);
}
@@ -85,7 +106,7 @@
throws IOException, XMLParserException {
InputSource is = new InputSource(inputStream);
-
+
return parseAbatorConfiguration(is);
}
@@ -143,7 +164,7 @@
}
}
- private AbatorConfiguration parseAbatorConfiguration(Node node) {
+ private AbatorConfiguration parseAbatorConfiguration(Node node) throws XMLParserException {
AbatorConfiguration abatorConfiguration = new AbatorConfiguration();
@@ -155,7 +176,9 @@
continue;
}
- if ("abatorContext".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
+ parseProperties(abatorConfiguration, childNode);
+ } else if ("abatorContext".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseAbatorContext(abatorConfiguration, childNode);
}
}
@@ -163,26 +186,65 @@
return abatorConfiguration;
}
+ private void parseProperties(AbatorConfiguration abatorConfiguration,
+ Node node) throws XMLParserException {
+ Properties attributes = parseAttributes(node);
+ String resource = attributes.getProperty("resource"); //$NON-NLS-1$
+ String url = attributes.getProperty("url"); //$NON-NLS-1$
+
+ if (!StringUtility.stringHasValue(resource)
+ && !StringUtility.stringHasValue(url)) {
+ throw new XMLParserException(Messages.getString("RuntimeError.14")); //$NON-NLS-1$
+ }
+
+ if (StringUtility.stringHasValue(resource)
+ && StringUtility.stringHasValue(url)) {
+ throw new XMLParserException(Messages.getString("RuntimeError.14")); //$NON-NLS-1$
+ }
+
+ URL resourceUrl;
+
+ try {
+ if (StringUtility.stringHasValue(resource)) {
+ resourceUrl = Thread.currentThread().getContextClassLoader()
+ .getResource(resource);
+ if (resourceUrl == null) {
+ throw new XMLParserException(Messages.getString("RuntimeError.15", resource)); //$NON-NLS-1$
+ }
+ } else {
+ resourceUrl = new URL(url);
+ }
+
+ InputStream inputStream = resourceUrl.openConnection()
+ .getInputStream();
+
+ properties.load(inputStream);
+ inputStream.close();
+ } catch (IOException e) {
+ if (StringUtility.stringHasValue(resource)) {
+ throw new XMLParserException(Messages.getString("RuntimeError.16", resource)); //$NON-NLS-1$
+ } else {
+ throw new XMLParserException(Messages.getString("RuntimeError.17", url)); //$NON-NLS-1$
+ }
+ }
+ }
+
private void parseAbatorContext(AbatorConfiguration abatorConfiguration,
Node node) {
- NamedNodeMap nnm = node.getAttributes();
- Node attribute = nnm.getNamedItem("generatorSet"); //$NON-NLS-1$
- String generatorSet = attribute == null ? null : attribute.getNodeValue();
+ Properties attributes = parseAttributes(node);
+ String generatorSet = attributes.getProperty("generatorSet"); //$NON-NLS-1$
+ String defaultModelType = attributes.getProperty("defaultModelType"); //$NON-NLS-1$
+ String id = attributes.getProperty("id"); //$NON-NLS-1$
+
+ ModelType mt = defaultModelType == null ? null : ModelType
+ .getModelType(defaultModelType);
- attribute = nnm.getNamedItem("defaultModelType"); //$NON-NLS-1$
- String defaultModelType = attribute == null ? null : attribute.getNodeValue();
- ModelType mt = defaultModelType == null ? null : ModelType.getModelType(defaultModelType);
-
AbatorContext abatorContext = new AbatorContext(generatorSet, mt);
+ abatorContext.setId(id);
abatorConfiguration.addAbatorContext(abatorContext);
- attribute = nnm.getNamedItem("id"); //$NON-NLS-1$
- if (attribute != null) {
- abatorContext.setId(attribute.getNodeValue());
- }
-
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
@@ -215,19 +277,17 @@
abatorContext
.setSqlMapGeneratorConfiguration(sqlMapGeneratorConfiguration);
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String type = attributes.getProperty("type"); //$NON-NLS-1$
+ String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
+ String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
- Node attribute = nnm.getNamedItem("type"); //$NON-NLS-1$
- if (attribute != null) {
- sqlMapGeneratorConfiguration.setConfigurationType(attribute
- .getNodeValue());
+ if (StringUtility.stringHasValue(type)) {
+ sqlMapGeneratorConfiguration.setConfigurationType(type);
}
- attribute = nnm.getNamedItem("targetPackage"); //$NON-NLS-1$
- sqlMapGeneratorConfiguration.setTargetPackage(attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("targetProject"); //$NON-NLS-1$
- sqlMapGeneratorConfiguration.setTargetProject(attribute.getNodeValue());
+ sqlMapGeneratorConfiguration.setTargetPackage(targetPackage);
+ sqlMapGeneratorConfiguration.setTargetProject(targetProject);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
@@ -247,74 +307,91 @@
TableConfiguration tc = new TableConfiguration(abatorContext);
abatorContext.addTableConfiguration(tc);
- NamedNodeMap nnm = node.getAttributes();
-
- Node attribute = nnm.getNamedItem("catalog"); //$NON-NLS-1$
- tc.setCatalog(attribute == null ? null : attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("schema"); //$NON-NLS-1$
- tc.setSchema(attribute == null ? null : attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("domainObjectName"); //$NON-NLS-1$
- tc.setDomainObjectName(attribute == null ? null : attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("tableName"); //$NON-NLS-1$
- tc.setTableName(attribute.getNodeValue());
+ Properties attributes = parseAttributes(node);
+ String catalog = attributes.getProperty("catalog"); //$NON-NLS-1$
+ String schema = attributes.getProperty("schema"); //$NON-NLS-1$
+ String tableName = attributes.getProperty("tableName"); //$NON-NLS-1$
+ String domainObjectName = attributes.getProperty("domainObjectName"); //$NON-NLS-1$
+ String alias = attributes.getProperty("alias"); //$NON-NLS-1$
+ String enableInsert = attributes.getProperty("enableInsert"); //$NON-NLS-1$
+ String enableSelectByPrimaryKey = attributes
+ .getProperty("enableSelectByPrimaryKey"); //$NON-NLS-1$
+ String enableSelectByExample = attributes
+ .getProperty("enableSelectByExample"); //$NON-NLS-1$
+ String enableUpdateByPrimaryKey = attributes
+ .getProperty("enableUpdateByPrimaryKey"); //$NON-NLS-1$
+ String enableDeleteByPrimaryKey = attributes
+ .getProperty("enableDeleteByPrimaryKey"); //$NON-NLS-1$
+ String enableDeleteByExample = attributes
+ .getProperty("enableDeleteByExample"); //$NON-NLS-1$
+ String selectByPrimaryKeyQueryId = attributes
+ .getProperty("selectByPrimaryKeyQueryId"); //$NON-NLS-1$
+ String selectByExampleQueryId = attributes
+ .getProperty("selectByExampleQueryId"); //$NON-NLS-1$
+ String modelType = attributes.getProperty("modelType"); //$NON-NLS-1$
+
+ if (StringUtility.stringHasValue(catalog)) {
+ tc.setCatalog(catalog);
+ }
+
+ if (StringUtility.stringHasValue(schema)) {
+ tc.setSchema(schema);
+ }
+
+ if (StringUtility.stringHasValue(tableName)) {
+ tc.setTableName(tableName);
+ }
+
+ if (StringUtility.stringHasValue(domainObjectName)) {
+ tc.setDomainObjectName(domainObjectName);
+ }
- attribute = nnm.getNamedItem("alias"); //$NON-NLS-1$
- tc.setAlias(attribute == null ? null : attribute.getNodeValue());
+ if (StringUtility.stringHasValue(alias)) {
+ tc.setAlias(alias);
+ }
- attribute = nnm.getNamedItem("enableInsert"); //$NON-NLS-1$
- if (attribute != null) {
+ if (StringUtility.stringHasValue(enableInsert)) {
tc.setInsertStatementEnabled("true" //$NON-NLS-1$
- .equals(attribute.getNodeValue()));
+ .equals(enableInsert));
}
- attribute = nnm.getNamedItem("enableSelectByPrimaryKey"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setSelectByPrimaryKeyStatementEnabled("true".equals(attribute //$NON-NLS-1$
- .getNodeValue()));
+ if (StringUtility.stringHasValue(enableSelectByPrimaryKey)) {
+ tc.setSelectByPrimaryKeyStatementEnabled("true" //$NON-NLS-1$
+ .equals(enableSelectByPrimaryKey));
}
- attribute = nnm.getNamedItem("enableSelectByExample"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setSelectByExampleStatementEnabled("true".equals(attribute //$NON-NLS-1$
- .getNodeValue()));
+ if (StringUtility.stringHasValue(enableSelectByExample)) {
+ tc.setSelectByExampleStatementEnabled("true" //$NON-NLS-1$
+ .equals(enableSelectByExample));
}
- attribute = nnm.getNamedItem("enableUpdateByPrimaryKey"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setUpdateByPrimaryKeyStatementEnabled("true".equals(attribute //$NON-NLS-1$
- .getNodeValue()));
+ if (StringUtility.stringHasValue(enableUpdateByPrimaryKey)) {
+ tc.setUpdateByPrimaryKeyStatementEnabled("true" //$NON-NLS-1$
+ .equals(enableUpdateByPrimaryKey));
}
- attribute = nnm.getNamedItem("enableDeleteByPrimaryKey"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setDeleteByPrimaryKeyStatementEnabled("true".equals(attribute //$NON-NLS-1$
- .getNodeValue()));
+ if (StringUtility.stringHasValue(enableDeleteByPrimaryKey)) {
+ tc.setDeleteByPrimaryKeyStatementEnabled("true" //$NON-NLS-1$
+ .equals(enableDeleteByPrimaryKey));
}
- attribute = nnm.getNamedItem("enableDeleteByExample"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setDeleteByExampleStatementEnabled("true".equals(attribute //$NON-NLS-1$
- .getNodeValue()));
+ if (StringUtility.stringHasValue(enableDeleteByExample)) {
+ tc.setDeleteByExampleStatementEnabled("true" //$NON-NLS-1$
+ .equals(enableDeleteByExample));
}
- attribute = nnm.getNamedItem("selectByPrimaryKeyQueryId"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setSelectByPrimaryKeyQueryId(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(selectByPrimaryKeyQueryId)) {
+ tc.setSelectByPrimaryKeyQueryId(selectByPrimaryKeyQueryId);
}
- attribute = nnm.getNamedItem("selectByExampleQueryId"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setSelectByExampleQueryId(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(selectByExampleQueryId)) {
+ tc.setSelectByExampleQueryId(selectByExampleQueryId);
}
- attribute = nnm.getNamedItem("modelType"); //$NON-NLS-1$
- if (attribute != null) {
- tc.setModelType(ModelType.getModelType(attribute.getNodeValue()));
+ if (StringUtility.stringHasValue(modelType)) {
+ tc.setModelType(ModelType.getModelType(modelType));
}
-
+
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
@@ -336,52 +413,52 @@
}
private void parseColumnOverride(TableConfiguration tc, Node node) {
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String column = attributes.getProperty("column"); //$NON-NLS-1$
+ String property = attributes.getProperty("property"); //$NON-NLS-1$
+ String javaType = attributes.getProperty("javaType"); //$NON-NLS-1$
+ String jdbcType = attributes.getProperty("jdbcType"); //$NON-NLS-1$
+ String typeHandler = attributes.getProperty("typeHandler"); //$NON-NLS-1$
ColumnOverride co = new ColumnOverride();
- Node attribute = nnm.getNamedItem("column"); //$NON-NLS-1$
- co.setColumnName(attribute.getNodeValue());
+ co.setColumnName(column);
- tc.addColumnOverride(co);
-
- attribute = nnm.getNamedItem("property"); //$NON-NLS-1$
- if (attribute != null) {
- co.setJavaProperty(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(property)) {
+ co.setJavaProperty(property);
}
- attribute = nnm.getNamedItem("javaType"); //$NON-NLS-1$
- if (attribute != null) {
- co.setJavaType(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(javaType)) {
+ co.setJavaType(javaType);
}
- attribute = nnm.getNamedItem("jdbcType"); //$NON-NLS-1$
- if (attribute != null) {
- co.setJdbcType(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(jdbcType)) {
+ co.setJdbcType(jdbcType);
}
- attribute = nnm.getNamedItem("typeHandler"); //$NON-NLS-1$
- if (attribute != null) {
- co.setTypeHandler(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(typeHandler)) {
+ co.setTypeHandler(typeHandler);
}
+
+ tc.addColumnOverride(co);
}
private void parseGeneratedKey(TableConfiguration tc, Node node) {
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
- String column = nnm.getNamedItem("column").getNodeValue(); //$NON-NLS-1$
- boolean identity = "true".equals(nnm.getNamedItem("identity").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$
- String sqlStatement = nnm.getNamedItem("sqlStatement").getNodeValue(); //$NON-NLS-1$
+ String column = attributes.getProperty("column"); //$NON-NLS-1$
+ boolean identity = "true".equals(attributes.getProperty("identity")); //$NON-NLS-1$ //$NON-NLS-2$
+ String sqlStatement = attributes.getProperty("sqlStatement"); //$NON-NLS-1$
GeneratedKey gk = new GeneratedKey(column, sqlStatement, identity);
tc.setGeneratedKey(gk);
}
private void parseIgnoreColumn(TableConfiguration tc, Node node) {
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String column = attributes.getProperty("column"); //$NON-NLS-1$
- Node attribute = nnm.getNamedItem("column"); //$NON-NLS-1$
- tc.addIgnoredColumn(attribute.getNodeValue());
+ tc.addIgnoredColumn(column);
}
private void parseJavaTypeResolver(AbatorContext abatorContext, Node node) {
@@ -390,12 +467,11 @@
abatorContext
.setJavaTypeResolverConfiguration(javaTypeResolverConfiguration);
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String type = attributes.getProperty("type"); //$NON-NLS-1$
- Node attribute = nnm.getNamedItem("type"); //$NON-NLS-1$
- if (attribute != null) {
- javaTypeResolverConfiguration.setConfigurationType(attribute
- .getNodeValue());
+ if (StringUtility.stringHasValue(type)) {
+ javaTypeResolverConfiguration.setConfigurationType(type);
}
NodeList nodeList = node.getChildNodes();
@@ -418,21 +494,17 @@
abatorContext
.setJavaModelGeneratorConfiguration(javaModelGeneratorConfiguration);
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String type = attributes.getProperty("type"); //$NON-NLS-1$
+ String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
+ String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
- Node attribute = nnm.getNamedItem("type"); //$NON-NLS-1$
- if (attribute != null) {
- javaModelGeneratorConfiguration.setConfigurationType(attribute
- .getNodeValue());
+ if (StringUtility.stringHasValue(type)) {
+ javaModelGeneratorConfiguration.setConfigurationType(type);
}
- attribute = nnm.getNamedItem("targetPackage"); //$NON-NLS-1$
- javaModelGeneratorConfiguration.setTargetPackage(attribute
- .getNodeValue());
-
- attribute = nnm.getNamedItem("targetProject"); //$NON-NLS-1$
- javaModelGeneratorConfiguration.setTargetProject(attribute
- .getNodeValue());
+ javaModelGeneratorConfiguration.setTargetPackage(targetPackage);
+ javaModelGeneratorConfiguration.setTargetProject(targetProject);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
@@ -453,17 +525,14 @@
abatorContext.setDaoGeneratorConfiguration(daoGeneratorConfiguration);
- NamedNodeMap nnm = node.getAttributes();
-
- Node attribute = nnm.getNamedItem("type"); //$NON-NLS-1$
- daoGeneratorConfiguration
- .setConfigurationType(attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("targetPackage"); //$NON-NLS-1$
- daoGeneratorConfiguration.setTargetPackage(attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("targetProject"); //$NON-NLS-1$
- daoGeneratorConfiguration.setTargetProject(attribute.getNodeValue());
+ Properties attributes = parseAttributes(node);
+ String type = attributes.getProperty("type"); //$NON-NLS-1$
+ String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
+ String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
+
+ daoGeneratorConfiguration.setConfigurationType(type);
+ daoGeneratorConfiguration.setTargetPackage(targetPackage);
+ daoGeneratorConfiguration.setTargetProject(targetProject);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
@@ -485,22 +554,21 @@
abatorContext
.setJdbcConnectionConfiguration(jdbcConnectionConfiguration);
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
+ String driverClass = attributes.getProperty("driverClass"); //$NON-NLS-1$
+ String connectionURL = attributes.getProperty("connectionURL"); //$NON-NLS-1$
+ String userId = attributes.getProperty("userId"); //$NON-NLS-1$
+ String password = attributes.getProperty("password"); //$NON-NLS-1$
- Node attribute = nnm.getNamedItem("driverClass"); //$NON-NLS-1$
- jdbcConnectionConfiguration.setDriverClass(attribute.getNodeValue());
+ jdbcConnectionConfiguration.setDriverClass(driverClass);
+ jdbcConnectionConfiguration.setConnectionURL(connectionURL);
- attribute = nnm.getNamedItem("connectionURL"); //$NON-NLS-1$
- jdbcConnectionConfiguration.setConnectionURL(attribute.getNodeValue());
-
- attribute = nnm.getNamedItem("userId"); //$NON-NLS-1$
- if (attribute != null) {
- jdbcConnectionConfiguration.setUserId(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(userId)) {
+ jdbcConnectionConfiguration.setUserId(userId);
}
- attribute = nnm.getNamedItem("password"); //$NON-NLS-1$
- if (attribute != null) {
- jdbcConnectionConfiguration.setPassword(attribute.getNodeValue());
+ if (StringUtility.stringHasValue(password)) {
+ jdbcConnectionConfiguration.setPassword(password);
}
NodeList nodeList = node.getChildNodes();
@@ -521,18 +589,59 @@
private void parseClassPathEntry(
JDBCConnectionConfiguration jdbcConnectionConfiguration, Node node) {
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
- jdbcConnectionConfiguration.addClasspathEntry(nnm.getNamedItem(
- "location").getNodeValue()); //$NON-NLS-1$
+ jdbcConnectionConfiguration.addClasspathEntry(attributes
+ .getProperty("location")); //$NON-NLS-1$
}
private void parseProperty(PropertyHolder propertyHolder, Node node) {
- NamedNodeMap nnm = node.getAttributes();
+ Properties attributes = parseAttributes(node);
- String name = nnm.getNamedItem("name").getNodeValue(); //$NON-NLS-1$
- String value = nnm.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
+ String name = attributes.getProperty("name"); //$NON-NLS-1$
+ String value = attributes.getProperty("value"); //$NON-NLS-1$
propertyHolder.addProperty(name, value);
+ }
+
+ private Properties parseAttributes(Node node) {
+ Properties attributes = new Properties();
+ NamedNodeMap nnm = node.getAttributes();
+ for (int i = 0; i < nnm.getLength(); i++) {
+ Node attribute = nnm.item(i);
+ String value = parsePropertyTokens(attribute.getNodeValue());
+ attributes.put(attribute.getNodeName(), value);
+ }
+
+ return attributes;
+ }
+
+ private String parsePropertyTokens(String string) {
+ final String OPEN = "${"; //$NON-NLS-1$
+ final String CLOSE = "}"; //$NON-NLS-1$
+
+ String newString = string;
+ if (newString != null) {
+ int start = newString.indexOf(OPEN);
+ int end = newString.indexOf(CLOSE);
+
+ while (start > -1 && end > start) {
+ String prepend = newString.substring(0, start);
+ String append = newString.substring(end + CLOSE.length());
+ String propName = newString.substring(start + OPEN.length(),
+ end);
+ String propValue = properties.getProperty(propName);
+ if (propValue == null) {
+ newString = prepend + propName + append;
+ } else {
+ newString = prepend + propValue + append;
+ }
+
+ start = newString.indexOf(OPEN);
+ end = newString.indexOf(CLOSE);
+ }
+ }
+
+ return newString;
}
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/config/xml/abator-config_1_0.dtd Tue Aug 15 19:32:09 2006
@@ -37,8 +37,18 @@
<!--
The abatorConfiguration element is the root element for Abator configurations.
-->
-<!ELEMENT abatorConfiguration (abatorContext+)>
+<!ELEMENT abatorConfiguration (properties?, abatorContext+)>
+<!--
+ The properties element is used to define a standard Java properties file
+ that contains placeholders for use in the remainder of the configuration
+ file.
+-->
+<!ELEMENT properties EMPTY>
+<!ATTLIST properties
+ resource CDATA #IMPLIED
+ url CDATA #IMPLIED>
+
<!--
The abatorContext element is used to describe a context for generating files, and the source
tables.
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/exception/XMLParserException.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/exception/XMLParserException.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/exception/XMLParserException.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/exception/XMLParserException.java Tue Aug 15 19:32:09 2006
@@ -15,6 +15,7 @@
*/
package org.apache.ibatis.abator.exception;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -22,7 +23,7 @@
*/
public class XMLParserException extends Exception {
- static final long serialVersionUID = 5172525430401340573L;
+ private static final long serialVersionUID = 5172525430401340573L;
private List errors;
@@ -34,6 +35,12 @@
this.errors = errors;
}
+ public XMLParserException(String error) {
+ super(error);
+ this.errors = new ArrayList();
+ errors.add(error);
+ }
+
public List getErrors() {
return errors;
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ConnectionFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ConnectionFactory.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ConnectionFactory.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/ConnectionFactory.java Tue Aug 15 19:32:09 2006
@@ -124,7 +124,7 @@
}
}
- ClassLoader parent = this.getClass().getClassLoader();
+ ClassLoader parent = Thread.currentThread().getContextClassLoader();
URLClassLoader ucl = new URLClassLoader((URL[]) urls
.toArray(new URL[urls.size()]), parent);
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/db/DatabaseIntrospector.java Tue Aug 15 19:32:09 2006
@@ -80,7 +80,10 @@
ResultSet rs = dbmd.getColumns(localCatalog, localSchema,
localTableName, null);
+ int returnedColumns = 0;
while (rs.next()) {
+ returnedColumns++;
+
ColumnDefinition cd = new ColumnDefinition(tc.getAlias());
cd.setJdbcType(rs.getInt("DATA_TYPE")); //$NON-NLS-1$
@@ -177,6 +180,11 @@
}
rs.close();
+
+ if (returnedColumns == 0) {
+ warnings.add(Messages.getString("Warning.19", tc.getCatalog(), //$NON-NLS-1$
+ tc.getSchema(), tc.getTableName()));
+ }
Iterator iter = introspectedTables.values().iterator();
while (iter.hasNext()) {
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorIterateImpl.java Tue Aug 15 19:32:09 2006
@@ -1255,17 +1255,21 @@
sb.append(table.getAliasedFullyQualifiedTableName());
answer.addElement((new TextElement(sb.toString())));
+ XmlElement isParameterPresenteElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresenteElement);
+
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
getSqlMapNamespace(table) + "." + getExampleWhereClauseId())); //$NON-NLS-1$
- answer.addElement(includeElement);
+ isParameterPresenteElement.addElement(includeElement);
XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
isNotNullElement
.addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
isNotNullElement
.addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
- answer.addElement(isNotNullElement);
+ isParameterPresenteElement.addElement(isNotNullElement);
return answer;
}
@@ -1323,17 +1327,21 @@
sb.append(table.getAliasedFullyQualifiedTableName());
answer.addElement(new TextElement(sb.toString()));
+ XmlElement isParameterPresenteElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresenteElement);
+
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
getSqlMapNamespace(table) + "." + getExampleWhereClauseId())); //$NON-NLS-1$
- answer.addElement(includeElement);
+ isParameterPresenteElement.addElement(includeElement);
XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
isNotNullElement
.addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
isNotNullElement
.addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
- answer.addElement(isNotNullElement);
+ isParameterPresenteElement.addElement(isNotNullElement);
return answer;
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/sqlmap/SqlMapGeneratorLegacyImpl.java Tue Aug 15 19:32:09 2006
@@ -176,16 +176,20 @@
sb.append(table.getAliasedFullyQualifiedTableName());
answer.addElement((new TextElement(sb.toString())));
+ XmlElement isParameterPresenteElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresenteElement);
+
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
getSqlMapNamespace(table)
+ "." + getExampleWhereClauseId())); //$NON-NLS-1$
- answer.addElement(includeElement);
+ isParameterPresenteElement.addElement(includeElement);
XmlElement isPropAvail = new XmlElement("isPropertyAvailable"); //$NON-NLS-1$
isPropAvail.addAttribute(new Attribute("property", "ABATOR_ORDER_BY_CLAUSE")); //$NON-NLS-1$ //$NON-NLS-2$
isPropAvail.addElement(new TextElement("order by $ABATOR_ORDER_BY_CLAUSE$")); //$NON-NLS-1$
- answer.addElement(isPropAvail);
+ isParameterPresenteElement.addElement(isPropAvail);
return answer;
}
@@ -239,16 +243,20 @@
sb.append(table.getAliasedFullyQualifiedTableName());
answer.addElement((new TextElement(sb.toString())));
+ XmlElement isParameterPresenteElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresenteElement);
+
XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
getSqlMapNamespace(table)
+ "." + getExampleWhereClauseId())); //$NON-NLS-1$
- answer.addElement(includeElement);
+ isParameterPresenteElement.addElement(includeElement);
XmlElement isPropAvail = new XmlElement("isPropertyAvailable"); //$NON-NLS-1$
isPropAvail.addAttribute(new Attribute("property", "ABATOR_ORDER_BY_CLAUSE")); //$NON-NLS-1$ //$NON-NLS-2$
isPropAvail.addElement(new TextElement("order by $ABATOR_ORDER_BY_CLAUSE$")); //$NON-NLS-1$
- answer.addElement(isPropAvail);
+ isParameterPresenteElement.addElement(isPropAvail);
return answer;
}
Modified: ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/Messages.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/Messages.java?rev=431771&r1=431770&r2=431771&view=diff
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/Messages.java (original)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/src/org/apache/ibatis/abator/internal/util/messages/Messages.java Tue Aug 15 19:32:09 2006
@@ -54,4 +54,12 @@
return '!' + key + '!';
}
}
+
+ public static String getString(String key, String parm1, String parm2, String parm3) {
+ try {
+ return MessageFormat.format(RESOURCE_BUNDLE.getString(key), new String[] {parm1, parm2, parm3});
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
}
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=431771&r1=431770&r2=431771&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 15 19:32:09 2006
@@ -26,6 +26,10 @@
RuntimeError.11=Enumerations do not have super classes
RuntimeError.12=Internal Error - Cannot calculate record type for selectByExample method
RuntimeError.13=Invalid model type: {0}
+RuntimeError.14=Either resource or URL is required on the <properties> element, but not both
+RuntimeError.15=<properties> resource {0} does not exist
+RuntimeError.16=Cannot load properties from <properties> resource {0}
+RuntimeError.17=Cannot load properties from <properties> url {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
@@ -47,6 +51,7 @@
Warning.16=Invalid value for exampleMethodVisibility specified ({0}), defaulting to public
Warning.17=Cannot instantiate DAO method name calculator of type {0}, using default calculator
Warning.18=Table {0} contains only LOB fields, this table will be ignored
+Warning.19=Table configuration with catalog {0}, schema {1}, and table {2} did not resolve to any tables
Progress.0=Connecting to the Database
Progress.1=Introspecting table {0}
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/README.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/README.txt?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/README.txt (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/README.txt Tue Aug 15 19:32:09 2006
@@ -0,0 +1,3 @@
+The files in this source tree are used to test code generated from Abator
+during the build. They will normally only compile successfully during
+the Abator build.
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/BaseTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/BaseTest.java?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/BaseTest.java (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/BaseTest.java Tue Aug 15 19:32:09 2006
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package abatortest;
+
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import java.util.Random;
+
+import com.ibatis.common.jdbc.ScriptRunner;
+import com.ibatis.common.resources.Resources;
+import com.ibatis.dao.client.DaoManager;
+import com.ibatis.dao.client.DaoManagerBuilder;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Jeff Butler
+ *
+ */
+public abstract class BaseTest extends TestCase {
+
+ protected static DaoManager daoManager;
+ private static DateFormat dateOnlyFormat = SimpleDateFormat.getDateInstance();
+ private static DateFormat timeOnlyFormat = SimpleDateFormat.getTimeInstance();
+
+ protected static void initDaoManager(String configFile, Properties props) throws Exception {
+ Reader reader = Resources.getResourceAsReader(configFile);
+ daoManager = DaoManagerBuilder.buildDaoManager(reader, props);
+ reader.close();
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ Connection conn = null;
+
+ try {
+ Class.forName("org.hsqldb.jdbcDriver");
+ conn = DriverManager.getConnection("jdbc:hsqldb:mem:aname", "sa",
+ "");
+
+ Reader reader = Resources.getResourceAsReader("abatortest/CreateDB.sql");
+
+ ScriptRunner runner = new ScriptRunner(conn, true, false);
+ runner.setLogWriter(null);
+ runner.setErrorLogWriter(null);
+ runner.runScript(reader);
+ conn.commit();
+
+ reader.close();
+ } finally {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+ }
+
+ protected byte[] generateRandomBlob() {
+ Random random = new Random(System.currentTimeMillis());
+
+ byte[] answer = new byte[256];
+
+ random.nextBytes(answer);
+
+ return answer;
+ }
+
+ protected boolean blobsAreEqual(byte[] blob1, byte[] blob2) {
+ if (blob1 == null) {
+ return blob2 == null;
+ }
+
+ if (blob2 == null) {
+ return blob1 == null;
+ }
+
+ boolean rc = blob1.length == blob2.length;
+
+ if (rc) {
+ for (int i = 0; i < blob1.length; i++) {
+ if (blob1[i] != blob2[i]) {
+ rc = false;
+ break;
+ }
+ }
+ }
+
+ return rc;
+ }
+
+ protected boolean datesAreEqual(Date date1, Date date2) {
+ if (date1 == null) {
+ return date2 == null;
+ }
+
+ if (date2 == null) {
+ return date1 == null;
+ }
+
+ return dateOnlyFormat.format(date1).equals(dateOnlyFormat.format(date2));
+
+ }
+
+ protected boolean timesAreEqual(Date date1, Date date2) {
+ if (date1 == null) {
+ return date2 == null;
+ }
+
+ if (date2 == null) {
+ return date1 == null;
+ }
+
+ return timeOnlyFormat.format(date1).equals(timeOnlyFormat.format(date2));
+
+ }
+}
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/CreateDB.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/CreateDB.sql?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/CreateDB.sql (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/CreateDB.sql Tue Aug 15 19:32:09 2006
@@ -0,0 +1,63 @@
+drop table FieldsOnly if exists;
+drop table PKOnly if exists;
+drop table PKFields if exists;
+drop table PKBlobs if exists;
+drop table PKFieldsBlobs if exists;
+drop table FieldsBlobs if exists;
+drop table BlobsOnly if exists;
+
+create table FieldsOnly (
+ IntegerField int,
+ DoubleField double,
+ FloatField float
+);
+
+create table PKOnly (
+ id int not null,
+ seq_num int not null,
+ primary key(id, seq_num)
+);
+
+create table PKFields (
+ id1 int not null,
+ id2 int not null,
+ firstName varchar(20),
+ lastName varchar(20),
+ dateField date,
+ timeField time,
+ timestampField timestamp,
+ decimal30Field decimal(3, 0),
+ decimal60Field decimal(6, 0),
+ decimal100Field decimal(10, 0),
+ decimal155Field decimal(15, 5),
+ primary key (id1, id2)
+);
+
+create table PKBlobs (
+ id int not null,
+ blob1 longvarbinary,
+ blob2 longvarbinary,
+ primary key (id)
+);
+
+create table PKFieldsBlobs (
+ id1 int not null,
+ id2 int not null,
+ firstName varchar(20),
+ lastName varchar(20),
+ blob1 longvarbinary,
+ primary key (id1, id2)
+);
+
+create table FieldsBlobs (
+ firstName varchar(20),
+ lastName varchar(20),
+ blob1 longvarbinary,
+ blob2 longvarbinary
+);
+
+-- this table should be ignored, nothing generated
+create table BlobsOnly (
+ blob1 longvarbinary,
+ blob2 longvarbinary
+);
Added: ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/abatorConfig.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/abatorConfig.xml?rev=431771&view=auto
==============================================================================
--- ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/abatorConfig.xml (added)
+++ ibatis/trunk/java/mapper/mapper2/tools/abator/core/test/abatortest/abatorConfig.xml Tue Aug 15 19:32:09 2006
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE abatorConfiguration
+ PUBLIC "-//Apache Software Foundation//DTD Abator for iBATIS Configuration 1.0//EN"
+ "http://ibatis.apache.org/dtd/abator-config_1_0.dtd">
+
+<abatorConfiguration>
+
+ <abatorContext generatorSet="Java5" defaultModelType="flat">
+ <property name="suppressTypeWarnings" value="true" /> <!-- should be ignored -->
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.flat.java5.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.flat.java5.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.flat.java5.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Java2" defaultModelType="flat">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.flat.java2.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.flat.java2.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.flat.java2.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Legacy" defaultModelType="flat">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.flat.legacy.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.flat.legacy.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.flat.legacy.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Java5" defaultModelType="hierarchical">
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.hierarchical.java5.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.hierarchical.java5.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.hierarchical.java5.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Java2" defaultModelType="hierarchical">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.hierarchical.java2.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.hierarchical.java2.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.hierarchical.java2.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Legacy" defaultModelType="hierarchical">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.hierarchical.legacy.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.hierarchical.legacy.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.hierarchical.legacy.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Java5" defaultModelType="conditional">
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.conditional.java5.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.conditional.java5.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.conditional.java5.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Java2" defaultModelType="conditional">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.conditional.java2.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.conditional.java2.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.conditional.java2.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext generatorSet="Legacy" defaultModelType="conditional">
+ <property name="suppressTypeWarnings" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.conditional.legacy.model" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.conditional.legacy.xml" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.conditional.legacy.dao" targetProject="${generated.source.dir}">
+ <property name="enableSubPackages" value="true" />
+ </daoGenerator>
+
+ <table tableName="FieldsOnly" />
+ <table tableName="PKOnly" />
+ <table tableName="PKFields" />
+ <table tableName="PKBlobs" />
+ <table tableName="PKFieldsBlobs" />
+ <table tableName="FieldsBlobs" />
+ </abatorContext>
+
+ <abatorContext id="miscellaneousTests" generatorSet="Java5">
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator targetPackage="abatortest.generated.miscellaneous.model" targetProject="${generated.source.dir}">
+ <property name="trimStrings" value="true" />
+ <property name="rootClass" value="abatortest.execute.miscellaneous.BaseClass" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="abatortest.generated.miscellaneous.xml" targetProject="${generated.source.dir}">
+ </sqlMapGenerator>
+
+ <daoGenerator type="IBATIS" targetPackage="abatortest.generated.miscellaneous.dao" targetProject="${generated.source.dir}">
+ <property name="rootInterface" value="abatortest.execute.miscellaneous.BaseInterface" />
+ <property name="methodNameCalculator" value="EXTENDED"/>
+ </daoGenerator>
+
+ <table tableName="BlobsOnly" /> <!-- should generate a warning -->
+ <table tableName="PKFields" domainObjectName="MyObject">
+ <ignoreColumn column="fred" /> <!-- should generate a warning -->
+ <ignoreColumn column="decimal30Field" />
+ <columnOverride column="datefield" property="startDate"/>
+ <columnOverride column="decimal155Field" javaType="java.lang.Double" />
+ <columnOverride column="decimal60Field" javaType="int" />
+ <columnOverride column="firstName" javaType="abatortest.execute.miscellaneous.FirstName"
+ typeHandler="abatortest.execute.miscellaneous.FirstNameTypeHandler"/>
+ <columnOverride column="timeField" javaType="abatortest.execute.miscellaneous.MyTime"
+ typeHandler="abatortest.execute.miscellaneous.MyTimeTypeHandler"/>
+ </table>
+ </abatorContext>
+</abatorConfiguration>