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 2008/06/05 21:40:23 UTC
svn commit: r663717 [1/2] - in /ibatis/trunk/java/tools/ibator/core: build/
doc/ htmldoc/ htmldoc/configreference/ src/org/apache/ibatis/ibator/ant/
src/org/apache/ibatis/ibator/api/ src/org/apache/ibatis/ibator/config/
src/org/apache/ibatis/ibator/con...
Author: jgbutler
Date: Thu Jun 5 12:40:22 2008
New Revision: 663717
URL: http://svn.apache.org/viewvc?rev=663717&view=rev
Log:
ibator: many changes to improve extensibility and enable future refactorings
Added:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableDefaultImpl.java
- copied, changed from r652164, ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableImpl.java
Removed:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableImpl.java
Modified:
ibatis/trunk/java/tools/ibator/core/build/version.properties
ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/ibatorContext.html
ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/IbatorAntTask.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/DAOGenerator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/FullyQualifiedTable.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedFile.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedJavaFile.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedXmlFile.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/JavaModelGenerator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/SqlMapGenerator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/ExtendedDAOMethodNameCalculator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinition.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinitions.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/dao/BaseDAOGenerator.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/model/JavaModelGeneratorJava2Impl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/model/JavaModelGeneratorJava5Impl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/rules/ConditionalModelRules.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/rules/FlatModelRules.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/rules/HierarchicalModelRules.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/rules/IbatorRules.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/sqlmap/SqlMapGeneratorIterateImpl.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/sqlmap/XmlConstants.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/EqualsHashCodePlugin.java
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/SerializablePlugin.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseClass.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/FirstName.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java
Modified: ibatis/trunk/java/tools/ibator/core/build/version.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/version.properties?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/version.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/build/version.properties Thu Jun 5 12:40:22 2008
@@ -1,4 +1,4 @@
#ibator build version info
-#Sat May 03 15:21:33 CDT 2008
+#Thu Jun 05 13:28:34 CDT 2008
version=1.2.0
-buildNum=541
+buildNum=556
Modified: ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt Thu Jun 5 12:40:22 2008
@@ -15,6 +15,8 @@
2. Added support for runtimeCatalog and runtimeSchema properties to the
table configuration. Thanks to Dan Turkenkopf for the idea and the
patch!
+3. Added abiliy to configure an implementation of IntrospectedTable interface.
+ This to allow overriding of many default behaviors of ibator.
Changes:
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/ibatorContext.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/ibatorContext.html?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/ibatorContext.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/configreference/ibatorContext.html Thu Jun 5 12:40:22 2008
@@ -109,6 +109,17 @@
</table>
</td>
</tr>
+ <tr>
+ <td valign="top">introspectedTableImplementation</td>
+ <td>This atribute can be used to configure a custom implementation of the
+ <code>org.apache.ibatis.ibator.api.IntrospectedTable</code> interface
+ for this context. Implementations of this interface can provide
+ custom behavior for many of the core ibator functions. The default
+ implementation of the interface is
+ <code>org.apache.ibatis.ibator.internal.db.IntrospectedTableDefaultImpl</code>
+ and that class is designed for extensibility.
+ </td>
+ </tr>
</table>
<h2>Child Elements</h2>
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html Thu Jun 5 12:40:22 2008
@@ -41,6 +41,11 @@
<a href="configreference/table.html"><table></a>
configuration element. Thanks to Dan Turkenkopf for the idea and the
patch!</li>
+ <li>Added the ability to provide a custom implementation of the
+ IntrospectedTable interface. Implementations of this interface can
+ change many of the core behaviors of ibator. See the
+ <a href="configreference/ibatorContext.html"><ibatorContext></a> page
+ for further information.</li>
</ul>
<h3>Changes from Abator</h3>
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/IbatorAntTask.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/IbatorAntTask.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/IbatorAntTask.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/ant/IbatorAntTask.java Thu Jun 5 12:40:22 2008
@@ -57,9 +57,17 @@
* </target>
* </project>
* </pre>
- *
- * The task also supports these optional attributes:
+ *
+ * The task requires that the attribute "configFile" be set to an
+ * existing ibator XML configuration file.
+ * <p>
+ * The task supports these optional attributes:
* <ul>
+ * <li>"overwrite" - if true, then existing Java files will be overwritten.
+ * if false (default), then existing Java files will be untouched and
+ * ibator will write new Java files with a unique name</li>
+ * <li>"verbose" - if true, then ibator will log progress messages to
+ * the Ant log. Default is false</li>
* <li>"contextIds" - a comma delimited list of contaxtIds to use
* for this run</li>
* <li>"fullyQualifiedTableNames" - a comma delimited list of
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/DAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/DAOGenerator.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/DAOGenerator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/DAOGenerator.java Thu Jun 5 12:40:22 2008
@@ -60,43 +60,6 @@
void setWarnings(List<String> warnings);
/**
- * Sets the target package for this instance. This value should be used to
- * calculate the package for the DAO interface and implementation classes.
- *
- * This method will be called before any of the get methods.
- *
- * @param targetPackage
- * The target package from the configuration
- */
- void setTargetPackage(String targetPackage);
-
- /**
- *
- * @param targetProject
- */
- void setTargetProject(String targetProject);
-
- /**
- * Sets the instance of JavaModelGenerator associated with this instance.
- *
- * This method will be called before any of the get methods.
- *
- * @param javaModelGenerator
- * The JavaModelGenerator associated with this instance
- */
- void setJavaModelGenerator(JavaModelGenerator javaModelGenerator);
-
- /**
- * Sets the instance of SqlMapGenerator associated with this instance.
- *
- * This method will be called before any of the get methods.
- *
- * @param sqlMapGenerator
- * The SqlMapGenerator associated with this instance
- */
- void setSqlMapGenerator(SqlMapGenerator sqlMapGenerator);
-
- /**
* This method returns a list of GenerateJavaFile objects. The list may
* include any, or all, of the following types of generated java classes:
*
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/FullyQualifiedTable.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/FullyQualifiedTable.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/FullyQualifiedTable.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/FullyQualifiedTable.java Thu Jun 5 12:40:22 2008
@@ -287,7 +287,7 @@
}
}
- // TODO - strip characters that are not valid in pacckage names
+ // TODO - strip characters that are not valid in package names
return sb.toString();
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedFile.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedFile.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedFile.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedFile.java Thu Jun 5 12:40:22 2008
@@ -72,4 +72,6 @@
public String toString() {
return getFormattedContent();
}
+
+ public abstract boolean isMergeable();
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedJavaFile.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedJavaFile.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedJavaFile.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedJavaFile.java Thu Jun 5 12:40:22 2008
@@ -59,4 +59,26 @@
public String getTargetPackage() {
return compilationUnit.getType().getPackageName();
}
+
+ /**
+ * This method is required by the Eclipse Java merger. If you are
+ * not running in Eclipse, or some other system that implements the
+ * Java merge function, you may return null from this method.
+ *
+ * @return the CompilationUnit associated with this file, or
+ * null if the file is not mergable.
+ */
+ public CompilationUnit getCompilationUnit() {
+ return compilationUnit;
+ }
+
+ /**
+ * A Java file is mergable if the getCompilationUnit() method
+ * returns a valid compilation unit.
+ *
+ */
+ @Override
+ public boolean isMergeable() {
+ return true;
+ }
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedXmlFile.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedXmlFile.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedXmlFile.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/GeneratedXmlFile.java Thu Jun 5 12:40:22 2008
@@ -72,6 +72,7 @@
return targetPackage;
}
+ @Override
public boolean isMergeable() {
return isMergeable;
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java Thu Jun 5 12:40:22 2008
@@ -18,8 +18,12 @@
import java.util.List;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
import org.apache.ibatis.ibator.config.GeneratedKey;
+import org.apache.ibatis.ibator.config.IbatorContext;
+import org.apache.ibatis.ibator.config.TableConfiguration;
import org.apache.ibatis.ibator.internal.db.ColumnDefinition;
+import org.apache.ibatis.ibator.internal.db.ColumnDefinitions;
import org.apache.ibatis.ibator.internal.rules.IbatorRules;
/**
@@ -29,7 +33,7 @@
*
*/
public interface IntrospectedTable {
- FullyQualifiedTable getTable();
+ FullyQualifiedTable getFullyQualifiedTable();
String getSelectByExampleQueryId();
String getSelectByPrimaryKeyQueryId();
GeneratedKey getGeneratedKey();
@@ -93,7 +97,52 @@
boolean hasBLOBColumns();
+ boolean hasBaseColumns();
+
IbatorRules getRules();
String getTableConfigurationProperty(String property);
+
+ FullyQualifiedJavaType getPrimaryKeyType();
+
+ /**
+ *
+ * @return the type for the record (the class that holds non-primary
+ * key and non-BLOB fields). Note that
+ * the value will be calculated regardless of whether the table has these columns or not.
+ */
+ FullyQualifiedJavaType getBaseRecordType();
+
+ /**
+ *
+ * @return the type for the example class.
+ */
+ FullyQualifiedJavaType getExampleType();
+
+ /**
+ *
+ * @return the type for the record with BLOBs class. Note that
+ * the value will be calculated regardless of whether the table has BLOB columns or not.
+ */
+ FullyQualifiedJavaType getRecordWithBLOBsType();
+
+ String getSqlMapFileName();
+
+ /**
+ * Calculates the package for the current table.
+ *
+ * @return the package for the SqlMap for the current table
+ */
+ String getSqlMapPackage();
+
+ FullyQualifiedJavaType getDAOImplementationType();
+
+ FullyQualifiedJavaType getDAOInterfaceType();
+
+ boolean hasAnyColumns();
+
+ void setTableConfiguration(TableConfiguration tableConfiguration);
+ void setColumnDefinitions(ColumnDefinitions columnDefinitions);
+ void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable);
+ void setIbatorContext(IbatorContext ibatorContext);
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/JavaModelGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/JavaModelGenerator.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/JavaModelGenerator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/JavaModelGenerator.java Thu Jun 5 12:40:22 2008
@@ -18,7 +18,6 @@
import java.util.List;
import java.util.Properties;
-import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
import org.apache.ibatis.ibator.config.IbatorContext;
/**
@@ -70,50 +69,6 @@
void setWarnings(List<String> warnings);
/**
- * Sets the target package of the generator taken from the
- * JavaModelGeneratorConfiguration element. This method is
- * called before any getXXX method.
- *
- * @param targetPackage the configuration element's target package
- */
- void setTargetPackage(String targetPackage);
-
- /**
- * Sets the target project of the generator taken from the
- * JavaModelGeneratorConfiguration element. This method is
- * called before any getXXX method.
- *
- * @param targetProject the configuration element's target project
- */
- void setTargetProject(String targetProject);
-
- FullyQualifiedJavaType getPrimaryKeyType(FullyQualifiedTable table);
-
- /**
- *
- * @param table the table for which the name should be generated
- * @return the type for the record (the class that holds non-primary
- * key and non-BLOB fields). Note that
- * the value will be calculated regardless of whether the table has these columns or not.
- */
- FullyQualifiedJavaType getBaseRecordType(FullyQualifiedTable table);
-
- /**
- *
- * @param table the table for which the name should be generated
- * @return the type for the example class.
- */
- FullyQualifiedJavaType getExampleType(FullyQualifiedTable table);
-
- /**
- *
- * @param table the table for which the name should be generated
- * @return the type for the record with BLOBs class. Note that
- * the value will be calculated regardless of whether the table has BLOB columns or not.
- */
- FullyQualifiedJavaType getRecordWithBLOBsType(FullyQualifiedTable table);
-
- /**
* This method returns a list of GenerateJavaFile objects. The list may
* include any, or all, of the following types of generated java classes:
*
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/SqlMapGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/SqlMapGenerator.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/SqlMapGenerator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/SqlMapGenerator.java Thu Jun 5 12:40:22 2008
@@ -62,11 +62,5 @@
*/
void setIbatorContext(IbatorContext ibatorContext);
- void setTargetPackage(String targetPackage);
-
- void setTargetProject(String targetProject);
-
- void setJavaModelGenerator(JavaModelGenerator javaModelGenerator);
-
List<GeneratedXmlFile> getGeneratedXMLFiles(IntrospectedTable introspectedTable, ProgressCallback callback);
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/IbatorContext.java Thu Jun 5 12:40:22 2008
@@ -80,6 +80,8 @@
private List<IbatorPluginConfiguration> pluginConfigurations;
+ private String introspectedTableImplementation;
+
/**
* Constructs an IbatorContext object.
*
@@ -242,8 +244,8 @@
JavaTypeResolver javaTypeResolver = IbatorObjectFactory.createJavaTypeResolver(this, warnings);
JavaModelGenerator javaModelGenerator = IbatorObjectFactory.createJavaModelGenerator(this, warnings);
- SqlMapGenerator sqlMapGenerator = IbatorObjectFactory.createSqlMapGenerator(this, javaModelGenerator, warnings);
- DAOGenerator daoGenerator = IbatorObjectFactory.createDAOGenerator(this, javaModelGenerator, sqlMapGenerator, warnings);
+ SqlMapGenerator sqlMapGenerator = IbatorObjectFactory.createSqlMapGenerator(this, warnings);
+ DAOGenerator daoGenerator = IbatorObjectFactory.createDAOGenerator(this, warnings);
pluginAggregator = new IbatorPluginAggregator();
for (IbatorPluginConfiguration ibatorPluginConfiguration : pluginConfigurations) {
IbatorPlugin plugin = IbatorObjectFactory.createIbatorPlugin(this, ibatorPluginConfiguration);
@@ -409,6 +411,10 @@
xmlElement.addAttribute(new Attribute("generatorSet", configuredGeneratorSet)); //$NON-NLS-1$
}
+ if (StringUtility.stringHasValue(introspectedTableImplementation)) {
+ xmlElement.addAttribute(new Attribute("introspectedTableImplementation", introspectedTableImplementation)); //$NON-NLS-1$
+ }
+
addPropertyXmlElements(xmlElement);
if (commentGeneratorConfiguration != null) {
@@ -495,4 +501,13 @@
public String getConfiguredGeneratorSet() {
return configuredGeneratorSet;
}
+
+ public String getIntrospectedTableImplementation() {
+ return introspectedTableImplementation;
+ }
+
+ public void setIntrospectedTableImplementation(
+ String introspectedTableImplementation) {
+ this.introspectedTableImplementation = introspectedTableImplementation;
+ }
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/IbatorConfigurationParser.java Thu Jun 5 12:40:22 2008
@@ -240,12 +240,14 @@
String generatorSet = attributes.getProperty("generatorSet"); //$NON-NLS-1$
String defaultModelType = attributes.getProperty("defaultModelType"); //$NON-NLS-1$
String id = attributes.getProperty("id"); //$NON-NLS-1$
+ String introspectedTableImplementation = attributes.getProperty("introspectedTableImplementation"); //$NON-NLS-1$
ModelType mt = defaultModelType == null ? null : ModelType
.getModelType(defaultModelType);
IbatorContext ibatorContext = new IbatorContext(generatorSet, mt);
ibatorContext.setId(id);
+ ibatorContext.setIntrospectedTableImplementation(introspectedTableImplementation);
ibatorConfiguration.addIbatorContext(ibatorContext);
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/config/xml/ibator-config_1_0.dtd Thu Jun 5 12:40:22 2008
@@ -54,7 +54,8 @@
javaModelGenerator, sqlMapGenerator, daoGenerator?, table+)>
<!ATTLIST ibatorContext id ID #REQUIRED
defaultModelType CDATA #IMPLIED
- generatorSet CDATA #IMPLIED>
+ generatorSet CDATA #IMPLIED
+ introspectedTableImplementation CDATA #IMPLIED>
<!--
The jdbcConnection element is used to describe the JDBC connection that ibator
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/ExtendedDAOMethodNameCalculator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/ExtendedDAOMethodNameCalculator.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/ExtendedDAOMethodNameCalculator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/ExtendedDAOMethodNameCalculator.java Thu Jun 5 12:40:22 2008
@@ -36,7 +36,7 @@
public String getInsertMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("insert"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
return sb.toString();
}
@@ -53,7 +53,7 @@
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
IbatorRules rules = introspectedTable.getRules();
@@ -79,7 +79,7 @@
public String getUpdateByPrimaryKeyWithBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
IbatorRules rules = introspectedTable.getRules();
@@ -97,7 +97,7 @@
public String getDeleteByExampleMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("delete"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByExample"); //$NON-NLS-1$
return sb.toString();
@@ -106,7 +106,7 @@
public String getDeleteByPrimaryKeyMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("delete"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByPrimaryKey"); //$NON-NLS-1$
return sb.toString();
@@ -120,7 +120,7 @@
public String getSelectByExampleWithoutBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("select"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByExample"); //$NON-NLS-1$
IbatorRules rules = introspectedTable.getRules();
@@ -140,7 +140,7 @@
public String getSelectByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("select"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByExample"); //$NON-NLS-1$
IbatorRules rules = introspectedTable.getRules();
@@ -155,7 +155,7 @@
public String getSelectByPrimaryKeyMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("select"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByPrimaryKey"); //$NON-NLS-1$
return sb.toString();
@@ -165,7 +165,7 @@
public String getUpdateByPrimaryKeySelectiveMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByPrimaryKeySelective"); //$NON-NLS-1$
return sb.toString();
@@ -174,7 +174,7 @@
public String getCountByExampleMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("count"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByExample"); //$NON-NLS-1$
return sb.toString();
@@ -183,7 +183,7 @@
public String getUpdateByExampleSelectiveMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
sb.append("ByExampleSelective"); //$NON-NLS-1$
return sb.toString();
@@ -192,7 +192,7 @@
public String getUpdateByExampleWithBLOBsMethodName(IntrospectedTable introspectedTable) {
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
IbatorRules rules = introspectedTable.getRules();
@@ -211,7 +211,7 @@
StringBuffer sb = new StringBuffer();
sb.append("update"); //$NON-NLS-1$
- sb.append(introspectedTable.getTable().getDomainObjectName());
+ sb.append(introspectedTable.getFullyQualifiedTable().getDomainObjectName());
IbatorRules rules = introspectedTable.getRules();
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java Thu Jun 5 12:40:22 2008
@@ -19,7 +19,9 @@
import org.apache.ibatis.ibator.api.CommentGenerator;
import org.apache.ibatis.ibator.api.DAOGenerator;
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
import org.apache.ibatis.ibator.api.IbatorPlugin;
+import org.apache.ibatis.ibator.api.IntrospectedTable;
import org.apache.ibatis.ibator.api.JavaModelGenerator;
import org.apache.ibatis.ibator.api.JavaTypeResolver;
import org.apache.ibatis.ibator.api.SqlMapGenerator;
@@ -30,6 +32,10 @@
import org.apache.ibatis.ibator.config.JavaModelGeneratorConfiguration;
import org.apache.ibatis.ibator.config.JavaTypeResolverConfiguration;
import org.apache.ibatis.ibator.config.SqlMapGeneratorConfiguration;
+import org.apache.ibatis.ibator.config.TableConfiguration;
+import org.apache.ibatis.ibator.internal.db.ColumnDefinitions;
+import org.apache.ibatis.ibator.internal.db.IntrospectedTableDefaultImpl;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
/**
@@ -115,7 +121,7 @@
}
public static SqlMapGenerator createSqlMapGenerator(IbatorContext context,
- JavaModelGenerator javaModelGenerator, List<String> warnings) {
+ List<String> warnings) {
SqlMapGeneratorConfiguration config = context.getSqlMapGeneratorConfiguration();
String type;
@@ -129,11 +135,8 @@
SqlMapGenerator answer = (SqlMapGenerator) createObject(type);
answer.setWarnings(warnings);
- answer.setJavaModelGenerator(javaModelGenerator);
answer.addConfigurationProperties(config.getProperties());
answer.setIbatorContext(context);
- answer.setTargetPackage(config.getTargetPackage());
- answer.setTargetProject(config.getTargetProject());
return answer;
}
@@ -155,14 +158,12 @@
answer.addConfigurationProperties(config.getProperties());
answer.setIbatorContext(context);
- answer.setTargetPackage(config.getTargetPackage());
- answer.setTargetProject(config.getTargetProject());
return answer;
}
public static DAOGenerator createDAOGenerator(IbatorContext context,
- JavaModelGenerator javaModelGenerator, SqlMapGenerator sqlMapGenerator, List<String> warnings) {
+ List<String> warnings) {
DAOGeneratorConfiguration config = context.getDaoGeneratorConfiguration();
@@ -175,12 +176,8 @@
DAOGenerator answer = (DAOGenerator) createObject(type);
answer.setWarnings(warnings);
- answer.setJavaModelGenerator(javaModelGenerator);
answer.addConfigurationProperties(config.getProperties());
answer.setIbatorContext(context);
- answer.setSqlMapGenerator(sqlMapGenerator);
- answer.setTargetPackage(config.getTargetPackage());
- answer.setTargetProject(config.getTargetProject());
return answer;
}
@@ -205,4 +202,21 @@
return answer;
}
+
+ public static IntrospectedTable createIntrospectedTable(TableConfiguration tableConfiguration, ColumnDefinitions columnDefinitions,
+ FullyQualifiedTable table, IbatorContext ibatorContext) {
+
+ String type = ibatorContext.getIntrospectedTableImplementation();
+ if (!StringUtility.stringHasValue(type)) {
+ type = IntrospectedTableDefaultImpl.class.getName();
+ }
+
+ IntrospectedTable answer = (IntrospectedTable) createObject(type);
+ answer.setColumnDefinitions(columnDefinitions);
+ answer.setFullyQualifiedTable(table);
+ answer.setIbatorContext(ibatorContext);
+ answer.setTableConfiguration(tableConfiguration);
+
+ return answer;
+ }
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinition.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinition.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinition.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinition.java Thu Jun 5 12:40:22 2008
@@ -158,8 +158,9 @@
public boolean isBLOBColumn() {
String typeName = resolvedJavaType.getJdbcTypeName();
- return "BLOB".equals(typeName) || "LONGVARBINARY".equals(typeName) //$NON-NLS-1$ //$NON-NLS-2$
- || "LONGVARCHAR".equals(typeName) || "CLOB".equals(typeName); //$NON-NLS-1$ //$NON-NLS-2$
+ return "BINARY".equals(typeName) || "BLOB".equals(typeName) //$NON-NLS-1$ //$NON-NLS-2$
+ || "CLOB".equals(typeName) || "LONGVARBINARY".equals(typeName) //$NON-NLS-1$ //$NON-NLS-2$
+ || "LONGVARCHAR".equals(typeName) || "VARBINARY".equals(typeName); //$NON-NLS-1$ //$NON-NLS-2$
}
public boolean isStringColumn() {
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinitions.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinitions.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinitions.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/ColumnDefinitions.java Thu Jun 5 12:40:22 2008
@@ -25,7 +25,6 @@
* @author Jeff Butler
*/
public class ColumnDefinitions {
-
private List<ColumnDefinition> primaryKeyColumns;
private List<ColumnDefinition> baseColumns;
private List<ColumnDefinition> blobColumns;
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java Thu Jun 5 12:40:22 2008
@@ -36,6 +36,7 @@
import org.apache.ibatis.ibator.config.GeneratedKey;
import org.apache.ibatis.ibator.config.PropertyRegistry;
import org.apache.ibatis.ibator.config.TableConfiguration;
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
import org.apache.ibatis.ibator.internal.types.ResolvedJavaType;
import org.apache.ibatis.ibator.internal.util.JavaBeansUtil;
import org.apache.ibatis.ibator.internal.util.StringUtility;
@@ -61,13 +62,13 @@
this.warnings = warnings;
}
- private void calculatePrimaryKey(IntrospectedTableImpl introspectedTable) {
+ private void calculatePrimaryKey(FullyQualifiedTable table, ColumnDefinitions columnDefinitions) {
ResultSet rs = null;
-
+
try {
- rs = databaseMetaData.getPrimaryKeys(introspectedTable.getTable().getIntrospectedCatalog(),
- introspectedTable.getTable().getIntrospectedSchema(),
- introspectedTable.getTable().getIntrospectedTableName());
+ rs = databaseMetaData.getPrimaryKeys(table.getIntrospectedCatalog(),
+ table.getIntrospectedSchema(),
+ table.getIntrospectedTableName());
} catch (SQLException e) {
closeResultSet(rs);
warnings.add(Messages.getString("Warning.15")); //$NON-NLS-1$
@@ -78,7 +79,7 @@
while (rs.next()) {
String columnName = rs.getString("COLUMN_NAME"); //$NON-NLS-1$
- introspectedTable.getColumnDefinitions().addPrimaryKeyColumn(columnName);
+ columnDefinitions.addPrimaryKeyColumn(columnName);
}
} catch (SQLException e) {
// ignore the primary key if there's any error
@@ -99,13 +100,13 @@
}
private void reportIntrospectionWarnings(
- ColumnDefinitions columnDefinitions,
+ IntrospectedTable introspectedTable,
TableConfiguration tableConfiguration,
FullyQualifiedTable table) {
// make sure that every column listed in column overrides
// actually exists in the table
for (ColumnOverride columnOverride : tableConfiguration.getColumnOverrides()) {
- if (columnDefinitions.getColumn(columnOverride.getColumnName()) == null) {
+ if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
warnings.add(Messages.getString("Warning.3", //$NON-NLS-1$
columnOverride.getColumnName(), table.toString()));
}
@@ -120,7 +121,7 @@
GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
if (generatedKey != null
- && columnDefinitions.getColumn(generatedKey.getColumn()) == null) {
+ && introspectedTable.getColumn(generatedKey.getColumn()) == null) {
if (generatedKey.isIdentity()) {
warnings.add(Messages.getString("Warning.5", //$NON-NLS-1$
generatedKey.getColumn(), table.toString()));
@@ -140,7 +141,7 @@
* @return a list of introspected tables
* @throws SQLException
*/
- public List<? extends IntrospectedTable> introspectTables(TableConfiguration tc) throws SQLException {
+ public List<IntrospectedTable> introspectTables(TableConfiguration tc) throws SQLException {
// get the raw columns from the DB
Map<ActualTableName, List<ColumnDefinition>> columns = getColumns(tc);
@@ -156,34 +157,28 @@
applyColumnOverrides(tc, columns);
calculateIdentityColumns(tc, columns);
- List<IntrospectedTableImpl> introspectedTables = calculateIntrospectedTables(tc, columns);
-
- for (IntrospectedTableImpl it : introspectedTables) {
- calculatePrimaryKey(it);
- }
+ List<IntrospectedTable> introspectedTables = calculateIntrospectedTables(tc, columns);
// now introspectedTables has all the columns from all the
// tables in the configuration. Do some validation...
- Iterator<IntrospectedTableImpl> iter = introspectedTables.iterator();
+ Iterator<IntrospectedTable> iter = introspectedTables.iterator();
while (iter.hasNext()) {
- IntrospectedTableImpl introspectedTable = iter.next();
-
- ColumnDefinitions cds = introspectedTable.getColumnDefinitions();
+ IntrospectedTable introspectedTable = iter.next();
- if (!cds.hasAnyColumns()) {
+ if (!introspectedTable.hasAnyColumns()) {
// add warning that the table has no columns, remove from the list
- warnings.add(Messages.getString("Warning.1", introspectedTable.getTable().toString())); //$NON-NLS-1$
+ warnings.add(Messages.getString("Warning.1", introspectedTable.getFullyQualifiedTable().toString())); //$NON-NLS-1$
iter.remove();
- } else if (!cds.hasPrimaryKeyColumns()
- && !cds.hasBaseColumns()) {
+ } else if (!introspectedTable.hasPrimaryKeyColumns()
+ && !introspectedTable.hasBaseColumns()) {
// add warning that the table has only BLOB columns, remove from the list
- warnings.add(Messages.getString("Warning.18", introspectedTable.getTable().toString())); //$NON-NLS-1$
+ warnings.add(Messages.getString("Warning.18", introspectedTable.getFullyQualifiedTable().toString())); //$NON-NLS-1$
iter.remove();
} else {
// now make sure that all columns called out in the configuration
// actually exist
- reportIntrospectionWarnings(cds, tc, introspectedTable.getTable());
+ reportIntrospectionWarnings(introspectedTable, tc, introspectedTable.getFullyQualifiedTable());
}
}
@@ -428,14 +423,14 @@
return answer;
}
- private List<IntrospectedTableImpl> calculateIntrospectedTables(TableConfiguration tc,
+ private List<IntrospectedTable> calculateIntrospectedTables(TableConfiguration tc,
Map<ActualTableName, List<ColumnDefinition>> columns) {
boolean delimitIdentifiers = tc.isDelimitIdentifiers()
|| StringUtility.stringContainsSpace(tc.getCatalog())
|| StringUtility.stringContainsSpace(tc.getSchema())
|| StringUtility.stringContainsSpace(tc.getTableName());
- List<IntrospectedTableImpl> answer = new ArrayList<IntrospectedTableImpl>();
+ List<IntrospectedTable> answer = new ArrayList<IntrospectedTable>();
for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
ActualTableName atn = entry.getKey();
@@ -459,12 +454,16 @@
ibatorContext);
ColumnDefinitions cds = new ColumnDefinitions();
- IntrospectedTableImpl introspectedTable = new IntrospectedTableImpl(tc, cds, table);
- answer.add(introspectedTable);
for (ColumnDefinition cd : entry.getValue()) {
cds.addColumn(cd);
}
+
+ calculatePrimaryKey(table, cds);
+
+ IntrospectedTable introspectedTable =
+ IbatorObjectFactory.createIntrospectedTable(tc, cds, table, ibatorContext);
+ answer.add(introspectedTable);
}
return answer;
Copied: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableDefaultImpl.java (from r652164, ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableImpl.java)
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableDefaultImpl.java?p2=ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableDefaultImpl.java&p1=ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableImpl.java&r1=652164&r2=663717&rev=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableImpl.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/IntrospectedTableDefaultImpl.java Thu Jun 5 12:40:22 2008
@@ -21,49 +21,44 @@
import org.apache.ibatis.ibator.api.FullyQualifiedTable;
import org.apache.ibatis.ibator.api.IntrospectedTable;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.ibator.config.DAOGeneratorConfiguration;
import org.apache.ibatis.ibator.config.GeneratedKey;
+import org.apache.ibatis.ibator.config.IbatorContext;
+import org.apache.ibatis.ibator.config.JavaModelGeneratorConfiguration;
import org.apache.ibatis.ibator.config.ModelType;
+import org.apache.ibatis.ibator.config.PropertyRegistry;
+import org.apache.ibatis.ibator.config.SqlMapGeneratorConfiguration;
import org.apache.ibatis.ibator.config.TableConfiguration;
-import org.apache.ibatis.ibator.internal.rules.IbatorRules;
import org.apache.ibatis.ibator.internal.rules.ConditionalModelRules;
import org.apache.ibatis.ibator.internal.rules.FlatModelRules;
import org.apache.ibatis.ibator.internal.rules.HierarchicalModelRules;
+import org.apache.ibatis.ibator.internal.rules.IbatorRules;
/**
* @author Jeff Butler
*
*/
-public class IntrospectedTableImpl implements IntrospectedTable {
+public class IntrospectedTableDefaultImpl implements IntrospectedTable {
private TableConfiguration tableConfiguration;
private ColumnDefinitions columnDefinitions;
- private FullyQualifiedTable table;
+ private FullyQualifiedTable fullyQualifiedTable;
private IbatorRules rules;
+ private IbatorContext ibatorContext;
/**
*
*/
- public IntrospectedTableImpl(TableConfiguration tableConfiguration, ColumnDefinitions columnDefinitions,
- FullyQualifiedTable table) {
+ public IntrospectedTableDefaultImpl() {
super();
- this.columnDefinitions = columnDefinitions;
- this.tableConfiguration = tableConfiguration;
- this.table = table;
-
- if (tableConfiguration.getModelType() == ModelType.HIERARCHICAL) {
- this.rules = new HierarchicalModelRules(tableConfiguration, columnDefinitions);
- } else if (tableConfiguration.getModelType() == ModelType.FLAT) {
- this.rules = new FlatModelRules(tableConfiguration, columnDefinitions);
- } else {
- this.rules = new ConditionalModelRules(tableConfiguration, columnDefinitions);
- }
}
/* (non-Javadoc)
* @see org.apache.ibatis.ibator.api.IntrospectedTable#getTable()
*/
- public FullyQualifiedTable getTable() {
- return table;
+ public FullyQualifiedTable getFullyQualifiedTable() {
+ return fullyQualifiedTable;
}
/* (non-Javadoc)
@@ -99,11 +94,17 @@
return columnDefinitions.hasJDBCTimeColumns();
}
- public ColumnDefinitions getColumnDefinitions() {
- return columnDefinitions;
- }
-
public IbatorRules getRules() {
+ if (rules == null) {
+ if (tableConfiguration.getModelType() == ModelType.HIERARCHICAL) {
+ this.rules = new HierarchicalModelRules(tableConfiguration, this);
+ } else if (tableConfiguration.getModelType() == ModelType.FLAT) {
+ this.rules = new FlatModelRules(tableConfiguration, this);
+ } else {
+ this.rules = new ConditionalModelRules(tableConfiguration, this);
+ }
+ }
+
return rules;
}
@@ -161,4 +162,154 @@
public String getTableConfigurationProperty(String property) {
return tableConfiguration.getProperty(property);
}
+
+ public FullyQualifiedJavaType getPrimaryKeyType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getJavaModelPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Key"); //$NON-NLS-1$
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public FullyQualifiedJavaType getBaseRecordType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getJavaModelPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public FullyQualifiedJavaType getRecordWithBLOBsType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getJavaModelPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("WithBLOBs"); //$NON-NLS-1$
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public FullyQualifiedJavaType getExampleType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getJavaModelPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("Example"); //$NON-NLS-1$
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public boolean hasBaseColumns() {
+ return columnDefinitions.hasBaseColumns();
+ }
+
+ /**
+ * Calculates an SQL Map file name for the table. Typically the name is
+ * "XXXX_SqlMap.xml" where XXXX is the fully qualified table name (delimited
+ * with underscores).
+ *
+ * @return the name of the SqlMap file
+ */
+ public String getSqlMapFileName() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(fullyQualifiedTable.getSqlMapNamespace());
+ sb.append("_SqlMap.xml"); //$NON-NLS-1$
+
+ return sb.toString();
+ }
+
+ /**
+ * Calculates the package for the current table.
+ *
+ * @return the package for the SqlMap for the current table
+ */
+ public String getSqlMapPackage() {
+ SqlMapGeneratorConfiguration config = ibatorContext.getSqlMapGeneratorConfiguration();
+
+ StringBuffer sb = new StringBuffer(config.getTargetPackage());
+ if ("true".equalsIgnoreCase(config.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) { //$NON-NLS-1$
+ sb.append(fullyQualifiedTable.getSubPackage());
+ }
+
+ return sb.toString();
+ }
+
+ public FullyQualifiedJavaType getDAOImplementationType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getDAOPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAOImpl"); //$NON-NLS-1$
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public FullyQualifiedJavaType getDAOInterfaceType() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(getDAOPackage());
+ sb.append('.');
+ sb.append(fullyQualifiedTable.getDomainObjectName());
+ sb.append("DAO"); //$NON-NLS-1$
+
+ FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString());
+
+ return fqjt;
+ }
+
+ public boolean hasAnyColumns() {
+ return columnDefinitions.hasAnyColumns();
+ }
+
+ protected String getDAOPackage() {
+ DAOGeneratorConfiguration config = ibatorContext.getDaoGeneratorConfiguration();
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(config.getTargetPackage());
+ if ("true".equalsIgnoreCase(config.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) { //$NON-NLS-1$
+ sb.append(fullyQualifiedTable.getSubPackage());
+ }
+
+ return sb.toString();
+ }
+
+ protected String getJavaModelPackage() {
+ JavaModelGeneratorConfiguration config = ibatorContext.getJavaModelGeneratorConfiguration();
+
+ StringBuffer sb = new StringBuffer();
+ sb.append(config.getTargetPackage());
+ if ("true".equalsIgnoreCase(config.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) { //$NON-NLS-1$
+ sb.append(fullyQualifiedTable.getSubPackage());
+ }
+
+ return sb.toString();
+ }
+
+ public void setColumnDefinitions(ColumnDefinitions columnDefinitions) {
+ this.columnDefinitions = columnDefinitions;
+ }
+
+ public void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable) {
+ this.fullyQualifiedTable = fullyQualifiedTable;
+ }
+
+ public void setIbatorContext(IbatorContext ibatorContext) {
+ this.ibatorContext = ibatorContext;
+ }
+
+ public void setTableConfiguration(TableConfiguration tableConfiguration) {
+ this.tableConfiguration = tableConfiguration;
+ }
}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/dao/BaseDAOGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/dao/BaseDAOGenerator.java?rev=663717&r1=663716&r2=663717&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/dao/BaseDAOGenerator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/java/dao/BaseDAOGenerator.java Thu Jun 5 12:40:22 2008
@@ -16,9 +16,7 @@
package org.apache.ibatis.ibator.internal.java.dao;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import org.apache.ibatis.ibator.api.CommentGenerator;
@@ -28,9 +26,7 @@
import org.apache.ibatis.ibator.api.GeneratedJavaFile;
import org.apache.ibatis.ibator.api.IbatorPlugin;
import org.apache.ibatis.ibator.api.IntrospectedTable;
-import org.apache.ibatis.ibator.api.JavaModelGenerator;
import org.apache.ibatis.ibator.api.ProgressCallback;
-import org.apache.ibatis.ibator.api.SqlMapGenerator;
import org.apache.ibatis.ibator.api.dom.java.CompilationUnit;
import org.apache.ibatis.ibator.api.dom.java.Field;
import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
@@ -43,9 +39,9 @@
import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
import org.apache.ibatis.ibator.config.IbatorContext;
import org.apache.ibatis.ibator.config.PropertyRegistry;
-import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
import org.apache.ibatis.ibator.internal.DefaultDAOMethodNameCalculator;
import org.apache.ibatis.ibator.internal.ExtendedDAOMethodNameCalculator;
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
import org.apache.ibatis.ibator.internal.db.ColumnDefinition;
import org.apache.ibatis.ibator.internal.rules.IbatorRules;
import org.apache.ibatis.ibator.internal.sqlmap.XmlConstants;
@@ -101,16 +97,6 @@
protected List<String> warnings;
- protected String targetPackage;
-
- protected String targetProject;
-
- protected JavaModelGenerator javaModelGenerator;
-
- protected SqlMapGenerator sqlMapGenerator;
-
- private Map<FullyQualifiedTable, Map<String, Object>> tableValueMaps;
-
private boolean useJava5Features;
protected JavaVisibility exampleMethodVisibility = JavaVisibility.PUBLIC;
@@ -125,7 +111,6 @@
super();
this.daoTemplate = daoTemplate;
this.useJava5Features = useJava5Features;
- tableValueMaps = new HashMap<FullyQualifiedTable, Map<String, Object>>();
properties = new Properties();
}
@@ -175,52 +160,18 @@
/*
* (non-Javadoc)
*
- * @see org.apache.ibatis.ibator.api.DAOGenerator#setTargetPackage(java.lang.String)
- */
- public void setTargetPackage(String targetPackage) {
- this.targetPackage = targetPackage;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.ibator.api.DAOGenerator#setTargetProject(java.lang.String)
- */
- public void setTargetProject(String targetProject) {
- this.targetProject = targetProject;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.ibator.api.DAOGenerator#setJavaModelGenerator(org.apache.ibatis.ibator.api.JavaModelGenerator)
- */
- public void setJavaModelGenerator(JavaModelGenerator javaModelGenerator) {
- this.javaModelGenerator = javaModelGenerator;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.ibatis.ibator.api.DAOGenerator#setSqlMapGenerator(org.apache.ibatis.ibator.api.SqlMapGenerator)
- */
- public void setSqlMapGenerator(SqlMapGenerator sqlMapGenerator) {
- this.sqlMapGenerator = sqlMapGenerator;
- }
-
- /*
- * (non-Javadoc)
- *
* @see org.apache.ibatis.ibator.api.DAOGenerator#getGeneratedJavaFiles(org.apache.ibatis.ibator.internal.db.IntrospectedTable,
* org.apache.ibatis.ibator.api.ProgressCallback)
*/
public List<GeneratedJavaFile> getGeneratedJavaFiles(IntrospectedTable introspectedTable,
ProgressCallback callback) {
+ String targetProject = ibatorContext.getDaoGeneratorConfiguration().getTargetProject();
+
List<GeneratedJavaFile> list = new ArrayList<GeneratedJavaFile>();
IbatorPlugin plugins = ibatorContext.getPlugins();
callback.startSubTask(Messages.getString("Progress.10", //$NON-NLS-1$
- introspectedTable.getTable().toString()));
+ introspectedTable.getFullyQualifiedTable().toString()));
TopLevelClass tlc = getDAOImplementation(introspectedTable);
if (plugins.daoImplementationGenerated(tlc, introspectedTable)) {
GeneratedJavaFile gjf = new GeneratedJavaFile(tlc, targetProject);
@@ -228,7 +179,7 @@
}
callback.startSubTask(Messages.getString("Progress.11", //$NON-NLS-1$
- introspectedTable.getTable().toString()));
+ introspectedTable.getFullyQualifiedTable().toString()));
Interface interfaze = getDAOInterface(introspectedTable);
if (plugins.daoInterfaceGenerated(interfaze, introspectedTable)) {
GeneratedJavaFile gjf = new GeneratedJavaFile(interfaze, targetProject);
@@ -241,16 +192,18 @@
protected TopLevelClass getDAOImplementation(
IntrospectedTable introspectedTable) {
+ FullyQualifiedJavaType interfaceType = introspectedTable.getDAOInterfaceType();
+ FullyQualifiedJavaType implementationType = introspectedTable.getDAOImplementationType();
+
CommentGenerator commentGenerator = ibatorContext.getCommentGenerator();
- FullyQualifiedTable table = introspectedTable.getTable();
- FullyQualifiedJavaType type = getDAOImplementationType(table);
- TopLevelClass answer = new TopLevelClass(type);
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ TopLevelClass answer = new TopLevelClass(implementationType);
answer.setVisibility(JavaVisibility.PUBLIC);
answer.setSuperClass(daoTemplate.getSuperClass());
answer.addImportedType(daoTemplate.getSuperClass());
- answer.addSuperInterface(getDAOInterfaceType(table));
- answer.addImportedType(getDAOInterfaceType(table));
+ answer.addSuperInterface(interfaceType);
+ answer.addImportedType(interfaceType);
for (FullyQualifiedJavaType fqjt : daoTemplate.getImplementationImports()) {
answer.addImportedType(fqjt);
@@ -260,7 +213,7 @@
// add constructor
answer.addMethod(daoTemplate.getConstructorClone(commentGenerator,
- getDAOImplementationType(table), table));
+ implementationType, table));
// add any fields from the template
for (Field field : daoTemplate.getFieldClones(commentGenerator, table)) {
@@ -409,8 +362,7 @@
}
protected Interface getDAOInterface(IntrospectedTable introspectedTable) {
- FullyQualifiedTable table = introspectedTable.getTable();
- Interface answer = new Interface(getDAOInterfaceType(table));
+ Interface answer = new Interface(introspectedTable.getDAOInterfaceType());
answer.setVisibility(JavaVisibility.PUBLIC);
String rootInterface = introspectedTable.getTableConfigurationProperty(PropertyRegistry.ANY_ROOT_INTERFACE);
@@ -557,30 +509,10 @@
return answer;
}
- protected FullyQualifiedJavaType getDAOImplementationType(
- FullyQualifiedTable table) {
- String key = "getDAOImplementationType"; //$NON-NLS-1$
-
- Map<String, Object> map = getTableValueMap(table);
- FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) map.get(key);
- if (fqjt == null) {
- StringBuffer sb = new StringBuffer();
- sb.append(getDAOPackage(table));
- sb.append('.');
- sb.append(table.getDomainObjectName());
- sb.append("DAOImpl"); //$NON-NLS-1$
-
- fqjt = new FullyQualifiedJavaType(sb.toString());
- map.put(key, fqjt);
- }
-
- return fqjt;
- }
-
protected Method getInsertMethod(IntrospectedTable introspectedTable,
boolean interfaceMethod, CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
Method method = new Method();
FullyQualifiedJavaType returnType;
@@ -605,7 +537,7 @@
method.setName(methodNameCalculator.getInsertMethodName(introspectedTable));
FullyQualifiedJavaType parameterType =
- introspectedTable.getRules().calculateAllFieldsClass(javaModelGenerator, table);
+ introspectedTable.getRules().calculateAllFieldsClass();
compilationUnit.addImportedType(parameterType);
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
@@ -664,9 +596,9 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType =
- javaModelGenerator.getBaseRecordType(table);
+ introspectedTable.getBaseRecordType();
compilationUnit.addImportedType(parameterType);
Method method = new Method();
@@ -702,13 +634,13 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+ parameterType = introspectedTable.getRecordWithBLOBsType();
} else {
- parameterType = javaModelGenerator.getBaseRecordType(table);
+ parameterType = introspectedTable.getBaseRecordType();
}
compilationUnit.addImportedType(parameterType);
@@ -746,13 +678,13 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+ parameterType = introspectedTable.getRecordWithBLOBsType();
} else {
- parameterType = javaModelGenerator.getBaseRecordType(table);
+ parameterType = introspectedTable.getBaseRecordType();
}
compilationUnit.addImportedType(parameterType);
@@ -794,8 +726,8 @@
return null;
}
- FullyQualifiedTable table = introspectedTable.getTable();
- FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ FullyQualifiedJavaType type = introspectedTable.getExampleType();
compilationUnit.addImportedType(type);
compilationUnit.addImportedType(FullyQualifiedJavaType
.getNewListInstance());
@@ -807,9 +739,9 @@
if (useJava5Features) {
FullyQualifiedJavaType fqjt;
if (introspectedTable.getRules().generateBaseRecordClass()) {
- fqjt = javaModelGenerator.getBaseRecordType(table);
+ fqjt = introspectedTable.getBaseRecordType();
} else if (introspectedTable.getRules().generatePrimaryKeyClass()) {
- fqjt = javaModelGenerator.getPrimaryKeyType(table);
+ fqjt = introspectedTable.getPrimaryKeyType();
} else {
throw new RuntimeException(Messages
.getString("RuntimeError.12")); //$NON-NLS-1$
@@ -865,8 +797,8 @@
return null;
}
- FullyQualifiedTable table = introspectedTable.getTable();
- FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ FullyQualifiedJavaType type = introspectedTable.getExampleType();
compilationUnit.addImportedType(type);
compilationUnit.addImportedType(FullyQualifiedJavaType
.getNewListInstance());
@@ -878,10 +810,10 @@
if (useJava5Features) {
FullyQualifiedJavaType fqjt;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- fqjt = javaModelGenerator.getRecordWithBLOBsType(table);
+ fqjt = introspectedTable.getRecordWithBLOBsType();
} else {
// the blob fileds must be rolled up into the base class
- fqjt = javaModelGenerator.getBaseRecordType(table);
+ fqjt = introspectedTable.getBaseRecordType();
}
compilationUnit.addImportedType(fqjt);
@@ -931,20 +863,20 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
FullyQualifiedJavaType returnType =
- introspectedTable.getRules().calculateAllFieldsClass(javaModelGenerator, table);
+ introspectedTable.getRules().calculateAllFieldsClass();
method.setReturnType(returnType);
compilationUnit.addImportedType(returnType);
method.setName(methodNameCalculator.getSelectByPrimaryKeyMethodName(introspectedTable));
if (introspectedTable.getRules().generatePrimaryKeyClass()) {
- FullyQualifiedJavaType type = javaModelGenerator.getPrimaryKeyType(table);
+ FullyQualifiedJavaType type = introspectedTable.getPrimaryKeyType();
compilationUnit.addImportedType(type);
method.addParameter(new Parameter(type, "key")); //$NON-NLS-1$
} else {
@@ -969,7 +901,7 @@
if (!introspectedTable.getRules().generatePrimaryKeyClass()) {
// no primary key class, but primary key is enabled. Primary
// key columns must be in the base class.
- FullyQualifiedJavaType keyType = javaModelGenerator.getBaseRecordType(table);
+ FullyQualifiedJavaType keyType = introspectedTable.getBaseRecordType();
compilationUnit.addImportedType(keyType);
sb.setLength(0);
@@ -1013,8 +945,8 @@
return null;
}
- FullyQualifiedTable table = introspectedTable.getTable();
- FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ FullyQualifiedJavaType type = introspectedTable.getExampleType();
compilationUnit.addImportedType(type);
Method method = new Method();
@@ -1049,7 +981,7 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
@@ -1057,7 +989,7 @@
method.setName(methodNameCalculator.getDeleteByPrimaryKeyMethodName(introspectedTable));
if (introspectedTable.getRules().generatePrimaryKeyClass()) {
- FullyQualifiedJavaType type = javaModelGenerator.getPrimaryKeyType(table);
+ FullyQualifiedJavaType type = introspectedTable.getPrimaryKeyType();
compilationUnit.addImportedType(type);
method.addParameter(new Parameter(type, "key")); //$NON-NLS-1$
} else {
@@ -1082,7 +1014,7 @@
if (!introspectedTable.getRules().generatePrimaryKeyClass()) {
// no primary key class, but primary key is enabled. Primary
// key columns must be in the base class.
- FullyQualifiedJavaType keyType = javaModelGenerator.getBaseRecordType(table);
+ FullyQualifiedJavaType keyType = introspectedTable.getBaseRecordType();
compilationUnit.addImportedType(keyType);
sb.setLength(0);
@@ -1123,8 +1055,8 @@
return null;
}
- FullyQualifiedTable table = introspectedTable.getTable();
- FullyQualifiedJavaType type = javaModelGenerator.getExampleType(table);
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ FullyQualifiedJavaType type = introspectedTable.getExampleType();
compilationUnit.addImportedType(type);
Method method = new Method();
@@ -1160,55 +1092,6 @@
return method;
}
- protected String getDAOPackage(FullyQualifiedTable table) {
- String key = "getDAOPackage"; //$NON-NLS-1$
- String s;
-
- Map<String, Object> map = getTableValueMap(table);
- s = (String) map.get(key);
- if (s == null) {
- StringBuffer sb = new StringBuffer(targetPackage);
- if ("true".equalsIgnoreCase(properties.getProperty(PropertyRegistry.ANY_ENABLE_SUB_PACKAGES))) { //$NON-NLS-1$
- sb.append(table.getSubPackage());
- }
-
- s = sb.toString();
- map.put(key, s);
- }
-
- return s;
- }
-
- protected FullyQualifiedJavaType getDAOInterfaceType(
- FullyQualifiedTable table) {
- String key = "getDAOInterfaceType"; //$NON-NLS-1$
-
- Map<String, Object> map = getTableValueMap(table);
- FullyQualifiedJavaType fqjt = (FullyQualifiedJavaType) map.get(key);
- if (fqjt == null) {
- StringBuffer sb = new StringBuffer();
- sb.append(getDAOPackage(table));
- sb.append('.');
- sb.append(table.getDomainObjectName());
- sb.append("DAO"); //$NON-NLS-1$
-
- fqjt = new FullyQualifiedJavaType(sb.toString());
- map.put(key, fqjt);
- }
-
- return fqjt;
- }
-
- private Map<String, Object> getTableValueMap(FullyQualifiedTable table) {
- Map<String, Object> map = tableValueMaps.get(table);
- if (map == null) {
- map = new HashMap<String, Object>();
- tableValueMaps.put(table, map);
- }
-
- return map;
- }
-
public void setIbatorContext(IbatorContext ibatorContext) {
this.ibatorContext = ibatorContext;
}
@@ -1217,15 +1100,15 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+ parameterType = introspectedTable.getRecordWithBLOBsType();
} else if (introspectedTable.getRules().generateBaseRecordClass()) {
- parameterType = javaModelGenerator.getBaseRecordType(table);
+ parameterType = introspectedTable.getBaseRecordType();
} else {
- parameterType = javaModelGenerator.getPrimaryKeyType(table);
+ parameterType = introspectedTable.getPrimaryKeyType();
}
compilationUnit.addImportedType(parameterType);
@@ -1235,7 +1118,7 @@
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleSelectiveMethodName(introspectedTable));
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
- method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+ method.addParameter(new Parameter(introspectedTable.getExampleType(), "example")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
@@ -1265,14 +1148,14 @@
protected InnerClass getUpdateByExampleParms (IntrospectedTable introspectedTable,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
- compilationUnit.addImportedType(javaModelGenerator.getExampleType(table));
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+ compilationUnit.addImportedType(introspectedTable.getExampleType());
InnerClass answer = new InnerClass(
new FullyQualifiedJavaType("UpdateByExampleParms")); //$NON-NLS-1$
answer.setVisibility(JavaVisibility.PRIVATE);
answer.setStatic(true);
- answer.setSuperClass(javaModelGenerator.getExampleType(table));
+ answer.setSuperClass(introspectedTable.getExampleType());
ibatorContext.getCommentGenerator().addClassComment(answer, table);
Method method = new Method();
@@ -1283,7 +1166,7 @@
new Parameter(FullyQualifiedJavaType.getObjectInstance(),
"record")); //$NON-NLS-1$
method.addParameter(
- new Parameter(javaModelGenerator.getExampleType(table),
+ new Parameter(introspectedTable.getExampleType(),
"example")); //$NON-NLS-1$
method.addBodyLine("super(example);"); //$NON-NLS-1$
method.addBodyLine("this.record = record;"); //$NON-NLS-1$
@@ -1308,12 +1191,12 @@
protected Method getUpdateByExampleWithBLOBsMethod(
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
- parameterType = javaModelGenerator.getRecordWithBLOBsType(table);
+ parameterType = introspectedTable.getRecordWithBLOBsType();
} else {
- parameterType = javaModelGenerator.getBaseRecordType(table);
+ parameterType = introspectedTable.getBaseRecordType();
}
compilationUnit.addImportedType(parameterType);
@@ -1323,7 +1206,7 @@
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleWithBLOBsMethodName(introspectedTable));
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
- method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+ method.addParameter(new Parameter(introspectedTable.getExampleType(), "example")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);
@@ -1354,12 +1237,12 @@
IntrospectedTable introspectedTable, boolean interfaceMethod,
CompilationUnit compilationUnit) {
- FullyQualifiedTable table = introspectedTable.getTable();
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
FullyQualifiedJavaType parameterType;
if (introspectedTable.getRules().generateBaseRecordClass()) {
- parameterType = javaModelGenerator.getBaseRecordType(table);
+ parameterType = introspectedTable.getBaseRecordType();
} else {
- parameterType = javaModelGenerator.getPrimaryKeyType(table);
+ parameterType = introspectedTable.getPrimaryKeyType();
}
compilationUnit.addImportedType(parameterType);
@@ -1369,7 +1252,7 @@
method.setReturnType(FullyQualifiedJavaType.getIntInstance());
method.setName(methodNameCalculator.getUpdateByExampleWithoutBLOBsMethodName(introspectedTable));
method.addParameter(new Parameter(parameterType, "record")); //$NON-NLS-1$
- method.addParameter(new Parameter(javaModelGenerator.getExampleType(table), "example")); //$NON-NLS-1$
+ method.addParameter(new Parameter(introspectedTable.getExampleType(), "example")); //$NON-NLS-1$
for (FullyQualifiedJavaType fqjt : daoTemplate.getCheckedExceptions()) {
method.addException(fqjt);