<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>empire-db-commits@incubator.apache.org Archives</title>
<link rel="self" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/?format=atom"/>
<link href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/"/>
<id>http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/</id>
<updated>2009-12-07T21:27:36Z</updated>
<entry>
<title>[jira] Created: (EMPIREDB-64) CodeGenerator Maven Plugin</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200912.mbox/%3c735712276.1259882900732.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c735712276-1259882900732-JavaMail-jira@brutus%3e</id>
<updated>2009-12-03T23:28:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
CodeGenerator Maven Plugin
--------------------------

                 Key: EMPIREDB-64
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-64
             Project: Empire-DB
          Issue Type: New Feature
          Components: CodeGenerator
            Reporter: Francis De Brabandere
            Assignee: Francis De Brabandere
            Priority: Minor


Create a code generating maven plugin, I suggest we have a look how for example other maven
code gererating plugins work (adding an extra folder to the source paths)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886977 - /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200912.mbox/%3c20091203231048.286B8238888F@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203231048-286B8238888F@eris-apache-org%3e</id>
<updated>2009-12-03T23:10:47Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Dec  3 23:10:46 2009
New Revision: 886977

URL: http://svn.apache.org/viewvc?rev=886977&amp;view=rev
Log:
get rid of all toUpperCase() since there are databases (mysql) that are case-sensitive. If
we want uppercase table variables in the code that is something to do in the CodeGenWriter.
removed unneeded exception catching
removed obsolete comments as they only clutter the code

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=886977&amp;r1=886976&amp;r2=886977&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Thu Dec  3 23:10:46 2009
@@ -54,7 +54,6 @@
 	private DatabaseMetaData dbMeta;
 	private Connection con;
 	private CodeGenConfig config;
-	private DBDatabase db;
 
 	/**
 	 * create a empty in memory Database and populates it
@@ -67,72 +66,49 @@
 	 * returns the populated DBDatabase
 	 */
 	public DBDatabase loadDbModel() {
-	    this.db = new InMemoryDatabase();
+		DBDatabase db = new InMemoryDatabase();
 	    try {           
-            // Get a JDBC Connection
-            con = getJDBCConnection(config);
-            
-            // create the database in memory
-
-            this.dbMeta = con.getMetaData();
-            populateDatabase();
-                        
+            con = openJDBCConnection(config);
+            populateDatabase(db);
         } 
         catch (SQLException e) 
         {
-            throw new RuntimeException("Unable to read database metadata!", e);
+            throw new RuntimeException("Unable to read database metadata: " + e.getMessage(),
e);
         }
-        catch (Exception e) 
-        {
-            log.error(e.getMessage(), e);
-        } 
         finally 
         {
             DBUtil.close(con, log);
         }
-		return db;
+        return db;
 	}
 
-	// ----------- private members
-
-	   /**
-     * &lt;PRE&gt;
+	/**
      * Opens and returns a JDBC-Connection.
      * JDBC url, user and password for the connection are obained from the SampleConfig bean
      * Please use the config.xml file to change connection params.
-     * &lt;/PRE&gt;
      */
-    private Connection getJDBCConnection(CodeGenConfig config) {
-        // Establish a new database connection
+    private Connection openJDBCConnection(CodeGenConfig config) throws SQLException{
+        log.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
         Connection conn = null;
-        log.info("Connecting to Database'" + config.getJdbcURL() + "' / User="
-                + config.getJdbcUser());
         try {
-            // Connect to the databse
             Class.forName(config.getJdbcClass()).newInstance();
-            conn = DriverManager.getConnection(config.getJdbcURL(), config
-                    .getJdbcUser(), config.getJdbcPwd());
-            log.info("Connected successfully");
-            // set the AutoCommit to false this session. You must commit
-            // explicitly now
-            conn.setAutoCommit(true);
-            log.info("AutoCommit is " + conn.getAutoCommit());
-
-        } catch (Exception e) {
-            log.fatal("Failed to connect directly to '" + config.getJdbcURL()
-                    + "' / User=" + config.getJdbcUser(), e);
-            throw new RuntimeException(e);
+        }catch(Exception ex){
+        	throw new SQLException("Could not load database driver: " + config.getJdbcClass());
         }
+        conn = DriverManager.getConnection(config.getJdbcURL(), config.getJdbcUser(), config.getJdbcPwd());
+        log.info("Connected successfully");
         return conn;
     }
 	
 	/**
-	 * queries the metadata of the database for tables and populates the
+	 * Queries the metadata of the database for tables and populates the
 	 * database with those
+	 * @throws SQLException 
 	 */
-	private void populateDatabase() {
+	private void populateDatabase(DBDatabase db) throws SQLException {
 		ResultSet tables = null;
-		try {
+		try{
+            this.dbMeta = con.getMetaData();
 		    // Get table metadata
 		    tables = dbMeta.getTables(
 		            config.getDbCatalog(), 
@@ -140,30 +116,27 @@
 		            config.getDbTablePattern(),
 					new String[] { "TABLE" });
 		    // Add all tables
-            int count = 0;
+            int tableCount = 0;
 			while (tables.next()) {
 				String tableName = tables.getString("TABLE_NAME");
-				// Ignore system tables containing a '$' symbol (required for
-				// Oracle!)
+				// Ignore system tables containing a '$' symbol (required for Oracle!)
 				if (tableName.indexOf('$') &gt;= 0) {
 					log.info("Ignoring system table " + tableName);
 					continue;
 				}
-				// end system table exclusion
-				log.info("Adding table " + tableName);
-				addTable(tableName);
-				count++;
+				log.info("TABLE: " + tableName);
+				DBTable table = new DBTable(tableName, db);
+				populateTable(table);
+				tableCount++;
 			}
-			// Count added
-			if (count==0) {
+
+			if (tableCount==0) {
 			    // getTables returned no result
 			    String info = "catalog="+config.getDbCatalog(); 
                 info += "/ schema="+config.getDbSchema(); 
                 info += "/ pattern="+config.getDbTablePattern(); 
 			    log.warn("DatabaseMetaData.getTables() returned no tables! Please check parameters:
"+info);
 			}
-		} catch (SQLException e) {
-			error(e);
 		} finally {
 			DBUtil.close(tables, log);
 		}
@@ -172,23 +145,23 @@
 	/**
 	 * queries the metadata for columns of a specific table and populates the
 	 * table with that information
+	 * @throws SQLException 
 	 */
-	private void addTable(String name) {
-		DBTable t = new DBTable(name.toUpperCase(), db);
-		List&lt;String&gt; pkCols = this.findPkColumns(name);
+	private void populateTable(DBTable t) throws SQLException {
+		List&lt;String&gt; pkCols = this.findPkColumns(t.getName());
 		String lockColName = config.getTimestampColumn();
 		DBColumn[] keys = new DBColumn[pkCols.size()];
 		ResultSet rs = null;
 		try {
 			rs = dbMeta.getColumns(config.getDbCatalog(), config.getDbSchema(),
-					name, null);
+					t.getName(), null);
 	        int i=0;
 			while (rs.next()) {
 				DBTableColumn c = addColumn(t, rs);
 				// check if it is a KeyColumn
-				if (pkCols.contains(c.getName().toUpperCase()))
+				if (pkCols.contains(c.getName()))
 					keys[i++] = c;
-
+				
 				// check if it is the Timestamp/Locking Column
 				if (lockColName!=null &amp;&amp; c.getName().equalsIgnoreCase(lockColName))
 					t.setTimestampColumn(c);
@@ -197,10 +170,9 @@
 	        for (i=0; i&lt;keys.length; i++)
 	            if (keys[i]==null)
 	                error(Errors.ItemNotFound, pkCols.get(i));
-			// Set Primary Key
-	        t.setPrimaryKey(keys);
-		} catch (SQLException e) {
-			error(e);
+	        if(keys.length &gt; 0){
+	        	t.setPrimaryKey(keys);
+	        }
 		} finally {
 			DBUtil.close(rs, log);
 		}
@@ -209,19 +181,17 @@
 	/**
 	 * Returns a list of column names that define the primarykey of the given
 	 * table.
+	 * @throws SQLException 
 	 */
-	private List&lt;String&gt; findPkColumns(String tableName) {
+	private List&lt;String&gt; findPkColumns(String tableName) throws SQLException {
 		List&lt;String&gt; cols = new ArrayList&lt;String&gt;();
 		ResultSet rs = null;
 		try {
 			rs = dbMeta.getPrimaryKeys(config.getDbCatalog(), config
 					.getDbSchema(), tableName);
 			while (rs.next()) {
-				cols.add(rs.getString("COLUMN_NAME").toUpperCase());
+				cols.add(rs.getString("COLUMN_NAME"));
 			}
-
-		} catch (SQLException e) {
-			throw new RuntimeException(e);
 		} finally {
 			DBUtil.close(rs, log);
 		}
@@ -242,7 +212,7 @@
 		if (rs.getString("IS_NULLABLE").equalsIgnoreCase("NO"))
 			required = true;
 
-		log.info("\tCOLUMN:\t" + name);
+		log.info("\tCOLUMN:\t" + name + " ("+empireType+")");
 		return t.addColumn(name, empireType, colSize, required, defaultValue);
 	}
 
@@ -298,7 +268,7 @@
 			empireType = DataType.UNKNOWN;
 			log.warn("SQL column type " + sqlType + " not supported.");
 		}
-		log.info("Mapping date type " + String.valueOf(sqlType) + " to "
+		log.debug("Mapping date type " + String.valueOf(sqlType) + " to "
 				+ empireType);
 		return empireType;
 	}




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Commented: (EMPIREDB-52) CodeGenerator project setup</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200912.mbox/%3c470353305.1259877500720.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c470353305-1259877500720-JavaMail-jira@brutus%3e</id>
<updated>2009-12-03T21:58:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

    [ https://issues.apache.org/jira/browse/EMPIREDB-52?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=12785555#action_12785555
] 

Francis De Brabandere commented on EMPIREDB-52:
-----------------------------------------------

CODEGEN-0.5.patch applied

&gt; CodeGenerator project setup
&gt; ---------------------------
&gt;
&gt;                 Key: EMPIREDB-52
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-52
&gt;             Project: Empire-DB
&gt;          Issue Type: New Feature
&gt;          Components: CodeGenerator
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Rainer Döbele
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;         Attachments: codegen-0.4.patch, codegen-0.5.patch, codegen.0.3.patch
&gt;
&gt;
&gt; The empire-db code generator is a new subproject which should be capable of generating
source code classes from an existing database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r886936 - in /incubator/empire-db/trunk/empire-db-codegen/src/main: java/org/apache/empire/db/codegen/CodeGenWriter.java resources/templates/Database.vm resources/templates/Table.vm</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200912.mbox/%3c20091203215525.2B78D23888EC@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091203215525-2B78D23888EC@eris-apache-org%3e</id>
<updated>2009-12-03T21:55:24Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Dec  3 21:55:24 2009
New Revision: 886936

URL: http://svn.apache.org/viewvc?rev=886936&amp;view=rev
Log:
EMPIREDB-52 - code submitted by Benjamin (CODEGEN-0.5.patch of Dec.1)

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java?rev=886936&amp;r1=886935&amp;r2=886936&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
Thu Dec  3 21:55:24 2009
@@ -52,13 +52,13 @@
  * &lt;p&gt;
  * NOTE: THIS VERSION HAS SEVERE RESTRICTIONS:
  * &lt;ol&gt;
- * &lt;li&gt; Only tables are currently modeled (we'll add views to a later version).&lt;/li&gt;

- * &lt;li&gt; Table indexes are not yet modeled (exception is primary key). Again, 
- * this will be added to later editions.&lt;/li&gt;  
- * &lt;li&gt; It is assumed that each table has a single INTEGER auto-generated primary
- * key column that has the same name for all tables. &lt;/li&gt; 
- * &lt;li&gt; It is assumed that each table has a single TIMESTAMP optimistic locking
- * column that has the same name for all tables.&lt;/li&gt; 
+ * &lt;li&gt;Only tables are currently modeled (we'll add views to a later version).&lt;/li&gt;
+ * &lt;li&gt;Table indexes are not yet modeled (exception is primary key). Again, this
+ * will be added to later editions.&lt;/li&gt;
+ * &lt;li&gt;It is assumed that each table has a single INTEGER auto-generated primary
+ * key column that has the same name for all tables.&lt;/li&gt;
+ * &lt;li&gt;It is assumed that each table has a single TIMESTAMP optimistic locking
+ * column that has the same name for all tables.&lt;/li&gt;
  * &lt;/ol&gt;
  */
 
@@ -75,7 +75,7 @@
 
 	// Services
 	private final ParserUtil pUtil;
-	
+
 	// Properties
 	private final CodeGenConfig config;
 	private File baseDir;
@@ -88,7 +88,8 @@
 	public CodeGenWriter(CodeGenConfig config) {
 		// we have to keep this in sync with our logging system
 		// http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#simpleexampleofacustomlogger
-		Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute() );
+		Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,
+				new CommonsLogLogChute());
 		try {
 			Velocity.init();
 		} catch (Exception e) {
@@ -101,10 +102,12 @@
 
 	/**
 	 * Generates the java code files for the database
-	 * @param db the DBDatabase to generate files for
+	 * 
+	 * @param db
+	 *            the DBDatabase to generate files for
 	 */
 	public List&lt;File&gt; generateCodeFiles(DBDatabase db) {
-	    List&lt;File&gt; generatedFiles = new ArrayList&lt;File&gt;();
+		List&lt;File&gt; generatedFiles = new ArrayList&lt;File&gt;();
 
 		// Prepare directories for generated source files
 		this.initDirectories(config.getTargetFolder(), config.getPackageName());
@@ -118,10 +121,12 @@
 		// Create base record class
 		generatedFiles.add(this.createBaseRecordClass(db));
 		// Create table classes, record interfaces and record classes
-		for (DBTable table : db.getTables()) 
-		{
-		    generatedFiles.add(this.createTableClass(db, table));
-		    generatedFiles.add(this.createRecordClass(db, table));
+		for (DBTable table : db.getTables()) {
+			if (!config.isNestTables()) {
+				// if table nesting is disabled, create separate table classes 
+				generatedFiles.add(this.createTableClass(db, table));
+			}
+			generatedFiles.add(this.createRecordClass(db, table));
 		}
 		return generatedFiles;
 	}
@@ -161,6 +166,9 @@
 		context.put("dbClassName", config.getDbClassName());
 		context.put("tableSubPackage", "tables");
 		context.put("database", db);
+		context.put("nestTables", config.isNestTables());
+		context.put("baseTableClassName", config.getTableBaseName());
+
 		writeFile(file, TEMPLATE_PATH + "/" + DATABASE_TEMPLATE, context);
 		return file;
 	}
@@ -183,6 +191,7 @@
 		context.put("tablePackageName", config.getPackageName() + ".tables");
 		context.put("baseTableClassName", config.getTableBaseName());
 		context.put("dbClassName", config.getDbClassName());
+		context.put("nestTables", config.isNestTables());
 		context.put("table", table);
 		writeFile(file, TEMPLATE_PATH + "/" + TABLE_TEMPLATE, context);
 		return file;
@@ -201,13 +210,15 @@
 	}
 
 	private File createRecordClass(DBDatabase db, DBTable table) {
-		File file = new File(recordDir, pUtil.getRecordClassName(table
-				.getName())
-				+ ".java");
+		File file = new File(recordDir, pUtil.getRecordClassName(table.getName()) + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("parser", pUtil);
 		context.put("basePackageName", config.getPackageName());
-		context.put("tablePackageName", config.getPackageName() + ".tables");
+		// If the tables shall be nested within the database classe, their include path for the
records needs to be changed
+		if (config.isNestTables())
+			context.put("tablePackageName", config.getPackageName() + "." + config.getDbClassName());
+		else
+			context.put("tablePackageName", config.getPackageName() + ".tables");
 		context.put("recordPackageName", config.getPackageName() + ".records");
 		context.put("baseRecordClassName", config.getRecordBaseName());
 		context.put("dbClassName", config.getDbClassName());

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm?rev=886936&amp;r1=886935&amp;r2=886936&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm Thu
Dec  3 21:55:24 2009
@@ -27,6 +27,10 @@
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBReader;
 import org.apache.empire.db.DBRecord;
+#if($nestTables == true)
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBTableColumn;
+#end
 
 import $basePackageName.$tableSubPackage.*;
 
@@ -115,4 +119,11 @@
 		}
 		return records;
 	}
+	
+	#if($nestTables == true)
+		#foreach ($table in $database.tables)
+			#parse( "src/main/resources/templates/Table.vm" )
+		#end
+	#end
+	
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm?rev=886936&amp;r1=886935&amp;r2=886936&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm Thu
Dec  3 21:55:24 2009
@@ -16,6 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  *#
+
+#if($nestTables == false)
 package $tablePackageName;
 
 import java.util.ArrayList;
@@ -23,10 +25,10 @@
 
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBTableColumn;
-
 import $basePackageName.${dbClassName};
+#end
 
-public class $parser.getTableClassName($table.name) extends ${baseTableClassName} {
+public #if($nestTables == true)static#end  class $parser.getTableClassName($table.name) extends
${baseTableClassName} {
 	// Primary key column
 	private List&lt;DBTableColumn&gt; keyColumns= new ArrayList&lt;DBTableColumn&gt;();
 	




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Updated: (EMPIREDB-52) CodeGenerator project setup</title>
<author><name>&quot;Benjamin Venditti (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200912.mbox/%3c1360280655.1259710160804.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c1360280655-1259710160804-JavaMail-jira@brutus%3e</id>
<updated>2009-12-01T23:29:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-52?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benjamin Venditti updated EMPIREDB-52:
--------------------------------------

    Attachment: codegen-0.5.patch

Hi there,

I have created a small patch that adds the functionality for creating nested table classes
withn the database class, instead of creating separate table class files.

The patch contains the following changes:
 modifications:
  - CodeGenWriter.java
  - Database.vm
  - Table.vm

&gt; CodeGenerator project setup
&gt; ---------------------------
&gt;
&gt;                 Key: EMPIREDB-52
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-52
&gt;             Project: Empire-DB
&gt;          Issue Type: New Feature
&gt;          Components: CodeGenerator
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Rainer Döbele
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;         Attachments: codegen-0.4.patch, codegen-0.5.patch, codegen.0.3.patch
&gt;
&gt;
&gt; The empire-db code generator is a new subproject which should be capable of generating
source code classes from an existing database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Commented: (EMPIREDB-62) Allow to set limit for maximum number of rows returned</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c673679297.1259512400641.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c673679297-1259512400641-JavaMail-jira@brutus%3e</id>
<updated>2009-11-29T16:33:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

    [ https://issues.apache.org/jira/browse/EMPIREDB-62?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=12783424#action_12783424
] 

Francis De Brabandere commented on EMPIREDB-62:
-----------------------------------------------

You might also want to implement paging as most of the time you will want to use both

MySQL LIMIT [offset], [max]
http://dev.mysql.com/doc/refman/5.4/en/select.html

&gt; Allow to set limit for maximum number of rows returned
&gt; ------------------------------------------------------
&gt;
&gt;                 Key: EMPIREDB-62
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-62
&gt;             Project: Empire-DB
&gt;          Issue Type: Improvement
&gt;          Components: Core
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Rainer Döbele
&gt;            Assignee: Rainer Döbele
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;
&gt; Currently it is not possible to limit the number of rows returned by a query.
&gt; The question is whether to add it to ths sql phrase or use setMaxRows() before executing
the statement.
&gt; SQL is somewhat different for each database vendor:
&gt; SQL Server:
&gt; SELECT TOP 10 id, name, ...
&gt; FROM contacts
&gt; MySQL:
&gt; SELECT id, name, ...
&gt; FROM contacts
&gt; LIMIT 10
&gt; ORACLE:
&gt; SELECT id, name, ...
&gt; FROM contacts
&gt; WHERE ROWNUM &lt;= 10

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Created: (EMPIREDB-63) Provide overloads for DBDatabase.queryObjectList() and querySimpleList() to allow using other collection types.</title>
<author><name>=?utf-8?Q?Rainer_D=C3=B6bele_=28JIRA=29?= &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c731352264.1259498300624.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c731352264-1259498300624-JavaMail-jira@brutus%3e</id>
<updated>2009-11-29T12:38:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Provide overloads for DBDatabase.queryObjectList() and querySimpleList() to allow using other
collection types.
---------------------------------------------------------------------------------------------------------------

                 Key: EMPIREDB-63
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-63
             Project: Empire-DB
          Issue Type: Improvement
          Components: Core
    Affects Versions: empire-db-2.0.6-incubating
            Reporter: Rainer Döbele
            Priority: Minor
             Fix For: empire-db-2.0.6-incubating


ArrayList is used to store results in querySimpleList and queryObjectList.
It should be possible to use other types of collections for those functions.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Created: (EMPIREDB-62) Allow to set limit for maximum number of rows returned</title>
<author><name>=?utf-8?Q?Rainer_D=C3=B6bele_=28JIRA=29?= &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c2056502976.1259497220724.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c2056502976-1259497220724-JavaMail-jira@brutus%3e</id>
<updated>2009-11-29T12:20:20Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Allow to set limit for maximum number of rows returned
------------------------------------------------------

                 Key: EMPIREDB-62
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-62
             Project: Empire-DB
          Issue Type: Improvement
          Components: Core
    Affects Versions: empire-db-2.0.6-incubating
            Reporter: Rainer Döbele
            Assignee: Rainer Döbele
             Fix For: empire-db-2.0.6-incubating


Currently it is not possible to limit the number of rows returned by a query.
The question is whether to add it to ths sql phrase or use setMaxRows() before executing the
statement.

SQL is somewhat different for each database vendor:

SQL Server:
SELECT TOP 10 id, name, ...
FROM contacts

MySQL:
SELECT id, name, ...
FROM contacts
LIMIT 10

ORACLE:
SELECT id, name, ...
FROM contacts
WHERE ROWNUM &lt;= 10



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r885154 - in /incubator/empire-db/trunk/empire-db-codegen: ./ src/main/java/org/apache/empire/db/codegen/ src/test/java/org/apache/empire/db/codegen/</title>
<author><name>doebele@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091128220716.BB1CF23888FE@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091128220716-BB1CF23888FE@eris-apache-org%3e</id>
<updated>2009-11-28T22:07:16Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: doebele
Date: Sat Nov 28 22:07:15 2009
New Revision: 885154

URL: http://svn.apache.org/viewvc?rev=885154&amp;view=rev
Log:
EMPIREDB-52 - Renamed CodeGen to CodeGenWriter. Error handling etc.

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
      - copied, changed from r885142, incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Removed:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Modified:
    incubator/empire-db/trunk/empire-db-codegen/config.xml
    incubator/empire-db/trunk/empire-db-codegen/pom.xml
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java

Modified: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=885154&amp;r1=885153&amp;r2=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Sat Nov 28 22:07:15 2009
@@ -25,6 +25,12 @@
 		&lt;jdbcURL&gt;jdbc:oracle:thin:@192.168.0.2:1521:ora10&lt;/jdbcURL&gt;
 		&lt;jdbcUser&gt;DBSAMPLE&lt;/jdbcUser&gt;
 		&lt;jdbcPwd&gt;DBSAMPLE&lt;/jdbcPwd&gt;
+		&lt;!-- 
+		&lt;jdbcClass&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/jdbcClass&gt;
+		&lt;jdbcURL&gt;jdbc:sqlserver://localhost:1433&lt;/jdbcURL&gt;
+		&lt;jdbcUser&gt;empire-db&lt;/jdbcUser&gt;
+		&lt;jdbcPwd&gt;empire-db&lt;/jdbcPwd&gt;
+		--&gt;
 
 		&lt;!-- Schema options --&gt;
 		&lt;dbCatalog&gt;&lt;/dbCatalog&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/pom.xml?rev=885154&amp;r1=885153&amp;r2=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/pom.xml Sat Nov 28 22:07:15 2009
@@ -47,13 +47,21 @@
 		    &lt;!-- &lt;scope&gt;runtime&lt;/scope&gt; --&gt;
 		&lt;/dependency&gt;
 
-		&lt;!-- 
+		&lt;!-- ojdbc 
 		&lt;dependency&gt;
 		    &lt;groupId&gt;ojdbc&lt;/groupId&gt;
 		    &lt;artifactId&gt;ojdbc&lt;/artifactId&gt;
 		    &lt;version&gt;14&lt;/version&gt;
 		&lt;/dependency&gt;
 		--&gt;
+
+		&lt;!-- msssql 
+		&lt;dependency&gt;
+		    &lt;groupId&gt;microsoft&lt;/groupId&gt;
+		    &lt;artifactId&gt;sqljdbc&lt;/artifactId&gt;
+		    &lt;version&gt;1.0&lt;/version&gt;
+		&lt;/dependency&gt;
+		--&gt;
 		
 	&lt;/dependencies&gt;
 &lt;/project&gt;
\ No newline at end of file

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java?rev=885154&amp;r1=885153&amp;r2=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
Sat Nov 28 22:07:15 2009
@@ -42,6 +42,8 @@
 	 *            arguments
 	 */
 	public static void main(String[] args) {
+	    ErrorObject.setExceptionsEnabled(true);
+	    // Start code generator
 		CodeGenApp app = new CodeGenApp();
 		app.start((args.length &gt; 0 ? args[0] : DEFAULT_CONFIG_FILE));
 	}	
@@ -61,7 +63,7 @@
 		DBDatabase db = parser.loadDbModel();
 		
 		// create the source-code for that database
-		CodeGen codeGen = new CodeGen(config);
+		CodeGenWriter codeGen = new CodeGenWriter(config);
 		codeGen.generateCodeFiles(db);
 		
 		log.info("Code generation completed sucessfully!");

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=885154&amp;r1=885153&amp;r2=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Sat Nov 28 22:07:15 2009
@@ -29,6 +29,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.ErrorObject;
+import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
@@ -42,7 +44,7 @@
  * 
  * @author Benjamin Venditti
  */
-public class CodeGenParser {
+public class CodeGenParser extends ErrorObject {
 
 	public static class InMemoryDatabase extends DBDatabase {
 	}
@@ -131,9 +133,14 @@
 	private void populateDatabase() {
 		ResultSet tables = null;
 		try {
-			tables = dbMeta.getTables(config.getDbCatalog(), config
-					.getDbSchema(), config.getDbTablePattern(),
+		    // Get table metadata
+		    tables = dbMeta.getTables(
+		            config.getDbCatalog(), 
+		            config.getDbSchema(), 
+		            config.getDbTablePattern(),
 					new String[] { "TABLE" });
+		    // Add all tables
+            int count = 0;
 			while (tables.next()) {
 				String tableName = tables.getString("TABLE_NAME");
 				// Ignore system tables containing a '$' symbol (required for
@@ -145,9 +152,18 @@
 				// end system table exclusion
 				log.info("Adding table " + tableName);
 				addTable(tableName);
+				count++;
+			}
+			// Count added
+			if (count==0) {
+			    // getTables returned no result
+			    String info = "catalog="+config.getDbCatalog(); 
+                info += "/ schema="+config.getDbSchema(); 
+                info += "/ pattern="+config.getDbTablePattern(); 
+			    log.warn("DatabaseMetaData.getTables() returned no tables! Please check parameters:
"+info);
 			}
 		} catch (SQLException e) {
-			throw new RuntimeException(e);
+			error(e);
 		} finally {
 			DBUtil.close(tables, log);
 		}
@@ -162,26 +178,29 @@
 		List&lt;String&gt; pkCols = this.findPkColumns(name);
 		String lockColName = config.getTimestampColumn();
 		DBColumn[] keys = new DBColumn[pkCols.size()];
-		int i = 0;
 		ResultSet rs = null;
 		try {
 			rs = dbMeta.getColumns(config.getDbCatalog(), config.getDbSchema(),
 					name, null);
+	        int i=0;
 			while (rs.next()) {
 				DBTableColumn c = addColumn(t, rs);
 				// check if it is a KeyColumn
-				if (pkCols.contains(c.getName()))
+				if (pkCols.contains(c.getName().toUpperCase()))
 					keys[i++] = c;
 
 				// check if it is the Timestamp/Locking Column
-				if (lockColName != null
-						&amp;&amp; c.getName().toUpperCase().equals(
-								lockColName.toUpperCase()))
+				if (lockColName!=null &amp;&amp; c.getName().equalsIgnoreCase(lockColName))
 					t.setTimestampColumn(c);
 			}
-			t.setPrimaryKey(keys);
+	        // Check whether all key columns have been set
+	        for (i=0; i&lt;keys.length; i++)
+	            if (keys[i]==null)
+	                error(Errors.ItemNotFound, pkCols.get(i));
+			// Set Primary Key
+	        t.setPrimaryKey(keys);
 		} catch (SQLException e) {
-			throw new RuntimeException(e);
+			error(e);
 		} finally {
 			DBUtil.close(rs, log);
 		}

Copied: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
(from r885142, incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java)
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java?p2=incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java&amp;p1=incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java&amp;r1=885142&amp;r2=885154&amp;rev=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenWriter.java
Sat Nov 28 22:07:15 2009
@@ -36,6 +36,7 @@
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
 import org.apache.velocity.runtime.log.CommonsLogLogChute;
 
 /**
@@ -61,8 +62,8 @@
  * &lt;/ol&gt;
  */
 
-public class CodeGen {
-	private static final Log log = LogFactory.getLog(CodeGen.class);
+public class CodeGenWriter {
+	private static final Log log = LogFactory.getLog(CodeGenWriter.class);
 
 	// Templates
 	public static final String TEMPLATE_PATH = "src/main/resources/templates/";
@@ -84,10 +85,10 @@
 	/**
 	 * Constructor
 	 */
-	public CodeGen(CodeGenConfig config) {
+	public CodeGenWriter(CodeGenConfig config) {
 		// we have to keep this in sync with our logging system
 		// http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#simpleexampleofacustomlogger
-		Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute() );
+		Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute() );
 		try {
 			Velocity.init();
 		} catch (Exception e) {

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java?rev=885154&amp;r1=885153&amp;r2=885154&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
Sat Nov 28 22:07:15 2009
@@ -41,7 +41,7 @@
     {
         CodeGenConfig config = new CodeGenConfig();
         config.init("testconfig.xml", true, false);
-        CodeGen codeGen = new CodeGen(config);
+        CodeGenWriter codeGen = new CodeGenWriter(config);
         
         DBDatabase db = new DBDatabase()
         {




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Commented: (EMPIREDB-61) Create a scala example project</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c932039554.1258881760624.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c932039554-1258881760624-JavaMail-jira@brutus%3e</id>
<updated>2009-11-22T09:22:40Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

    [ https://issues.apache.org/jira/browse/EMPIREDB-61?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=12781107#action_12781107
] 

Francis De Brabandere commented on EMPIREDB-61:
-----------------------------------------------

see this google code project:
http://code.google.com/p/uykfd/source/browse/src/main/scala/org/acooke/uykfd/db/Schema.scala#21

and this mailing list thread:
http://www.mail-archive.com/empire-db-user@incubator.apache.org/msg00091.html

&gt; Create a scala example project
&gt; ------------------------------
&gt;
&gt;                 Key: EMPIREDB-61
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-61
&gt;             Project: Empire-DB
&gt;          Issue Type: Improvement
&gt;          Components: Core
&gt;            Reporter: Francis De Brabandere
&gt;            Priority: Minor
&gt;
&gt; Try to add a empire-db - scala example to the examples

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Resolved: (EMPIREDB-32) Create unit tests</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c848484747.1258881648672.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c848484747-1258881648672-JavaMail-jira@brutus%3e</id>
<updated>2009-11-22T09:20:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-32?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Francis De Brabandere resolved EMPIREDB-32.
-------------------------------------------

    Resolution: Later
      Assignee: Francis De Brabandere

This is more a state of mind than something that should be in the issue tracker. So I'm closing
this issue... just try to write tests when you write new code

&gt; Create unit tests
&gt; -----------------
&gt;
&gt;                 Key: EMPIREDB-32
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-32
&gt;             Project: Empire-DB
&gt;          Issue Type: Task
&gt;          Components: Core
&gt;            Reporter: Francis De Brabandere
&gt;            Assignee: Francis De Brabandere
&gt;            Priority: Minor
&gt;
&gt; This projects needs unit testing and continuous integration. Without this the chances
for regressions are way to high!
&gt; I suggest we do this after migrating to maven as maven is great for running the tests
and generating reports

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Created: (EMPIREDB-61) Create a scala example project</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c1917467818.1258881546224.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c1917467818-1258881546224-JavaMail-jira@brutus%3e</id>
<updated>2009-11-22T09:19:06Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Create a scala example project
------------------------------

                 Key: EMPIREDB-61
                 URL: https://issues.apache.org/jira/browse/EMPIREDB-61
             Project: Empire-DB
          Issue Type: Improvement
          Components: Core
            Reporter: Francis De Brabandere
            Priority: Minor


Try to add a empire-db - scala example to the examples

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882884 - in /incubator/empire-db/trunk: empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/ empire-db-str...</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091121112948.DDC7023888CF@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091121112948-DDC7023888CF@eris-apache-org%3e</id>
<updated>2009-11-21T11:29:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sat Nov 21 11:29:47 2009
New Revision: 882884

URL: http://svn.apache.org/viewvc?rev=882884&amp;view=rev
Log:
fixing some findbugs issues

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
    incubator/empire-db/trunk/empire-db-struts2/src/main/java/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=882884&amp;r1=882883&amp;r2=882884&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
Sat Nov 21 11:29:47 2009
@@ -48,7 +48,7 @@
 
 public class SampleAdvApp 
 {
-    public static Logger logger = Logger.getLogger(SampleAdvApp.class.getName());
+    private static final Logger logger = Logger.getLogger(SampleAdvApp.class.getName());
 
     private static final SampleAdvDB db = new SampleAdvDB();
 

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java?rev=882884&amp;r1=882883&amp;r2=882884&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
Sat Nov 21 11:29:47 2009
@@ -43,7 +43,7 @@
 
 public class SampleApp 
 {
-	public static Logger logger = Logger.getLogger(SampleApp.class.getName());
+	private static final Logger logger = Logger.getLogger(SampleApp.class.getName());
 
 	private static final SampleDB db = new SampleDB();
 

Modified: incubator/empire-db/trunk/empire-db-struts2/src/main/java/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-struts2/src/main/java/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java?rev=882884&amp;r1=882883&amp;r2=882884&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-struts2/src/main/java/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java
(original)
+++ incubator/empire-db/trunk/empire-db-struts2/src/main/java/org/apache/empire/struts2/jsp/components/info/CalendarInfo.java
Sat Nov 21 11:29:47 2009
@@ -35,16 +35,17 @@
     // Logger
     protected static Log log = LogFactory.getLog(ControlComponent.class);
 
-    // FIXME SimpleDateFormat is not thread safe, do not keep it in static context
-    protected static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+    private static final String DATE_FORMAT = "yyyyMMdd";
     
     public static String formatDate(Date date)
     {
+    	SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
         return dateFormat.format(date);
     }
     
     public static Date parseDate(String date)
     {
+    	SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
         if (date==null || date.length()!=dateFormat.toPattern().length())
         {   // Error: Invalid Date supplied. Using Today
             log.error("Invalid date format: " + String.valueOf(date));




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882360 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119233343.F397D23888CF@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119233343-F397D23888CF@eris-apache-org%3e</id>
<updated>2009-11-19T23:33:43Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 23:33:43 2009
New Revision: 882360

URL: http://svn.apache.org/viewvc?rev=882360&amp;view=rev
Log:
reenable the java 5 enforcer for CI builds

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=882360&amp;r1=882359&amp;r2=882360&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Thu Nov 19 23:33:43 2009
@@ -107,7 +107,7 @@
 						&lt;/executions&gt;
 					&lt;/plugin&gt;
 					&lt;!-- enable enforcer for java 1.5 --&gt;
-					&lt;!-- plugin&gt;
+					&lt;plugin&gt;
 						&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 						&lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
 						&lt;executions&gt;
@@ -118,7 +118,7 @@
 								&lt;/goals&gt;
 							&lt;/execution&gt;
 						&lt;/executions&gt;
-					&lt;/plugin--&gt;
+					&lt;/plugin&gt;
 				&lt;/plugins&gt;
 			&lt;/build&gt;
 		&lt;/profile&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882347 - /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119230329.E5A1F238888F@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119230329-E5A1F238888F@eris-apache-org%3e</id>
<updated>2009-11-19T23:03:29Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 23:03:29 2009
New Revision: 882347

URL: http://svn.apache.org/viewvc?rev=882347&amp;view=rev
Log:
velocity logging is now integrated with commons logging like the rest of our code

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=882347&amp;r1=882346&amp;r2=882347&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Thu Nov 19 23:03:29 2009
@@ -36,7 +36,7 @@
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.log.CommonsLogLogChute;
 
 /**
  * This is the entry class for generating the java persistence model based on a
@@ -85,9 +85,9 @@
 	 * Constructor
 	 */
 	public CodeGen(CodeGenConfig config) {
-		Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
-        	"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
-		Velocity.setProperty("runtime.log.logsystem.log4j.category", "org.apache.velocity");
+		// we have to keep this in sync with our logging system
+		// http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#simpleexampleofacustomlogger
+		Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new CommonsLogLogChute() );
 		try {
 			Velocity.init();
 		} catch (Exception e) {




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882344 - in /incubator/empire-db/trunk: ./ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-examples/empire-db-example-advanced/ empire-db-examples/empire-db-example-basic/ empire-db-examples/empire-db-example-cxf/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119225439.12BAA238888E@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119225439-12BAA238888E@eris-apache-org%3e</id>
<updated>2009-11-19T22:54:38Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 22:54:38 2009
New Revision: 882344

URL: http://svn.apache.org/viewvc?rev=882344&amp;view=rev
Log:
This should fix the xml file license issue
velocity logging is now integrated with log4j

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/xcf.xml
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Thu Nov 19 22:54:38 2009
@@ -36,6 +36,7 @@
 import org.apache.velocity.app.Velocity;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.RuntimeConstants;
 
 /**
  * This is the entry class for generating the java persistence model based on a
@@ -84,6 +85,9 @@
 	 * Constructor
 	 */
 	public CodeGen(CodeGenConfig config) {
+		Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
+        	"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
+		Velocity.setProperty("runtime.log.logsystem.log4j.category", "org.apache.velocity");
 		try {
 			Velocity.init();
 		} catch (Exception e) {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/config.xml Thu
Nov 19 22:54:38 2009
@@ -1,24 +1,22 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!-- 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- --&gt; 
+&lt;!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+--&gt;
 &lt;config&gt;
 
 	&lt;properties&gt;

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml Thu Nov
19 22:54:38 2009
@@ -1,24 +1,22 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!-- 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- --&gt; 
+&lt;!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+--&gt;
 &lt;config&gt;
 
 	&lt;properties&gt;

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/config.xml?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/config.xml Thu Nov
19 22:54:38 2009
@@ -1,24 +1,22 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!-- 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- --&gt; 
+&lt;!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+--&gt;
 &lt;config&gt;
 
 	&lt;properties&gt;

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/xcf.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/xcf.xml?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/xcf.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/xcf.xml Thu Nov 19
22:54:38 2009
@@ -1,19 +1,22 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-	&lt;!--
-		Licensed to the Apache Software Foundation (ASF) under one or more
-		contributor license agreements. See the NOTICE file distributed with
-		this work for additional information regarding copyright ownership.
-		The ASF licenses this file to You under the Apache License, Version
-		2.0 (the "License"); you may not use this file except in compliance
-		with the License. You may obtain a copy of the License at
-
-		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
-		applicable law or agreed to in writing, software distributed under the
-		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-		CONDITIONS OF ANY KIND, either express or implied. See the License for
-		the specific language governing permissions and limitations under the
-		License.
-	--&gt;
+&lt;!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+--&gt;
 &lt;beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://cxf.apache.org/core"

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=882344&amp;r1=882343&amp;r2=882344&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Thu Nov 19 22:54:38 2009
@@ -107,7 +107,7 @@
 						&lt;/executions&gt;
 					&lt;/plugin&gt;
 					&lt;!-- enable enforcer for java 1.5 --&gt;
-					&lt;plugin&gt;
+					&lt;!-- plugin&gt;
 						&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 						&lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
 						&lt;executions&gt;
@@ -118,7 +118,7 @@
 								&lt;/goals&gt;
 							&lt;/execution&gt;
 						&lt;/executions&gt;
-					&lt;/plugin&gt;
+					&lt;/plugin--&gt;
 				&lt;/plugins&gt;
 			&lt;/build&gt;
 		&lt;/profile&gt;
@@ -335,8 +335,6 @@
 			       			&lt;exclude&gt;**/.project&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.classpath&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.tomcatplugin&lt;/exclude&gt;
-			       			&lt;!-- FIXME In fact these logs should be removed after testing --&gt;
-			       			&lt;exclude&gt;**/*.log&lt;/exclude&gt;
 			       		&lt;/excludes&gt;
 			       	&lt;/configuration&gt;
 			  	&lt;/plugin&gt;
@@ -500,6 +498,7 @@
 		&lt;site&gt;
 			&lt;id&gt;people.apache.org.site&lt;/id&gt;
 			&lt;name&gt;Empire-db Maven Site&lt;/name&gt;
+			&lt;!-- FIXME find a place for this --&gt;
 			&lt;url&gt;scp://people.apache.org/home/francisdb/public_html/empire-db/site&lt;/url&gt;
 		&lt;/site&gt;
 	&lt;/distributionManagement&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882180 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119153336.6A0FF23889B5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119153336-6A0FF23889B5@eris-apache-org%3e</id>
<updated>2009-11-19T15:33:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 15:33:36 2009
New Revision: 882180

URL: http://svn.apache.org/viewvc?rev=882180&amp;view=rev
Log:
added fixme on the log file issue

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=882180&amp;r1=882179&amp;r2=882180&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Thu Nov 19 15:33:36 2009
@@ -335,6 +335,7 @@
 			       			&lt;exclude&gt;**/.project&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.classpath&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.tomcatplugin&lt;/exclude&gt;
+			       			&lt;!-- FIXME In fact these logs should be removed after testing --&gt;
 			       			&lt;exclude&gt;**/*.log&lt;/exclude&gt;
 			       		&lt;/excludes&gt;
 			       	&lt;/configuration&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882178 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119153236.27FB623888FD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119153236-27FB623888FD@eris-apache-org%3e</id>
<updated>2009-11-19T15:32:36Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 15:32:35 2009
New Revision: 882178

URL: http://svn.apache.org/viewvc?rev=882178&amp;view=rev
Log:
ignore log files for rat check

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=882178&amp;r1=882177&amp;r2=882178&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Thu Nov 19 15:32:35 2009
@@ -335,6 +335,7 @@
 			       			&lt;exclude&gt;**/.project&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.classpath&lt;/exclude&gt;
 			       			&lt;exclude&gt;**/.tomcatplugin&lt;/exclude&gt;
+			       			&lt;exclude&gt;**/*.log&lt;/exclude&gt;
 			       		&lt;/excludes&gt;
 			       	&lt;/configuration&gt;
 			  	&lt;/plugin&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882167 - in /incubator/empire-db/trunk: empire-assembly-all.xml empire-db-codegen/config.xml empire-db-codegen/src/test/resources/testconfig.xml pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119150505.1DA5923888D4@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119150505-1DA5923888D4@eris-apache-org%3e</id>
<updated>2009-11-19T15:05:04Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 15:05:04 2009
New Revision: 882167

URL: http://svn.apache.org/viewvc?rev=882167&amp;view=rev
Log:
fixing the header check

Modified:
    incubator/empire-db/trunk/empire-assembly-all.xml
    incubator/empire-db/trunk/empire-db-codegen/config.xml
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/empire-assembly-all.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-assembly-all.xml?rev=882167&amp;r1=882166&amp;r2=882167&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-assembly-all.xml (original)
+++ incubator/empire-db/trunk/empire-assembly-all.xml Thu Nov 19 15:05:04 2009
@@ -1,19 +1,21 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
 &lt;!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.	See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.	 You may obtain a copy of the License at
-
-		http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
 --&gt;
 &lt;assembly&gt;
 	&lt;id&gt;&lt;/id&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=882167&amp;r1=882166&amp;r2=882167&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Thu Nov 19 15:05:04 2009
@@ -1,24 +1,22 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!-- 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- --&gt; 
+&lt;!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+--&gt;
 &lt;config&gt;
 
 	&lt;properties&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml?rev=882167&amp;r1=882166&amp;r2=882167&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml Thu Nov
19 15:05:04 2009
@@ -1,19 +1,21 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
 &lt;!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.	See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.	 You may obtain a copy of the License at
-
-		http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+   http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
 --&gt;
 &lt;config&gt;
 

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=882167&amp;r1=882166&amp;r2=882167&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Thu Nov 19 15:05:04 2009
@@ -67,7 +67,7 @@
 				&lt;plugins&gt;
 					&lt;!-- check the headers --&gt;
 					&lt;plugin&gt;
-						&lt;groupId&gt;com.google.code.maven-license-plugin&lt;/groupId&gt;
+						&lt;groupId&gt;com.mycila.maven-license-plugin&lt;/groupId&gt;
 						&lt;artifactId&gt;maven-license-plugin&lt;/artifactId&gt;
 					&lt;/plugin&gt;
 					&lt;plugin&gt;
@@ -385,9 +385,9 @@
 					&lt;/configuration&gt;
 				&lt;/plugin&gt;
 				&lt;plugin&gt;
-		            &lt;groupId&gt;com.google.code.maven-license-plugin&lt;/groupId&gt;
+		            &lt;groupId&gt;com.mycila.maven-license-plugin&lt;/groupId&gt;
 		            &lt;artifactId&gt;maven-license-plugin&lt;/artifactId&gt;
-		            &lt;version&gt;1.4.0&lt;/version&gt;
+		            &lt;version&gt;1.5.0&lt;/version&gt;
 		            &lt;configuration&gt;
 		                &lt;basedir&gt;${basedir}&lt;/basedir&gt;
 		                &lt;header&gt;tools/header.txt&lt;/header&gt;
@@ -397,13 +397,8 @@
 		                &lt;aggregate&gt;false&lt;/aggregate&gt;
 		                &lt;includes&gt;
 		                    &lt;include&gt;src/**&lt;/include&gt;
-		                    &lt;include&gt;**/test/**&lt;/include&gt;
+		                    &lt;include&gt;**/*.xml&lt;/include&gt;
 		                &lt;/includes&gt;
-		                &lt;mapping&gt;
-		                    &lt;jwc&gt;XML_STYLE&lt;/jwc&gt;
-		                    &lt;application&gt;XML_STYLE&lt;/application&gt;
-		                    &lt;myFileExtension&gt;JAVADOC_STYLE&lt;/myFileExtension&gt;
-		                &lt;/mapping&gt;
 		                &lt;encoding&gt;UTF-8&lt;/encoding&gt;
 		            &lt;/configuration&gt;
 		            &lt;executions&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882128 - /incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119123323.A3CEB2388998@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119123323-A3CEB2388998@eris-apache-org%3e</id>
<updated>2009-11-19T12:33:23Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 12:33:23 2009
New Revision: 882128

URL: http://svn.apache.org/viewvc?rev=882128&amp;view=rev
Log:
trying to fix header

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml?rev=882128&amp;r1=882127&amp;r2=882128&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml Thu Nov
19 12:33:23 2009
@@ -1,24 +1,20 @@
 &lt;?xml version="1.0" encoding="UTF-8"?&gt;
-&lt;!-- 
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- --&gt; 
+&lt;!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.	See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.	 You may obtain a copy of the License at
+
+		http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+--&gt;
 &lt;config&gt;
 
 	&lt;properties&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r882059 - in /incubator/empire-db/trunk/empire-db-codegen/src: main/java/org/apache/empire/db/codegen/ test/java/org/apache/empire/db/codegen/ test/resources/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091119070841.BE1C1238888E@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091119070841-BE1C1238888E@eris-apache-org%3e</id>
<updated>2009-11-19T07:08:38Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Thu Nov 19 07:08:35 2009
New Revision: 882059

URL: http://svn.apache.org/viewvc?rev=882059&amp;view=rev
Log:
added initial unit test for codegen

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/log4j.properties
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml
Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=882059&amp;r1=882058&amp;r2=882059&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Thu Nov 19 07:08:35 2009
@@ -22,14 +22,13 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
-import java.sql.Connection;
-import java.sql.DriverManager;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
-import org.apache.empire.db.codegen.util.DBUtil;
 import org.apache.empire.db.codegen.util.FileUtils;
 import org.apache.empire.db.codegen.util.ParserUtil;
 import org.apache.velocity.Template;
@@ -96,90 +95,30 @@
 	}
 
 	/**
-	 * Generates the code according to the provided configuration file
-	 * @param config
+	 * Generates the java code files for the database
+	 * @param db the DBDatabase to generate files for
 	 */
-	public void generate(){
-
-		Connection conn = null;
-		try {			
-			// Get a JDBC Connection
-			conn = getJDBCConnection();
-			
-			// create the database in memory
-			DBDatabase db = parseDataModel(conn);
-			
-			// create the source-code for that database
-			generateCodeFiles(db);
-			
-			log.info("Code generation completed sucessfully!");
-		} 
-		catch (Exception e) 
-		{
-			log.error(e.getMessage(), e);
-		} 
-		finally 
-		{
-			DBUtil.close(conn, log);
-		}
-	}
-	
-	/**
-	 * &lt;PRE&gt;
-	 * Opens and returns a JDBC-Connection.
-	 * JDBC url, user and password for the connection are obained from the SampleConfig bean
-	 * Please use the config.xml file to change connection params.
-	 * &lt;/PRE&gt;
-	 */
-	private Connection getJDBCConnection() {
-		// Establish a new database connection
-		Connection conn = null;
-		log.info("Connecting to Database'" + config.getJdbcURL() + "' / User="
-				+ config.getJdbcUser());
-		try {
-			// Connect to the databse
-			Class.forName(config.getJdbcClass()).newInstance();
-			conn = DriverManager.getConnection(config.getJdbcURL(), config
-					.getJdbcUser(), config.getJdbcPwd());
-			log.info("Connected successfully");
-			// set the AutoCommit to false this session. You must commit
-			// explicitly now
-			conn.setAutoCommit(true);
-			log.info("AutoCommit is " + conn.getAutoCommit());
-
-		} catch (Exception e) {
-			log.fatal("Failed to connect directly to '" + config.getJdbcURL()
-					+ "' / User=" + config.getJdbcUser(), e);
-			throw new RuntimeException(e);
-		}
-		return conn;
-	}
-
-	public DBDatabase parseDataModel(Connection conn) {
-		CodeGenParser cgp = new CodeGenParser(conn, config);
-		DBDatabase memoryDB = cgp.getDb();
-		return memoryDB;
-	}
-
-	public void generateCodeFiles(DBDatabase db) {
+	public List&lt;File&gt; generateCodeFiles(DBDatabase db) {
+	    List&lt;File&gt; generatedFiles = new ArrayList&lt;File&gt;();
 
 		// Prepare directories for generated source files
 		this.initDirectories(config.getTargetFolder(), config.getPackageName());
 
 		// Create the DB class
-		this.createDatabaseClass(db);
+		generatedFiles.add(this.createDatabaseClass(db));
 
 		// Create base table class
-		this.createBaseTableClass(db);
+		generatedFiles.add(this.createBaseTableClass(db));
 
 		// Create base record class
-		this.createBaseRecordClass(db);
+		generatedFiles.add(this.createBaseRecordClass(db));
 		// Create table classes, record interfaces and record classes
 		for (DBTable table : db.getTables()) 
 		{
-			this.createTableClass(db, table);
-			this.createRecordClass(db, table);
+		    generatedFiles.add(this.createTableClass(db, table));
+		    generatedFiles.add(this.createRecordClass(db, table));
 		}
+		return generatedFiles;
 	}
 
 	private void initDirectories(String srcLocation, String packageName) {
@@ -208,7 +147,7 @@
 		this.recordDir.mkdir();
 	}
 
-	private void createDatabaseClass(DBDatabase db) {
+	private File createDatabaseClass(DBDatabase db) {
 		File file = new File(baseDir, config.getDbClassName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("parser", pUtil);
@@ -218,17 +157,19 @@
 		context.put("tableSubPackage", "tables");
 		context.put("database", db);
 		writeFile(file, TEMPLATE_PATH + "/" + DATABASE_TEMPLATE, context);
+		return file;
 	}
 
-	private void createBaseTableClass(DBDatabase db) {
+	private File createBaseTableClass(DBDatabase db) {
 		File file = new File(tableDir, config.getTableBaseName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("tablePackageName", config.getPackageName() + ".tables");
 		context.put("baseTableClassName", config.getTableBaseName());
 		writeFile(file, TEMPLATE_PATH + "/" + BASE_TABLE_TEMPLATE, context);
+		return file;
 	}
 
-	private void createTableClass(DBDatabase db, DBTable table) {
+	private File createTableClass(DBDatabase db, DBTable table) {
 		File file = new File(tableDir, pUtil.getTableClassName(table.getName())
 				+ ".java");
 		VelocityContext context = new VelocityContext();
@@ -239,9 +180,10 @@
 		context.put("dbClassName", config.getDbClassName());
 		context.put("table", table);
 		writeFile(file, TEMPLATE_PATH + "/" + TABLE_TEMPLATE, context);
+		return file;
 	}
 
-	private void createBaseRecordClass(DBDatabase db) {
+	private File createBaseRecordClass(DBDatabase db) {
 		File file = new File(recordDir, config.getRecordBaseName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("baseRecordClassName", config.getRecordBaseName());
@@ -250,9 +192,10 @@
 		context.put("recordPackageName", config.getPackageName() + ".records");
 		context.put("baseTableClassName", config.getTableBaseName());
 		writeFile(file, TEMPLATE_PATH + "/" + BASE_RECORD_TEMPLATE, context);
+		return file;
 	}
 
-	private void createRecordClass(DBDatabase db, DBTable table) {
+	private File createRecordClass(DBDatabase db, DBTable table) {
 		File file = new File(recordDir, pUtil.getRecordClassName(table
 				.getName())
 				+ ".java");
@@ -269,6 +212,7 @@
 
 		context.put("table", table);
 		writeFile(file, TEMPLATE_PATH + "/" + RECORD_TEMPLATE, context);
+		return file;
 	}
 
 	private static void writeFile(File file, String templatePath,

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java?rev=882059&amp;r1=882058&amp;r2=882059&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
Thu Nov 19 07:08:35 2009
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.empire.commons.ErrorObject;
+import org.apache.empire.db.DBDatabase;
 
 /**
  * Console code generator application, takes the config file as first argument.
@@ -55,8 +56,15 @@
 		// log all options
 		listOptions(config);
 		
+		// read the database model
+		CodeGenParser parser = new CodeGenParser(config);
+		DBDatabase db = parser.loadDbModel();
+		
+		// create the source-code for that database
 		CodeGen codeGen = new CodeGen(config);
-		codeGen.generate();
+		codeGen.generateCodeFiles(db);
+		
+		log.info("Code generation completed sucessfully!");
 	}
 	
 	/**
@@ -98,4 +106,6 @@
 		log.info("NestViews=" + config.isNestViews());
 		log.info("CreateRecordProperties=" + config.isCreateRecordProperties());
 	}
+	
+
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=882059&amp;r1=882058&amp;r2=882059&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Thu Nov 19 07:08:35 2009
@@ -16,11 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.empire.db.codegen;
 
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
@@ -48,6 +48,7 @@
 	}
 
 	private static final Log log = LogFactory.getLog(CodeGenParser.class);
+	
 	private DatabaseMetaData dbMeta;
 	private Connection con;
 	private CodeGenConfig config;
@@ -56,28 +57,73 @@
 	/**
 	 * create a empty in memory Database and populates it
 	 */
-	public CodeGenParser(Connection conn, CodeGenConfig config) {
-
-		this.con = conn;
-		this.db = new InMemoryDatabase();
-		this.config = config;
-		try {
-			this.dbMeta = con.getMetaData();
-			populateDatabase();
-		} catch (SQLException e) {
-			throw new RuntimeException("Unable to read database metadata!", e);
-		}
+	public CodeGenParser(CodeGenConfig config) {
+	    this.config = config;
 	}
 
 	/**
 	 * returns the populated DBDatabase
 	 */
-	public DBDatabase getDb() {
+	public DBDatabase loadDbModel() {
+	    this.db = new InMemoryDatabase();
+	    try {           
+            // Get a JDBC Connection
+            con = getJDBCConnection(config);
+            
+            // create the database in memory
+
+            this.dbMeta = con.getMetaData();
+            populateDatabase();
+                        
+        } 
+        catch (SQLException e) 
+        {
+            throw new RuntimeException("Unable to read database metadata!", e);
+        }
+        catch (Exception e) 
+        {
+            log.error(e.getMessage(), e);
+        } 
+        finally 
+        {
+            DBUtil.close(con, log);
+        }
 		return db;
 	}
 
 	// ----------- private members
 
+	   /**
+     * &lt;PRE&gt;
+     * Opens and returns a JDBC-Connection.
+     * JDBC url, user and password for the connection are obained from the SampleConfig bean
+     * Please use the config.xml file to change connection params.
+     * &lt;/PRE&gt;
+     */
+    private Connection getJDBCConnection(CodeGenConfig config) {
+        // Establish a new database connection
+        Connection conn = null;
+        log.info("Connecting to Database'" + config.getJdbcURL() + "' / User="
+                + config.getJdbcUser());
+        try {
+            // Connect to the databse
+            Class.forName(config.getJdbcClass()).newInstance();
+            conn = DriverManager.getConnection(config.getJdbcURL(), config
+                    .getJdbcUser(), config.getJdbcPwd());
+            log.info("Connected successfully");
+            // set the AutoCommit to false this session. You must commit
+            // explicitly now
+            conn.setAutoCommit(true);
+            log.info("AutoCommit is " + conn.getAutoCommit());
+
+        } catch (Exception e) {
+            log.fatal("Failed to connect directly to '" + config.getJdbcURL()
+                    + "' / User=" + config.getJdbcUser(), e);
+            throw new RuntimeException(e);
+        }
+        return conn;
+    }
+	
 	/**
 	 * queries the metadata of the database for tables and populates the
 	 * database with those

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java?rev=882059&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenTest.java
Thu Nov 19 07:08:35 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.codegen;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.codegen.util.FileUtils;
+import org.junit.After;
+import org.junit.Test;
+
+public class CodeGenTest
+{
+	@After
+	public void cleanup(){
+		File generated = new File("target/generated");
+		FileUtils.deleteDirectory(generated);
+	}
+
+    @Test
+    public void testCodeGen()
+    {
+        CodeGenConfig config = new CodeGenConfig();
+        config.init("testconfig.xml", true, false);
+        CodeGen codeGen = new CodeGen(config);
+        
+        DBDatabase db = new DBDatabase()
+        {
+        };
+        
+        List&lt;File&gt; files = codeGen.generateCodeFiles(db);
+        assertEquals(3, files.size());
+        for(File file:files){
+        	System.out.println(file);
+        }
+        
+        // TODO try to compile the resulting files???
+        
+        // Commons jci 1.0 seems not able to handle java 5
+//        List&lt;String&gt; arguments = new ArrayList&lt;String&gt;();
+//        String strFile;
+//        for(File file:files){
+//        	strFile = file.getPath().replace(config.getTargetFolder()+"/", "");
+//            arguments.add(strFile);
+//            System.out.println(strFile);
+//        }
+//        JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse");
+//        JavaCompilerSettings settings = new JavaCompilerSettings();
+//        settings.setSourceVersion("1.5");
+//        settings.setTargetVersion("1.5");
+//        settings.setVerbose(true);
+//        CompilationResult result = compiler.compile(
+//        		arguments.toArray(new String[arguments.size()]), 
+//        		new FileResourceReader(new File(config.getTargetFolder())), 
+//        		new FileResourceStore(new File("target/compiledsources.test")),
+//        		getClass().getClassLoader(),
+//        		settings);
+//
+//        System.out.println( result.getErrors().length + " errors");
+//        for(CompilationProblem problem:result.getErrors()){
+//        	System.out.println( problem);
+//        }
+//        System.out.println( result.getWarnings().length + " warnings");
+//        for(CompilationProblem warning:result.getWarnings()){
+//        	System.out.println( warning);
+//        }
+        
+        // ONLY for java 6
+//        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+//        arguments.add("-classpath");
+//        arguments.add(System.getProperty("java.class.path"));
+//        for(File file:files){
+//            System.out.println(file);
+//            arguments.add(file.getAbsolutePath());
+//        }
+//
+//        int compilationResult = compiler.run(null, null, null, arguments.toArray(new String[arguments.size()]));
+//        assertEquals("Compilation Failed", 0, compilationResult);
+        
+    }
+
+}

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/log4j.properties?rev=882059&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/log4j.properties (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/log4j.properties Thu Nov
19 07:08:35 2009
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+log4j.rootCategory=DEBUG, console
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.conversionPattern = %d{ISO8601} %-5p [%c] - %m%n

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml?rev=882059&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/testconfig.xml Thu Nov
19 07:08:35 2009
@@ -0,0 +1,75 @@
+&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+&lt;!-- 
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ --&gt; 
+&lt;config&gt;
+
+	&lt;properties&gt;
+		&lt;!-- provider name must match the property-section containing the connection data --&gt;
+		&lt;jdbcClass&gt;oracle.jdbc.driver.OracleDriver&lt;/jdbcClass&gt;
+		&lt;jdbcURL&gt;jdbc:oracle:thin:@192.168.0.2:1521:ora10&lt;/jdbcURL&gt;
+		&lt;jdbcUser&gt;DBSAMPLE&lt;/jdbcUser&gt;
+		&lt;jdbcPwd&gt;DBSAMPLE&lt;/jdbcPwd&gt;
+
+		&lt;!-- Schema options --&gt;
+		&lt;dbCatalog&gt;&lt;/dbCatalog&gt;
+		&lt;dbSchema&gt;DBSAMPLE&lt;/dbSchema&gt;
+		&lt;dbTablePattern&gt;&lt;/dbTablePattern&gt;
+		&lt;timestampColumn&gt;CREATIONDATE&lt;/timestampColumn&gt;
+		
+		&lt;!-- generation options --&gt;
+		&lt;targetFolder&gt;target/generated/dbsample&lt;/targetFolder&gt;
+		&lt;packageName&gt;org.apache.empire.db.samples.dbsample&lt;/packageName&gt;
+		&lt;dbClassName&gt;SampleDB&lt;/dbClassName&gt;
+		&lt;tableBaseName&gt;SampleTable&lt;/tableBaseName&gt;
+		&lt;viewBaseName&gt;SampleView&lt;/viewBaseName&gt;
+		&lt;recordBaseName&gt;SampleRecord&lt;/recordBaseName&gt;
+		&lt;tableClassPrefix&gt;T&lt;/tableClassPrefix&gt;
+		&lt;tableClassSuffix&gt;Table&lt;/tableClassSuffix&gt;
+		&lt;viewClassPrefix&gt;V&lt;/viewClassPrefix&gt;
+		&lt;nestTables&gt;True&lt;/nestTables&gt;
+		&lt;nestViews&gt;False&lt;/nestViews&gt;
+		&lt;createRecordProperties&gt;true&lt;/createRecordProperties&gt;
+	&lt;/properties&gt;
+	
+	&lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
+
+		&lt;appender name="default" class="org.apache.log4j.ConsoleAppender"&gt;
+			&lt;!-- layout class="org.apache.log4j.TTCCLayout"/ --&gt;
+			&lt;layout class="org.apache.log4j.PatternLayout"&gt;
+				&lt;!-- param name="ConversionPattern" value="NSB(%c) %-5p %m	at %l%n"/ --&gt;
+				&lt;param name="ConversionPattern" value="%-5p [%d{yyyy/MM/dd HH:mm}]: %m		at %l %n"/&gt;
+			&lt;/layout&gt;
+		&lt;/appender&gt;
+	
+		&lt;!-- log detail configuration --&gt;
+		&lt;logger name="org.apache.empire.commons" additivity="false"&gt;
+			&lt;level value="warn"/&gt;
+			&lt;appender-ref ref="default"/&gt;
+		&lt;/logger&gt;
+	
+		&lt;root&gt;
+			&lt;priority value="info"/&gt;
+			&lt;appender-ref ref="default"/&gt;
+		&lt;/root&gt;
+
+	&lt;/log4j:configuration&gt;
+	
+&lt;/config&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r881628 - in /incubator/empire-db/trunk/empire-db-codegen/src: main/java/org/apache/empire/db/codegen/ main/java/org/apache/empire/db/codegen/util/ test/java/org/apache/empire/db/codegen/util/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091117235648.A9CA423888FD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091117235648-A9CA423888FD@eris-apache-org%3e</id>
<updated>2009-11-17T23:56:48Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Nov 17 23:56:48 2009
New Revision: 881628

URL: http://svn.apache.org/viewvc?rev=881628&amp;view=rev
Log:
EMPIREDB-52 - Split up the actual application and the code generator service + some other
cleanup

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=881628&amp;r1=881627&amp;r2=881628&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Tue Nov 17 23:56:48 2009
@@ -27,9 +27,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
+import org.apache.empire.db.codegen.util.DBUtil;
 import org.apache.empire.db.codegen.util.FileUtils;
 import org.apache.empire.db.codegen.util.ParserUtil;
 import org.apache.velocity.Template;
@@ -43,19 +43,22 @@
  * database schema. It uses the Empire DB open-source framework to build a java
  * persistence layer for an application. The Apache Velocity template engine is
  * used to create the output interfaces and classes.
- * 
+ * &lt;p&gt;
  * The Empire DB framework doesn't try to hide the underlying database and data
  * model but instead embraces its power by modeling it within java. The result
  * is a persistence layer that uses a more "object-oriented, type safe" SQL to
  * access persistent data.
- * 
- * NOTE: THIS VERSION HAS SEVERE RESTRICTIONS: 1. Only tables are currently
- * modeled (we'll add views to a later version). 2. Table indexes are not yet
- * modeled (exception is primary key). Again, this will be added to later
- * editions. 3. It is assumed that each table has a single INTEGER
- * auto-generated primary key column that has the same name for all tables. 4.
- * It is assumed that each table has a single TIMESTAMP optimistic locking
- * column that has the same name for all tables.
+ * &lt;p&gt;
+ * NOTE: THIS VERSION HAS SEVERE RESTRICTIONS:
+ * &lt;ol&gt;
+ * &lt;li&gt; Only tables are currently modeled (we'll add views to a later version).&lt;/li&gt;

+ * &lt;li&gt; Table indexes are not yet modeled (exception is primary key). Again, 
+ * this will be added to later editions.&lt;/li&gt;  
+ * &lt;li&gt; It is assumed that each table has a single INTEGER auto-generated primary
+ * key column that has the same name for all tables. &lt;/li&gt; 
+ * &lt;li&gt; It is assumed that each table has a single TIMESTAMP optimistic locking
+ * column that has the same name for all tables.&lt;/li&gt; 
+ * &lt;/ol&gt;
  */
 
 public class CodeGen {
@@ -69,8 +72,11 @@
 	public static final String BASE_RECORD_TEMPLATE = "BaseRecord.vm";
 	public static final String RECORD_TEMPLATE = "Record.vm";
 
+	// Services
+	private final ParserUtil pUtil;
+	
 	// Properties
-	private CodeGenConfig config;
+	private final CodeGenConfig config;
 	private File baseDir;
 	private File tableDir;
 	private File recordDir;
@@ -78,80 +84,46 @@
 	/**
 	 * Constructor
 	 */
-	public CodeGen() {
+	public CodeGen(CodeGenConfig config) {
 		try {
 			Velocity.init();
 		} catch (Exception e) {
 			log.fatal(e);
 			throw new RuntimeException(e);
 		}
+		this.pUtil = new ParserUtil(config);
+		this.config = config;
 	}
 
 	/**
-	 * &lt;PRE&gt;
-	 * This is the entry point of the Empire-DB Sample Application
-	 * Please check the config.xml configuration file for Database and Connection settings.
-	 * &lt;/PRE&gt;
-	 * 
-	 * @param args
-	 *            arguments
+	 * Generates the code according to the provided configuration file
+	 * @param config
 	 */
-	public static void main(String[] args) {
-		Connection conn = null;
-		try {
-			// Init Configuration
-			CodeGenConfig config = new CodeGenConfig();
-			config.init((args.length &gt; 0 ? args[0] : "config.xml"));
-
-			// Enable Exceptions
-			ErrorObject.setExceptionsEnabled(true);
+	public void generate(){
 
+		Connection conn = null;
+		try {			
 			// Get a JDBC Connection
-			conn = getJDBCConnection(config);
-
-			// List options
-			log.info("Database connection successful. Config options are:");
-			log.info("SchemaName=" + String.valueOf(config.getDbSchema()));
-			log.info("TimestampColumn="
-					+ String.valueOf(config.getTimestampColumn()));
-			log.info("TargetFolder=" + config.getTargetFolder());
-			log.info("PackageName=" + config.getPackageName());
-			log.info("DbClassName=" + config.getDbClassName());
-			log.info("TableBaseName=" + config.getTableBaseName());
-			log.info("ViewBaseName=" + config.getViewBaseName());
-			log.info("RecordBaseName=" + config.getRecordBaseName());
-			log.info("TableClassPrefix=" + config.getTableClassPrefix());
-			log.info("ViewClassPrefi=" + config.getViewClassPrefix());
-			log.info("NestTable=" + config.isNestTables());
-			log.info("NestViews=" + config.isNestViews());
-			log.info("CreateRecordProperties="
-					+ config.isCreateRecordProperties());
-
-			if (config.getTableClassPrefix() == null)
-				config.setTableClassPrefix("");
-
-			if (config.getTableClassSuffix() == null)
-				config.setTableClassSuffix("");
-
-			CodeGen codeGen = new CodeGen();
-			// create the database in the memory
-			DBDatabase db = codeGen.parseDataModel(conn, config);
-
+			conn = getJDBCConnection();
+			
+			// create the database in memory
+			DBDatabase db = parseDataModel(conn);
+			
 			// create the source-code for that database
-			codeGen.generateCodeFiles(db, config);
-
+			generateCodeFiles(db);
+			
 			log.info("Code generation completed sucessfully!");
-
-		} catch (Exception e) {
-			// Error
+		} 
+		catch (Exception e) 
+		{
 			log.error(e.getMessage(), e);
-		} finally {
-			// done
-			if (conn != null)
-				close(conn);
+		} 
+		finally 
+		{
+			DBUtil.close(conn, log);
 		}
 	}
-
+	
 	/**
 	 * &lt;PRE&gt;
 	 * Opens and returns a JDBC-Connection.
@@ -159,7 +131,7 @@
 	 * Please use the config.xml file to change connection params.
 	 * &lt;/PRE&gt;
 	 */
-	private static Connection getJDBCConnection(CodeGenConfig config) {
+	private Connection getJDBCConnection() {
 		// Establish a new database connection
 		Connection conn = null;
 		log.info("Connecting to Database'" + config.getJdbcURL() + "' / User="
@@ -183,27 +155,13 @@
 		return conn;
 	}
 
-	/**
-	 * Closes a JDBC-Connection.
-	 */
-	private static void close(Connection conn) {
-		log.info("Closing database connection");
-		try {
-			conn.close();
-		} catch (Exception e) {
-			log.fatal("Error closing connection", e);
-		}
-	}
-
-	public DBDatabase parseDataModel(Connection conn, CodeGenConfig config) {
-		this.config = config;
+	public DBDatabase parseDataModel(Connection conn) {
 		CodeGenParser cgp = new CodeGenParser(conn, config);
 		DBDatabase memoryDB = cgp.getDb();
 		return memoryDB;
 	}
 
-	public void generateCodeFiles(DBDatabase db, CodeGenConfig config) {
-		this.config = config;
+	public void generateCodeFiles(DBDatabase db) {
 
 		// Prepare directories for generated source files
 		this.initDirectories(config.getTargetFolder(), config.getPackageName());
@@ -217,7 +175,8 @@
 		// Create base record class
 		this.createBaseRecordClass(db);
 		// Create table classes, record interfaces and record classes
-		for (DBTable table : db.getTables()) {
+		for (DBTable table : db.getTables()) 
+		{
 			this.createTableClass(db, table);
 			this.createRecordClass(db, table);
 		}
@@ -250,7 +209,6 @@
 	}
 
 	private void createDatabaseClass(DBDatabase db) {
-		ParserUtil pUtil = new ParserUtil(config);
 		File file = new File(baseDir, config.getDbClassName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("parser", pUtil);
@@ -271,7 +229,6 @@
 	}
 
 	private void createTableClass(DBDatabase db, DBTable table) {
-		ParserUtil pUtil = new ParserUtil(config);
 		File file = new File(tableDir, pUtil.getTableClassName(table.getName())
 				+ ".java");
 		VelocityContext context = new VelocityContext();
@@ -296,7 +253,6 @@
 	}
 
 	private void createRecordClass(DBDatabase db, DBTable table) {
-		ParserUtil pUtil = new ParserUtil(config);
 		File file = new File(recordDir, pUtil.getRecordClassName(table
 				.getName())
 				+ ".java");

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java?rev=881628&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
Tue Nov 17 23:56:48 2009
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.codegen;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.ErrorObject;
+
+/**
+ * Console code generator application, takes the config file as first argument.
+ *
+ */
+public class CodeGenApp {
+	
+	private static final Log log = LogFactory.getLog(CodeGenApp.class);
+	
+	private static final String DEFAULT_CONFIG_FILE = "config.xml";
+	
+	
+	/**
+	 * This is the entry point of the Code generator Sample Application.
+	 * Please check the config.xml configuration file for Database and Connection settings.
+	 * 
+	 * @param args
+	 *            arguments
+	 */
+	public static void main(String[] args) {
+		CodeGenApp app = new CodeGenApp();
+		app.start((args.length &gt; 0 ? args[0] : DEFAULT_CONFIG_FILE));
+	}	
+	
+	/**
+	 * Starts the actual generation according to the provided config file
+	 */
+	private void start(final String file){
+		// load configuration file
+		CodeGenConfig config = loadConfig(file);
+
+		// log all options
+		listOptions(config);
+		
+		CodeGen codeGen = new CodeGen(config);
+		codeGen.generate();
+	}
+	
+	/**
+	 * Loads the configuration file and
+	 * @param configFile
+	 * @return
+	 */
+	private CodeGenConfig loadConfig(String configFile){
+		// Init Configuration
+		CodeGenConfig config = new CodeGenConfig();
+		config.init(configFile);
+
+		// Enable Exceptions
+		ErrorObject.setExceptionsEnabled(true);
+
+		if (config.getTableClassPrefix() == null)
+			config.setTableClassPrefix("");
+
+		if (config.getTableClassSuffix() == null)
+			config.setTableClassSuffix("");
+		
+		return config;
+	}
+	
+	private void listOptions(CodeGenConfig config){
+		// List options
+		log.info("Database connection successful. Config options are:");
+		log.info("SchemaName=" + String.valueOf(config.getDbSchema()));
+		log.info("TimestampColumn="	+ String.valueOf(config.getTimestampColumn()));
+		log.info("TargetFolder=" + config.getTargetFolder());
+		log.info("PackageName=" + config.getPackageName());
+		log.info("DbClassName=" + config.getDbClassName());
+		log.info("TableBaseName=" + config.getTableBaseName());
+		log.info("ViewBaseName=" + config.getViewBaseName());
+		log.info("RecordBaseName=" + config.getRecordBaseName());
+		log.info("TableClassPrefix=" + config.getTableClassPrefix());
+		log.info("ViewClassPrefi=" + config.getViewClassPrefix());
+		log.info("NestTable=" + config.isNestTables());
+		log.info("NestViews=" + config.isNestViews());
+		log.info("CreateRecordProperties=" + config.isCreateRecordProperties());
+	}
+}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java?rev=881628&amp;r1=881627&amp;r2=881628&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
Tue Nov 17 23:56:48 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.empire.db.codegen.util;
 
+import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
@@ -32,7 +33,7 @@
 	}
 	
 	/**
-	 * Closes a sql resultset and logs exceptions
+	 * Closes a sql resultset and logs exceptions.
 	 * 
 	 * @param rs the resultset to close
 	 * @param log the logger instance to use for logging
@@ -45,8 +46,22 @@
 				rs.close();
 			b = true;
 		} catch (SQLException e) {
-			log.error("The resultset could not bel closed!", e);
+			log.error("The resultset could not be closed!", e);
 		}
 		return b;
 	}
+	
+	/**
+	 * Closes a JDBC-Connection and logs exceptions.
+	 */
+	public static void close(Connection conn, Log log) {
+		if(conn != null){
+			log.info("Closing database connection");
+			try {
+				conn.close();
+			} catch (Exception e) {
+				log.fatal("Error closing connection", e);
+			}
+		}
+	}
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java?rev=881628&amp;r1=881627&amp;r2=881628&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
Tue Nov 17 23:56:48 2009
@@ -16,7 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.empire.db.codegen.util;
 
 import org.apache.commons.logging.Log;
@@ -32,9 +31,10 @@
  */
 public class ParserUtil {
 
-	private CodeGenConfig config;
 	private static final Log log = LogFactory.getLog(ParserUtil.class);
 
+	private CodeGenConfig config;
+	
 	public ParserUtil(CodeGenConfig config) {
 
 		this.config = config;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java?rev=881628&amp;r1=881627&amp;r2=881628&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
Tue Nov 17 23:56:48 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.util;
 
 import static org.junit.Assert.assertFalse;
@@ -16,7 +34,7 @@
 	public void testCloseResultSet() throws SQLException {
 		// null
 		Log log = Mockito.mock(Log.class);
-		boolean succes = DBUtil.close(null, log);
+		boolean succes = DBUtil.close((ResultSet)null, log);
 		assertTrue(succes);
 		
 		// normal
@@ -30,7 +48,7 @@
 		Mockito.doThrow(exception).when(rsFail).close();
 		boolean succes3 = DBUtil.close(rsFail, log);
 		assertFalse(succes3);
-		Mockito.verify(log).error("The resultset could not bel closed!", exception);
+		Mockito.verify(log).error("The resultset could not be closed!", exception);
 	}
 
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java?rev=881628&amp;r1=881627&amp;r2=881628&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
Tue Nov 17 23:56:48 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.util;
 
 import static org.junit.Assert.assertEquals;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r881610 - in /incubator/empire-db/trunk: ./ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ empire-db-codegen/src/test/java/org/ empire-db-codegen/src/test/jav...</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091117230603.AD92423889B5@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091117230603-AD92423889B5@eris-apache-org%3e</id>
<updated>2009-11-17T23:06:03Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Nov 17 23:06:02 2009
New Revision: 881610

URL: http://svn.apache.org/viewvc?rev=881610&amp;view=rev
Log:
EMPIREDB-52 - Cleaning up and added 2 unit tests

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Tue Nov 17 23:06:02 2009
@@ -317,19 +317,21 @@
 
 	private static void writeFile(File file, String templatePath,
 			VelocityContext context) {
+		Writer writer = null;
 		try {
 			Template template = Velocity.getTemplate(templatePath);
-			Writer writer = new FileWriter(file);
+			writer = new FileWriter(file);
 			template.merge(context, writer);
-			writer.close();
 		} catch (IOException e) {
-			e.printStackTrace();
+			log.error(e.getMessage(), e);
 		} catch (ResourceNotFoundException e) {
-			e.printStackTrace();
+			log.error(e.getMessage(), e);
 		} catch (ParseErrorException e) {
-			e.printStackTrace();
+			log.error(e.getMessage(), e);
 		} catch (Exception e) {
-			e.printStackTrace();
+			log.error(e.getMessage(), e);
+		} finally {
+			FileUtils.close(writer);
 		}
 
 	}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Tue Nov 17 23:06:02 2009
@@ -103,7 +103,7 @@
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
 		} finally {
-			DBUtil.closeResultSet(tables, log);
+			DBUtil.close(tables, log);
 		}
 	}
 
@@ -137,7 +137,7 @@
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
 		} finally {
-			DBUtil.closeResultSet(rs, log);
+			DBUtil.close(rs, log);
 		}
 	}
 
@@ -158,7 +158,7 @@
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
 		} finally {
-			DBUtil.closeResultSet(rs, log);
+			DBUtil.close(rs, log);
 		}
 		return cols;
 	}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
Tue Nov 17 23:06:02 2009
@@ -23,8 +23,22 @@
 
 import org.apache.commons.logging.Log;
 
-public class DBUtil {
-	public static boolean closeResultSet(ResultSet rs, Log log) {
+
+public final class DBUtil {
+	
+	private DBUtil()
+	{
+		// Utility class
+	}
+	
+	/**
+	 * Closes a sql resultset and logs exceptions
+	 * 
+	 * @param rs the resultset to close
+	 * @param log the logger instance to use for logging
+	 * @return true on succes
+	 */
+	public static boolean close(ResultSet rs, Log log) {
 		boolean b = false;
 		try {
 			if(rs!=null)

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
Tue Nov 17 23:06:02 2009
@@ -20,6 +20,7 @@
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -30,7 +31,23 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * File utilities
+ * TODO would be better to let these methods throw IOExceptions!
+ *
+ */
 public class FileUtils {
+	
+	private static final Log log =  LogFactory.getLog(FileUtils.class);
+	
+	private FileUtils()
+	{
+		// Utility class
+	}
+	
 	/**
 	 * Recursively cleans (removes) all files under the given 
 	 * directory.  Note that this removes all sub-directories
@@ -38,29 +55,50 @@
 	 * @param directory
 	 */
 	public static void cleanDirectory(File directory) {
-		if (directory.isDirectory()) {
+		boolean success;
+		if (directory.isDirectory()) 
+		{
             String[] children = directory.list();
-            for (int i=0; i&lt;children.length; i++) {
+            for (int i=0; i&lt;children.length; i++) 
+            {
             	File child = new File(directory, children[i]);
-            	if (child.isDirectory()) deleteDirectory(child);
-            	else child.delete();
+            	if (child.isDirectory())
+            	{
+            		success = deleteDirectory(child);
+            	}
+            	else 
+            	{
+            		success = child.delete();
+            	}
+            	if(!success){
+            		// TODO throw IO Exception or return false?
+            	}
             }
         }
 	}
 	
 	/**
 	 * Recursively deletes a directory and everything under it.
+	 * 
 	 * @param directory
+	 * @return true on success
 	 */
-	public static void deleteDirectory(File directory) {
-        if (directory.isDirectory()) {
+	public static boolean deleteDirectory(File directory) {
+		boolean globalSuccess = true;
+		boolean success;
+        if (directory.isDirectory()) 
+        {
             String[] children = directory.list();
-            for (int i=0; i&lt;children.length; i++) {
-            	deleteDirectory(new File(directory, children[i]));
+            for (int i=0; i&lt;children.length; i++) 
+            {
+            	success = deleteDirectory(new File(directory, children[i]));
+            	globalSuccess = success &amp;&amp; globalSuccess;
             }
         }   
         // The directory is now empty so delete it
-        directory.delete();
+        success = directory.delete();
+        globalSuccess = success &amp;&amp; globalSuccess;
+        return globalSuccess;
 	}
 	
 	/**
@@ -68,6 +106,7 @@
 	 * Files in sub-directories not deleted.
 	 * @param directory
 	 */
+	// TODO remove as not in use?
 	public static void deleteFiles(File directory) {
 		if (directory.isDirectory()) {
             String[] children = directory.list();
@@ -76,86 +115,139 @@
             }
         }
 	}
+	
+	// TODO remove as not in use?
 	public static Object readObject(String fileName) {
 		Object o = null;
+		ObjectInputStream ois = null;
 		try {
-			ObjectInputStream ois = new ObjectInputStream(
+			ois = new ObjectInputStream(
 				new FileInputStream(fileName));
 			o = ois.readObject();
-			ois.close();
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 		} catch (IOException e) {
 			e.printStackTrace();
 		} catch (ClassNotFoundException e) {
 			e.printStackTrace();
+		} finally {
+			close(ois);
 		}
 		return o;
 	}
 	
+	// TODO remove as not in use?	
 	public static void writeObject(String fileName, Object o) {
+		ObjectOutputStream oos = null;
 		try {
-			ObjectOutputStream oos = new ObjectOutputStream(
+			oos = new ObjectOutputStream(
 				new FileOutputStream(fileName));
 			oos.writeObject(o);
-			oos.close();
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 		} catch (IOException e) {
 			e.printStackTrace();
+		} finally {
+			close(oos);
 		}
 	}
+	
+	/**
+	 * Reads a file to String
+	 * 
+	 * @param file the file to read
+	 * @return the file contents as String
+	 */
+	// TODO remove as not in use?
 	public static String getFileAsString(File file) {
 		StringBuilder sb = new StringBuilder();
+		BufferedReader br = null;
 		try {
-			BufferedReader br = new BufferedReader(
-					new FileReader(file));
+			br = new BufferedReader( new FileReader(file));
 			String line;
-			while ( (line = br.readLine()) != null) {
+			while ( (line = br.readLine()) != null) 
+			{
 				sb.append(line).append("\n");
 			}
-			br.close();
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
+		} 
+		catch (IOException e) 
+		{
+			log.error(e.getMessage(), e);
+		}
+		finally
+		{
+			close(br);
 		}
 		return sb.toString();
 	}
 
+	// TODO remove as not in use?
 	public static void writeStringToFile(File file, String contents) {
+		BufferedWriter bw = null;
 		try {
-			if (!file.exists()) {
+			if (!file.exists()) 
+			{
 				file.createNewFile();
 			}
-			BufferedWriter bw;
+
 			bw = new BufferedWriter(new FileWriter(file));
 			bw.write(contents);
-			bw.close();
-		} catch (IOException e) {
-			e.printStackTrace();
+		} 
+		catch (IOException e) 
+		{
+			log.error(e.getMessage(), e);
+		} 
+		finally
+		{
+			close(bw);
 		}
 
 	}
 
-	public static void replaceAll(File file, String input, String output) {
+	// TODO remove as not in use?
+	public static void replaceAll(File file, String input, String output)
+	{
 		String fileText = getFileAsString(file);
 		StringBuilder sb = new StringBuilder(fileText);
 		int index = -1;
 		int length = input.length();
-		while ( (index = sb.indexOf(input)) != -1 ) {
+		while ( (index = sb.indexOf(input)) != -1 )
+		{
 			sb.replace(index, index + length, output);
 		}
-		BufferedWriter bw;
+		BufferedWriter bw = null;
 		try {
 			bw = new BufferedWriter(
 					new FileWriter(file));
 			bw.write(sb.toString());
-			bw.close();
-		} catch (IOException e) {
-			e.printStackTrace();
+		} 
+		catch (IOException e) 
+		{
+			log.error(e.getMessage(), e);
+		}
+		finally
+		{
+			close(bw);
+		}
+	}
+	
+	/**
+	 * Closes a closeable and logs exceptions
+	 * @param closeable
+	 */
+	public static void close(Closeable closeable)
+	{
+		if(closeable != null)
+		{
+			try 
+			{
+				closeable.close();
+			} 
+			catch (IOException e) 
+			{
+				log.warn(e.getMessage());
+			}
 		}
-
 	}
 
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
Tue Nov 17 23:06:02 2009
@@ -30,7 +30,6 @@
 /**
  * This class is used by the velocity templates.
  */
-
 public class ParserUtil {
 
 	private CodeGenConfig config;
@@ -78,10 +77,11 @@
 	 * uses this information to generate the neccessary import expression.
 	 */
 	public boolean hasBigDecimalField(DBTable t) {
-		for (DBColumn c : t.getColumns())
+		
+		for (DBColumn c : t.getColumns()){
 			if (getJavaType(c).equalsIgnoreCase("BigDecimal"))
 				return true;
-
+		}
 		return false;
 	}
 
@@ -92,9 +92,10 @@
 	public boolean hasDateField(DBTable t) {
 
 		for (DBColumn c : t.getColumns())
+		{
 			if (getJavaType(c).equalsIgnoreCase("Date"))
 				return true;
-
+		}
 		return false;
 	}
 
@@ -169,7 +170,8 @@
 		StringBuilder sb = new StringBuilder();
 		sb.append(Character.toUpperCase(name.charAt(0)));
 		boolean upperCase = false;
-		for (int i = 1; i &lt; name.length(); i++) {
+		for (int i = 1; i &lt; name.length(); i++) 
+		{
 			char c = name.charAt(i);
 			if (c == '_') {
 				upperCase = true;

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java?rev=881610&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/DBUtilTest.java
Tue Nov 17 23:06:02 2009
@@ -0,0 +1,36 @@
+package org.apache.empire.db.codegen.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class DBUtilTest {
+
+	@Test
+	public void testCloseResultSet() throws SQLException {
+		// null
+		Log log = Mockito.mock(Log.class);
+		boolean succes = DBUtil.close(null, log);
+		assertTrue(succes);
+		
+		// normal
+		ResultSet rs = Mockito.mock(ResultSet.class);
+		boolean succes2 = DBUtil.close(rs, log);
+		assertTrue(succes2);
+		
+		// exception
+		ResultSet rsFail = Mockito.mock(ResultSet.class);
+		Exception exception = new SQLException("test");
+		Mockito.doThrow(exception).when(rsFail).close();
+		boolean succes3 = DBUtil.close(rsFail, log);
+		assertFalse(succes3);
+		Mockito.verify(log).error("The resultset could not bel closed!", exception);
+	}
+
+}

Added: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java?rev=881610&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/util/FileUtilsTest.java
Tue Nov 17 23:06:02 2009
@@ -0,0 +1,45 @@
+package org.apache.empire.db.codegen.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FileUtilsTest {
+	
+	private File testParent;
+
+	@Before
+	public void createTestFolder(){
+		testParent = new File("target/testparent");
+		cleanup();
+		boolean success = testParent.mkdirs();
+		assertTrue("could not create test file",success);
+	}
+	
+	@After
+	public void cleanup(){
+		if(testParent.exists()){
+			boolean success = testParent.delete();
+			assertTrue(success);
+		}
+	}
+	
+	@Test
+	public void testCleanDirectory() {
+		File testChildren = new File(testParent, "this/is/a/test");
+		boolean success = testChildren.mkdirs();
+		assertTrue("Could not create test folder", success);
+		FileUtils.cleanDirectory(testParent);
+		assertTrue("Parent was deleted", testParent.exists());
+		assertEquals(0, testParent.list().length);
+		
+		// TODO test with files
+		// TODO test fail if file in use
+	}
+
+}

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=881610&amp;r1=881609&amp;r2=881610&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Tue Nov 17 23:06:02 2009
@@ -263,6 +263,11 @@
 				&lt;artifactId&gt;junit&lt;/artifactId&gt;
 				&lt;version&gt;4.6&lt;/version&gt;
 			&lt;/dependency&gt; 
+			&lt;dependency&gt;
+				&lt;groupId&gt;org.mockito&lt;/groupId&gt;
+				&lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
+				&lt;version&gt;1.8.0&lt;/version&gt;
+			&lt;/dependency&gt; 
 		&lt;/dependencies&gt;
 	&lt;/dependencyManagement&gt;
 	&lt;dependencies&gt;
@@ -282,6 +287,11 @@
 			&lt;artifactId&gt;junit&lt;/artifactId&gt;
 			&lt;scope&gt;test&lt;/scope&gt;
 		&lt;/dependency&gt;
+		&lt;dependency&gt;
+			&lt;groupId&gt;org.mockito&lt;/groupId&gt;
+			&lt;artifactId&gt;mockito-core&lt;/artifactId&gt;
+			&lt;scope&gt;test&lt;/scope&gt;
+		&lt;/dependency&gt;
 	&lt;/dependencies&gt;
 
 	&lt;build&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r881552 - /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091117215158.279F123888D8@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091117215158-279F123888D8@eris-apache-org%3e</id>
<updated>2009-11-17T21:51:58Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Nov 17 21:51:57 2009
New Revision: 881552

URL: http://svn.apache.org/viewvc?rev=881552&amp;view=rev
Log:
EMPIREDB-52 - code submitted by Benjamin (codegen-0.4.patch of Nov.14)

Removed:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r881544 - in /incubator/empire-db/trunk/empire-db-codegen: ./ src/main/java/org/apache/empire/db/codegen/ src/main/java/org/apache/empire/db/codegen/types/ src/main/java/org/apache/empire/db/codegen/util/ src/main/resources/templates/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091117214503.F3E162388989@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091117214503-F3E162388989@eris-apache-org%3e</id>
<updated>2009-11-17T21:45:03Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Nov 17 21:45:03 2009
New Revision: 881544

URL: http://svn.apache.org/viewvc?rev=881544&amp;view=rev
Log:
EMPIREDB-52 - code submitted by Benjamin (codegen-0.4.patch of Nov.14)

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
Removed:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
Modified:
    incubator/empire-db/trunk/empire-db-codegen/config.xml
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm

Modified: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Tue Nov 17 21:45:03 2009
@@ -42,6 +42,7 @@
 		&lt;viewBaseName&gt;SampleView&lt;/viewBaseName&gt;
 		&lt;recordBaseName&gt;SampleRecord&lt;/recordBaseName&gt;
 		&lt;tableClassPrefix&gt;T&lt;/tableClassPrefix&gt;
+		&lt;tableClassSuffix&gt;Table&lt;/tableClassSuffix&gt;
 		&lt;viewClassPrefix&gt;V&lt;/viewClassPrefix&gt;
 		&lt;nestTables&gt;True&lt;/nestTables&gt;
 		&lt;nestViews&gt;False&lt;/nestViews&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Tue Nov 17 21:45:03 2009
@@ -28,9 +28,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.empire.commons.ErrorObject;
-import org.apache.empire.db.codegen.types.Database;
-import org.apache.empire.db.codegen.types.Table;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
 import org.apache.empire.db.codegen.util.FileUtils;
+import org.apache.empire.db.codegen.util.ParserUtil;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
@@ -126,8 +127,18 @@
 			log.info("CreateRecordProperties="
 					+ config.isCreateRecordProperties());
 
+			if (config.getTableClassPrefix() == null)
+				config.setTableClassPrefix("");
+
+			if (config.getTableClassSuffix() == null)
+				config.setTableClassSuffix("");
+
 			CodeGen codeGen = new CodeGen();
-			codeGen.generateCode(conn, config);
+			// create the database in the memory
+			DBDatabase db = codeGen.parseDataModel(conn, config);
+
+			// create the source-code for that database
+			codeGen.generateCodeFiles(db, config);
 
 			log.info("Code generation completed sucessfully!");
 
@@ -184,27 +195,18 @@
 		}
 	}
 
-	/**
-	 * Generates the source code for the persistence layer.
-	 */
-	public void generateCode(Connection conn, CodeGenConfig config) {
+	public DBDatabase parseDataModel(Connection conn, CodeGenConfig config) {
+		this.config = config;
+		CodeGenParser cgp = new CodeGenParser(conn, config);
+		DBDatabase memoryDB = cgp.getDb();
+		return memoryDB;
+	}
 
+	public void generateCodeFiles(DBDatabase db, CodeGenConfig config) {
 		this.config = config;
-		String packageName = config.getPackageName();
-		String targetFolder = config.getTargetFolder();
-		String dbLockingCol = config.getTimestampColumn();
-		
-		// passing an empty string my
-		String dbCatalog = config.getDbCatalog();
-		String dbSchema = config.getDbSchema();
-		String dbTablePattern = config.getDbTablePattern();
-		dbTablePattern=dbTablePattern==""?dbTablePattern:null;
-
-		Database db = new Database(conn, dbSchema, dbCatalog, dbTablePattern);
-		db.populateTableMetaData(dbLockingCol);
-		
+
 		// Prepare directories for generated source files
-		this.initDirectories(targetFolder, packageName);
+		this.initDirectories(config.getTargetFolder(), config.getPackageName());
 
 		// Create the DB class
 		this.createDatabaseClass(db);
@@ -214,9 +216,8 @@
 
 		// Create base record class
 		this.createBaseRecordClass(db);
-
 		// Create table classes, record interfaces and record classes
-		for (Table table : db.getTables()) {
+		for (DBTable table : db.getTables()) {
 			this.createTableClass(db, table);
 			this.createRecordClass(db, table);
 		}
@@ -248,9 +249,12 @@
 		this.recordDir.mkdir();
 	}
 
-	private void createDatabaseClass(Database db) {
+	private void createDatabaseClass(DBDatabase db) {
+		ParserUtil pUtil = new ParserUtil(config);
 		File file = new File(baseDir, config.getDbClassName() + ".java");
 		VelocityContext context = new VelocityContext();
+		context.put("parser", pUtil);
+		context.put("tableClassSuffix", config.getTableClassSuffix());
 		context.put("basePackageName", config.getPackageName());
 		context.put("dbClassName", config.getDbClassName());
 		context.put("tableSubPackage", "tables");
@@ -258,7 +262,7 @@
 		writeFile(file, TEMPLATE_PATH + "/" + DATABASE_TEMPLATE, context);
 	}
 
-	private void createBaseTableClass(Database db) {
+	private void createBaseTableClass(DBDatabase db) {
 		File file = new File(tableDir, config.getTableBaseName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("tablePackageName", config.getPackageName() + ".tables");
@@ -266,9 +270,12 @@
 		writeFile(file, TEMPLATE_PATH + "/" + BASE_TABLE_TEMPLATE, context);
 	}
 
-	private void createTableClass(Database db, Table table) {
-		File file = new File(tableDir, table.getClassName() + ".java");
+	private void createTableClass(DBDatabase db, DBTable table) {
+		ParserUtil pUtil = new ParserUtil(config);
+		File file = new File(tableDir, pUtil.getTableClassName(table.getName())
+				+ ".java");
 		VelocityContext context = new VelocityContext();
+		context.put("parser", pUtil);
 		context.put("basePackageName", config.getPackageName());
 		context.put("tablePackageName", config.getPackageName() + ".tables");
 		context.put("baseTableClassName", config.getTableBaseName());
@@ -277,7 +284,7 @@
 		writeFile(file, TEMPLATE_PATH + "/" + TABLE_TEMPLATE, context);
 	}
 
-	private void createBaseRecordClass(Database db) {
+	private void createBaseRecordClass(DBDatabase db) {
 		File file = new File(recordDir, config.getRecordBaseName() + ".java");
 		VelocityContext context = new VelocityContext();
 		context.put("baseRecordClassName", config.getRecordBaseName());
@@ -288,16 +295,22 @@
 		writeFile(file, TEMPLATE_PATH + "/" + BASE_RECORD_TEMPLATE, context);
 	}
 
-	private void createRecordClass(Database db, Table table) {
-		File file = new File(recordDir, table.getRecordClassName() + ".java");
+	private void createRecordClass(DBDatabase db, DBTable table) {
+		ParserUtil pUtil = new ParserUtil(config);
+		File file = new File(recordDir, pUtil.getRecordClassName(table
+				.getName())
+				+ ".java");
 		VelocityContext context = new VelocityContext();
+		context.put("parser", pUtil);
 		context.put("basePackageName", config.getPackageName());
 		context.put("tablePackageName", config.getPackageName() + ".tables");
 		context.put("recordPackageName", config.getPackageName() + ".records");
 		context.put("baseRecordClassName", config.getRecordBaseName());
 		context.put("dbClassName", config.getDbClassName());
-		context.put("createRecordProperties", config.isCreateRecordProperties());
-		
+		context
+				.put("createRecordProperties", config
+						.isCreateRecordProperties());
+
 		context.put("table", table);
 		writeFile(file, TEMPLATE_PATH + "/" + RECORD_TEMPLATE, context);
 	}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
Tue Nov 17 21:45:03 2009
@@ -92,6 +92,19 @@
      * Where XX is the prefix.
      */
     private String tableClassPrefix = "T";
+    
+    /**
+     * Suffix used for generating table class names.&lt;br/&gt; 
+     * The Table name is appended before the suffix starting with captial letter followed
by lower case letters.&lt;br/&gt;
+     * Occurrence an of underscore indicates a new word which will again start with a capital
letter.&lt;br/&gt;
+     * e.g.&lt;br/&gt;
+     * &lt;ul&gt;
+     *  &lt;li&gt;Table "names" -&gt; Class "NamesTable"&lt;/li&gt;
+     *  &lt;li&gt;Table "flight_bookings" -&gt; Class "FlightBookingsTable"&lt;/li&gt;
+     * &lt;/ul&gt;
+     * Where "Table" is the suffix.
+     */
+    private String tableClassSuffix = "Table";
     /**
      * Prefix used for generating view class names.&lt;br/&gt; 
      * The Table name is appended after the prefix starting with captial letter followed
by lower case letters.&lt;br/&gt;
@@ -288,6 +301,16 @@
     {
         this.tableClassPrefix = tableClassPrefix;
     }
+    
+    public String getTableClassSuffix()
+    {
+        return tableClassSuffix;
+    }
+
+    public void setTableClassSuffix(String tableClassSuffix)
+    {
+        this.tableClassSuffix = tableClassSuffix;
+    }
 
     public String getViewClassPrefix()
     {

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java?rev=881544&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Tue Nov 17 21:45:03 2009
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.empire.db.codegen;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBTableColumn;
+import org.apache.empire.db.codegen.util.DBUtil;
+
+/**
+ * This class is used to create a in memory DBDatabase of a given SQLConnection
+ * and Configuration
+ * 
+ * @author Benjamin Venditti
+ */
+public class CodeGenParser {
+
+	public static class InMemoryDatabase extends DBDatabase {
+	}
+
+	private static final Log log = LogFactory.getLog(CodeGenParser.class);
+	private DatabaseMetaData dbMeta;
+	private Connection con;
+	private CodeGenConfig config;
+	private DBDatabase db;
+
+	/**
+	 * create a empty in memory Database and populates it
+	 */
+	public CodeGenParser(Connection conn, CodeGenConfig config) {
+
+		this.con = conn;
+		this.db = new InMemoryDatabase();
+		this.config = config;
+		try {
+			this.dbMeta = con.getMetaData();
+			populateDatabase();
+		} catch (SQLException e) {
+			throw new RuntimeException("Unable to read database metadata!", e);
+		}
+	}
+
+	/**
+	 * returns the populated DBDatabase
+	 */
+	public DBDatabase getDb() {
+		return db;
+	}
+
+	// ----------- private members
+
+	/**
+	 * queries the metadata of the database for tables and populates the
+	 * database with those
+	 */
+	private void populateDatabase() {
+		ResultSet tables = null;
+		try {
+			tables = dbMeta.getTables(config.getDbCatalog(), config
+					.getDbSchema(), config.getDbTablePattern(),
+					new String[] { "TABLE" });
+			while (tables.next()) {
+				String tableName = tables.getString("TABLE_NAME");
+				// Ignore system tables containing a '$' symbol (required for
+				// Oracle!)
+				if (tableName.indexOf('$') &gt;= 0) {
+					log.info("Ignoring system table " + tableName);
+					continue;
+				}
+				// end system table exclusion
+				log.info("Adding table " + tableName);
+				addTable(tableName);
+			}
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		} finally {
+			DBUtil.closeResultSet(tables, log);
+		}
+	}
+
+	/**
+	 * queries the metadata for columns of a specific table and populates the
+	 * table with that information
+	 */
+	private void addTable(String name) {
+		DBTable t = new DBTable(name.toUpperCase(), db);
+		List&lt;String&gt; pkCols = this.findPkColumns(name);
+		String lockColName = config.getTimestampColumn();
+		DBColumn[] keys = new DBColumn[pkCols.size()];
+		int i = 0;
+		ResultSet rs = null;
+		try {
+			rs = dbMeta.getColumns(config.getDbCatalog(), config.getDbSchema(),
+					name, null);
+			while (rs.next()) {
+				DBTableColumn c = addColumn(t, rs);
+				// check if it is a KeyColumn
+				if (pkCols.contains(c.getName()))
+					keys[i++] = c;
+
+				// check if it is the Timestamp/Locking Column
+				if (lockColName != null
+						&amp;&amp; c.getName().toUpperCase().equals(
+								lockColName.toUpperCase()))
+					t.setTimestampColumn(c);
+			}
+			t.setPrimaryKey(keys);
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		} finally {
+			DBUtil.closeResultSet(rs, log);
+		}
+	}
+
+	/**
+	 * Returns a list of column names that define the primarykey of the given
+	 * table.
+	 */
+	private List&lt;String&gt; findPkColumns(String tableName) {
+		List&lt;String&gt; cols = new ArrayList&lt;String&gt;();
+		ResultSet rs = null;
+		try {
+			rs = dbMeta.getPrimaryKeys(config.getDbCatalog(), config
+					.getDbSchema(), tableName);
+			while (rs.next()) {
+				cols.add(rs.getString("COLUMN_NAME").toUpperCase());
+			}
+
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		} finally {
+			DBUtil.closeResultSet(rs, log);
+		}
+		return cols;
+	}
+
+	/**
+	 * Adds DBColumn object to the given DBTable. The DBColumn is created from
+	 * the given ResultSet
+	 */
+	private DBTableColumn addColumn(DBTable t, ResultSet rs)
+			throws SQLException {
+		String name = rs.getString("COLUMN_NAME");
+		DataType empireType = getEmpireDataType(rs.getInt("DATA_TYPE"));
+		int colSize = rs.getInt("COLUMN_SIZE");
+		boolean required = false;
+		String defaultValue = rs.getString("COLUMN_DEF");
+		if (rs.getString("IS_NULLABLE").equalsIgnoreCase("NO"))
+			required = true;
+
+		log.info("\tCOLUMN:\t" + name);
+		return t.addColumn(name, empireType, colSize, required, defaultValue);
+	}
+
+	/**
+	 * converts a SQL DataType to a EmpireDataType
+	 */
+	private DataType getEmpireDataType(int sqlType) {
+		DataType empireType = DataType.UNKNOWN;
+		switch (sqlType) {
+		case Types.INTEGER:
+		case Types.SMALLINT:
+		case Types.TINYINT:
+		case Types.BIGINT:
+			empireType = DataType.INTEGER;
+			break;
+		case Types.VARCHAR:
+			empireType = DataType.TEXT;
+			break;
+		case Types.DATE:
+			empireType = DataType.DATE;
+			break;
+		case Types.TIMESTAMP:
+		case Types.TIME:
+			empireType = DataType.DATETIME;
+			break;
+		case Types.CHAR:
+			empireType = DataType.CHAR;
+			break;
+		case Types.DOUBLE:
+		case Types.FLOAT:
+		case Types.REAL:
+			empireType = DataType.DOUBLE;
+			break;
+		case Types.DECIMAL:
+		case Types.NUMERIC:
+			empireType = DataType.DECIMAL;
+			break;
+		case Types.BIT:
+		case Types.BOOLEAN:
+			empireType = DataType.BOOL;
+			break;
+		case Types.CLOB:
+		case Types.LONGVARCHAR:
+			empireType = DataType.CLOB;
+			break;
+		case Types.BINARY:
+		case Types.VARBINARY:
+		case Types.LONGVARBINARY:
+		case Types.BLOB:
+			empireType = DataType.BLOB;
+			break;
+		default:
+			empireType = DataType.UNKNOWN;
+			log.warn("SQL column type " + sqlType + " not supported.");
+		}
+		log.info("Mapping date type " + String.valueOf(sqlType) + " to "
+				+ empireType);
+		return empireType;
+	}
+
+}

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java?rev=881544&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
(added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ParserUtil.java
Tue Nov 17 21:45:03 2009
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.empire.db.codegen.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBTableColumn;
+import org.apache.empire.db.codegen.CodeGenConfig;
+
+/**
+ * This class is used by the velocity templates.
+ */
+
+public class ParserUtil {
+
+	private CodeGenConfig config;
+	private static final Log log = LogFactory.getLog(ParserUtil.class);
+
+	public ParserUtil(CodeGenConfig config) {
+
+		this.config = config;
+	}
+
+	/**
+	 * Returns the java table class name for a given table name.
+	 */
+	public String getTableClassName(String tableName) {
+		return config.getTableClassPrefix() + javaClassName(tableName)
+				+ config.getTableClassSuffix();
+	}
+
+	/**
+	 * Returns the java record class name for a given table name.
+	 */
+	public String getRecordClassName(String tableName) {
+		return javaClassName(tableName) + "Record";
+	}
+
+	/**
+	 * Returns the "getter" name for a given DBColumn.
+	 */
+	public String getAccessorName(DBColumn c) {
+
+		return deriveAccessorName(c.getName(), getJavaType(c).equalsIgnoreCase(
+				"Boolean"));
+	}
+
+	/**
+	 * Returns the "setter" name for a given DBColumn
+	 */
+	public String getMutatorName(DBColumn c) {
+
+		return deriveMutatorName(c.getName());
+	}
+
+	/**
+	 * Returns whether the given table uses BigDecimal class or not. Velocity
+	 * uses this information to generate the neccessary import expression.
+	 */
+	public boolean hasBigDecimalField(DBTable t) {
+		for (DBColumn c : t.getColumns())
+			if (getJavaType(c).equalsIgnoreCase("BigDecimal"))
+				return true;
+
+		return false;
+	}
+
+	/**
+	 * Returns whether the given table uses Date class or not. Velocity
+	 * uses this information to generate the neccessary import expression.
+	 */
+	public boolean hasDateField(DBTable t) {
+
+		for (DBColumn c : t.getColumns())
+			if (getJavaType(c).equalsIgnoreCase("Date"))
+				return true;
+
+		return false;
+	}
+
+	/**
+	 * Returns whether the given table has a locking column or not.
+	 */
+	public boolean hasLockingColumn(DBTable t) {
+
+		return t.getTimestampColumn() != null;
+	}
+
+	/**
+	 * Returns the corresponding java type of the given empire DataType.
+	 */
+	public String getJavaType(DBColumn c) {
+		DataType type = getDataType(c);
+		if (type.equals(DataType.INTEGER))
+			return "Long";
+		else if (type.equals(DataType.TEXT))
+			return "String";
+		else if (type.equals(DataType.DATE))
+			return "Date";
+		else if (type.equals(DataType.DATETIME))
+			return "Date";
+		else if (type.equals(DataType.CHAR))
+			return "String";
+		else if (type.equals(DataType.DOUBLE))
+			return "Double";
+		else if (type.equals(DataType.DECIMAL))
+			return "BigDecimal";
+		else if (type.equals(DataType.BOOL))
+			return "Boolean";
+		else if (type.equals(DataType.CLOB))
+			return "String";
+		else if (type.equals(DataType.BLOB))
+			return "Byte[]";
+		else if (type.equals(DataType.UNKNOWN))
+			return "Byte[]";
+		else {
+			log.warn("SQL column type " + type.toString() + " not supported.");
+			return "Byte[]";
+		}
+	}
+
+	/**
+	 * Returns the empire DataType of the given DBColumn.
+	 */
+	public DataType getDataType(DBColumn c) {
+		DBTableColumn dbC = (DBTableColumn) c;
+		return dbC.getDataType();
+	}
+
+	/**
+	 * Returns the default value of the given DBColumn.
+	 */
+	public String getDefaultValue(DBColumn c) {
+		DBTableColumn dbC = (DBTableColumn) c;
+		Object val = dbC.getDefaultValue();
+		if (val == null)
+			return "null";
+
+		return "\"" + val + "\"";
+	}
+
+	// ----------- private members
+	
+	
+	/**
+	 * Derives a java class name from a database table name.
+	 */
+	private static String javaClassName(String name) {
+		StringBuilder sb = new StringBuilder();
+		sb.append(Character.toUpperCase(name.charAt(0)));
+		boolean upperCase = false;
+		for (int i = 1; i &lt; name.length(); i++) {
+			char c = name.charAt(i);
+			if (c == '_') {
+				upperCase = true;
+				continue;
+			}
+			if (upperCase)
+				sb.append(Character.toUpperCase(c));
+			else
+				sb.append(Character.toLowerCase(c));
+			upperCase = false;
+		}
+		return sb.toString();
+	}
+
+	/**
+	 * Derives the accessor method name based on the attribute name.
+	 * 
+	 * @param attribute
+	 * @param isBoolean
+	 * @return
+	 */
+	private static String deriveAccessorName(String attribute, boolean isBoolean) {
+		StringBuilder sb = new StringBuilder();
+		if (isBoolean)
+			sb.append("is");
+		else
+			sb.append("get");
+		sb.append(Character.toUpperCase(attribute.charAt(0)));
+		sb.append(attribute.substring(1));
+		return sb.toString();
+	}
+
+	/**
+	 * Derives the mutator method name based on the attribute name.
+	 * 
+	 * @param attribute
+	 * @return
+	 */
+	private static String deriveMutatorName(String attribute) {
+		StringBuilder sb = new StringBuilder();
+		sb.append("set");
+		sb.append(Character.toUpperCase(attribute.charAt(0)));
+		sb.append(attribute.substring(1));
+		return sb.toString();
+	}
+
+}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm Tue
Nov 17 21:45:03 2009
@@ -36,7 +36,8 @@
 	private static final long serialVersionUID = 1L;
 
 #foreach($table in $database.tables)
-	public final $table.className T_$table.tableName = new ${table.className}(this);
+	#set($tblClass=$parser.getTableClassName($table.name))
+	public final $tblClass T_${table.name} = new $tblClass(this);
 #end
 	
 	/**

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm Tue
Nov 17 21:45:03 2009
@@ -18,13 +18,17 @@
  *#
 package ${recordPackageName};
 
-#if ($table.hasBigDecimalField())
+#if ($parser.hasBigDecimalField($table))
 import java.math.BigDecimal;
 #end
 
+#if ($parser.hasDateField($table))
+import java.util.Date;
+#end
+
 import ${basePackageName}.${dbClassName};
 import ${recordPackageName}.${baseRecordClassName};
-import ${tablePackageName}.${table.className};
+import ${tablePackageName}.$parser.getTableClassName($table.name);
 
 /**
  * Auto-generated class that represents one record (or row) of data from a
@@ -37,20 +41,20 @@
  * This class provides protected method that subclasses should use to provide
  * access to related records.
  */
-public class ${table.recordClassName} extends ${baseRecordClassName}&lt;${table.className}&gt;
{
-	public ${table.recordClassName}() {
-		super(${dbClassName}.get().T_${table.tableName});
+public class $parser.getRecordClassName($table.name) extends ${baseRecordClassName}&lt;$parser.getTableClassName($table.name)&gt;
{
+	public $parser.getRecordClassName($table.name)() {
+		super(${dbClassName}.get().T_${table.name});
 	}
 	
 #if($createRecordProperties == true)
 	// Access methods for all attributes
 #foreach($col in $table.columns)
-	public ${col.javaTypeString} ${col.javaAccessorName}() {
-		${col.originalJavaTypeString} ${col.javaName} = (${col.originalJavaTypeString})super.getValue(getDbTable().C_${col.name});
-		return ${col.returnExpression};
+
+	public $parser.getJavaType($col) $parser.getAccessorName($col)() {
+		return ($parser.getJavaType($col))super.getValue(getDbTable().C_${col.name});
 	}
-	public void ${col.javaMutatorName}(${col.javaTypeString} ${col.javaName}) {
-		super.setValue(getDbTable().C_${col.name}, ${col.setExpression});
+	public void $parser.getMutatorName($col)($parser.getJavaType($col) val) {
+		super.setValue(getDbTable().C_${col.name}, val);
 	}
 #end
 #end

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm?rev=881544&amp;r1=881543&amp;r2=881544&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm Tue
Nov 17 21:45:03 2009
@@ -26,7 +26,7 @@
 
 import $basePackageName.${dbClassName};
 
-public class ${table.className} extends ${baseTableClassName} {
+public class $parser.getTableClassName($table.name) extends ${baseTableClassName} {
 	// Primary key column
 	private List&lt;DBTableColumn&gt; keyColumns= new ArrayList&lt;DBTableColumn&gt;();
 	
@@ -35,26 +35,24 @@
 	public final DBTableColumn C_${col.name};
 #end
 	
-	public ${table.className}(${dbClassName} db) {
-		super("${table.tableName}", db);
+	public $parser.getTableClassName($table.name)(${dbClassName} db) {
+		super("$parser.getTableClassName($table.name)", db);
 		
 		// all columns
 #foreach ($col in $table.columns)
-		C_${col.name} = super.addColumn("${col.name}", DataType.${col.empireType}, ${col.colSize},
${col.required}, ${col.defaultValue});
+		C_${col.name} = super.addColumn("${col.name}", DataType.${parser.getDataType($col)}, ${col.size},
${col.isRequired()}, ${parser.getDefaultValue($col)});
 #end
 
 
 		// configure primary columns
-#foreach ($col in $table.columns)
-#if($col.primaryColumn == true)
+#foreach ($col in $table.keyColumns)
     	keyColumns.add(C_${col.name});
 #end
-#end
 		super.setPrimaryKey((DBTableColumn[]) keyColumns.toArray());
 		
 		// Optimistic locking column
-#if($table.hasLockColumn == true)
-		super.setTimestampColumn(C_${table.lockColumn.name});
+#if($parser.hasLockingColumn($table) == true)
+		super.setTimestampColumn(C_${table.getTimestampColumn().name});
 #else
 		/*no locking column specified*/
 #end




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r880966 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091116212834.B8C732388901@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091116212834-B8C732388901@eris-apache-org%3e</id>
<updated>2009-11-16T21:28:34Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Mon Nov 16 21:28:34 2009
New Revision: 880966

URL: http://svn.apache.org/viewvc?rev=880966&amp;view=rev
Log:
fixing all maven plugin versions (discovered by trying to build using maven 3.0 alpha 3)

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=880966&amp;r1=880965&amp;r2=880966&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Mon Nov 16 21:28:34 2009
@@ -22,6 +22,7 @@
 		&lt;groupId&gt;org.apache&lt;/groupId&gt;
 		&lt;artifactId&gt;apache&lt;/artifactId&gt;
 		&lt;version&gt;6&lt;/version&gt;
+		&lt;!-- TODO switch to apache parent 7 (see mail) --&gt;
 	&lt;/parent&gt;
 	
 	&lt;groupId&gt;org.apache.empire-db&lt;/groupId&gt;
@@ -416,6 +417,11 @@
 						&lt;/rules&gt;
 					&lt;/configuration&gt;
 				&lt;/plugin&gt;
+				&lt;plugin&gt;
+					&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+					&lt;artifactId&gt;maven-eclipse-plugin&lt;/artifactId&gt;
+					&lt;version&gt;2.7&lt;/version&gt;
+				&lt;/plugin&gt;
 			&lt;/plugins&gt;
 		&lt;/pluginManagement&gt;
 	&lt;/build&gt;
@@ -424,6 +430,7 @@
 			&lt;plugin&gt;
 		        &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
 		        &lt;artifactId&gt;rat-maven-plugin&lt;/artifactId&gt;
+		        &lt;version&gt;1.0-alpha-3&lt;/version&gt;
 		    &lt;/plugin&gt;
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
@@ -451,10 +458,12 @@
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
 				&lt;artifactId&gt;jdepend-maven-plugin&lt;/artifactId&gt;
+				&lt;version&gt;2.0-beta-2&lt;/version&gt;
 			&lt;/plugin&gt;
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
 				&lt;artifactId&gt;cobertura-maven-plugin&lt;/artifactId&gt;
+				&lt;version&gt;2.3&lt;/version&gt;
 				&lt;configuration&gt;
 					&lt;formats&gt;
 						&lt;format&gt;html&lt;/format&gt;
@@ -465,14 +474,17 @@
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 				&lt;artifactId&gt;maven-jxr-plugin&lt;/artifactId&gt;
+				&lt;version&gt;2.1&lt;/version&gt;
 			&lt;/plugin&gt;
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 				&lt;artifactId&gt;maven-javadoc-plugin&lt;/artifactId&gt;
+				&lt;version&gt;2.6.1&lt;/version&gt;
 			&lt;/plugin&gt;
 			&lt;plugin&gt;
 				&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
 				&lt;artifactId&gt;maven-changelog-plugin&lt;/artifactId&gt;
+				&lt;version&gt;2.1&lt;/version&gt;
 			&lt;/plugin&gt;
 		&lt;/plugins&gt;
 	&lt;/reporting&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Updated: (EMPIREDB-52) CodeGenerator project setup</title>
<author><name>&quot;Benjamin Venditti (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c1208726424.1258208319599.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c1208726424-1258208319599-JavaMail-jira@brutus%3e</id>
<updated>2009-11-14T14:18:39Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-52?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benjamin Venditti updated EMPIREDB-52:
--------------------------------------

    Attachment: codegen-0.4.patch

Hi there,

I have created a new patch that will get rid of the additional Database, Table and Column
bean classes.
The codegen now uses the empire DBDatabase, DBTable and DBColumn classes instead.

The patch contains the following changes:
 modifications:
  - CodeGen.java
  - CodeGenConfig.java
  - config.xml
  - Database.vm
  - Record.vm
  - Table.vm

deletions:
  - package org.apache.empire.db.codegen.types
  - StringUtils.java  // partly moved to ParserUtil.java

additions:
  - CodeGenParser.java  // Used to create a empty DBDatabase and to populate that
  - ParserUtil.java              // Used by the velocity templates to get strings like accessor
name, mutator name, table class name, record class name ...

&gt; CodeGenerator project setup
&gt; ---------------------------
&gt;
&gt;                 Key: EMPIREDB-52
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-52
&gt;             Project: Empire-DB
&gt;          Issue Type: New Feature
&gt;          Components: CodeGenerator
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Rainer Döbele
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;         Attachments: codegen-0.4.patch, codegen.0.3.patch
&gt;
&gt;
&gt; The empire-db code generator is a new subproject which should be capable of generating
source code classes from an existing database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r831666 - in /incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen: CodeGen.java types/Column.java types/Database.java types/Table.java util/DBUtil.java</title>
<author><name>doebele@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091101104308.81EF123888DA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091101104308-81EF123888DA@eris-apache-org%3e</id>
<updated>2009-11-01T10:43:08Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: doebele
Date: Sun Nov  1 10:43:07 2009
New Revision: 831666

URL: http://svn.apache.org/viewvc?rev=831666&amp;view=rev
Log:
EMPIREDB-52 - Minor improvements to Benjamin's code

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=831666&amp;r1=831665&amp;r2=831666&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
Sun Nov  1 10:43:07 2009
@@ -200,7 +200,7 @@
 		String dbTablePattern = config.getDbTablePattern();
 		dbTablePattern=dbTablePattern==""?dbTablePattern:null;
 
-		Database db = new Database(conn, log, dbSchema, dbCatalog, dbTablePattern);
+		Database db = new Database(conn, dbSchema, dbCatalog, dbTablePattern);
 		db.populateTableMetaData(dbLockingCol);
 		
 		// Prepare directories for generated source files

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java?rev=831666&amp;r1=831665&amp;r2=831666&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
Sun Nov  1 10:43:07 2009
@@ -22,11 +22,15 @@
 import java.sql.SQLException;
 import java.sql.Types;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.codegen.util.StringUtils;
 
 public class Column {
-	private String name;
+    private static final Log log = LogFactory.getLog(Database.class);
+
+    private String name;
 	private int sqlType;
 	private int colSize; // max length if string, precision is numeric
 	private int decimalDigits; // max decimal digits allowed (real numbers)
@@ -145,76 +149,75 @@
 		this.javaName = StringUtils.deriveAttributeName(this.name);
 		DataType empireType = DataType.UNKNOWN;
 		switch (this.sqlType) {
-		case Types.INTEGER:
-		case Types.SMALLINT:
-		case Types.TINYINT:
-		case Types.BIGINT:
-			empireType = DataType.INTEGER;
-			empireTypeString = "DataType.INTEGER";
-			javaTypeString = "Long";
-			break;
-		case Types.VARCHAR:
-			empireType = DataType.TEXT;
-			empireTypeString = "DataType.TEXT";
-			javaTypeString = "String";
-			break;
-		case Types.DATE:
-			empireType = DataType.DATE;
-			empireTypeString = "DataType.DATE";
-			javaTypeString = "Date";
-			break;
-		case Types.TIMESTAMP:
-		case Types.TIME:
-			empireType = DataType.DATETIME;
-			empireTypeString = "DataType.DATETIME";
-			javaTypeString = "Date";
-			break;
-		case Types.CHAR:
-			empireType = DataType.CHAR;
-			empireTypeString = "DataType.CHAR";
-			javaTypeString = "String";
-			break;
-		case Types.DOUBLE:
-		case Types.FLOAT:
-		case Types.REAL:
-			empireType = DataType.DOUBLE;
-			empireTypeString = "DataType.DOUBLE";
-			javaTypeString = "Double";
-			break;
-		case Types.DECIMAL:
-		case Types.NUMERIC:
-			empireType = DataType.DECIMAL;
-			empireTypeString = "DataType.DECIMAL";
-			javaTypeString = "BigDecimal";
-			break;
-		case Types.BIT:
-		case Types.BOOLEAN:
-			empireType = DataType.BOOL;
-			empireTypeString = "DataType.BOOL";
-			javaTypeString = "Boolean";
-			break;
-		case Types.CLOB:
-		case Types.LONGVARCHAR:
-			empireType = DataType.CLOB;
-			empireTypeString = "DataType.CLOB";
-			javaTypeString = "String";
-			break;
-		case Types.BINARY:
-		case Types.VARBINARY:
-		case Types.LONGVARBINARY:
-		case Types.BLOB:
-			empireType = DataType.BLOB;
-			empireTypeString = "DataType.BLOB";
-			javaTypeString = "Byte[]";
-			break;
-		default:
-			empireType = DataType.UNKNOWN;
-			empireTypeString = "DataType.UNKNOWN";
-			javaTypeString = "Byte[]";
-			System.out.println("SQL column type " + this.sqlType
-					+ " not supported.");
+    		case Types.INTEGER:
+    		case Types.SMALLINT:
+    		case Types.TINYINT:
+    		case Types.BIGINT:
+    			empireType = DataType.INTEGER;
+    			empireTypeString = "DataType.INTEGER";
+    			javaTypeString = "Long";
+    			break;
+    		case Types.VARCHAR:
+    			empireType = DataType.TEXT;
+    			empireTypeString = "DataType.TEXT";
+    			javaTypeString = "String";
+    			break;
+    		case Types.DATE:
+    			empireType = DataType.DATE;
+    			empireTypeString = "DataType.DATE";
+    			javaTypeString = "Date";
+    			break;
+    		case Types.TIMESTAMP:
+    		case Types.TIME:
+    			empireType = DataType.DATETIME;
+    			empireTypeString = "DataType.DATETIME";
+    			javaTypeString = "Date";
+    			break;
+    		case Types.CHAR:
+    			empireType = DataType.CHAR;
+    			empireTypeString = "DataType.CHAR";
+    			javaTypeString = "String";
+    			break;
+    		case Types.DOUBLE:
+    		case Types.FLOAT:
+    		case Types.REAL:
+    			empireType = DataType.DOUBLE;
+    			empireTypeString = "DataType.DOUBLE";
+    			javaTypeString = "Double";
+    			break;
+    		case Types.DECIMAL:
+    		case Types.NUMERIC:
+    			empireType = DataType.DECIMAL;
+    			empireTypeString = "DataType.DECIMAL";
+    			javaTypeString = "BigDecimal";
+    			break;
+    		case Types.BIT:
+    		case Types.BOOLEAN:
+    			empireType = DataType.BOOL;
+    			empireTypeString = "DataType.BOOL";
+    			javaTypeString = "Boolean";
+    			break;
+    		case Types.CLOB:
+    		case Types.LONGVARCHAR:
+    			empireType = DataType.CLOB;
+    			empireTypeString = "DataType.CLOB";
+    			javaTypeString = "String";
+    			break;
+    		case Types.BINARY:
+    		case Types.VARBINARY:
+    		case Types.LONGVARBINARY:
+    		case Types.BLOB:
+    			empireType = DataType.BLOB;
+    			empireTypeString = "DataType.BLOB";
+    			javaTypeString = "Byte[]";
+    			break;
+    		default:
+    			empireType = DataType.UNKNOWN;
+    			empireTypeString = "DataType.UNKNOWN";
+    			javaTypeString = "Byte[]";
+    			log.warn("SQL column type " + this.sqlType + " not supported.");
 		}
-
+		log.info("Mapping date type " + String.valueOf(this.sqlType) + " to " + empireType);
 		return empireType;
 	}
 

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java?rev=831666&amp;r1=831665&amp;r2=831666&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
Sun Nov  1 10:43:07 2009
@@ -27,22 +27,23 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.empire.db.codegen.util.DBUtil;
 
 public class Database {
-	private DatabaseMetaData metaData;
+    private static final Log log = LogFactory.getLog(Database.class);
+
+    private DatabaseMetaData metaData;
 	private String catalogName;
 	private String schemaPattern;
 	private String tablePattern;
 	private Connection con;
-	private Log log;
 
 	private Map&lt;String, Table&gt; tableMap = new HashMap&lt;String, Table&gt;();
 
-	public Database(Connection con, Log log, String schemaPattern,
+	public Database(Connection con, String schemaPattern,
 			String catalogName, String tablePattern) {
 
-		this.log = log;
 		this.con = con;
 		this.schemaPattern = schemaPattern;
 		this.catalogName = catalogName;
@@ -69,9 +70,14 @@
 					new String[] { "TABLE" });
 			while (tables.next()) {
 				String tableName = tables.getString("TABLE_NAME");
-				System.out.println("TABLE:\t" + tableName);
-				Table table = new Table(tableName, lockColName, schemaPattern, catalogName,
-						dbMeta, log);
+				// Ignore system tables containing a '$' symbol (required for Oracle!)
+				if (tableName.indexOf('$')&gt;=0) {
+	                log.info("Ignoring system table " + tableName);
+	                continue;
+				}
+				// end system table exclusion
+				log.info("Adding table " + tableName);
+				Table table = new Table(tableName, lockColName, schemaPattern, catalogName, dbMeta);
 				this.tableMap.put(tableName.toUpperCase(), table);
 			}
 		} catch (SQLException e) {

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java?rev=831666&amp;r1=831665&amp;r2=831666&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
Sun Nov  1 10:43:07 2009
@@ -27,24 +27,25 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.codegen.util.DBUtil;
 import org.apache.empire.db.codegen.util.StringUtils;
 
 public class Table {
-	private String tableName;
+    private static final Log log = LogFactory.getLog(Database.class);
+
+    private String tableName;
 	private List&lt;String&gt; pkCols;
 	private List&lt;Column&gt; columns;
 	private Column lockCol;
-	private Log log;
 	private String lockColName;
 
 	private Map&lt;String, Column&gt; columnMap = new HashMap&lt;String, Column&gt;();
 
 	public Table(String tableName,String lockColName, String schemaPattern, String catalogName,
-			DatabaseMetaData dbMeta, Log log) {
+			DatabaseMetaData dbMeta) {
 		this.tableName = tableName.toUpperCase();
-		this.log = log;
 		this.lockColName=lockColName;
 		this.createColumns(dbMeta, schemaPattern, catalogName);
 	}

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java?rev=831666&amp;r1=831665&amp;r2=831666&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
Sun Nov  1 10:43:07 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.util;
 
 import java.sql.ResultSet;




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r831663 - in /incubator/empire-db/trunk/empire-db-codegen: ./ src/main/java/org/apache/empire/db/codegen/ src/main/java/org/apache/empire/db/codegen/types/ src/main/java/org/apache/empire/db/codegen/util/ src/main/resources/templates/</title>
<author><name>doebele@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200911.mbox/%3c20091101102114.0A06723888D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091101102114-0A06723888D0@eris-apache-org%3e</id>
<updated>2009-11-01T10:21:13Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: doebele
Date: Sun Nov  1 10:21:13 2009
New Revision: 831663

URL: http://svn.apache.org/viewvc?rev=831663&amp;view=rev
Log:
EMPIREDB-52 - code submitted by Benjamin (codegen.0.3.patch of Oct.26)

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java   (with props)
Modified:
    incubator/empire-db/trunk/empire-db-codegen/config.xml
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm

Modified: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Sun Nov  1 10:21:13 2009
@@ -29,8 +29,10 @@
 		&lt;jdbcPwd&gt;DBSAMPLE&lt;/jdbcPwd&gt;
 
 		&lt;!-- Schema options --&gt;
+		&lt;dbCatalog&gt;&lt;/dbCatalog&gt;
 		&lt;dbSchema&gt;DBSAMPLE&lt;/dbSchema&gt;
-		&lt;timestampColumn&gt;&lt;/timestampColumn&gt;
+		&lt;dbTablePattern&gt;&lt;/dbTablePattern&gt;
+		&lt;timestampColumn&gt;CREATIONDATE&lt;/timestampColumn&gt;
 		
 		&lt;!-- generation options --&gt;
 		&lt;targetFolder&gt;target/generated/dbsample&lt;/targetFolder&gt;
@@ -43,7 +45,7 @@
 		&lt;viewClassPrefix&gt;V&lt;/viewClassPrefix&gt;
 		&lt;nestTables&gt;True&lt;/nestTables&gt;
 		&lt;nestViews&gt;False&lt;/nestViews&gt;
-		&lt;createRecordProperties&gt;True&lt;/createRecordProperties&gt;
+		&lt;createRecordProperties&gt;true&lt;/createRecordProperties&gt;
 	&lt;/properties&gt;
 	
 	&lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java Sun Nov  1 10:21:13 2009
@@ -39,285 +39,286 @@
 
 /**
  * This is the entry class for generating the java persistence model based on a
- * database schema.  It uses the Empire DB open-source framework to build a 
- * java persistence layer for an application.  The Apache Velocity template 
- * engine is used to create the output interfaces and classes.  
+ * database schema. It uses the Empire DB open-source framework to build a java
+ * persistence layer for an application. The Apache Velocity template engine is
+ * used to create the output interfaces and classes.
  * 
- * The Empire DB framework doesn't try to hide the underlying database and data 
- * model but instead embraces its power by modeling it within java.  The result 
+ * The Empire DB framework doesn't try to hide the underlying database and data
+ * model but instead embraces its power by modeling it within java. The result
  * is a persistence layer that uses a more "object-oriented, type safe" SQL to
- * access persistent data. 
+ * access persistent data.
  * 
- * NOTE:  THIS VERSION HAS SEVERE RESTRICTIONS:
- * 1. Only tables are currently modeled (we'll add views to a later version).
- * 2. Table indexes are not yet modeled (exception is primary key).  Again, this
- *      will be added to later editions.
- * 3. It is assumed that each table has a single INTEGER auto-generated primary
- *      key column that has the same name for all tables.
- * 4. It is assumed that each table has a single TIMESTAMP optimistic locking
- *      column that has the same name for all tables.
+ * NOTE: THIS VERSION HAS SEVERE RESTRICTIONS: 1. Only tables are currently
+ * modeled (we'll add views to a later version). 2. Table indexes are not yet
+ * modeled (exception is primary key). Again, this will be added to later
+ * editions. 3. It is assumed that each table has a single INTEGER
+ * auto-generated primary key column that has the same name for all tables. 4.
+ * It is assumed that each table has a single TIMESTAMP optimistic locking
+ * column that has the same name for all tables.
  */
 
-public class CodeGen
-{
-    private static final Log log = LogFactory.getLog(CodeGen.class);
-
-    // Templates
-    public static final String TEMPLATE_PATH     =    "src/main/resources/templates/";
-    public static final String DATABASE_TEMPLATE =    "Database.vm";
-    public static final String BASE_TABLE_TEMPLATE =  "BaseTable.vm";
-    public static final String TABLE_TEMPLATE =       "Table.vm";
-    public static final String BASE_RECORD_TEMPLATE = "BaseRecord.vm";
-    public static final String RECORD_TEMPLATE =      "Record.vm";
-    
-    // Properties
-    private CodeGenConfig config;
-    private File baseDir;
-    private File tableDir;
-    private File recordDir;
-    
-    /**
-     * Constructor
-     */
-    public CodeGen() {
-        try {
-            Velocity.init();
-        } catch(Exception e) {
-            log.fatal(e);
-            throw new RuntimeException(e);
-        }
-    }
-    
-    /**
-     * &lt;PRE&gt;
-     * This is the entry point of the Empire-DB Sample Application
-     * Please check the config.xml configuration file for Database and Connection settings.
-     * &lt;/PRE&gt;
-     * @param args arguments
-     */
-    public static void main(String[] args)
-    {
-        Connection conn = null;
-        try
-        {
-            // Init Configuration
-            CodeGenConfig config = new CodeGenConfig();
-            config.init((args.length &gt; 0 ? args[0] : "config.xml" ));
-
-            // Enable Exceptions
-            ErrorObject.setExceptionsEnabled(true);
-
-            // Get a JDBC Connection
-            conn = getJDBCConnection(config);
-            
-            // List options
-            log.info("Database connection successful. Config options are:");
-            log.info("SchemaName="+String.valueOf(config.getDbSchema()));
-            log.info("TimestampColumn="+String.valueOf(config.getTimestampColumn()));
-            log.info("TargetFolder="+config.getTargetFolder());
-            log.info("PackageName="+config.getPackageName());
-            log.info("DbClassName="+config.getDbClassName());
-            log.info("TableBaseName="+config.getTableBaseName());
-            log.info("ViewBaseName="+config.getViewBaseName());
-            log.info("RecordBaseName="+config.getRecordBaseName());
-            log.info("TableClassPrefix="+config.getTableClassPrefix());
-            log.info("ViewClassPrefi="+config.getViewClassPrefix());
-            log.info("NestTable="+config.isNestTables());
-            log.info("NestViews="+config.isNestViews());
-            log.info("CreateRecordProperties="+config.isCreateRecordProperties());
-            
-            CodeGen codeGen = new CodeGen();
-            codeGen.generateCode(conn, config);
-            
-            log.info("Code generation completed sucessfully!");
-            
-        } catch(Exception e) {
-            // Error
-            log.error(e.getMessage(), e);
-        } finally {
-            // done
-            if (conn!=null)
-                close(conn);
-        }
-    }
-    
-    /**
-     * &lt;PRE&gt;
-     * Opens and returns a JDBC-Connection.
-     * JDBC url, user and password for the connection are obained from the SampleConfig bean
-     * Please use the config.xml file to change connection params.
-     * &lt;/PRE&gt;
-     */
-    private static Connection getJDBCConnection(CodeGenConfig config)
-    {
-        // Establish a new database connection
-        Connection conn = null;
-        log.info("Connecting to Database'" + config.getJdbcURL() + "' / User=" + config.getJdbcUser());
-        try
-        {
-            // Connect to the databse
-            Class.forName(config.getJdbcClass()).newInstance();
-            conn = DriverManager.getConnection(config.getJdbcURL(), config.getJdbcUser(), config.getJdbcPwd());
-            log.info("Connected successfully");
-            // set the AutoCommit to false this session. You must commit
-            // explicitly now
-            conn.setAutoCommit(true);
-            log.info("AutoCommit is " + conn.getAutoCommit());
-
-        } catch (Exception e)
-        {
-            log.fatal("Failed to connect directly to '" + config.getJdbcURL() + "' / User=" + config.getJdbcUser(), e);
-            throw new RuntimeException(e);
-        }
-        return conn;
-    }
-    
-    /**
-     * Closes a JDBC-Connection.
-     */
-    private static void close(Connection conn)
-    {
-        log.info("Closing database connection");
-        try {
-            conn.close();
-        } catch (Exception e) {
-            log.fatal("Error closing connection", e);
-        }
-    }
-    
-    /**
-     * Generates the source code for the persistence layer.
-     */
-    public void generateCode(Connection conn, CodeGenConfig config) {
-        
-        this.config = config;
-        String packageName = config.getPackageName();
-        String targetFolder = config.getTargetFolder();
-        String dbSchema = config.getDbSchema();
-        String dbLockingCol = config.getTimestampColumn();
-        String dbPkCol = "ID"; // must be made obsolete
-        
-        Database db = new Database(conn, dbSchema);
-        db.populateTableMetaData(dbPkCol, dbLockingCol);
-        
-        // Prepare directories for generated source files
-        this.initDirectories(targetFolder, packageName);
-        
-        // Create the DB class
-        this.createDatabaseClass(db);
-    
-        // Create base table class
-        this.createBaseTableClass(db);
-
-        // Create base record class
-        this.createBaseRecordClass(db);
-        
-        // Create table classes, record interfaces and record classes
-        for (Table table: db.getTables()) {
-            this.createTableClass(db, table);
-            this.createRecordClass(db, table);
-        }
-    }
-    
-    private void initDirectories(String srcLocation, String packageName) {
-        // Create the directory structure for the generated source code.
-        File baseDir = new File(srcLocation);
-        if (!baseDir.exists()) {
-            baseDir.mkdirs();
-        }       
-        StringBuilder sb = new StringBuilder();
-        sb.append(srcLocation).append("/");
-        sb.append(packageName.replaceAll("\\.", "/"));
-        this.baseDir = new File(sb.toString());
-        if (!this.baseDir.exists()) {
-            this.baseDir.mkdirs();
-        }
-        
-        // Clean out the directory so old code is wiped out.
-        FileUtils.cleanDirectory(this.baseDir);
-        
-        // Create the table package directory
-        this.tableDir = new File(this.baseDir, "tables");
-        this.tableDir.mkdir();
-
-        // Create the record package directory
-        this.recordDir = new File(this.baseDir, "records");
-        this.recordDir.mkdir();
-    }
-    
-    private void createDatabaseClass(Database db) {
-        File file = new File(this.baseDir, db.getClassName() + ".java");
-        String packageName = config.getPackageName();
-        VelocityContext context = new VelocityContext();
-        context.put("basePackageName", packageName);       
-        context.put("tableSubPackage", "tables");
-        context.put("database", db);
-        this.writeFile(file, DATABASE_TEMPLATE, context);
-    }
-    
-    private void createBaseTableClass(Database db) {
-        File file = new File(this.tableDir,  db.getBaseTableClassName() + ".java");
-        String packageName = config.getPackageName();
-        VelocityContext context = new VelocityContext();
-        context.put("tablePackageName", packageName + ".tables");      
-        context.put("db", db);
-        this.writeFile(file, BASE_TABLE_TEMPLATE, context);
-    }
-    
-    private void createTableClass(Database db, Table table) {
-        File file = new File(this.tableDir, table.getClassName() + ".java");
-        String packageName = config.getPackageName();
-        VelocityContext context = new VelocityContext();
-        context.put("tablePackageName", packageName + ".tables");      
-        context.put("db", db);
-        context.put("table", table);
-        this.writeFile(file, TABLE_TEMPLATE, context);
-    }
-    
-    private void createBaseRecordClass(Database db) {
-        File file = new File(this.recordDir, "BaseRecord.java");
-        String packageName = config.getPackageName();
-        VelocityContext context = new VelocityContext();
-        context.put("basePackageName", packageName);       
-        context.put("tablePackageName", packageName + ".tables");      
-        context.put("recordPackage", packageName + ".records");        
-        context.put("database", db);
-        this.writeFile(file, BASE_RECORD_TEMPLATE, context);
-    }
-    
-    private void createRecordClass(Database db, Table table) {
-        File file = new File(this.recordDir, table.getRecordClassName() + ".java");
-        String packageName = config.getPackageName();
-        VelocityContext context = new VelocityContext();
-        context.put("basePackageName", packageName);       
-        context.put("tablePackageName", packageName + ".tables");      
-        context.put("recordPackage", packageName + ".records");        
-        context.put("database", db);
-        context.put("table", table);        
-        this.writeFile(file, RECORD_TEMPLATE, context);
-    }
-
-    private void writeFile(File file, String templateName, VelocityContext context) {
-        try {
-            log.info("Writing file for template: " + templateName);
-            Template template = Velocity.getTemplate(TEMPLATE_PATH + templateName);
-            Writer writer = new FileWriter(file);
-            template.merge(context, writer);
-            writer.close();
-        } catch (IOException e) {
-            log.error(e.getClass().getName()+": "+e.getMessage());
-            throw new RuntimeException(e);
-        } catch (ResourceNotFoundException e) {
-            log.error(e.getClass().getName()+": "+e.getMessage());
-            throw new RuntimeException(e);
-        } catch (ParseErrorException e) {
-            log.error(e.getClass().getName()+": "+e.getMessage());
-            throw new RuntimeException(e);
-        } catch (Exception e) {
-            log.error(e.getClass().getName()+": "+e.getMessage());
-            throw new RuntimeException(e);
-        }
-        
-    }
-    
+public class CodeGen {
+	private static final Log log = LogFactory.getLog(CodeGen.class);
+
+	// Templates
+	public static final String TEMPLATE_PATH = "src/main/resources/templates/";
+	public static final String DATABASE_TEMPLATE = "Database.vm";
+	public static final String BASE_TABLE_TEMPLATE = "BaseTable.vm";
+	public static final String TABLE_TEMPLATE = "Table.vm";
+	public static final String BASE_RECORD_TEMPLATE = "BaseRecord.vm";
+	public static final String RECORD_TEMPLATE = "Record.vm";
+
+	// Properties
+	private CodeGenConfig config;
+	private File baseDir;
+	private File tableDir;
+	private File recordDir;
+
+	/**
+	 * Constructor
+	 */
+	public CodeGen() {
+		try {
+			Velocity.init();
+		} catch (Exception e) {
+			log.fatal(e);
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * &lt;PRE&gt;
+	 * This is the entry point of the Empire-DB Sample Application
+	 * Please check the config.xml configuration file for Database and Connection settings.
+	 * &lt;/PRE&gt;
+	 * 
+	 * @param args
+	 *            arguments
+	 */
+	public static void main(String[] args) {
+		Connection conn = null;
+		try {
+			// Init Configuration
+			CodeGenConfig config = new CodeGenConfig();
+			config.init((args.length &gt; 0 ? args[0] : "config.xml"));
+
+			// Enable Exceptions
+			ErrorObject.setExceptionsEnabled(true);
+
+			// Get a JDBC Connection
+			conn = getJDBCConnection(config);
+
+			// List options
+			log.info("Database connection successful. Config options are:");
+			log.info("SchemaName=" + String.valueOf(config.getDbSchema()));
+			log.info("TimestampColumn="
+					+ String.valueOf(config.getTimestampColumn()));
+			log.info("TargetFolder=" + config.getTargetFolder());
+			log.info("PackageName=" + config.getPackageName());
+			log.info("DbClassName=" + config.getDbClassName());
+			log.info("TableBaseName=" + config.getTableBaseName());
+			log.info("ViewBaseName=" + config.getViewBaseName());
+			log.info("RecordBaseName=" + config.getRecordBaseName());
+			log.info("TableClassPrefix=" + config.getTableClassPrefix());
+			log.info("ViewClassPrefi=" + config.getViewClassPrefix());
+			log.info("NestTable=" + config.isNestTables());
+			log.info("NestViews=" + config.isNestViews());
+			log.info("CreateRecordProperties="
+					+ config.isCreateRecordProperties());
+
+			CodeGen codeGen = new CodeGen();
+			codeGen.generateCode(conn, config);
+
+			log.info("Code generation completed sucessfully!");
+
+		} catch (Exception e) {
+			// Error
+			log.error(e.getMessage(), e);
+		} finally {
+			// done
+			if (conn != null)
+				close(conn);
+		}
+	}
+
+	/**
+	 * &lt;PRE&gt;
+	 * Opens and returns a JDBC-Connection.
+	 * JDBC url, user and password for the connection are obained from the SampleConfig bean
+	 * Please use the config.xml file to change connection params.
+	 * &lt;/PRE&gt;
+	 */
+	private static Connection getJDBCConnection(CodeGenConfig config) {
+		// Establish a new database connection
+		Connection conn = null;
+		log.info("Connecting to Database'" + config.getJdbcURL() + "' / User="
+				+ config.getJdbcUser());
+		try {
+			// Connect to the databse
+			Class.forName(config.getJdbcClass()).newInstance();
+			conn = DriverManager.getConnection(config.getJdbcURL(), config
+					.getJdbcUser(), config.getJdbcPwd());
+			log.info("Connected successfully");
+			// set the AutoCommit to false this session. You must commit
+			// explicitly now
+			conn.setAutoCommit(true);
+			log.info("AutoCommit is " + conn.getAutoCommit());
+
+		} catch (Exception e) {
+			log.fatal("Failed to connect directly to '" + config.getJdbcURL()
+					+ "' / User=" + config.getJdbcUser(), e);
+			throw new RuntimeException(e);
+		}
+		return conn;
+	}
+
+	/**
+	 * Closes a JDBC-Connection.
+	 */
+	private static void close(Connection conn) {
+		log.info("Closing database connection");
+		try {
+			conn.close();
+		} catch (Exception e) {
+			log.fatal("Error closing connection", e);
+		}
+	}
+
+	/**
+	 * Generates the source code for the persistence layer.
+	 */
+	public void generateCode(Connection conn, CodeGenConfig config) {
+
+		this.config = config;
+		String packageName = config.getPackageName();
+		String targetFolder = config.getTargetFolder();
+		String dbLockingCol = config.getTimestampColumn();
+		
+		// passing an empty string my
+		String dbCatalog = config.getDbCatalog();
+		String dbSchema = config.getDbSchema();
+		String dbTablePattern = config.getDbTablePattern();
+		dbTablePattern=dbTablePattern==""?dbTablePattern:null;
+
+		Database db = new Database(conn, log, dbSchema, dbCatalog, dbTablePattern);
+		db.populateTableMetaData(dbLockingCol);
+		
+		// Prepare directories for generated source files
+		this.initDirectories(targetFolder, packageName);
+
+		// Create the DB class
+		this.createDatabaseClass(db);
+
+		// Create base table class
+		this.createBaseTableClass(db);
+
+		// Create base record class
+		this.createBaseRecordClass(db);
+
+		// Create table classes, record interfaces and record classes
+		for (Table table : db.getTables()) {
+			this.createTableClass(db, table);
+			this.createRecordClass(db, table);
+		}
+	}
+
+	private void initDirectories(String srcLocation, String packageName) {
+		// Create the directory structure for the generated source code.
+		File baseDir = new File(srcLocation);
+		if (!baseDir.exists()) {
+			baseDir.mkdirs();
+		}
+		StringBuilder sb = new StringBuilder();
+		sb.append(srcLocation).append("/");
+		sb.append(packageName.replaceAll("\\.", "/"));
+		this.baseDir = new File(sb.toString());
+		if (!this.baseDir.exists()) {
+			this.baseDir.mkdirs();
+		}
+
+		// Clean out the directory so old code is wiped out.
+		FileUtils.cleanDirectory(this.baseDir);
+
+		// Create the table package directory
+		this.tableDir = new File(this.baseDir, "tables");
+		this.tableDir.mkdir();
+
+		// Create the record package directory
+		this.recordDir = new File(this.baseDir, "records");
+		this.recordDir.mkdir();
+	}
+
+	private void createDatabaseClass(Database db) {
+		File file = new File(baseDir, config.getDbClassName() + ".java");
+		VelocityContext context = new VelocityContext();
+		context.put("basePackageName", config.getPackageName());
+		context.put("dbClassName", config.getDbClassName());
+		context.put("tableSubPackage", "tables");
+		context.put("database", db);
+		writeFile(file, TEMPLATE_PATH + "/" + DATABASE_TEMPLATE, context);
+	}
+
+	private void createBaseTableClass(Database db) {
+		File file = new File(tableDir, config.getTableBaseName() + ".java");
+		VelocityContext context = new VelocityContext();
+		context.put("tablePackageName", config.getPackageName() + ".tables");
+		context.put("baseTableClassName", config.getTableBaseName());
+		writeFile(file, TEMPLATE_PATH + "/" + BASE_TABLE_TEMPLATE, context);
+	}
+
+	private void createTableClass(Database db, Table table) {
+		File file = new File(tableDir, table.getClassName() + ".java");
+		VelocityContext context = new VelocityContext();
+		context.put("basePackageName", config.getPackageName());
+		context.put("tablePackageName", config.getPackageName() + ".tables");
+		context.put("baseTableClassName", config.getTableBaseName());
+		context.put("dbClassName", config.getDbClassName());
+		context.put("table", table);
+		writeFile(file, TEMPLATE_PATH + "/" + TABLE_TEMPLATE, context);
+	}
+
+	private void createBaseRecordClass(Database db) {
+		File file = new File(recordDir, config.getRecordBaseName() + ".java");
+		VelocityContext context = new VelocityContext();
+		context.put("baseRecordClassName", config.getRecordBaseName());
+		context.put("basePackageName", config.getPackageName());
+		context.put("tablePackageName", config.getPackageName() + ".tables");
+		context.put("recordPackageName", config.getPackageName() + ".records");
+		context.put("baseTableClassName", config.getTableBaseName());
+		writeFile(file, TEMPLATE_PATH + "/" + BASE_RECORD_TEMPLATE, context);
+	}
+
+	private void createRecordClass(Database db, Table table) {
+		File file = new File(recordDir, table.getRecordClassName() + ".java");
+		VelocityContext context = new VelocityContext();
+		context.put("basePackageName", config.getPackageName());
+		context.put("tablePackageName", config.getPackageName() + ".tables");
+		context.put("recordPackageName", config.getPackageName() + ".records");
+		context.put("baseRecordClassName", config.getRecordBaseName());
+		context.put("dbClassName", config.getDbClassName());
+		context.put("createRecordProperties", config.isCreateRecordProperties());
+		
+		context.put("table", table);
+		writeFile(file, TEMPLATE_PATH + "/" + RECORD_TEMPLATE, context);
+	}
+
+	private static void writeFile(File file, String templatePath,
+			VelocityContext context) {
+		try {
+			Template template = Velocity.getTemplate(templatePath);
+			Writer writer = new FileWriter(file);
+			template.merge(context, writer);
+			writer.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ResourceNotFoundException e) {
+			e.printStackTrace();
+		} catch (ParseErrorException e) {
+			e.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+	}
+
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java Sun Nov  1 10:21:13 2009
@@ -32,9 +32,19 @@
     
     // generation options
     /**
+     * name of the database catalog (may be null)
+     */
+    private String dbCatalog = null;
+    
+    /**
      * name of the database schema (may be null)
      */
     private String dbSchema = null;
+    
+    /**
+     * name of the table pattern (may be null)
+     */
+    private String dbTablePattern = null;
     /**
      * Name of the timestamp column used for optimistic locking (may be null)
      */
@@ -168,15 +178,36 @@
     
     // ------- generation options -------
 
+    public String getDbCatalog()
+    {
+        return dbCatalog;
+    }
+    
+    public void setDbCatalog(String dbCatalog)
+    {
+        this.dbCatalog=dbCatalog;
+    }
+    
     public String getDbSchema()
     {
         return dbSchema;
     }
-
+    
     public void setDbSchema(String dbSchema)
     {
         this.dbSchema = dbSchema;
     }
+    
+    public String getDbTablePattern()
+    {
+        return dbTablePattern;
+    }
+
+    public void setDbTablePattern(String dbTablePattern)
+    {
+        this.dbTablePattern = dbTablePattern;
+    }
+    
 
     public String getTimestampColumn()
     {

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java Sun Nov  1 10:21:13 2009
@@ -22,175 +22,129 @@
 import java.sql.SQLException;
 import java.sql.Types;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.codegen.util.StringUtils;
 
 public class Column {
-    private static final Log log = LogFactory.getLog(Column.class);
-
-    private String name;
+	private String name;
 	private int sqlType;
-	private int colSize;		// max length if string, precision is numeric
-	private int decimalDigits;	// max decimal digits allowed (real numbers)
+	private int colSize; // max length if string, precision is numeric
+	private int decimalDigits; // max decimal digits allowed (real numbers)
 	private boolean required;
-	private String defaultValue;	
-	private String fkTableName;	// Reference parent table if column if FK
+	private String defaultValue;
 	private boolean pkCol;
-	private boolean lockingCol;	// 
-	
+
 	// Java transformation
 	private String javaName;
 	private DataType empireType;
 	private String empireTypeString;
 	private String originalJavaTypeString;
 	private String javaTypeString;
-	
+
 	private boolean convertToBoolean;
 	private String trueValue;
 	private String falseValue;
 
 	private boolean convertToEnum;
-	
+
 	public String getJavaName() {
 		return javaName;
 	}
+
 	public void setJavaName(String javaName) {
 		this.javaName = javaName;
 	}
+
 	public String getJavaTypeString() {
 		return javaTypeString;
 	}
+
 	public String getEmpireTypeString() {
 		return empireTypeString;
 	}
+
 	public DataType getEmpireType() {
 		return empireType;
 	}
+
 	public Column(ResultSet rs) {
-		this(rs, false, false);
+		this(rs, false);
 	}
+
 	public Column(ResultSet rs, boolean primaryKey) {
-		this(rs, primaryKey, false);
-	}
-	public Column(ResultSet rs, boolean primaryKey, boolean foreignKey) {
-		if (primaryKey &amp;&amp; foreignKey) {
-			throw new RuntimeException("Can't have a column that is both " +
-					"a primary and a foreign key.");
-		}
-		
+
+		this.pkCol = primaryKey;
 		try {
-			if (!primaryKey &amp;&amp; !foreignKey) {
-				// Simple column
-				this.name = rs.getString("COLUMN_NAME").toUpperCase();
-				this.sqlType = rs.getInt("DATA_TYPE");
-				this.empireType = this.deriveJavaInfo();
-				this.colSize = rs.getInt("COLUMN_SIZE");
-				this.decimalDigits = rs.getInt("DECIMAL_DIGITS");
-				String nullable = rs.getString("IS_NULLABLE");
-				if (nullable.equalsIgnoreCase("NO"))
-					this.required = true;
-				else
-					this.required = false;
-				this.defaultValue = rs.getString("COLUMN_DEF");
-			}
-			else if (primaryKey) {
-				// Primary key column
-				this.name = rs.getString("COLUMN_NAME").toUpperCase();
-				this.sqlType = Types.INTEGER;
-				this.empireType = DataType.AUTOINC;
+			this.name = rs.getString("COLUMN_NAME").toUpperCase();
+			this.sqlType = rs.getInt("DATA_TYPE");
+			this.empireType = this.deriveJavaInfo();
+			this.colSize = rs.getInt("COLUMN_SIZE");
+			this.decimalDigits = rs.getInt("DECIMAL_DIGITS");
+			String nullable = rs.getString("IS_NULLABLE");
+			if (nullable.equalsIgnoreCase("NO"))
 				this.required = true;
-				this.javaName = StringUtils.deriveAttributeName(this.name);
-				this.javaTypeString = "Integer";
-				this.pkCol = true;
-			}
-			else {
-				// Foreign key column
-				this.name = rs.getString("FKCOLUMN_NAME").toUpperCase();
-				this.sqlType = Types.INTEGER;
-				this.empireType = DataType.INTEGER;
-				this.fkTableName = rs.getString("PKTABLE_NAME").toUpperCase();
-				this.javaName = StringUtils.deriveAttributeName(this.name);
-				this.javaTypeString = "Integer";
-			}
-			
+			else
+				this.required = false;
+			this.defaultValue = rs.getString("COLUMN_DEF");
+
 			this.originalJavaTypeString = this.javaTypeString;
-		}
-		catch (SQLException e) {
+		} catch (SQLException e) {
 			throw new RuntimeException(e);
 		}
 	}
+
 	@Override
 	public boolean equals(Object obj) {
 		if (obj instanceof Column) {
-			Column that = (Column)obj;
+			Column that = (Column) obj;
 			if (this.name.equals(that.name)) {
 				return true;
 			}
 		}
 		return false;
 	}
-	
-	public void convertToBoolean(String trueValue, String falseValue) {
-		if (this.empireType != DataType.TEXT) {
-			throw new RuntimeException(this.name + " must be a string type " +
-					"to convert to boolean");
-		}
-		this.convertToBoolean = true;
-		this.javaTypeString = "Boolean";
-		this.trueValue = trueValue;
-		this.falseValue = falseValue;
-	}
-	
-	public boolean isForeignKey() {
-		return (this.fkTableName != null);
-	}
-	public String getFkTableName() {
-		return fkTableName;
-	}
+
 	public String getName() {
 		return name.toUpperCase();
 	}
+
 	public int getSqlType() {
 		return sqlType;
 	}
+
 	public int getColSize() {
 		return colSize;
 	}
+
 	public int getDecimalDigits() {
 		return decimalDigits;
 	}
+
 	public boolean isRequired() {
 		return required;
 	}
+
 	public String getDefaultValue() {
-		if (defaultValue == null) return "null";
-		
+		if (defaultValue == null)
+			return "null";
+
 		return "\"" + defaultValue + "\"";
 	}
-	public boolean isLockingCol() {
-		return lockingCol;
-	}
-	public void setLockingCol(boolean lockingCol) {
-		this.lockingCol = lockingCol;
-	}
-	public boolean isPkCol() {
+
+	public boolean isPrimaryColumn() {
 		return this.pkCol;
 	}
+
 	public boolean isBoolean() {
 		if (this.javaTypeString.equalsIgnoreCase("Boolean"))
 			return true;
 		return false;
 	}
-	public boolean isModifiable() {
-		return (!this.isPkCol() &amp;&amp; !this.isLockingCol());
-	}
-	
+
 	private DataType deriveJavaInfo() {
 		this.javaName = StringUtils.deriveAttributeName(this.name);
 		DataType empireType = DataType.UNKNOWN;
-		switch(this.sqlType) {
+		switch (this.sqlType) {
 		case Types.INTEGER:
 		case Types.SMALLINT:
 		case Types.TINYINT:
@@ -257,70 +211,65 @@
 			empireType = DataType.UNKNOWN;
 			empireTypeString = "DataType.UNKNOWN";
 			javaTypeString = "Byte[]";
-			System.out.println("SQL column type " + this.sqlType + " not supported.");
+			System.out.println("SQL column type " + this.sqlType
+					+ " not supported.");
 		}
-		
+
 		return empireType;
 	}
+
 	public boolean isConvertToBoolean() {
 		return convertToBoolean;
 	}
+
 	public String getTrueValue() {
 		return trueValue;
 	}
+
 	public String getFalseValue() {
 		return falseValue;
 	}
+
 	public String getOriginalJavaTypeString() {
 		return originalJavaTypeString;
 	}
+
 	public boolean isConvertToEnum() {
 		return convertToEnum;
 	}
+
 	public String getJavaAccessorName() {
-		return StringUtils.deriveAccessorName(javaName, 
-				this.javaTypeString.equalsIgnoreCase("boolean"));
+		return StringUtils.deriveAccessorName(javaName, this.javaTypeString
+				.equalsIgnoreCase("boolean"));
 	}
+
 	public String getJavaMutatorName() {
 		return StringUtils.deriveMutatorName(javaName);
 	}
-	
+
 	public String getReturnExpression() {
 		if (this.convertToBoolean) {
 			StringBuilder sb = new StringBuilder(this.javaName);
 			sb.append(".equalsIgnoreCase(\"");
 			sb.append(this.trueValue).append("\")");
 			return sb.toString();
-		}
-		else if (this.convertToEnum) {
-			return this.javaTypeString + ".fromDbString(" +
-			this.javaName + ")";
-		}
-		else {
+		} else if (this.convertToEnum) {
+			return this.javaTypeString + ".fromDbString(" + this.javaName + ")";
+		} else {
 			return this.javaName;
 		}
 	}
+
 	public String getSetExpression() {
 		if (this.convertToBoolean) {
 			StringBuilder sb = new StringBuilder(this.javaName);
 			sb.append(" ? \"").append(this.trueValue).append("\" ");
 			sb.append(" : \"").append(this.falseValue).append("\")");
 			return sb.toString();
-		}
-		else if (this.convertToEnum) {
+		} else if (this.convertToEnum) {
 			return this.javaName + ".toDbString()";
-		}
-		else {
+		} else {
 			return this.javaName;
 		}
 	}
-	public String getPopulateFkRecordMethodName() {
-		StringBuilder sb = new StringBuilder(this.getName());
-		StringUtils.replaceAll(sb, "_" + Table.getPkColName(),
-				"");
-		StringBuilder methodName = new StringBuilder("populate");
-		methodName.append(StringUtils.javaClassName(sb.toString()));
-		methodName.append("Record");
-		return methodName.toString();
-	}
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java Sun Nov  1 10:21:13 2009
@@ -27,110 +27,65 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.empire.db.codegen.util.StringUtils;
+import org.apache.empire.db.codegen.util.DBUtil;
 
 public class Database {
-    private static final Log log = LogFactory.getLog(Database.class);
-    
-    private Connection connection;
-	private String schemaName;
-	
+	private DatabaseMetaData metaData;
+	private String catalogName;
+	private String schemaPattern;
+	private String tablePattern;
+	private Connection con;
+	private Log log;
+
 	private Map&lt;String, Table&gt; tableMap = new HashMap&lt;String, Table&gt;();
 
-	public Database(Connection connection, String schemaName) {
-		// Set properties
-		this.connection = connection;
-        this.schemaName = schemaName;
-	}
-	
-	public Connection getConnection() {
-	    return connection;
-	}
-	
-	private void close(ResultSet rs) {
-	    try {
-	        rs.close();
-	    } catch(SQLException e) {
-            throw new RuntimeException(e);
-	    }
+	public Database(Connection con, Log log, String schemaPattern,
+			String catalogName, String tablePattern) {
+
+		this.log = log;
+		this.con = con;
+		this.schemaPattern = schemaPattern;
+		this.catalogName = catalogName;
+		this.tablePattern = tablePattern;
+		
+		try {
+			this.metaData = this.con.getMetaData();
+		} catch (SQLException e) {
+			throw new RuntimeException("Unable to retrieve database metadata!",
+					e);
+		}
+
 	}
 
 	/**
 	 * Populates meta data for tables in the database.
-	 * @param pkColName Primary key column name.  Note: We assume a single
-	 * 		auto-generated PK column with the same name is used for every
-	 * 		table in the DB.
-	 * @param lockColName Lock column name used for optimistic locking.
-	 * 		Note: We assume a single timestamp column with the same name 
-	 * 		is used for every table in the DB.
+	 * 
 	 */
-	public void populateTableMetaData(String pkColName, String lockColName) {
-		Table.setPkColName(pkColName);
-		Table.setLockColName(lockColName);
-		DatabaseMetaData dbMeta = this.getDbMetaData();
+	public void populateTableMetaData(String lockColName) {
+		DatabaseMetaData dbMeta = this.metaData;
 		ResultSet tables = null;
 		try {
-            log.info("Reading Tables for schema " + schemaName);
-			tables = dbMeta.getTables(null, this.schemaName, null, new String[] {"TABLE"});
+			tables = dbMeta.getTables(catalogName, schemaPattern, tablePattern,
+					new String[] { "TABLE" });
 			while (tables.next()) {
 				String tableName = tables.getString("TABLE_NAME");
-				// rd: required for oracle
-				if (tableName.indexOf('$')&gt;=0)
-				    continue; // ignore table names with a "$"
-				// end oracle
-				log.info("Reading Table metadata for " + tableName);
-				Table table = new Table(tableName, this.schemaName, dbMeta);
-				this.tableMap.put(tableName.toUpperCase(), table);				
-			}
-			
-			for (String tableName: this.tableMap.keySet()) {
-				Table table = this.tableMap.get(tableName);
-				for (Column fkCol: table.getFkCols()) {
-					Table parentTable = this.tableMap.get(
-							fkCol.getFkTableName());
-					parentTable.addChildTable(fkCol.getName(), table);
-				}
+				System.out.println("TABLE:\t" + tableName);
+				Table table = new Table(tableName, lockColName, schemaPattern, catalogName,
+						dbMeta, log);
+				this.tableMap.put(tableName.toUpperCase(), table);
 			}
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
 		} finally {
-		    close(tables);
-		}
-	}
-	/**
-	 * Gets the database meta data.
-	 * @return The database meta data.
-	 */
-	public DatabaseMetaData getDbMetaData() {
-		try {
-			return this.getConnection().getMetaData();
-		} catch (SQLException e) {
-			e.printStackTrace();
-			throw new RuntimeException(e);
+			DBUtil.closeResultSet(tables, log);
 		}
 	}
 	
-	public String getClassName() {
-		return StringUtils.javaClassName(this.schemaName) + "Database";
-	}
-
-	public String getBaseTableClassName() {
-		return StringUtils.javaClassName(this.schemaName) + "Table";
-	}
-
-	public String getInstanceName() {
-		return StringUtils.deriveAttributeNameFromClass(this.getClassName());
-	}
-
 	public Collection&lt;Table&gt; getTables() {
 		return tableMap.values();
 	}
+
 	public Table getTable(String name) {
 		return this.tableMap.get(name.toUpperCase());
 	}
-	
-	public String getSchemaName() {
-		return schemaName;
-	}
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java Sun Nov  1 10:21:13 2009
@@ -27,80 +27,55 @@
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.empire.data.DataType;
+import org.apache.empire.db.codegen.util.DBUtil;
 import org.apache.empire.db.codegen.util.StringUtils;
 
 public class Table {
-    private static final Log log = LogFactory.getLog(Table.class);
-    
-    private String tableName;
-	private Column pkCol;
-	private List&lt;Column&gt; fkCols;
-	private List&lt;Column&gt; simpleCols;
-	private Column lockingCol;
-	
+	private String tableName;
+	private List&lt;String&gt; pkCols;
+	private List&lt;Column&gt; columns;
+	private Column lockCol;
+	private Log log;
+	private String lockColName;
+
 	private Map&lt;String, Column&gt; columnMap = new HashMap&lt;String, Column&gt;();
-	
-	private List&lt;Child&gt; childTables = new ArrayList&lt;Child&gt;();
-	
-	private static String pkColName;
-	private static String lockColName;
 
-	public Table(String tableName, String schema, 
-			DatabaseMetaData dbMeta) {
+	public Table(String tableName,String lockColName, String schemaPattern, String catalogName,
+			DatabaseMetaData dbMeta, Log log) {
 		this.tableName = tableName.toUpperCase();
-		this.createColumns(dbMeta, schema);
-	}
-	
-	public static String getPkColName() {
-		return pkColName;
-	}
-	public static void setPkColName(String name) {
-		pkColName = name;
-	}
-	public static String getLockColName() {
-		return lockColName;
-	}
-	public static void setLockColName(String name) {
-		lockColName = name;
-	}
-	
-	public void addChildTable(String fkColName, Table table) {
-		this.childTables.add(new Child(fkColName, table));
-	}
-	public List&lt;Child&gt; getChildTables() {
-		return this.childTables;
+		this.log = log;
+		this.lockColName=lockColName;
+		this.createColumns(dbMeta, schemaPattern, catalogName);
 	}
+
 	public String getTableName() {
 		return tableName.toUpperCase();
 	}
 
-	public Column getPkCol() {
-		return pkCol;
+	public List&lt;Column&gt; getColumns() {
+		return columns;
 	}
-
-	public List&lt;Column&gt; getFkCols() {
-		return fkCols;
+	
+	public boolean getHasLockColumn() {
+		return lockCol!=null;
 	}
-
-	public List&lt;Column&gt; getSimpleCols() {
-		return simpleCols;
+	
+	public Column getLockColumn() {
+		return lockCol;
 	}
 
-	public Column getLockingCol() {
-		return this.lockingCol;
-	}
-	
 	public String getClassName() {
 		return StringUtils.javaClassName(this.tableName) + "Table";
 	}
+
 	public String getRecordClassName() {
 		return StringUtils.javaClassName(this.tableName) + "Record";
 	}
+
 	public boolean hasBigDecimalField() {
 		boolean bdField = false;
-		for (Column col: this.simpleCols) {
+		for (Column col : this.columns) {
 			if (col.getEmpireType() == DataType.DECIMAL) {
 				bdField = true;
 				break;
@@ -108,97 +83,56 @@
 		}
 		return bdField;
 	}
-	public boolean hasChildRecords() {
-		return !this.childTables.isEmpty();
-	}
+
 	public Column getColumn(String name) {
 		return this.columnMap.get(name.toUpperCase());
 	}
-	public static class Child {
-		Child(String fkColName, Table childTable) {
-			this.fkColName = fkColName;
-			this.childTable = childTable;
-		}
-		private String fkColName;
-		private Table childTable;
-		public String getFkColName() {
-			return fkColName.toUpperCase();
-		}
-		public Table getChildTable() {
-			return childTable;
-		}
-		public String getChildType() {
-			return StringUtils.javaClassName(childTable.getTableName());
-		}
-		public String getFkType() {
-			StringBuilder sb = new StringBuilder(this.fkColName.toUpperCase());
-			StringUtils.replaceAll(sb, "_" + Table.getPkColName(),
-					"");
-			return StringUtils.javaClassName(sb.toString());
-		}
-		public String getFkMutatorName() {
-			Column col = childTable.getColumn(this.fkColName);
-			return col.getJavaMutatorName();
-		}
-	}
+
 	// ------------------------------------------------------------------------
 	// Private members
 	// ------------------------------------------------------------------------
-	private void createColumns(DatabaseMetaData dbMeta, String schema) {
-		this.pkCol = this.findPkColumn(dbMeta, schema);
-		this.columnMap.put(pkCol.getName().toUpperCase(), pkCol);
-		this.simpleCols = new ArrayList&lt;Column&gt;();
-		this.fkCols = this.findFkColumns(dbMeta, schema);
-		for (Column col: this.fkCols) {
-			this.columnMap.put(col.getName().toUpperCase(), col);
-		}
+	private void createColumns(DatabaseMetaData dbMeta, String schemaPattern,
+			String catalogName) {
+		this.pkCols = this.findPkColumns(dbMeta, schemaPattern, catalogName);
+		this.columns = new ArrayList&lt;Column&gt;();
+		ResultSet rs = null;
 		try {
-			ResultSet rs = dbMeta.getColumns(null, schema, tableName, "");			
+			rs = dbMeta.getColumns(catalogName, schemaPattern, tableName, null);
+			boolean isKeyCol;
+			String colName;
 			while (rs.next()) {
-				Column col = new Column(rs);
-				if (!col.equals(pkCol) &amp;&amp; !fkCols.contains(col)) {
-					if (col.getName().equalsIgnoreCase(lockColName)) {
-						this.lockingCol = col;
-						col.setLockingCol(true);
-					}
-					else {
-						this.simpleCols.add(col);
-					}
-					this.columnMap.put(col.getName().toUpperCase(), col);
-				}
+				colName = rs.getString("COLUMN_NAME").toUpperCase();
+				log.info("\tCOLUMN:\t" + colName);
+				isKeyCol = pkCols.contains(colName);
+
+				Column col = new Column(rs, isKeyCol);
+				this.columns.add(col);
+				this.columnMap.put(col.getName().toUpperCase(), col);
+				if(lockColName!=null &amp;&amp; col.getName().toUpperCase().equals(lockColName.toUpperCase()))
+					lockCol=col;
 			}
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
-		}		
+		} finally {
+			DBUtil.closeResultSet(rs, log);
+		}
 	}
-	
-	private Column findPkColumn(DatabaseMetaData dbMeta, String schema) {
-		try {
-			ResultSet pkRs = dbMeta.getPrimaryKeys(null, schema, tableName);
-			if(pkRs.next()) {
-				Column col = new Column(pkRs, true);
-				return col;
-			}
-			else {
-				throw new RuntimeException("Primary key not found for table " +
-						this.tableName);
-			}
 
-		} catch (SQLException e) {
-			throw new RuntimeException(e);
-		}		
-	}
-	private List&lt;Column&gt; findFkColumns(DatabaseMetaData dbMeta, String schema) {
-		List&lt;Column&gt; fkCols = new ArrayList&lt;Column&gt;();
+	private List&lt;String&gt; findPkColumns(DatabaseMetaData dbMeta,
+			String schemaPattern, String catalogName) {
+		List&lt;String&gt; cols = new ArrayList&lt;String&gt;();
+		ResultSet rs = null;
 		try {
-			ResultSet fkRs = dbMeta.getImportedKeys(null, schema, tableName);
-			while(fkRs.next()) {
-				Column col = new Column(fkRs, false, true);
-				fkCols.add(col);
+			rs = dbMeta.getPrimaryKeys(catalogName, schemaPattern, tableName);
+			while (rs.next()) {
+				cols.add(rs.getString("COLUMN_NAME").toUpperCase());
 			}
+
 		} catch (SQLException e) {
 			throw new RuntimeException(e);
-		}		
-		return fkCols;
+		} finally {
+			DBUtil.closeResultSet(rs, log);
+		}
+		return cols;
 	}
 }

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java?rev=831663&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java Sun Nov  1 10:21:13 2009
@@ -0,0 +1,20 @@
+package org.apache.empire.db.codegen.util;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.commons.logging.Log;
+
+public class DBUtil {
+	public static boolean closeResultSet(ResultSet rs, Log log) {
+		boolean b = false;
+		try {
+			if(rs!=null)
+				rs.close();
+			b = true;
+		} catch (SQLException e) {
+			log.error("The resultset could not bel closed!", e);
+		}
+		return b;
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/DBUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm Sun Nov  1 10:21:13 2009
@@ -16,15 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  *#
-package ${recordPackage};
+package ${recordPackageName};
 
 import org.apache.empire.db.DBRecord;
-import ${tablePackageName}.${database.baseTableClassName};
+import ${tablePackageName}.${baseTableClassName};
 
-//import ${basePackageName}.${database.className};
 
-public abstract class BaseRecord&lt;T extends ${database.baseTableClassName}&gt; extends DBRecord {
-	public BaseRecord(T table) {
+public abstract class ${baseRecordClassName}&lt;T extends ${baseTableClassName}&gt; extends DBRecord {
+	public ${baseRecordClassName}(T table) {
 		super.init(table, DBRecord.REC_EMTPY, null);
 	}
 

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm Sun Nov  1 10:21:13 2009
@@ -21,8 +21,8 @@
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
 
-public class ${db.baseTableClassName} extends DBTable {
-	public ${db.baseTableClassName}(String name, DBDatabase db) {
+public class ${baseTableClassName} extends DBTable {
+	public ${baseTableClassName}(String name, DBDatabase db) {
 		super(name, db);
 	}
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm Sun Nov  1 10:21:13 2009
@@ -30,7 +30,11 @@
 
 import $basePackageName.$tableSubPackage.*;
 
-public class $database.className extends DBDatabase {
+public class $dbClassName extends DBDatabase {
+
+	private static $dbClassName instance;
+	private static final long serialVersionUID = 1L;
+
 #foreach($table in $database.tables)
 	public final $table.className T_$table.tableName = new ${table.className}(this);
 #end
@@ -39,24 +43,17 @@
 	 * Returns the instance of the database.
 	 * @return
 	 */
-	public static $database.className get() {
+	public static $dbClassName get() {
 		if (instance == null) {
-			instance = new GamesDatabase();
+			instance = new ${dbClassName}();
 		}
 		return instance;
 	}
 	
 	/**
-	 * Default constructor for the $database.className.  Relationship between the
-	 * tables that make up the database are specified here. 
+	 * Default constructor for the $dbClassName.
 	 */
-	private ${database.className}() {
-		// FK relationships
-#foreach($table in $database.tables)
-#foreach($fkCol in $table.fkCols)
-		super.addRelation(T_${table.tableName}.${fkCol.name}.referenceOn(T_${fkCol.fkTableName}.${table.pkColName}));
-#end
-#end
+	private ${dbClassName}() {
 	}
 	
 	/**
@@ -117,7 +114,4 @@
 		}
 		return records;
 	}
-		
-	private static $database.className instance;
-	private static final long serialVersionUID = 1L;
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm Sun Nov  1 10:21:13 2009
@@ -16,14 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  *#
-package ${recordPackage};
+package ${recordPackageName};
 
 #if ($table.hasBigDecimalField())
 import java.math.BigDecimal;
 #end
-import java.util.Date;
 
-import ${basePackageName}.${database.className};
+import ${basePackageName}.${dbClassName};
+import ${recordPackageName}.${baseRecordClassName};
 import ${tablePackageName}.${table.className};
 
 /**
@@ -37,54 +37,23 @@
  * This class provides protected method that subclasses should use to provide
  * access to related records.
  */
-public class ${table.recordClassName} extends BaseRecord&lt;${table.className}&gt; {
+public class ${table.recordClassName} extends ${baseRecordClassName}&lt;${table.className}&gt; {
 	public ${table.recordClassName}() {
-		super(${database.className}.get().T_${table.tableName});
+		super(${dbClassName}.get().T_${table.tableName});
 	}
 	
-	// Primary key getter
-	public Integer ${table.pkCol.javaAccessorName}() {
-		return (Integer)super.getValue(getDbTable().${table.pkCol.name});
-	}
-	
-	// Access methods for simple attributes
-#foreach($col in $table.simpleCols)
+#if($createRecordProperties == true)
+	// Access methods for all attributes
+#foreach($col in $table.columns)
 	public ${col.javaTypeString} ${col.javaAccessorName}() {
-		${col.originalJavaTypeString} ${col.javaName} = (${col.originalJavaTypeString})super.getValue(getDbTable().${col.name});
+		${col.originalJavaTypeString} ${col.javaName} = (${col.originalJavaTypeString})super.getValue(getDbTable().C_${col.name});
 		return ${col.returnExpression};
 	}
 	public void ${col.javaMutatorName}(${col.javaTypeString} ${col.javaName}) {
-		super.setValue(getDbTable().${col.name}, ${col.setExpression});
+		super.setValue(getDbTable().C_${col.name}, ${col.setExpression});
 	}
 #end
+#end
+
 
-	// Optimistic locking getter
-	public ${table.lockingCol.javaTypeString} ${table.lockingCol.javaAccessorName}() {
-		return (${table.lockingCol.javaTypeString})super.getValue(getDbTable().${table.lockingCol.name});		
-	}
-	
-	@Override
-    public boolean equals(Object object) {  
-        if (object == this)  
-            return true;  
-        if ((object == null) || !(object instanceof ${table.recordClassName}))  
-            return false;  
-   
-        final ${table.recordClassName} a = (${table.recordClassName})object;  
-   
-        if (${table.pkCol.javaAccessorName}() != null &amp;&amp; a.${table.pkCol.javaAccessorName}() != null) {  
-            return ${table.pkCol.javaAccessorName}().equals(a.${table.pkCol.javaAccessorName}());  
-        }  
-        return false;  
-    }
-    
-    // FK references
-    #foreach($col in $table.fkCols)
-	public Integer ${col.javaAccessorName}() {
-		return (Integer)super.getValue(getDbTable().${col.name});
-	}
-	public void ${col.javaMutatorName}(Integer ${col.javaName}) {
-		super.setValue(getDbTable().${col.name}, ${col.javaName});
-	}
-    #end
 }
\ No newline at end of file

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm?rev=831663&amp;r1=831662&amp;r2=831663&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm Sun Nov  1 10:21:13 2009
@@ -18,51 +18,47 @@
  *#
 package $tablePackageName;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.empire.data.DataType;
-import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTableColumn;
 
-public class ${table.className} extends ${db.baseTableClassName} {
+import $basePackageName.${dbClassName};
+
+public class ${table.className} extends ${baseTableClassName} {
 	// Primary key column
-	public final DBTableColumn ${table.pkCol.name};
+	private List&lt;DBTableColumn&gt; keyColumns= new ArrayList&lt;DBTableColumn&gt;();
 	
 	// Regular attributes
-#foreach ($col in $table.simpleCols)
-	public final DBTableColumn ${col.name};
+#foreach ($col in $table.columns)
+	public final DBTableColumn C_${col.name};
 #end
 	
-	// Optimistic locking attribute
-	public final DBTableColumn ${table.lockingCol.name};
-	
-	// Foreign key columns
-#foreach ($col in $table.fkCols)
-	public final DBTableColumn ${col.name};
-#end
-	
-	public ${table.className}(DBDatabase db) {
+	public ${table.className}(${dbClassName} db) {
 		super("${table.tableName}", db);
 		
-		// Primary key column
-		${table.pkCol.name} = super.addColumn("${table.pkCol.name}", DataType.AUTOINC, 0, true);
-		
-		// Regular attributes
-#foreach ($col in $table.simpleCols)
-		${col.name} = super.addColumn("${col.name}", DataType.${col.empireType}, ${col.colSize}, ${col.required}, ${col.defaultValue});
+		// all columns
+#foreach ($col in $table.columns)
+		C_${col.name} = super.addColumn("${col.name}", DataType.${col.empireType}, ${col.colSize}, ${col.required}, ${col.defaultValue});
 #end
 
-		// Optimistic locking attribute
-		${table.lockingCol.name} = super.addColumn("${table.lockingCol.name}", DataType.DATETIME, 0, false);
-		
-		// Foreign key columns
-#foreach ($col in $table.fkCols)
-		${col.name} = super.addColumn("${col.name}", DataType.INTEGER, 0, ${col.required});
-#end		
-		// Primary key
-		super.setPrimaryKey(${table.pkCol.name});
+
+		// configure primary columns
+#foreach ($col in $table.columns)
+#if($col.primaryColumn == true)
+    	keyColumns.add(C_${col.name});
+#end
+#end
+		super.setPrimaryKey((DBTableColumn[]) keyColumns.toArray());
 		
 		// Optimistic locking column
-		super.setTimestampColumn(${table.lockingCol.name});
-		
+#if($table.hasLockColumn == true)
+		super.setTimestampColumn(C_${table.lockColumn.name});
+#else
+		/*no locking column specified*/
+#end
+
 		// Set cascade delete
 		super.setCascadeDelete(true);		
 	}




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r830389 - /incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091027230515.8AF2123888A0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091027230515-8AF2123888A0@eris-apache-org%3e</id>
<updated>2009-10-27T23:05:15Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Oct 27 23:05:15 2009
New Revision: 830389

URL: http://svn.apache.org/viewvc?rev=830389&amp;view=rev
Log:
fixing brackets code style

Modified:
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java?rev=830389&amp;r1=830388&amp;r2=830389&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
Tue Oct 27 23:05:15 2009
@@ -49,15 +49,13 @@
     public static Connection conn;
     
     @BeforeClass
-    public static void setup() throws ClassNotFoundException, SQLException, IOException{
+    public static void setup() throws ClassNotFoundException, SQLException, IOException
+    {
         // clean up possible previous test files
         FileUtils.deleteDirectory(new File(PATH));
         
         Class.forName("org.hsqldb.jdbcDriver");
-        conn = DriverManager.getConnection("jdbc:hsqldb:"
-                                           + PATH,    // filenames
-                                           "sa",                     // username
-                                           "");                      // password
+        conn = DriverManager.getConnection("jdbc:hsqldb:" + PATH, "sa", "");
         DBDatabaseDriver driver = new DBDatabaseDriverHSql();
         db = new CompanyDB();
         db.open(driver, conn);
@@ -69,13 +67,17 @@
     }
     
     @AfterClass
-    public static void shutdown() throws SQLException, IOException{
-        try{
+    public static void shutdown() throws SQLException, IOException
+    {
+        try
+        {
             DBSQLScript script = new DBSQLScript();
             db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
             db.getDriver().getDDLScript(DBCmdType.DROP, db.DEPARTMENT, script);
             script.run(db.getDriver(), conn, true);
-        }finally{
+        }
+        finally
+        {
             DBTools.close(conn);
             // clean up
             FileUtils.deleteDirectory(new File(PATH));
@@ -84,7 +86,8 @@
     }
     
     @Test
-    public void test(){
+    public void test()
+    {
         DBRecord dep = new DBRecord();
         dep.create(db.DEPARTMENT);
         dep.setValue(db.DEPARTMENT.NAME, "junit");




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r830388 - in /incubator/empire-db/trunk: empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/ empire-db-codegen/src/main/resources/templates/ empire-db/ empir...</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091027225818.E12D723888AD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091027225818-E12D723888AD@eris-apache-org%3e</id>
<updated>2009-10-27T22:58:18Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Tue Oct 27 22:58:17 2009
New Revision: 830388

URL: http://svn.apache.org/viewvc?rev=830388&amp;view=rev
Log:
added missing apache headers
fix possible test failure because of database file leftovers

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
    incubator/empire-db/trunk/empire-db/pom.xml
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.types;
 
 import java.sql.ResultSet;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.types;
 
 import java.sql.Connection;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.types;
 
 import java.sql.DatabaseMetaData;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.util;
 
 import java.io.BufferedReader;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
Tue Oct 27 22:58:17 2009
@@ -1,9 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.empire.db.codegen.util;
 
 public class StringUtils {
 	/**
 	 * Derives a java class name from a database table name.
-	 * @param tableName
+	 * @param name
 	 * @return
 	 */
 	public static String javaClassName(String name) {
@@ -62,7 +80,7 @@
 	/**
 	 * Derives the mutator method name based on the attribute name.
 	 * @param attribute
-	 * @return
+	 * @return 
 	 */
 	public static String deriveMutatorName(String attribute) {
 		StringBuilder sb = new StringBuilder();

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
 package ${recordPackage};
 
 import org.apache.empire.db.DBRecord;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
Tue Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
 package $tablePackageName;
 
 import org.apache.empire.db.DBDatabase;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm Tue
Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
 package $basePackageName;
 
 import java.sql.Connection;

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm Tue
Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
 package ${recordPackage};
 
 #if ($table.hasBigDecimalField())

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm Tue
Oct 27 22:58:17 2009
@@ -1,3 +1,21 @@
+#*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *#
 package $tablePackageName;
 
 import org.apache.empire.data.DataType;

Modified: incubator/empire-db/trunk/empire-db/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/pom.xml?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db/pom.xml Tue Oct 27 22:58:17 2009
@@ -35,10 +35,17 @@
 			&lt;groupId&gt;commons-collections&lt;/groupId&gt;
 			&lt;artifactId&gt;commons-collections&lt;/artifactId&gt;
 		&lt;/dependency&gt;
+		&lt;!-- TEST --&gt;
 		&lt;dependency&gt;
 		    &lt;groupId&gt;hsqldb&lt;/groupId&gt;
 		    &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
 		    &lt;scope&gt;test&lt;/scope&gt;
 		&lt;/dependency&gt; 
+		&lt;dependency&gt;
+		    &lt;groupId&gt;commons-io&lt;/groupId&gt;
+		    &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
+		    &lt;version&gt;1.4&lt;/version&gt;
+		    &lt;scope&gt;test&lt;/scope&gt;
+		&lt;/dependency&gt; 
 	&lt;/dependencies&gt;
 &lt;/project&gt;
\ No newline at end of file

Modified: incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java?rev=830388&amp;r1=830387&amp;r2=830388&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/hsql/DBDatabaseDriverHSqlTest.java
Tue Oct 27 22:58:17 2009
@@ -22,11 +22,14 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.io.File;
+import java.io.IOException;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Date;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.empire.db.CompanyDB;
 import org.apache.empire.db.DBCmdType;
 import org.apache.empire.db.DBDatabaseDriver;
@@ -40,14 +43,19 @@
 
 public class DBDatabaseDriverHSqlTest
 {
+    private static final String PATH = "target/hsqldb-unit-test/";
+    
     public static CompanyDB db;
     public static Connection conn;
     
     @BeforeClass
-    public static void setup() throws ClassNotFoundException, SQLException{
+    public static void setup() throws ClassNotFoundException, SQLException, IOException{
+        // clean up possible previous test files
+        FileUtils.deleteDirectory(new File(PATH));
+        
         Class.forName("org.hsqldb.jdbcDriver");
         conn = DriverManager.getConnection("jdbc:hsqldb:"
-                                           + "target/hsqldb-unit-test/",    // filenames
+                                           + PATH,    // filenames
                                            "sa",                     // username
                                            "");                      // password
         DBDatabaseDriver driver = new DBDatabaseDriverHSql();
@@ -61,7 +69,7 @@
     }
     
     @AfterClass
-    public static void shutdown() throws SQLException{
+    public static void shutdown() throws SQLException, IOException{
         try{
             DBSQLScript script = new DBSQLScript();
             db.getDriver().getDDLScript(DBCmdType.DROP, db.EMPLOYEE, script);
@@ -69,7 +77,10 @@
             script.run(db.getDriver(), conn, true);
         }finally{
             DBTools.close(conn);
+            // clean up
+            FileUtils.deleteDirectory(new File(PATH));
         }
+
     }
     
     @Test




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Updated: (EMPIREDB-52) CodeGenerator project setup</title>
<author><name>&quot;Benjamin Venditti (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c1490399926.1256601359539.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c1490399926-1256601359539-JavaMail-jira@brutus%3e</id>
<updated>2009-10-26T23:55:59Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-52?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Benjamin Venditti updated EMPIREDB-52:
--------------------------------------

    Attachment: codegen.0.3.patch

Hi there,

i have crated a eclipse-patch (0.3) that contains the codegenerator with very basic functionality
and considers rainers changes.
I have taken care of multi-column primary keys and unclosed ResultSets.

The generator is quit basic at the moment and the following will not work:
   - nested table generation within the database
   - relation mapping (foreign key dependencies)
   - views
   - name prefix for tables, views

I also removed some lines from the thom's code like special getters/setters for primary/locking
columns.
Additional configuration options were added "catalogName" and "tablePattern". They can be
used to further specify the metadata to be read from the database.

I'd be happy if anyone could have a look at it. 

&gt; CodeGenerator project setup
&gt; ---------------------------
&gt;
&gt;                 Key: EMPIREDB-52
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-52
&gt;             Project: Empire-DB
&gt;          Issue Type: New Feature
&gt;          Components: CodeGenerator
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Rainer Döbele
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;         Attachments: codegen.0.3.patch
&gt;
&gt;
&gt; The empire-db code generator is a new subproject which should be capable of generating
source code classes from an existing database.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r829996 - in /incubator/empire-db/trunk/empire-db-codegen: ./ src/main/java/org/apache/empire/db/codegen/ src/main/java/org/apache/empire/db/codegen/types/ src/main/java/org/apache/empire/db/codegen/util/ src/main/resources/templates/</title>
<author><name>doebele@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091026220820.07684238889C@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091026220820-07684238889C@eris-apache-org%3e</id>
<updated>2009-10-26T22:08:19Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: doebele
Date: Mon Oct 26 22:08:18 2009
New Revision: 829996

URL: http://svn.apache.org/viewvc?rev=829996&amp;view=rev
Log:
EMPIREDB-52 - Initial code submitted from Thomas merged

Added:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm   (with props)
    incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm   (with props)
Modified:
    incubator/empire-db/trunk/empire-db-codegen/config.xml
    incubator/empire-db/trunk/empire-db-codegen/pom.xml
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java

Modified: incubator/empire-db/trunk/empire-db-codegen/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=829996&amp;r1=829995&amp;r2=829996&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Mon Oct 26 22:08:18 2009
@@ -27,13 +27,18 @@
 		&lt;jdbcURL&gt;jdbc:oracle:thin:@192.168.0.2:1521:ora10&lt;/jdbcURL&gt;
 		&lt;jdbcUser&gt;DBSAMPLE&lt;/jdbcUser&gt;
 		&lt;jdbcPwd&gt;DBSAMPLE&lt;/jdbcPwd&gt;
+
+		&lt;!-- Schema options --&gt;
+		&lt;dbSchema&gt;DBSAMPLE&lt;/dbSchema&gt;
+		&lt;timestampColumn&gt;&lt;/timestampColumn&gt;
 		
 		&lt;!-- generation options --&gt;
-		&lt;packageName&gt;org.foo.db&lt;/packageName&gt;
-		&lt;dbClassName&gt;MyDB&lt;/dbClassName&gt;
-		&lt;tableBaseName&gt;MyTable&lt;/tableBaseName&gt;
-		&lt;viewBaseName&gt;MyView&lt;/viewBaseName&gt;
-		&lt;recordBaseName&gt;MyRecord&lt;/recordBaseName&gt;
+		&lt;targetFolder&gt;target/generated/dbsample&lt;/targetFolder&gt;
+		&lt;packageName&gt;org.apache.empire.db.samples.dbsample&lt;/packageName&gt;
+		&lt;dbClassName&gt;SampleDB&lt;/dbClassName&gt;
+		&lt;tableBaseName&gt;SampleTable&lt;/tableBaseName&gt;
+		&lt;viewBaseName&gt;SampleView&lt;/viewBaseName&gt;
+		&lt;recordBaseName&gt;SampleRecord&lt;/recordBaseName&gt;
 		&lt;tableClassPrefix&gt;T&lt;/tableClassPrefix&gt;
 		&lt;viewClassPrefix&gt;V&lt;/viewClassPrefix&gt;
 		&lt;nestTables&gt;True&lt;/nestTables&gt;

Modified: incubator/empire-db/trunk/empire-db-codegen/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/pom.xml?rev=829996&amp;r1=829995&amp;r2=829996&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/pom.xml Mon Oct 26 22:08:18 2009
@@ -32,7 +32,8 @@
 		&lt;dependency&gt;
 		    &lt;groupId&gt;org.apache.empire-db&lt;/groupId&gt;
 		    &lt;artifactId&gt;empire-db&lt;/artifactId&gt;
-		&lt;/dependency&gt; 
+		&lt;/dependency&gt;
+		 
 		&lt;dependency&gt;
 			&lt;groupId&gt;org.apache.velocity&lt;/groupId&gt;
 			&lt;artifactId&gt;velocity&lt;/artifactId&gt;
@@ -45,12 +46,14 @@
 		    &lt;artifactId&gt;hsqldb&lt;/artifactId&gt;
 		    &lt;!-- &lt;scope&gt;runtime&lt;/scope&gt; --&gt;
 		&lt;/dependency&gt;
-		&lt;!-- other  
+
+		&lt;!-- 
 		&lt;dependency&gt;
 		    &lt;groupId&gt;ojdbc&lt;/groupId&gt;
 		    &lt;artifactId&gt;ojdbc&lt;/artifactId&gt;
 		    &lt;version&gt;14&lt;/version&gt;
 		&lt;/dependency&gt;
 		--&gt;
+		
 	&lt;/dependencies&gt;
 &lt;/project&gt;
\ No newline at end of file

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java?rev=829996&amp;r1=829995&amp;r2=829996&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGen.java Mon Oct 26 22:08:18 2009
@@ -18,21 +18,76 @@
  */
 package org.apache.empire.db.codegen;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
 import java.sql.Connection;
-import java.sql.DatabaseMetaData;
 import java.sql.DriverManager;
-import java.sql.ResultSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.empire.commons.ErrorObject;
+import org.apache.empire.db.codegen.types.Database;
+import org.apache.empire.db.codegen.types.Table;
+import org.apache.empire.db.codegen.util.FileUtils;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+/**
+ * This is the entry class for generating the java persistence model based on a
+ * database schema.  It uses the Empire DB open-source framework to build a 
+ * java persistence layer for an application.  The Apache Velocity template 
+ * engine is used to create the output interfaces and classes.  
+ * 
+ * The Empire DB framework doesn't try to hide the underlying database and data 
+ * model but instead embraces its power by modeling it within java.  The result 
+ * is a persistence layer that uses a more "object-oriented, type safe" SQL to
+ * access persistent data. 
+ * 
+ * NOTE:  THIS VERSION HAS SEVERE RESTRICTIONS:
+ * 1. Only tables are currently modeled (we'll add views to a later version).
+ * 2. Table indexes are not yet modeled (exception is primary key).  Again, this
+ *      will be added to later editions.
+ * 3. It is assumed that each table has a single INTEGER auto-generated primary
+ *      key column that has the same name for all tables.
+ * 4. It is assumed that each table has a single TIMESTAMP optimistic locking
+ *      column that has the same name for all tables.
+ */
 
 public class CodeGen
 {
     private static final Log log = LogFactory.getLog(CodeGen.class);
 
-    private static CodeGenConfig config = new CodeGenConfig();
-
+    // Templates
+    public static final String TEMPLATE_PATH     =    "src/main/resources/templates/";
+    public static final String DATABASE_TEMPLATE =    "Database.vm";
+    public static final String BASE_TABLE_TEMPLATE =  "BaseTable.vm";
+    public static final String TABLE_TEMPLATE =       "Table.vm";
+    public static final String BASE_RECORD_TEMPLATE = "BaseRecord.vm";
+    public static final String RECORD_TEMPLATE =      "Record.vm";
+    
+    // Properties
+    private CodeGenConfig config;
+    private File baseDir;
+    private File tableDir;
+    private File recordDir;
+    
+    /**
+     * Constructor
+     */
+    public CodeGen() {
+        try {
+            Velocity.init();
+        } catch(Exception e) {
+            log.fatal(e);
+            throw new RuntimeException(e);
+        }
+    }
+    
     /**
      * &lt;PRE&gt;
      * This is the entry point of the Empire-DB Sample Application
@@ -46,16 +101,20 @@
         try
         {
             // Init Configuration
+            CodeGenConfig config = new CodeGenConfig();
             config.init((args.length &gt; 0 ? args[0] : "config.xml" ));
 
             // Enable Exceptions
             ErrorObject.setExceptionsEnabled(true);
 
             // Get a JDBC Connection
-            conn = getJDBCConnection();
+            conn = getJDBCConnection(config);
             
             // List options
             log.info("Database connection successful. Config options are:");
+            log.info("SchemaName="+String.valueOf(config.getDbSchema()));
+            log.info("TimestampColumn="+String.valueOf(config.getTimestampColumn()));
+            log.info("TargetFolder="+config.getTargetFolder());
             log.info("PackageName="+config.getPackageName());
             log.info("DbClassName="+config.getDbClassName());
             log.info("TableBaseName="+config.getTableBaseName());
@@ -65,23 +124,16 @@
             log.info("ViewClassPrefi="+config.getViewClassPrefix());
             log.info("NestTable="+config.isNestTables());
             log.info("NestViews="+config.isNestViews());
-            log.info("CreateRecordPropertie="+config.isCreateRecordProperties());
+            log.info("CreateRecordProperties="+config.isCreateRecordProperties());
             
-            // Get Metadata
-            DatabaseMetaData dmd = conn.getMetaData();
+            CodeGen codeGen = new CodeGen();
+            codeGen.generateCode(conn, config);
             
-            // Process Metadata
-            // ....
-            ResultSet rs = dmd.getCatalogs();
-            while (rs.next()) {
-                System.out.println(rs.getString(1));
-            }
-            rs.close();
+            log.info("Code generation completed sucessfully!");
             
         } catch(Exception e) {
             // Error
-            System.out.println(e.toString());
-            e.printStackTrace();
+            log.error(e.getMessage(), e);
         } finally {
             // done
             if (conn!=null)
@@ -96,7 +148,7 @@
      * Please use the config.xml file to change connection params.
      * &lt;/PRE&gt;
      */
-    private static Connection getJDBCConnection()
+    private static Connection getJDBCConnection(CodeGenConfig config)
     {
         // Establish a new database connection
         Connection conn = null;
@@ -133,4 +185,139 @@
         }
     }
     
+    /**
+     * Generates the source code for the persistence layer.
+     */
+    public void generateCode(Connection conn, CodeGenConfig config) {
+        
+        this.config = config;
+        String packageName = config.getPackageName();
+        String targetFolder = config.getTargetFolder();
+        String dbSchema = config.getDbSchema();
+        String dbLockingCol = config.getTimestampColumn();
+        String dbPkCol = "ID"; // must be made obsolete
+        
+        Database db = new Database(conn, dbSchema);
+        db.populateTableMetaData(dbPkCol, dbLockingCol);
+        
+        // Prepare directories for generated source files
+        this.initDirectories(targetFolder, packageName);
+        
+        // Create the DB class
+        this.createDatabaseClass(db);
+    
+        // Create base table class
+        this.createBaseTableClass(db);
+
+        // Create base record class
+        this.createBaseRecordClass(db);
+        
+        // Create table classes, record interfaces and record classes
+        for (Table table: db.getTables()) {
+            this.createTableClass(db, table);
+            this.createRecordClass(db, table);
+        }
+    }
+    
+    private void initDirectories(String srcLocation, String packageName) {
+        // Create the directory structure for the generated source code.
+        File baseDir = new File(srcLocation);
+        if (!baseDir.exists()) {
+            baseDir.mkdirs();
+        }       
+        StringBuilder sb = new StringBuilder();
+        sb.append(srcLocation).append("/");
+        sb.append(packageName.replaceAll("\\.", "/"));
+        this.baseDir = new File(sb.toString());
+        if (!this.baseDir.exists()) {
+            this.baseDir.mkdirs();
+        }
+        
+        // Clean out the directory so old code is wiped out.
+        FileUtils.cleanDirectory(this.baseDir);
+        
+        // Create the table package directory
+        this.tableDir = new File(this.baseDir, "tables");
+        this.tableDir.mkdir();
+
+        // Create the record package directory
+        this.recordDir = new File(this.baseDir, "records");
+        this.recordDir.mkdir();
+    }
+    
+    private void createDatabaseClass(Database db) {
+        File file = new File(this.baseDir, db.getClassName() + ".java");
+        String packageName = config.getPackageName();
+        VelocityContext context = new VelocityContext();
+        context.put("basePackageName", packageName);       
+        context.put("tableSubPackage", "tables");
+        context.put("database", db);
+        this.writeFile(file, DATABASE_TEMPLATE, context);
+    }
+    
+    private void createBaseTableClass(Database db) {
+        File file = new File(this.tableDir,  db.getBaseTableClassName() + ".java");
+        String packageName = config.getPackageName();
+        VelocityContext context = new VelocityContext();
+        context.put("tablePackageName", packageName + ".tables");      
+        context.put("db", db);
+        this.writeFile(file, BASE_TABLE_TEMPLATE, context);
+    }
+    
+    private void createTableClass(Database db, Table table) {
+        File file = new File(this.tableDir, table.getClassName() + ".java");
+        String packageName = config.getPackageName();
+        VelocityContext context = new VelocityContext();
+        context.put("tablePackageName", packageName + ".tables");      
+        context.put("db", db);
+        context.put("table", table);
+        this.writeFile(file, TABLE_TEMPLATE, context);
+    }
+    
+    private void createBaseRecordClass(Database db) {
+        File file = new File(this.recordDir, "BaseRecord.java");
+        String packageName = config.getPackageName();
+        VelocityContext context = new VelocityContext();
+        context.put("basePackageName", packageName);       
+        context.put("tablePackageName", packageName + ".tables");      
+        context.put("recordPackage", packageName + ".records");        
+        context.put("database", db);
+        this.writeFile(file, BASE_RECORD_TEMPLATE, context);
+    }
+    
+    private void createRecordClass(Database db, Table table) {
+        File file = new File(this.recordDir, table.getRecordClassName() + ".java");
+        String packageName = config.getPackageName();
+        VelocityContext context = new VelocityContext();
+        context.put("basePackageName", packageName);       
+        context.put("tablePackageName", packageName + ".tables");      
+        context.put("recordPackage", packageName + ".records");        
+        context.put("database", db);
+        context.put("table", table);        
+        this.writeFile(file, RECORD_TEMPLATE, context);
+    }
+
+    private void writeFile(File file, String templateName, VelocityContext context) {
+        try {
+            log.info("Writing file for template: " + templateName);
+            Template template = Velocity.getTemplate(TEMPLATE_PATH + templateName);
+            Writer writer = new FileWriter(file);
+            template.merge(context, writer);
+            writer.close();
+        } catch (IOException e) {
+            log.error(e.getClass().getName()+": "+e.getMessage());
+            throw new RuntimeException(e);
+        } catch (ResourceNotFoundException e) {
+            log.error(e.getClass().getName()+": "+e.getMessage());
+            throw new RuntimeException(e);
+        } catch (ParseErrorException e) {
+            log.error(e.getClass().getName()+": "+e.getMessage());
+            throw new RuntimeException(e);
+        } catch (Exception e) {
+            log.error(e.getClass().getName()+": "+e.getMessage());
+            throw new RuntimeException(e);
+        }
+        
+    }
+    
 }

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java?rev=829996&amp;r1=829995&amp;r2=829996&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java Mon Oct 26 22:08:18 2009
@@ -32,6 +32,19 @@
     
     // generation options
     /**
+     * name of the database schema (may be null)
+     */
+    private String dbSchema = null;
+    /**
+     * Name of the timestamp column used for optimistic locking (may be null)
+     */
+    private String timestampColumn = null; // e.g. "UPDATE_TIMESTAMP";
+
+    /**
+     * name of the target folder
+     */
+    private String targetFolder = "target/generated/db";
+    /**
      * name of the target package
      */
     private String packageName = "org.foo.db";
@@ -154,6 +167,36 @@
     }
     
     // ------- generation options -------
+
+    public String getDbSchema()
+    {
+        return dbSchema;
+    }
+
+    public void setDbSchema(String dbSchema)
+    {
+        this.dbSchema = dbSchema;
+    }
+
+    public String getTimestampColumn()
+    {
+        return timestampColumn;
+    }
+
+    public void setTimestampColumn(String timestampColumn)
+    {
+        this.timestampColumn = timestampColumn;
+    }
+
+    public String getTargetFolder()
+    {
+        return targetFolder;
+    }
+
+    public void setTargetFolder(String targetFolder)
+    {
+        this.targetFolder = targetFolder;
+    }
     
     public String getPackageName()
     {

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java Mon Oct 26 22:08:18 2009
@@ -0,0 +1,308 @@
+package org.apache.empire.db.codegen.types;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.codegen.util.StringUtils;
+
+public class Column {
+    private static final Log log = LogFactory.getLog(Column.class);
+
+    private String name;
+	private int sqlType;
+	private int colSize;		// max length if string, precision is numeric
+	private int decimalDigits;	// max decimal digits allowed (real numbers)
+	private boolean required;
+	private String defaultValue;	
+	private String fkTableName;	// Reference parent table if column if FK
+	private boolean pkCol;
+	private boolean lockingCol;	// 
+	
+	// Java transformation
+	private String javaName;
+	private DataType empireType;
+	private String empireTypeString;
+	private String originalJavaTypeString;
+	private String javaTypeString;
+	
+	private boolean convertToBoolean;
+	private String trueValue;
+	private String falseValue;
+
+	private boolean convertToEnum;
+	
+	public String getJavaName() {
+		return javaName;
+	}
+	public void setJavaName(String javaName) {
+		this.javaName = javaName;
+	}
+	public String getJavaTypeString() {
+		return javaTypeString;
+	}
+	public String getEmpireTypeString() {
+		return empireTypeString;
+	}
+	public DataType getEmpireType() {
+		return empireType;
+	}
+	public Column(ResultSet rs) {
+		this(rs, false, false);
+	}
+	public Column(ResultSet rs, boolean primaryKey) {
+		this(rs, primaryKey, false);
+	}
+	public Column(ResultSet rs, boolean primaryKey, boolean foreignKey) {
+		if (primaryKey &amp;&amp; foreignKey) {
+			throw new RuntimeException("Can't have a column that is both " +
+					"a primary and a foreign key.");
+		}
+		
+		try {
+			if (!primaryKey &amp;&amp; !foreignKey) {
+				// Simple column
+				this.name = rs.getString("COLUMN_NAME").toUpperCase();
+				this.sqlType = rs.getInt("DATA_TYPE");
+				this.empireType = this.deriveJavaInfo();
+				this.colSize = rs.getInt("COLUMN_SIZE");
+				this.decimalDigits = rs.getInt("DECIMAL_DIGITS");
+				String nullable = rs.getString("IS_NULLABLE");
+				if (nullable.equalsIgnoreCase("NO"))
+					this.required = true;
+				else
+					this.required = false;
+				this.defaultValue = rs.getString("COLUMN_DEF");
+			}
+			else if (primaryKey) {
+				// Primary key column
+				this.name = rs.getString("COLUMN_NAME").toUpperCase();
+				this.sqlType = Types.INTEGER;
+				this.empireType = DataType.AUTOINC;
+				this.required = true;
+				this.javaName = StringUtils.deriveAttributeName(this.name);
+				this.javaTypeString = "Integer";
+				this.pkCol = true;
+			}
+			else {
+				// Foreign key column
+				this.name = rs.getString("FKCOLUMN_NAME").toUpperCase();
+				this.sqlType = Types.INTEGER;
+				this.empireType = DataType.INTEGER;
+				this.fkTableName = rs.getString("PKTABLE_NAME").toUpperCase();
+				this.javaName = StringUtils.deriveAttributeName(this.name);
+				this.javaTypeString = "Integer";
+			}
+			
+			this.originalJavaTypeString = this.javaTypeString;
+		}
+		catch (SQLException e) {
+			throw new RuntimeException(e);
+		}
+	}
+	@Override
+	public boolean equals(Object obj) {
+		if (obj instanceof Column) {
+			Column that = (Column)obj;
+			if (this.name.equals(that.name)) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	public void convertToBoolean(String trueValue, String falseValue) {
+		if (this.empireType != DataType.TEXT) {
+			throw new RuntimeException(this.name + " must be a string type " +
+					"to convert to boolean");
+		}
+		this.convertToBoolean = true;
+		this.javaTypeString = "Boolean";
+		this.trueValue = trueValue;
+		this.falseValue = falseValue;
+	}
+	
+	public boolean isForeignKey() {
+		return (this.fkTableName != null);
+	}
+	public String getFkTableName() {
+		return fkTableName;
+	}
+	public String getName() {
+		return name.toUpperCase();
+	}
+	public int getSqlType() {
+		return sqlType;
+	}
+	public int getColSize() {
+		return colSize;
+	}
+	public int getDecimalDigits() {
+		return decimalDigits;
+	}
+	public boolean isRequired() {
+		return required;
+	}
+	public String getDefaultValue() {
+		if (defaultValue == null) return "null";
+		
+		return "\"" + defaultValue + "\"";
+	}
+	public boolean isLockingCol() {
+		return lockingCol;
+	}
+	public void setLockingCol(boolean lockingCol) {
+		this.lockingCol = lockingCol;
+	}
+	public boolean isPkCol() {
+		return this.pkCol;
+	}
+	public boolean isBoolean() {
+		if (this.javaTypeString.equalsIgnoreCase("Boolean"))
+			return true;
+		return false;
+	}
+	public boolean isModifiable() {
+		return (!this.isPkCol() &amp;&amp; !this.isLockingCol());
+	}
+	
+	private DataType deriveJavaInfo() {
+		this.javaName = StringUtils.deriveAttributeName(this.name);
+		DataType empireType = DataType.UNKNOWN;
+		switch(this.sqlType) {
+		case Types.INTEGER:
+		case Types.SMALLINT:
+		case Types.TINYINT:
+		case Types.BIGINT:
+			empireType = DataType.INTEGER;
+			empireTypeString = "DataType.INTEGER";
+			javaTypeString = "Long";
+			break;
+		case Types.VARCHAR:
+			empireType = DataType.TEXT;
+			empireTypeString = "DataType.TEXT";
+			javaTypeString = "String";
+			break;
+		case Types.DATE:
+			empireType = DataType.DATE;
+			empireTypeString = "DataType.DATE";
+			javaTypeString = "Date";
+			break;
+		case Types.TIMESTAMP:
+		case Types.TIME:
+			empireType = DataType.DATETIME;
+			empireTypeString = "DataType.DATETIME";
+			javaTypeString = "Date";
+			break;
+		case Types.CHAR:
+			empireType = DataType.CHAR;
+			empireTypeString = "DataType.CHAR";
+			javaTypeString = "String";
+			break;
+		case Types.DOUBLE:
+		case Types.FLOAT:
+		case Types.REAL:
+			empireType = DataType.DOUBLE;
+			empireTypeString = "DataType.DOUBLE";
+			javaTypeString = "Double";
+			break;
+		case Types.DECIMAL:
+		case Types.NUMERIC:
+			empireType = DataType.DECIMAL;
+			empireTypeString = "DataType.DECIMAL";
+			javaTypeString = "BigDecimal";
+			break;
+		case Types.BIT:
+		case Types.BOOLEAN:
+			empireType = DataType.BOOL;
+			empireTypeString = "DataType.BOOL";
+			javaTypeString = "Boolean";
+			break;
+		case Types.CLOB:
+		case Types.LONGVARCHAR:
+			empireType = DataType.CLOB;
+			empireTypeString = "DataType.CLOB";
+			javaTypeString = "String";
+			break;
+		case Types.BINARY:
+		case Types.VARBINARY:
+		case Types.LONGVARBINARY:
+		case Types.BLOB:
+			empireType = DataType.BLOB;
+			empireTypeString = "DataType.BLOB";
+			javaTypeString = "Byte[]";
+			break;
+		default:
+			empireType = DataType.UNKNOWN;
+			empireTypeString = "DataType.UNKNOWN";
+			javaTypeString = "Byte[]";
+			System.out.println("SQL column type " + this.sqlType + " not supported.");
+		}
+		
+		return empireType;
+	}
+	public boolean isConvertToBoolean() {
+		return convertToBoolean;
+	}
+	public String getTrueValue() {
+		return trueValue;
+	}
+	public String getFalseValue() {
+		return falseValue;
+	}
+	public String getOriginalJavaTypeString() {
+		return originalJavaTypeString;
+	}
+	public boolean isConvertToEnum() {
+		return convertToEnum;
+	}
+	public String getJavaAccessorName() {
+		return StringUtils.deriveAccessorName(javaName, 
+				this.javaTypeString.equalsIgnoreCase("boolean"));
+	}
+	public String getJavaMutatorName() {
+		return StringUtils.deriveMutatorName(javaName);
+	}
+	
+	public String getReturnExpression() {
+		if (this.convertToBoolean) {
+			StringBuilder sb = new StringBuilder(this.javaName);
+			sb.append(".equalsIgnoreCase(\"");
+			sb.append(this.trueValue).append("\")");
+			return sb.toString();
+		}
+		else if (this.convertToEnum) {
+			return this.javaTypeString + ".fromDbString(" +
+			this.javaName + ")";
+		}
+		else {
+			return this.javaName;
+		}
+	}
+	public String getSetExpression() {
+		if (this.convertToBoolean) {
+			StringBuilder sb = new StringBuilder(this.javaName);
+			sb.append(" ? \"").append(this.trueValue).append("\" ");
+			sb.append(" : \"").append(this.falseValue).append("\")");
+			return sb.toString();
+		}
+		else if (this.convertToEnum) {
+			return this.javaName + ".toDbString()";
+		}
+		else {
+			return this.javaName;
+		}
+	}
+	public String getPopulateFkRecordMethodName() {
+		StringBuilder sb = new StringBuilder(this.getName());
+		StringUtils.replaceAll(sb, "_" + Table.getPkColName(),
+				"");
+		StringBuilder methodName = new StringBuilder("populate");
+		methodName.append(StringUtils.javaClassName(sb.toString()));
+		methodName.append("Record");
+		return methodName.toString();
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Column.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java Mon Oct 26 22:08:18 2009
@@ -0,0 +1,118 @@
+package org.apache.empire.db.codegen.types;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.db.codegen.util.StringUtils;
+
+public class Database {
+    private static final Log log = LogFactory.getLog(Database.class);
+    
+    private Connection connection;
+	private String schemaName;
+	
+	private Map&lt;String, Table&gt; tableMap = new HashMap&lt;String, Table&gt;();
+
+	public Database(Connection connection, String schemaName) {
+		// Set properties
+		this.connection = connection;
+        this.schemaName = schemaName;
+	}
+	
+	public Connection getConnection() {
+	    return connection;
+	}
+	
+	private void close(ResultSet rs) {
+	    try {
+	        rs.close();
+	    } catch(SQLException e) {
+            throw new RuntimeException(e);
+	    }
+	}
+
+	/**
+	 * Populates meta data for tables in the database.
+	 * @param pkColName Primary key column name.  Note: We assume a single
+	 * 		auto-generated PK column with the same name is used for every
+	 * 		table in the DB.
+	 * @param lockColName Lock column name used for optimistic locking.
+	 * 		Note: We assume a single timestamp column with the same name 
+	 * 		is used for every table in the DB.
+	 */
+	public void populateTableMetaData(String pkColName, String lockColName) {
+		Table.setPkColName(pkColName);
+		Table.setLockColName(lockColName);
+		DatabaseMetaData dbMeta = this.getDbMetaData();
+		ResultSet tables = null;
+		try {
+            log.info("Reading Tables for schema " + schemaName);
+			tables = dbMeta.getTables(null, this.schemaName, null, new String[] {"TABLE"});
+			while (tables.next()) {
+				String tableName = tables.getString("TABLE_NAME");
+				// rd: required for oracle
+				if (tableName.indexOf('$')&gt;=0)
+				    continue; // ignore table names with a "$"
+				// end oracle
+				log.info("Reading Table metadata for " + tableName);
+				Table table = new Table(tableName, this.schemaName, dbMeta);
+				this.tableMap.put(tableName.toUpperCase(), table);				
+			}
+			
+			for (String tableName: this.tableMap.keySet()) {
+				Table table = this.tableMap.get(tableName);
+				for (Column fkCol: table.getFkCols()) {
+					Table parentTable = this.tableMap.get(
+							fkCol.getFkTableName());
+					parentTable.addChildTable(fkCol.getName(), table);
+				}
+			}
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		} finally {
+		    close(tables);
+		}
+	}
+	/**
+	 * Gets the database meta data.
+	 * @return The database meta data.
+	 */
+	public DatabaseMetaData getDbMetaData() {
+		try {
+			return this.getConnection().getMetaData();
+		} catch (SQLException e) {
+			e.printStackTrace();
+			throw new RuntimeException(e);
+		}
+	}
+	
+	public String getClassName() {
+		return StringUtils.javaClassName(this.schemaName) + "Database";
+	}
+
+	public String getBaseTableClassName() {
+		return StringUtils.javaClassName(this.schemaName) + "Table";
+	}
+
+	public String getInstanceName() {
+		return StringUtils.deriveAttributeNameFromClass(this.getClassName());
+	}
+
+	public Collection&lt;Table&gt; getTables() {
+		return tableMap.values();
+	}
+	public Table getTable(String name) {
+		return this.tableMap.get(name.toUpperCase());
+	}
+	
+	public String getSchemaName() {
+		return schemaName;
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Database.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java Mon Oct 26 22:08:18 2009
@@ -0,0 +1,186 @@
+package org.apache.empire.db.codegen.types;
+
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.codegen.util.StringUtils;
+
+public class Table {
+    private static final Log log = LogFactory.getLog(Table.class);
+    
+    private String tableName;
+	private Column pkCol;
+	private List&lt;Column&gt; fkCols;
+	private List&lt;Column&gt; simpleCols;
+	private Column lockingCol;
+	
+	private Map&lt;String, Column&gt; columnMap = new HashMap&lt;String, Column&gt;();
+	
+	private List&lt;Child&gt; childTables = new ArrayList&lt;Child&gt;();
+	
+	private static String pkColName;
+	private static String lockColName;
+
+	public Table(String tableName, String schema, 
+			DatabaseMetaData dbMeta) {
+		this.tableName = tableName.toUpperCase();
+		this.createColumns(dbMeta, schema);
+	}
+	
+	public static String getPkColName() {
+		return pkColName;
+	}
+	public static void setPkColName(String name) {
+		pkColName = name;
+	}
+	public static String getLockColName() {
+		return lockColName;
+	}
+	public static void setLockColName(String name) {
+		lockColName = name;
+	}
+	
+	public void addChildTable(String fkColName, Table table) {
+		this.childTables.add(new Child(fkColName, table));
+	}
+	public List&lt;Child&gt; getChildTables() {
+		return this.childTables;
+	}
+	public String getTableName() {
+		return tableName.toUpperCase();
+	}
+
+	public Column getPkCol() {
+		return pkCol;
+	}
+
+	public List&lt;Column&gt; getFkCols() {
+		return fkCols;
+	}
+
+	public List&lt;Column&gt; getSimpleCols() {
+		return simpleCols;
+	}
+
+	public Column getLockingCol() {
+		return this.lockingCol;
+	}
+	
+	public String getClassName() {
+		return StringUtils.javaClassName(this.tableName) + "Table";
+	}
+	public String getRecordClassName() {
+		return StringUtils.javaClassName(this.tableName) + "Record";
+	}
+	public boolean hasBigDecimalField() {
+		boolean bdField = false;
+		for (Column col: this.simpleCols) {
+			if (col.getEmpireType() == DataType.DECIMAL) {
+				bdField = true;
+				break;
+			}
+		}
+		return bdField;
+	}
+	public boolean hasChildRecords() {
+		return !this.childTables.isEmpty();
+	}
+	public Column getColumn(String name) {
+		return this.columnMap.get(name.toUpperCase());
+	}
+	public static class Child {
+		Child(String fkColName, Table childTable) {
+			this.fkColName = fkColName;
+			this.childTable = childTable;
+		}
+		private String fkColName;
+		private Table childTable;
+		public String getFkColName() {
+			return fkColName.toUpperCase();
+		}
+		public Table getChildTable() {
+			return childTable;
+		}
+		public String getChildType() {
+			return StringUtils.javaClassName(childTable.getTableName());
+		}
+		public String getFkType() {
+			StringBuilder sb = new StringBuilder(this.fkColName.toUpperCase());
+			StringUtils.replaceAll(sb, "_" + Table.getPkColName(),
+					"");
+			return StringUtils.javaClassName(sb.toString());
+		}
+		public String getFkMutatorName() {
+			Column col = childTable.getColumn(this.fkColName);
+			return col.getJavaMutatorName();
+		}
+	}
+	// ------------------------------------------------------------------------
+	// Private members
+	// ------------------------------------------------------------------------
+	private void createColumns(DatabaseMetaData dbMeta, String schema) {
+		this.pkCol = this.findPkColumn(dbMeta, schema);
+		this.columnMap.put(pkCol.getName().toUpperCase(), pkCol);
+		this.simpleCols = new ArrayList&lt;Column&gt;();
+		this.fkCols = this.findFkColumns(dbMeta, schema);
+		for (Column col: this.fkCols) {
+			this.columnMap.put(col.getName().toUpperCase(), col);
+		}
+		try {
+			ResultSet rs = dbMeta.getColumns(null, schema, tableName, "");			
+			while (rs.next()) {
+				Column col = new Column(rs);
+				if (!col.equals(pkCol) &amp;&amp; !fkCols.contains(col)) {
+					if (col.getName().equalsIgnoreCase(lockColName)) {
+						this.lockingCol = col;
+						col.setLockingCol(true);
+					}
+					else {
+						this.simpleCols.add(col);
+					}
+					this.columnMap.put(col.getName().toUpperCase(), col);
+				}
+			}
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		}		
+	}
+	
+	private Column findPkColumn(DatabaseMetaData dbMeta, String schema) {
+		try {
+			ResultSet pkRs = dbMeta.getPrimaryKeys(null, schema, tableName);
+			if(pkRs.next()) {
+				Column col = new Column(pkRs, true);
+				return col;
+			}
+			else {
+				throw new RuntimeException("Primary key not found for table " +
+						this.tableName);
+			}
+
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		}		
+	}
+	private List&lt;Column&gt; findFkColumns(DatabaseMetaData dbMeta, String schema) {
+		List&lt;Column&gt; fkCols = new ArrayList&lt;Column&gt;();
+		try {
+			ResultSet fkRs = dbMeta.getImportedKeys(null, schema, tableName);
+			while(fkRs.next()) {
+				Column col = new Column(fkRs, false, true);
+				fkCols.add(col);
+			}
+		} catch (SQLException e) {
+			throw new RuntimeException(e);
+		}		
+		return fkCols;
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/types/Table.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java Mon Oct 26 22:08:18 2009
@@ -0,0 +1,143 @@
+package org.apache.empire.db.codegen.util;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+public class FileUtils {
+	/**
+	 * Recursively cleans (removes) all files under the given 
+	 * directory.  Note that this removes all sub-directories
+	 * but not the parent directory.  
+	 * @param directory
+	 */
+	public static void cleanDirectory(File directory) {
+		if (directory.isDirectory()) {
+            String[] children = directory.list();
+            for (int i=0; i&lt;children.length; i++) {
+            	File child = new File(directory, children[i]);
+            	if (child.isDirectory()) deleteDirectory(child);
+            	else child.delete();
+            }
+        }
+	}
+	
+	/**
+	 * Recursively deletes a directory and everything under it.
+	 * @param directory
+	 */
+	public static void deleteDirectory(File directory) {
+        if (directory.isDirectory()) {
+            String[] children = directory.list();
+            for (int i=0; i&lt;children.length; i++) {
+            	deleteDirectory(new File(directory, children[i]));
+            }
+        }   
+        // The directory is now empty so delete it
+        directory.delete();
+	}
+	
+	/**
+	 * Non-recursive delete for all files in the given directory.
+	 * Files in sub-directories not deleted.
+	 * @param directory
+	 */
+	public static void deleteFiles(File directory) {
+		if (directory.isDirectory()) {
+            String[] children = directory.list();
+            for (int i=0; i&lt;children.length; i++) {
+            	new File(directory, children[i]).delete();
+            }
+        }
+	}
+	public static Object readObject(String fileName) {
+		Object o = null;
+		try {
+			ObjectInputStream ois = new ObjectInputStream(
+				new FileInputStream(fileName));
+			o = ois.readObject();
+			ois.close();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+		}
+		return o;
+	}
+	
+	public static void writeObject(String fileName, Object o) {
+		try {
+			ObjectOutputStream oos = new ObjectOutputStream(
+				new FileOutputStream(fileName));
+			oos.writeObject(o);
+			oos.close();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	public static String getFileAsString(File file) {
+		StringBuilder sb = new StringBuilder();
+		try {
+			BufferedReader br = new BufferedReader(
+					new FileReader(file));
+			String line;
+			while ( (line = br.readLine()) != null) {
+				sb.append(line).append("\n");
+			}
+			br.close();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return sb.toString();
+	}
+
+	public static void writeStringToFile(File file, String contents) {
+		try {
+			if (!file.exists()) {
+				file.createNewFile();
+			}
+			BufferedWriter bw;
+			bw = new BufferedWriter(new FileWriter(file));
+			bw.write(contents);
+			bw.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+	}
+
+	public static void replaceAll(File file, String input, String output) {
+		String fileText = getFileAsString(file);
+		StringBuilder sb = new StringBuilder(fileText);
+		int index = -1;
+		int length = input.length();
+		while ( (index = sb.indexOf(input)) != -1 ) {
+			sb.replace(index, index + length, output);
+		}
+		BufferedWriter bw;
+		try {
+			bw = new BufferedWriter(
+					new FileWriter(file));
+			bw.write(sb.toString());
+			bw.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+	}
+
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/FileUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java Mon Oct 26 22:08:18 2009
@@ -0,0 +1,86 @@
+package org.apache.empire.db.codegen.util;
+
+public class StringUtils {
+	/**
+	 * Derives a java class name from a database table name.
+	 * @param tableName
+	 * @return
+	 */
+	public static String javaClassName(String name) {
+		StringBuilder sb = new StringBuilder();
+		sb.append(Character.toUpperCase(name.charAt(0)));
+		boolean upperCase = false;
+		for (int i=1; i&lt;name.length(); i++) {
+			char c = name.charAt(i);
+			if (c == '_') {
+				upperCase = true;
+				continue;
+			}
+			if (upperCase) sb.append(Character.toUpperCase(c));
+			else sb.append(Character.toLowerCase(c));
+			upperCase = false;
+		}
+		return sb.toString();
+	}
+	/**
+	 * Derives a java attribute name from a database column name.
+	 * @param colName
+	 * @return
+	 */
+	public static String deriveAttributeName(String colName) {
+		String name = javaClassName(colName);
+		StringBuilder sb = new StringBuilder();
+		sb.append(Character.toLowerCase(name.charAt(0)));
+		sb.append(name.substring(1));
+		return sb.toString();
+	}
+	/**
+	 * Derives an attribute name from the given class name.
+	 * @param className
+	 * @return
+	 */
+	public static String deriveAttributeNameFromClass(String className) {
+		StringBuilder sb = new StringBuilder();
+		sb.append(Character.toLowerCase(className.charAt(0)));
+		sb.append(className.substring(1));
+		return sb.toString();
+	}
+	/**
+	 * Derives the accessor method name based on the attribute name.
+	 * @param attribute
+	 * @param isBoolean
+	 * @return
+	 */
+	public static String deriveAccessorName(String attribute, boolean isBoolean) {
+		StringBuilder sb = new StringBuilder();
+		if (isBoolean) sb.append("is");
+		else sb.append("get");
+		sb.append(Character.toUpperCase(attribute.charAt(0)));
+		sb.append(attribute.substring(1));
+		return sb.toString();
+	}
+	/**
+	 * Derives the mutator method name based on the attribute name.
+	 * @param attribute
+	 * @return
+	 */
+	public static String deriveMutatorName(String attribute) {
+		StringBuilder sb = new StringBuilder();
+		sb.append("set");
+		sb.append(Character.toUpperCase(attribute.charAt(0)));
+		sb.append(attribute.substring(1));
+		return sb.toString();
+	}
+
+	public static StringBuilder replaceAll(StringBuilder sb, 
+			String oldValue, String newValue) {
+		int strIndex = sb.indexOf(oldValue);
+		int endIndex;
+		while (strIndex &gt; -1) {
+			endIndex = strIndex + oldValue.length();
+			sb.replace(strIndex, endIndex, newValue);
+			strIndex = sb.indexOf(oldValue, strIndex);
+		}
+		return sb;
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/util/StringUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm Mon Oct 26 22:08:18 2009
@@ -0,0 +1,21 @@
+package ${recordPackage};
+
+import org.apache.empire.db.DBRecord;
+import ${tablePackageName}.${database.baseTableClassName};
+
+//import ${basePackageName}.${database.className};
+
+public abstract class BaseRecord&lt;T extends ${database.baseTableClassName}&gt; extends DBRecord {
+	public BaseRecord(T table) {
+		super.init(table, DBRecord.REC_EMTPY, null);
+	}
+
+	/**
+	 * Returns the table this record is based upon.
+	 * @return The table this record is based upon.
+	 */
+	@SuppressWarnings("unchecked")
+	public T getDbTable() {
+		return (T)super.getRowSet();
+	}
+}
\ No newline at end of file

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseRecord.vm
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm Mon Oct 26 22:08:18 2009
@@ -0,0 +1,10 @@
+package $tablePackageName;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTable;
+
+public class ${db.baseTableClassName} extends DBTable {
+	public ${db.baseTableClassName}(String name, DBDatabase db) {
+		super(name, db);
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseTable.vm
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm Mon Oct 26 22:08:18 2009
@@ -0,0 +1,105 @@
+package $basePackageName;
+
+import java.sql.Connection;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import org.apache.empire.db.DBCommand;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBReader;
+import org.apache.empire.db.DBRecord;
+
+import $basePackageName.$tableSubPackage.*;
+
+public class $database.className extends DBDatabase {
+#foreach($table in $database.tables)
+	public final $table.className T_$table.tableName = new ${table.className}(this);
+#end
+	
+	/**
+	 * Returns the instance of the database.
+	 * @return
+	 */
+	public static $database.className get() {
+		if (instance == null) {
+			instance = new GamesDatabase();
+		}
+		return instance;
+	}
+	
+	/**
+	 * Default constructor for the $database.className.  Relationship between the
+	 * tables that make up the database are specified here. 
+	 */
+	private ${database.className}() {
+		// FK relationships
+#foreach($table in $database.tables)
+#foreach($fkCol in $table.fkCols)
+		super.addRelation(T_${table.tableName}.${fkCol.name}.referenceOn(T_${fkCol.fkTableName}.${table.pkColName}));
+#end
+#end
+	}
+	
+	/**
+	 * Convenience method that returns a single DB record based on a given 
+	 * command (i.e. query).  Only use this method for queries that should only
+	 * return a single value. 
+	 * @param &lt;T&gt; The DB record type.
+	 * @param recordType The DB record class.
+	 * @param command The command (or query) to execute.
+	 * @return 
+	 */
+	public &lt;T extends DBRecord&gt; T findRecord(Class&lt;T&gt; recordType, 
+			DBCommand command, Connection conn) {
+		DBReader reader = new DBReader();
+		T record = null;
+		try {
+			if (reader.getRecordData(command, conn)) {
+				record = recordType.newInstance();
+				reader.initRecord(record.getRowSet(), record);
+			}
+		} catch (InstantiationException e) {
+			throw new RuntimeException(e);
+		} catch (IllegalAccessException e) {
+			throw new RuntimeException(e);
+		}
+		finally {
+			reader.close();
+		}	
+		return record;
+	}
+	
+	/**
+	 * Convenience method that returns a list of DB records based on a given 
+	 * command (i.e. query).
+	 * @param &lt;T&gt; The DB record type.
+	 * @param recordType The DB record class.
+	 * @param command The command (or query) to execute.
+	 * @return 
+	 */
+	public &lt;T extends DBRecord&gt; List&lt;T&gt; findRecords(Class&lt;T&gt; recordType, 
+			DBCommand command, Connection conn) {
+		List&lt;T&gt; records = new ArrayList&lt;T&gt;();
+		DBReader reader = new DBReader();
+		try {
+			reader.open(command, conn);
+			while (reader.moveNext()) {
+				T record = recordType.newInstance();
+				reader.initRecord(record.getRowSet(), record);
+				records.add(record);
+			}
+		} catch (InstantiationException e) {
+			throw new RuntimeException(e);
+		} catch (IllegalAccessException e) {
+			throw new RuntimeException(e);
+		}
+		finally {
+			reader.close();
+		}
+		return records;
+	}
+		
+	private static $database.className instance;
+	private static final long serialVersionUID = 1L;
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Database.vm
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm Mon Oct 26 22:08:18 2009
@@ -0,0 +1,72 @@
+package ${recordPackage};
+
+#if ($table.hasBigDecimalField())
+import java.math.BigDecimal;
+#end
+import java.util.Date;
+
+import ${basePackageName}.${database.className};
+import ${tablePackageName}.${table.className};
+
+/**
+ * Auto-generated class that represents one record (or row) of data from a
+ * database table.  One of these is generated for each table or view in the
+ * database.  The interface defines getters for auto-generated data (e.g. 
+ * primary key, time stamp field for optimistic locking).  It generates both
+ * getter and setter method for all other columns in the table, with the 
+ * exception of foreign key references.
+ *
+ * This class provides protected method that subclasses should use to provide
+ * access to related records.
+ */
+public class ${table.recordClassName} extends BaseRecord&lt;${table.className}&gt; {
+	public ${table.recordClassName}() {
+		super(${database.className}.get().T_${table.tableName});
+	}
+	
+	// Primary key getter
+	public Integer ${table.pkCol.javaAccessorName}() {
+		return (Integer)super.getValue(getDbTable().${table.pkCol.name});
+	}
+	
+	// Access methods for simple attributes
+#foreach($col in $table.simpleCols)
+	public ${col.javaTypeString} ${col.javaAccessorName}() {
+		${col.originalJavaTypeString} ${col.javaName} = (${col.originalJavaTypeString})super.getValue(getDbTable().${col.name});
+		return ${col.returnExpression};
+	}
+	public void ${col.javaMutatorName}(${col.javaTypeString} ${col.javaName}) {
+		super.setValue(getDbTable().${col.name}, ${col.setExpression});
+	}
+#end
+
+	// Optimistic locking getter
+	public ${table.lockingCol.javaTypeString} ${table.lockingCol.javaAccessorName}() {
+		return (${table.lockingCol.javaTypeString})super.getValue(getDbTable().${table.lockingCol.name});		
+	}
+	
+	@Override
+    public boolean equals(Object object) {  
+        if (object == this)  
+            return true;  
+        if ((object == null) || !(object instanceof ${table.recordClassName}))  
+            return false;  
+   
+        final ${table.recordClassName} a = (${table.recordClassName})object;  
+   
+        if (${table.pkCol.javaAccessorName}() != null &amp;&amp; a.${table.pkCol.javaAccessorName}() != null) {  
+            return ${table.pkCol.javaAccessorName}().equals(a.${table.pkCol.javaAccessorName}());  
+        }  
+        return false;  
+    }
+    
+    // FK references
+    #foreach($col in $table.fkCols)
+	public Integer ${col.javaAccessorName}() {
+		return (Integer)super.getValue(getDbTable().${col.name});
+	}
+	public void ${col.javaMutatorName}(Integer ${col.javaName}) {
+		super.setValue(getDbTable().${col.name}, ${col.javaName});
+	}
+    #end
+}
\ No newline at end of file

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Record.vm
------------------------------------------------------------------------------
    eol-style = native

Added: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm?rev=829996&amp;view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm (added)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm Mon Oct 26 22:08:18 2009
@@ -0,0 +1,51 @@
+package $tablePackageName;
+
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBTableColumn;
+
+public class ${table.className} extends ${db.baseTableClassName} {
+	// Primary key column
+	public final DBTableColumn ${table.pkCol.name};
+	
+	// Regular attributes
+#foreach ($col in $table.simpleCols)
+	public final DBTableColumn ${col.name};
+#end
+	
+	// Optimistic locking attribute
+	public final DBTableColumn ${table.lockingCol.name};
+	
+	// Foreign key columns
+#foreach ($col in $table.fkCols)
+	public final DBTableColumn ${col.name};
+#end
+	
+	public ${table.className}(DBDatabase db) {
+		super("${table.tableName}", db);
+		
+		// Primary key column
+		${table.pkCol.name} = super.addColumn("${table.pkCol.name}", DataType.AUTOINC, 0, true);
+		
+		// Regular attributes
+#foreach ($col in $table.simpleCols)
+		${col.name} = super.addColumn("${col.name}", DataType.${col.empireType}, ${col.colSize}, ${col.required}, ${col.defaultValue});
+#end
+
+		// Optimistic locking attribute
+		${table.lockingCol.name} = super.addColumn("${table.lockingCol.name}", DataType.DATETIME, 0, false);
+		
+		// Foreign key columns
+#foreach ($col in $table.fkCols)
+		${col.name} = super.addColumn("${col.name}", DataType.INTEGER, 0, ${col.required});
+#end		
+		// Primary key
+		super.setPrimaryKey(${table.pkCol.name});
+		
+		// Optimistic locking column
+		super.setTimestampColumn(${table.lockingCol.name});
+		
+		// Set cascade delete
+		super.setCascadeDelete(true);		
+	}
+}

Propchange: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/Table.vm
------------------------------------------------------------------------------
    eol-style = native




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r826525 - in /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire: db/DBQuery.java xml/XMLUtil.java</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091018205850.6AC5123888EA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091018205850-6AC5123888EA@eris-apache-org%3e</id>
<updated>2009-10-18T20:58:50Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sun Oct 18 20:58:49 2009
New Revision: 826525

URL: http://svn.apache.org/viewvc?rev=826525&amp;view=rev
Log:
more efficient java 5 way of iterating through maps

Modified:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLUtil.java

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java?rev=826525&amp;r1=826524&amp;r2=826525&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java Sun
Oct 18 20:58:49 2009
@@ -20,8 +20,8 @@
 
 import java.sql.Connection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.empire.commons.Errors;
@@ -413,13 +413,14 @@
         }
         // the commands
         Object[] keys = (Object[]) rec.getRowSetData();
-        Iterator&lt;DBRowSet&gt; tables = updCmds.keySet().iterator();
-        while (tables.hasNext())
+        DBRowSet table;
+        DBCommand upd;
+        for(Entry&lt;DBRowSet,DBCommand&gt; entry:updCmds.entrySet())
         {
             int i = 0;
             // Iterate through options
-            DBRowSet table = tables.next();
-            DBCommand upd = updCmds.get(table);
+            table = entry.getKey();
+            upd = entry.getValue();
             // Is there something to update
             if (upd.set == null)
                 continue; // nothing to do for this table!

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLUtil.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLUtil.java?rev=826525&amp;r1=826524&amp;r2=826525&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLUtil.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLUtil.java Sun
Oct 18 20:58:49 2009
@@ -18,8 +18,8 @@
  */
 package org.apache.empire.xml;
 
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -139,12 +139,9 @@
         if (root == null)
             return false;
         // Add Namespace attributes
-        Iterator&lt;String&gt; i = nsMap.keySet().iterator();
-        while (i.hasNext())
+        for(Entry&lt;String, String&gt; entry:nsMap.entrySet())
         {
-            String key = i.next();
-            String val = nsMap.get(key);
-            root.setAttribute("xmlns:" + key, val);
+            root.setAttribute("xmlns:" + entry.getKey(), entry.getValue());
         }
         return true;
     }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r826516 - in /incubator/empire-db/trunk/empire-db-examples: empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091018202839.E27A823888EA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091018202839-E27A823888EA@eris-apache-org%3e</id>
<updated>2009-10-18T20:28:39Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sun Oct 18 20:28:39 2009
New Revision: 826516

URL: http://svn.apache.org/viewvc?rev=826516&amp;view=rev
Log:
FindBugs: Missing throw for exception

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ServerControl.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleApplication.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ServerControl.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ServerControl.java?rev=826516&amp;r1=826515&amp;r2=826516&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ServerControl.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/server/ServerControl.java
Sun Oct 18 20:28:39 2009
@@ -231,8 +231,9 @@
         script.run(driver, conn, false);
         db.commit(conn);
         // Open again
-        if (!db.isOpen() &amp;&amp; !db.open(driver, conn))
-            new RuntimeException(driver.getErrorMessage());
+        if (!db.isOpen() &amp;&amp; !db.open(driver, conn)){
+            throw new RuntimeException(driver.getErrorMessage());
+        }
         // Insert Sample Departments
         int idDevDep = insertDepartmentSampleRecord(conn, "Development", "ITTK");
         int idSalDep = insertDepartmentSampleRecord(conn, "Sales", "ITTK");

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleApplication.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleApplication.java?rev=826516&amp;r1=826515&amp;r2=826516&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleApplication.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/SampleApplication.java
Sun Oct 18 20:28:39 2009
@@ -216,8 +216,9 @@
         script.run(driver, conn, false);
         db.commit(conn);
         // Open again
-        if (!db.isOpen() &amp;&amp; !db.open(driver, conn))
-            new RuntimeException(driver.getErrorMessage());
+        if (!db.isOpen() &amp;&amp; !db.open(driver, conn)){
+            throw new RuntimeException(driver.getErrorMessage());
+        }
 		// Insert Sample Departments
 		int idDevDep = insertDepartmentSampleRecord(conn, "Development", "ITTK");
 		int idSalDep = insertDepartmentSampleRecord(conn, "Sales", "ITTK");




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r826515 - /incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091018202011.4B24623888EA@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091018202011-4B24623888EA@eris-apache-org%3e</id>
<updated>2009-10-18T20:20:11Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sun Oct 18 20:20:10 2009
New Revision: 826515

URL: http://svn.apache.org/viewvc?rev=826515&amp;view=rev
Log:
remove obsolete semicolon

Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java?rev=826515&amp;r1=826514&amp;r2=826515&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/ws/records/EmployeeRecord.java
Sun Oct 18 20:20:10 2009
@@ -50,7 +50,7 @@
     	}
     	else
     	{
-    		opts=super.getFieldOptions(column);;
+    		opts = super.getFieldOptions(column);
     	}
     	return opts;
     }




</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r826511 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091018200203.10A0823888BD@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091018200203-10A0823888BD@eris-apache-org%3e</id>
<updated>2009-10-18T20:02:03Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sun Oct 18 20:02:02 2009
New Revision: 826511

URL: http://svn.apache.org/viewvc?rev=826511&amp;view=rev
Log:
EMPIREDB-55
fix enforced java version rule to allow all 1.5 versions

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=826511&amp;r1=826510&amp;r2=826511&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Sun Oct 18 20:02:02 2009
@@ -411,7 +411,7 @@
 					&lt;configuration&gt;
 						&lt;rules&gt;
 							&lt;requireJavaVersion&gt;
-								&lt;version&gt;[1.5]&lt;/version&gt;
+								&lt;version&gt;[1.5,1.6)&lt;/version&gt;
 							&lt;/requireJavaVersion&gt;
 						&lt;/rules&gt;
 					&lt;/configuration&gt;




</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Updated: (EMPIREDB-54) Streamline the release process</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c431750646.1255895611266.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c431750646-1255895611266-JavaMail-jira@brutus%3e</id>
<updated>2009-10-18T19:53:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-54?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Francis De Brabandere updated EMPIREDB-54:
------------------------------------------

    Description: 
Try to have the jar's in the dist and in the maven repository equal.
(minor issue on previous release vote)

Further it would be nice if we could add svn properties check (also for CI build) and other
related stuff. See previous 2.0.5-rc release vote threads on general@

  was:
Try to have the jar's in the dist and in the maven repository equal.
(minor issue on previous release vote)

Further it would be nice if we could add some java5 check, svn properties check (also for
CI build) and other related stuff. See previous 2.0.5-rc release vote threads on general@


&gt; Streamline the release process
&gt; ------------------------------
&gt;
&gt;                 Key: EMPIREDB-54
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-54
&gt;             Project: Empire-DB
&gt;          Issue Type: Improvement
&gt;          Components: Core
&gt;    Affects Versions: empire-db-2.0.6-incubating
&gt;            Reporter: Francis De Brabandere
&gt;            Assignee: Francis De Brabandere
&gt;
&gt; Try to have the jar's in the dist and in the maven repository equal.
&gt; (minor issue on previous release vote)
&gt; Further it would be nice if we could add svn properties check (also for CI build) and
other related stuff. See previous 2.0.5-rc release vote threads on general@

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>[jira] Resolved: (EMPIREDB-55) enforce java 1.5 for the maven release profile</title>
<author><name>&quot;Francis De Brabandere (JIRA)&quot; &lt;empire-db-dev@incubator.apache.org&gt;</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c349702198.1255895251291.JavaMail.jira@brutus%3e"/>
<id>urn:uuid:%3c349702198-1255895251291-JavaMail-jira@brutus%3e</id>
<updated>2009-10-18T19:47:31Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>

     [ https://issues.apache.org/jira/browse/EMPIREDB-55?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Francis De Brabandere resolved EMPIREDB-55.
-------------------------------------------

       Resolution: Fixed
    Fix Version/s: empire-db-2.0.6-incubating

Java 1.5 now enforced for 'release' and 'CI' profile


http://maven.apache.org/plugins/maven-enforcer-plugin/

&gt; enforce java 1.5 for the maven release profile
&gt; ----------------------------------------------
&gt;
&gt;                 Key: EMPIREDB-55
&gt;                 URL: https://issues.apache.org/jira/browse/EMPIREDB-55
&gt;             Project: Empire-DB
&gt;          Issue Type: Improvement
&gt;          Components: Core
&gt;            Reporter: Francis De Brabandere
&gt;            Assignee: Francis De Brabandere
&gt;             Fix For: empire-db-2.0.6-incubating
&gt;
&gt;
&gt; This should make sure we never accidentally release a Java 6 compiled empire-db version
&gt; http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
&gt; we could also enable this for the Continuous Integration profile

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



</pre>
</div>
</content>
</entry>
<entry>
<title>svn commit: r826510 - /incubator/empire-db/trunk/pom.xml</title>
<author><name>francisdb@apache.org</name></author>
<link rel="alternate" href="http://mail-archives.apache.org/mod_mbox/incubator-empire-db-commits/200910.mbox/%3c20091018194540.4DD4B23888D0@eris.apache.org%3e"/>
<id>urn:uuid:%3c20091018194540-4DD4B23888D0@eris-apache-org%3e</id>
<updated>2009-10-18T19:45:40Z</updated>
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>
Author: francisdb
Date: Sun Oct 18 19:45:39 2009
New Revision: 826510

URL: http://svn.apache.org/viewvc?rev=826510&amp;view=rev
Log:
EMPIREDB-55
Enforce java 1.5 for release and CI

Modified:
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=826510&amp;r1=826509&amp;r2=826510&amp;view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Sun Oct 18 19:45:39 2009
@@ -105,11 +105,24 @@
 							&lt;/execution&gt;
 						&lt;/executions&gt;
 					&lt;/plugin&gt;
+					&lt;!-- enable enforcer for java 1.5 --&gt;
+					&lt;plugin&gt;
+						&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+						&lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
+						&lt;executions&gt;
+							&lt;execution&gt;
+								&lt;id&gt;enforce-versions&lt;/id&gt;
+								&lt;goals&gt;
+									&lt;goal&gt;enforce&lt;/goal&gt;
+								&lt;/goals&gt;
+							&lt;/execution&gt;
+						&lt;/executions&gt;
+					&lt;/plugin&gt;
 				&lt;/plugins&gt;
 			&lt;/build&gt;
 		&lt;/profile&gt;
 		&lt;profile&gt;
-			&lt;!-- Part of the release profile, rest in apache parent pom --&gt;
+			&lt;!-- Part of the release profile, merged with release profile defined in apache parent
pom --&gt;
 			&lt;id&gt;release&lt;/id&gt;
 			&lt;build&gt;
 				&lt;plugins&gt;
@@ -126,6 +139,19 @@
 							&lt;/execution&gt;
 						&lt;/executions&gt;
 					&lt;/plugin&gt;
+					&lt;!-- enable enforcer for java 1.5 --&gt;
+					&lt;plugin&gt;
+						&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+						&lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
+						&lt;executions&gt;
+							&lt;execution&gt;
+								&lt;id&gt;enforce-versions&lt;/id&gt;
+								&lt;goals&gt;
+									&lt;goal&gt;enforce&lt;/goal&gt;
+								&lt;/goals&gt;
+							&lt;/execution&gt;
+						&lt;/executions&gt;
+					&lt;/plugin&gt;
 				&lt;/plugins&gt;
 			&lt;/build&gt;
 		&lt;/profile&gt;
@@ -377,6 +403,19 @@
 		                &lt;/execution&gt;
 		            &lt;/executions&gt;
 		        &lt;/plugin&gt;
+		        &lt;!-- When enforcer enabled this will make sure we compile using java 1.5 --&gt;
+				&lt;plugin&gt;
+					&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
+					&lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
+					&lt;version&gt;1.0-beta-1&lt;/version&gt;
+					&lt;configuration&gt;
+						&lt;rules&gt;
+							&lt;requireJavaVersion&gt;
+								&lt;version&gt;[1.5]&lt;/version&gt;
+							&lt;/requireJavaVersion&gt;
+						&lt;/rules&gt;
+					&lt;/configuration&gt;
+				&lt;/plugin&gt;
 			&lt;/plugins&gt;
 		&lt;/pluginManagement&gt;
 	&lt;/build&gt;




</pre>
</div>
</content>
</entry>
</feed>
