empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r905080 - in /incubator/empire-db/trunk: empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-codegen/src/main/resources/templates/ empire-db-examples/empire-db-example-codegen/ empire-db-examples/empire-db-example-codege...
Date Sun, 31 Jan 2010 17:43:21 GMT
Author: francisdb
Date: Sun Jan 31 17:43:20 2010
New Revision: 905080

URL: http://svn.apache.org/viewvc?rev=905080&view=rev
Log:
EMPIREDB-64
Some more options for the maven plugin
Get rid of deprecated api (com.sun.xxx)

Modified:
    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/CodeGenConfig.java
    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/BaseView.vm
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/pom.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/src/test/java/org/apache/empire/db/examples/codegen/ValidatePluginRunTest.java
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java

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=905080&r1=905079&r2=905080&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
Sun Jan 31 17:43:20 2010
@@ -33,7 +33,6 @@
 	
 	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.

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=905080&r1=905079&r2=905080&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 Jan 31 17:43:20 2010
@@ -57,7 +57,7 @@
 	/**
 	 * name of the template folder
 	 */
-	private String templateFolder = "src/main/resources/templates";	
+	private String templateFolder;	
 	
 	/**
 	 * name of the target package

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=905080&r1=905079&r2=905080&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
Sun Jan 31 17:43:20 2010
@@ -179,6 +179,7 @@
 	private File createDatabaseClass(DBDatabase db) {
 		File file = new File(baseDir, config.getDbClassName() + ".java");
 		VelocityContext context = new VelocityContext();
+		// TODO fall back to getPackageName() is the other names are not set
 		context.put("parser", parserUtil);
 		context.put("tableClassSuffix", config.getTableClassSuffix());
 		context.put("basePackageName", config.getPackageName());

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseView.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseView.vm?rev=905080&r1=905079&r2=905080&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseView.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/BaseView.vm Sun
Jan 31 17:43:20 2010
@@ -22,8 +22,6 @@
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBView;
 
-import sun.reflect.generics.reflectiveObjects.NotImplementedException;
-
 public class ${baseViewClassName} extends DBView {
 	public ${baseViewClassName}(String name, DBDatabase db) {
 		super(name, db);
@@ -33,6 +31,6 @@
     public DBCommandExpr createCommand()
     {
     	// TODO not IMPLEMENTED
-        throw new NotImplementedException();
+        throw new UnsupportedOperationException("Not iplemented");
     }
 }

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/pom.xml?rev=905080&r1=905079&r2=905080&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/pom.xml Sun Jan
31 17:43:20 2010
@@ -38,6 +38,7 @@
 					<jdbcURL>jdbc:hsqldb:file:target/hsqldb/sample;shutdown=true</jdbcURL>
 					<jdbcUser>sa</jdbcUser>
 					<jdbcPwd></jdbcPwd>
+					<packageName>org.apache.empire.db.example</packageName>
 				</configuration>
 				<executions>
 					<!-- 

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/src/test/java/org/apache/empire/db/examples/codegen/ValidatePluginRunTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/src/test/java/org/apache/empire/db/examples/codegen/ValidatePluginRunTest.java?rev=905080&r1=905079&r2=905080&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/src/test/java/org/apache/empire/db/examples/codegen/ValidatePluginRunTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-codegen/src/test/java/org/apache/empire/db/examples/codegen/ValidatePluginRunTest.java
Sun Jan 31 17:43:20 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.empire.db.examples.codegen;
 
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -33,5 +34,11 @@
 		assertTrue("No sources generated", file.exists());
 		// TODO add extra validation for the real generated sources
 	}
+	
+	@Test
+	public void testGeneratedClass() throws ClassNotFoundException{
+		Class<?> cls = Class.forName("org.apache.empire.db.example.MyDB");
+		assertNotNull("Could not load generated class.", cls);
+	}
 
 }

Modified: incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java?rev=905080&r1=905079&r2=905080&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
(original)
+++ incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
Sun Jan 31 17:43:20 2010
@@ -29,7 +29,7 @@
 import org.apache.maven.project.MavenProject;
 
 /**
- * Codegen goal
+ * Generates code by reading an existing database schema
  * 
  * @goal codegen
  * 
@@ -42,6 +42,14 @@
 	 * @readonly
 	 */
 	private MavenProject project;
+	
+	/**
+	 * Codegen configuration file, if the file is provided, only that file
+	 * is used to configure code generation
+	 * 
+	 * @parameter expression="${empiredb.configFile}"
+	 */
+	private File configFile;
 
 	/**
 	 * Location of the generated sources.
@@ -82,17 +90,37 @@
 	 * @parameter expression="${empiredb.jdbcPwd}"
 	 */
 	private String jdbcPwd;
+	
+	/**
+	 * Code generator template directory, if not set the default templates
+	 * are loaded from the classpath
+	 * 
+	 * @parameter expression="${empiredb.templateDirectory}"
+	 */
+	private String templateDirectory;
+	
+	/**
+	 * The package for the generated sources
+	 * 
+	 * @parameter expression="${empiredb.packageName}"
+	 */
+	private String packageName;
 
 	public void execute() throws MojoExecutionException {
-
+		
 		CodeGenConfig config = new CodeGenConfig();
-		config.setJdbcURL(jdbcURL);
-		config.setJdbcClass(jdbcClass);
-		config.setJdbcUser(jdbcUser);
-		config.setJdbcPwd(jdbcPwd);
-		config.setTargetFolder(targetDirectory.getAbsolutePath());
-		// load templates from the classpath
-		config.setTemplateFolder(null);
+		if(configFile != null){
+			getLog().info("Loading configuration file: " + configFile);
+			config.init(configFile.getAbsolutePath());
+		}else{
+			config.setJdbcURL(jdbcURL);
+			config.setJdbcClass(jdbcClass);
+			config.setJdbcUser(jdbcUser);
+			config.setJdbcPwd(jdbcPwd);
+			config.setTargetFolder(targetDirectory.getAbsolutePath());
+			config.setTemplateFolder(templateDirectory);
+			config.setPackageName(packageName);
+		}
 		
 		getLog().info("Generating code for " + jdbcURL + " ...");
 		



Mime
View raw message