empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1184818 - in /incubator/empire-db/trunk/empire-db-codegen/src/main: java/org/apache/empire/db/codegen/ resources/templates/
Date Sun, 16 Oct 2011 13:20:02 GMT
Author: doebele
Date: Sun Oct 16 13:20:02 2011
New Revision: 1184818

URL: http://svn.apache.org/viewvc?rev=1184818&view=rev
Log:
EMPIREDB-116
optimizations to velocity templates

Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenerator.java
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.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/BaseView.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-codegen/src/main/resources/templates/View.vm

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenerator.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenerator.java?rev=1184818&r1=1184817&r2=1184818&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenerator.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenerator.java
Sun Oct 16 13:20:02 2011
@@ -81,13 +81,6 @@ public class CodeGenerator {
 		// Init Configuration
 		CodeGenConfig config = new CodeGenConfig();
 		config.init(configFile);
-
-		if (config.getTableClassPrefix() == null)
-			config.setTableClassPrefix("");
-
-		if (config.getTableClassSuffix() == null)
-			config.setTableClassSuffix("");
-		
 		return config;
 	}
 	

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java?rev=1184818&r1=1184817&r2=1184818&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/WriterService.java
Sun Oct 16 13:20:02 2011
@@ -26,6 +26,7 @@ import java.util.Set;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBRecord;
@@ -70,8 +71,9 @@ public class WriterService {
 	 */
 	public String getTableClassName(String tableName)
 	{
-		return config.getTableClassPrefix() + deriveClassName(tableName)
-			+ config.getTableClassSuffix();
+		return StringUtils.toString(config.getTableClassPrefix(), "")
+			+ deriveClassName(tableName)
+			+ StringUtils.toString(config.getTableClassSuffix(),"");
 	}
 
 	/**
@@ -79,8 +81,9 @@ public class WriterService {
 	 */
 	public String getViewClassName(String viewName)
 	{
-		return config.getViewClassPrefix() + deriveClassName(viewName)
-			+ config.getViewClassSuffix();
+		return StringUtils.toString(config.getViewClassPrefix(), "")
+			+ deriveClassName(viewName)
+			+ StringUtils.toString(config.getViewClassSuffix(), "");
 	}
 	
 	/**

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=1184818&r1=1184817&r2=1184818&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 Oct 16 13:20:02 2011
@@ -23,6 +23,9 @@ import ${tablePackageName}.${baseTableCl
 
 
 public abstract class ${baseRecordClassName}<T extends ${baseTableClassName}> extends
DBRecord {
+
+	private static final long serialVersionUID = 1L;
+
 	public ${baseRecordClassName}(T table) {
 		super.init(table, DBRecord.REC_EMTPY, null);
 	}
@@ -32,7 +35,7 @@ public abstract class ${baseRecordClassN
 	 * @return The table this record is based upon.
 	 */
 	@SuppressWarnings("unchecked")
-	public T getDbTable() {
+	public T getTable() {
 		return (T)super.getRowSet();
 	}
 }
\ No newline at end of file

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=1184818&r1=1184817&r2=1184818&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 Oct 16 13:20:02 2011
@@ -22,6 +22,9 @@ import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
 
 public class ${baseTableClassName} extends DBTable {
+
+	private static final long serialVersionUID = 1L;
+
 	public ${baseTableClassName}(String name, DBDatabase db) {
 		super(name, db);
 	}

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=1184818&r1=1184817&r2=1184818&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
Oct 16 13:20:02 2011
@@ -18,19 +18,14 @@
  *#
 package $viewPackageName;
 
-import org.apache.empire.db.DBCommandExpr;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBView;
 
-public class ${baseViewClassName} extends DBView {
+public abstract class ${baseViewClassName} extends DBView {
+
+	private static final long serialVersionUID = 1L;
+
 	public ${baseViewClassName}(String name, DBDatabase db) {
 		super(name, db);
 	}
-	
-	@Override
-    public DBCommandExpr createCommand()
-    {
-    	// TODO not IMPLEMENTED
-        throw new UnsupportedOperationException("Not iplemented");
-    }
 }

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=1184818&r1=1184817&r2=1184818&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
Oct 16 13:20:02 2011
@@ -18,25 +18,35 @@
  *#
 package $basePackageName;
 
-import java.sql.Connection;
-
+#if($nestTables == true)
 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;
+#end
 
 #if($nestTables == true || $nestViews == true)
 import org.apache.empire.data.DataType;
 #end
+#if($nestViews == true)
+import org.apache.empire.db.DBCommandExpr;
+#end
+import org.apache.empire.db.DBDatabase;
+#if($preserveRelationNames == true)
+import org.apache.empire.db.DBRelation;
+#end
 #if($nestTables == true)
 import org.apache.empire.db.DBTableColumn;
 #end
+#if($nestViews == true)
+import org.apache.empire.exceptions.NotImplementedException;
+#end
 
+#if($nestTables==false || !($tablePackageName.equalsIgnoreCase($basePackageName)))
 import $tablePackageName.*;
+// $tablePackageName vs $basePackageName 
+#end
+#if($nestViews==false || ($viewPackageName!=$basePackageName))
 import $viewPackageName.*;
+#end
 
 public class $dbClassName extends DBDatabase {
 
@@ -72,7 +82,7 @@ public class $dbClassName extends DBData
 	#if($preserveRelationNames == true)
 	// Define foreign key relations
 #foreach ($relation in $database.relations)
-		addRelation("$relation.name", new DBReleation.DBReference[] {
+		addRelation("$relation.name", new DBRelation.DBReference[] {
 #foreach ($reference in $relation.references)
 #if($foreach.isLast())
         	${reference.sourceColumn.rowSet.name}.${parser.getAttributeName($reference.sourceColumn)}.referenceOn(${reference.targetColumn.rowSet.name}.${parser.getAttributeName($reference.targetColumn)})
});

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=1184818&r1=1184817&r2=1184818&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
Oct 16 13:20:02 2011
@@ -42,6 +42,9 @@ import ${tablePackageName}.$parser.getTa
  * access to related records.
  */
 public class $parser.getRecordClassName($table.name) extends ${baseRecordClassName}<$parser.getTableClassName($table.name)>
{
+
+	private static final long serialVersionUID = 1L;
+
 	public $parser.getRecordClassName($table.name)() {
 		super(${dbClassName}.get().${table.name});
 	}
@@ -51,10 +54,10 @@ public class $parser.getRecordClassName(
 #foreach($col in $table.columns)
 
 	public $parser.getJavaType($col).getName() $parser.getAccessorName($col)() {
-		return ($parser.getJavaType($col).getName())super.getValue(getDbTable().${parser.getAttributeName($col)});
+		return ($parser.getJavaType($col).getName())super.getValue(getTable().${parser.getAttributeName($col)});
 	}
 	public void $parser.getMutatorName($col)($parser.getJavaType($col).getName() val) {
-		super.setValue(getDbTable().${parser.getAttributeName($col)}, val);
+		super.setValue(getTable().${parser.getAttributeName($col)}, 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=1184818&r1=1184817&r2=1184818&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
Oct 16 13:20:02 2011
@@ -27,8 +27,13 @@ import org.apache.empire.db.DBTableColum
 import $basePackageName.${dbClassName};
 #end
 
-public #if($nestTables == true)static#end class $parser.getTableClassName($table.name) extends
${baseTableClassName} {
+#if($nestTables == true)
+  public static class $parser.getTableClassName($table.name) extends ${baseTableClassName}
{
+#else
+public class $parser.getTableClassName($table.name) extends ${baseTableClassName} {
+#end
 
+	private static final long serialVersionUID = 1L;
 	private List<DBTableColumn> keyColumns = new ArrayList<DBTableColumn>();
 	
 	// Regular attributes
@@ -61,4 +66,8 @@ public #if($nestTables == true)static#en
 		// Set cascade delete
 		setCascadeDelete(true);		
 	}
+#if($nestTables == true)
+  }
+#else
 }
+#end
\ No newline at end of file

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/View.vm
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/View.vm?rev=1184818&r1=1184817&r2=1184818&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/View.vm (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/resources/templates/View.vm Sun Oct
16 13:20:02 2011
@@ -21,11 +21,21 @@
 package $viewPackageName;
 
 import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBCommandExpr;
+import org.apache.empire.exceptions.NotImplementedException;
+
 import $basePackageName.${dbClassName};
+
 #end
 
-public #if($nestViews == true)static#end  class $parser.getViewClassName($view.name) extends
${baseViewClassName} {
+#if($nestViews == true)
+  public static class $parser.getViewClassName($view.name) extends ${baseViewClassName} {
+#else
+public class $parser.getViewClassName($view.name) extends ${baseViewClassName} {
+#end
 	
+	private static final long serialVersionUID = 1L;
+
 	// Regular attributes
 #foreach ($col in $view.columns)
 	public final DBViewColumn C_${parser.getAttributeName($col)};
@@ -39,4 +49,19 @@ public #if($nestViews == true)static#end
 		C_${parser.getAttributeName($col)} = super.addColumn("${col.name}", DataType.${col.getDataType()});
 #end		
 	}
+	
+	@Override
+    public DBCommandExpr createCommand()
+    {
+    	/*
+    	Supply a command for the creation of this view here.
+    	*/
+        throw new NotImplementedException(this, "createCommand");
+    }
+	
+#if($nestViews == true)
+  }
+#else
 }
+#end
+



Mime
View raw message