Author: jgbutler Date: Tue May 12 02:28:03 2009 New Revision: 773765 URL: http://svn.apache.org/viewvc?rev=773765&view=rev Log: [Ibator] Show errors properly when there is a configuration error. Also some changes to IntrospectedTable attributes
Added: ibatis/trunk/java/tools/ibator/core/htmldoc/reference/attributes.html 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/menu.html ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.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/exception/InvalidConfigurationException.java ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/RenameExampleClassPlugin.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=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/build/version.properties (original) +++ ibatis/trunk/java/tools/ibator/core/build/version.properties Tue May 12 02:28:03 2009 @@ -1,4 +1,4 @@ #Ibator build version info -#Wed Apr 22 12:17:30 CDT 2009 +#Tue Apr 28 18:50:09 CDT 2009 version=1.2.2 -buildNum=727 +buildNum=729 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=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt (original) +++ ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt Tue May 12 02:28:03 2009 @@ -26,6 +26,7 @@ 10. Gather column comments during introspection 11. IBATIS-592 - Additional attributes for SqlMaps 12. Fixed addCriterionfor JDBC* methods so that they all do a null check +13. Fixed IbatorRunner so that configuration errors are shown (thanks to Karel Rank) ------------------------------------------------------------------------------- Version 1.2.1: Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html (original) +++ ibatis/trunk/java/tools/ibator/core/htmldoc/menu.html Tue May 12 02:28:03 2009 @@ -52,6 +52,7 @@ <a href="reference/building.html" target="mainFrame">Building Ibator from Source</a><br/> <a href="reference/extending.html" target="mainFrame">Extending Ibator</a><br/> <a href="reference/pluggingIn.html" target="mainFrame">Implementing Ibator Plugins</a><br/> + <a href="reference/attributes.html" target="mainFrame">Introspected Table Attributes</a><br/> <a href="reference/logging.html" target="mainFrame">Logging Information</a><br/> <a href="philosophy.html" target="mainFrame">Design Philosophy</a><br/> <a href="license.html" target="mainFrame">Licensing Information</a><br/> Added: ibatis/trunk/java/tools/ibator/core/htmldoc/reference/attributes.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/reference/attributes.html?rev=773765&view=auto ============================================================================== --- ibatis/trunk/java/tools/ibator/core/htmldoc/reference/attributes.html (added) +++ ibatis/trunk/java/tools/ibator/core/htmldoc/reference/attributes.html Tue May 12 02:28:03 2009 @@ -0,0 +1,60 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <title>Introspected Table Attributes</title> + <link type="text/css" rel="stylesheet" href="../ibator.css"/> +</head> +<body> + +<div class="menuNav"> + <p> + <a href="../index.html" target="_top">Show Menu</a> + <a href="attributes.html" target="_top">Hide Menu</a> + </p> +</div> + +<h1>Introspected Table Attributes</h1> +<p>After the database introspection step, and before code generation begins, + Ibator calculates many attributes that are used by the actual code generators. + Plugins can override any of these attributes before code generation by + implementing the <code>initialized</code> method.</p> + +<table cellspacing="0" cellpadding="5" border="1"> + <tr> + <th>Attribute</th> + <th>Details</th> + </tr> + <tr> + <td valign="top">ATTR_BASE_RECORD_TYPE</td> + <td> + <table border="0"> + <tr> + <th align="right">Data Type:</th> + <td><code>org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType</code></td> + </tr> + <tr> + <th align="right">Setter:</th> + <td><code>setBaseRecordType</code></td> + </tr> + <tr> + <th align="right">Getter:</th> + <td><code>getBaseRecordType</code></td> + </tr> + <tr> + <th align="right" valign="top">Description:</th> + <td>The fully qualified type of the base record. + By default, this will be the + <code>targetPackage</code> specified in the + <code><javaModelGenerator></code> + configuration, plus the sub-package if sub-packages are enabled, + plus the calculated domain object name.</td> + </tr> + </table> + </td> + </tr> +</table> + +</body> +</html> Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html (original) +++ ibatis/trunk/java/tools/ibator/core/htmldoc/reference/intro.html Tue May 12 02:28:03 2009 @@ -23,6 +23,7 @@ <li><a href="building.html">Building Ibator from Source</a></li> <li><a href="extending.html">Extending Ibator</a></li> <li><a href="pluggingIn.html">Implementing Ibator Plugins</a></li> + <li><a href="attributes.html">Introspected Table Attributes</a></li> <li><a href="logging.html">Logging Information</a></li> </ul> </body> 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=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html (original) +++ ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html Tue May 12 02:28:03 2009 @@ -97,6 +97,7 @@ SqlMap namespace, and the calculated runtime table names. These can now be overridden in plugins.</li> <li>Fixed addCriterionfor JDBC* methods so that they all do a null check.</li> + <li>Fixed IbatorRunner so that configuration errors are shown (thanks to Karel Rank)</li> </ul> <h2>Version 1.2.1</h2> Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IbatorRunner.java Tue May 12 02:28:03 2009 @@ -121,7 +121,10 @@ e.printStackTrace(); return; } catch (InvalidConfigurationException e) { - e.printStackTrace(); + writeLine(Messages.getString("Progress.16")); //$NON-NLS-1$ + for (String error : e.getErrors()) { + writeLine(error); + } return; } catch (InterruptedException e) { // ignore (will never happen with the DefaultShellCallback) 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=773765&r1=773764&r2=773765&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 Tue May 12 02:28:03 2009 @@ -48,22 +48,6 @@ */ public abstract class IntrospectedTable { /** - * This attribute must be a class of type java.lang.String. - * <p/> - * Note: this attribute will not be set if DAOs - * are not being generated for this table. - */ - public static final String ATTR_DAO_IMPLEMENTATION_PACKAGE = "org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_IMPLEMENTATION_PACKAGE"; //$NON-NLS-1$ - - /** - * This attribute must be a class of type java.lang.String - * <p/> - * Note: this attribute will not be set if DAOs - * are not being generated for this table. - */ - public static final String ATTR_DAO_INTERFACE_PACKAGE = "org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_INTERFACE_PACKAGE"; //$NON-NLS-1$ - - /** * This attribute must be a class of type * org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType * <p/> @@ -82,11 +66,6 @@ public static final String ATTR_DAO_INTERFACE_TYPE = "org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_INTERFACE_TYPE"; //$NON-NLS-1$ /** - * This attribute must be a class of type java.lang.String - */ - public static final String ATTR_JAVA_MODEL_PACKAGE = "org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_JAVA_MODEL_PACKAGE"; //$NON-NLS-1$ - - /** * This attribute must be a class of type * org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType */ @@ -431,18 +410,6 @@ || blobColumns.size() > 0; } - public String getDAOInterfacePackage() { - return (String) getAttribute(ATTR_DAO_INTERFACE_PACKAGE); - } - - public String getDAOImplementationPackage() { - return (String) getAttribute(ATTR_DAO_IMPLEMENTATION_PACKAGE); - } - - public String getJavaModelPackage() { - return (String) getAttribute(ATTR_JAVA_MODEL_PACKAGE); - } - public void setTableConfiguration(TableConfiguration tableConfiguration) { this.tableConfiguration = tableConfiguration; } @@ -507,16 +474,8 @@ } public void initialize() { - setDAOImplementationPackage(calculateDAOImplementationPackage()); - setDAOInterfacePackage(calculateDAOInterfacePackage()); - setDAOImplementationType(calculateDAOImplementationType()); - setDAOInterfaceType(calculateDAOInterfaceType()); - - setJavaModelPackage(calculateJavaModelPackage()); - setPrimaryKeyType(calculatePrimaryKeyType()); - setBaseRecordType(calculateBaseRecordType()); - setRecordWithBLOBsType(calculateRecordWithBLOBsType()); - setExampleType(calculateExampleType()); + calculateDAOAttributes(); + calculateModelAttributes(); setSqlMapPackage(calculateSqlMapPackage()); setSqlMapFileName(calculateSqlMapFileName()); @@ -569,36 +528,28 @@ return sb.toString(); } - protected FullyQualifiedJavaType calculateDAOImplementationType() { + protected void calculateDAOAttributes() { if (ibatorContext.getDaoGeneratorConfiguration() == null) { - return null; + return; } StringBuilder sb = new StringBuilder(); - sb.append(getDAOImplementationPackage()); + sb.append(calculateDAOImplementationPackage()); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); sb.append("DAOImpl"); //$NON-NLS-1$ - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; - } - - protected FullyQualifiedJavaType calculateDAOInterfaceType() { - if (ibatorContext.getDaoGeneratorConfiguration() == null) { - return null; - } + setDAOImplementationType(fqjt); - StringBuilder sb = new StringBuilder(); - sb.append(getDAOInterfacePackage()); + sb.setLength(0); + sb.append(calculateDAOInterfacePackage()); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); sb.append("DAO"); //$NON-NLS-1$ - - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; + fqjt = new FullyQualifiedJavaType(sb.toString()); + setDAOInterfaceType(fqjt); } - + protected String calculateJavaModelPackage() { JavaModelGeneratorConfiguration config = ibatorContext.getJavaModelGeneratorConfiguration(); @@ -611,47 +562,39 @@ return sb.toString(); } - protected FullyQualifiedJavaType calculatePrimaryKeyType() { + protected void calculateModelAttributes() { + String pakkage = calculateJavaModelPackage(); + StringBuilder sb = new StringBuilder(); - sb.append(getJavaModelPackage()); + sb.append(pakkage); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); sb.append("Key"); //$NON-NLS-1$ - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; - } - - protected FullyQualifiedJavaType calculateBaseRecordType() { - StringBuilder sb = new StringBuilder(); - sb.append(getJavaModelPackage()); + setPrimaryKeyType(fqjt); + + sb.setLength(0); + sb.append(pakkage); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); + fqjt = new FullyQualifiedJavaType(sb.toString()); + setBaseRecordType(fqjt); - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; - } - - protected FullyQualifiedJavaType calculateRecordWithBLOBsType() { - StringBuilder sb = new StringBuilder(); - sb.append(getJavaModelPackage()); + sb.setLength(0); + sb.append(pakkage); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); sb.append("WithBLOBs"); //$NON-NLS-1$ + fqjt = new FullyQualifiedJavaType(sb.toString()); + setRecordWithBLOBsType(fqjt); - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; - } - - protected FullyQualifiedJavaType calculateExampleType() { - StringBuilder sb = new StringBuilder(); - sb.append(getJavaModelPackage()); + sb.setLength(0); + sb.append(pakkage); sb.append('.'); sb.append(fullyQualifiedTable.getDomainObjectName()); sb.append("Example"); //$NON-NLS-1$ - - FullyQualifiedJavaType fqjt = new FullyQualifiedJavaType(sb.toString()); - return fqjt; + fqjt = new FullyQualifiedJavaType(sb.toString()); + setExampleType(fqjt); } protected String calculateSqlMapPackage() { @@ -752,14 +695,6 @@ return tableConfiguration; } - public void setDAOImplementationPackage(String DAOImplementationPackage) { - setAttribute(ATTR_DAO_IMPLEMENTATION_PACKAGE, DAOImplementationPackage); - } - - public void setDAOInterfacePackage(String DAOInterfacePackage) { - setAttribute(ATTR_DAO_INTERFACE_PACKAGE, DAOInterfacePackage); - } - public void setDAOImplementationType(FullyQualifiedJavaType DAOImplementationType) { setAttribute(ATTR_DAO_IMPLEMENTATION_TYPE, DAOImplementationType); } @@ -768,10 +703,6 @@ setAttribute(ATTR_DAO_INTERFACE_TYPE, DAOInterfaceType); } - public void setJavaModelPackage(String javaModelPackage) { - setAttribute(ATTR_JAVA_MODEL_PACKAGE, javaModelPackage); - } - public void setPrimaryKeyType(FullyQualifiedJavaType primaryKeyType) { setAttribute(ATTR_PRIMARY_KEY_TYPE, primaryKeyType); } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/exception/InvalidConfigurationException.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/exception/InvalidConfigurationException.java?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/exception/InvalidConfigurationException.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/exception/InvalidConfigurationException.java Tue May 12 02:28:03 2009 @@ -22,18 +22,18 @@ */ public class InvalidConfigurationException extends Exception { static final long serialVersionUID = 4902307610148543411L; - - private List<String> errors; - /** - * - */ - public InvalidConfigurationException(List<String> errors) { - super(); - this.errors = errors; - } + private List<String> errors; - public List<String> getErrors() { - return errors; - } + /** + * + */ + public InvalidConfigurationException(List<String> errors) { + super(); + this.errors = errors; + } + + public List<String> getErrors() { + return errors; + } } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/XmlConstants.java Tue May 12 02:28:03 2009 @@ -30,6 +30,7 @@ } static { + // TODO - move these to attributes of introspected table. StringBuilder sb = new StringBuilder(); sb.append(MergeConstants.NEW_XML_ELEMENT_PREFIX); Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties Tue May 12 02:28:03 2009 @@ -81,6 +81,7 @@ Progress.13=Found SQL Statement: {0} Progress.14=Generating DAO Interface and Implementation for table {0} Progress.15=Saving file {0} +Progress.16=Invalid configuration. Details follow... Tracing.1=Retrieving column information for table "{0}" Tracing.2=Found column "{0}", data type {1}, in table "{2}" Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/RenameExampleClassPlugin.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/RenameExampleClassPlugin.java?rev=773765&r1=773764&r2=773765&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/RenameExampleClassPlugin.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/RenameExampleClassPlugin.java Tue May 12 02:28:03 2009 @@ -93,14 +93,12 @@ @Override public void initialized(IntrospectedTable introspectedTable) { - FullyQualifiedJavaType oldType = (FullyQualifiedJavaType) - introspectedTable.getAttribute(IntrospectedTable.ATTR_EXAMPLE_TYPE); + FullyQualifiedJavaType oldType = introspectedTable.getExampleType(); String typeName = oldType.getFullyQualifiedName(); Matcher matcher = pattern.matcher(typeName); typeName = matcher.replaceAll(replaceString); - introspectedTable.setAttribute(IntrospectedTable.ATTR_EXAMPLE_TYPE, - new FullyQualifiedJavaType(typeName)); + introspectedTable.setExampleType(new FullyQualifiedJavaType(typeName)); } }