empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1142593 - in /incubator/empire-db/trunk/empire-db-codegen: config.xml pom.xml src/main/java/org/apache/empire/db/codegen/CodeGenConfig.java src/main/java/org/apache/empire/db/codegen/CodeGenParser.java
Date Mon, 04 Jul 2011 09:21:44 GMT
Author: doebele
Date: Mon Jul  4 09:21:43 2011
New Revision: 1142593

URL: http://svn.apache.org/viewvc?rev=1142593&view=rev
Log:
EMPIREDB-110

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/CodeGenConfig.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/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/config.xml?rev=1142593&r1=1142592&r2=1142593&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/config.xml Mon Jul  4 09:21:43 2011
@@ -48,12 +48,12 @@
 		<tableBaseName>SampleTable</tableBaseName>
 		<viewBaseName>SampleView</viewBaseName>
 		<recordBaseName>SampleRecord</recordBaseName>
-		<tableClassPrefix>T</tableClassPrefix>
-		<tableClassSuffix>Table</tableClassSuffix>
-		<viewClassPrefix>V</viewClassPrefix>
-		<viewClassSuffix>View</viewClassSuffix>
-		<nestTables>True</nestTables>
-		<nestViews>False</nestViews>
+		<tableClassPrefix>T_</tableClassPrefix>
+		<tableClassSuffix></tableClassSuffix>
+		<viewClassPrefix>V_</viewClassPrefix>
+		<viewClassSuffix></viewClassSuffix>
+		<nestTables>true</nestTables>
+		<nestViews>false</nestViews>
 		<createRecordProperties>true</createRecordProperties>
 	</properties>
 	

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=1142593&r1=1142592&r2=1142593&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-codegen/pom.xml Mon Jul  4 09:21:43 2011
@@ -40,6 +40,12 @@
 			<version>1.7</version>
 		</dependency>
 
+		<!-- use log4j for logging -->
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-log4j12</artifactId>
+		</dependency>
+
 		<!--  Databases -->
 		<!-- hsql -->
 		<dependency>
@@ -55,10 +61,9 @@
 		    <version>5.1.1</version>
 		</dependency>-->
 		
-		
-		<!-- ojdbc 
+		<!-- ojdbc  
 		<dependency>
-		    <groupId>ojdbc</groupId>
+		    <groupId>com.oracle</groupId>
 		    <artifactId>ojdbc</artifactId>
 		    <version>14</version>
 		</dependency>

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=1142593&r1=1142592&r2=1142593&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 Jul  4 09:21:43 2011
@@ -18,9 +18,20 @@
  */
 package org.apache.empire.db.codegen;
 
+import org.apache.empire.commons.Errors;
 import org.apache.empire.xml.XMLConfiguration;
+import org.apache.empire.xml.XMLUtil;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.slf4j.Logger;
+import org.w3c.dom.Element;
 
 public class CodeGenConfig extends XMLConfiguration {
+
+	private static final Logger log = org.slf4j.LoggerFactory.getLogger(CodeGenConfig.class);
+	
+    // the logging configuration root node name
+    private final String loggingNodeName = "log4j:configuration";
+	
 	private String jdbcClass;
 
 	private String jdbcURL;
@@ -169,13 +180,13 @@ public class CodeGenConfig extends XMLCo
 	 * if TRUE table classes should be declared as inner classes of DBDatabase.<br/>
 	 * if FALSE table classes should be declared as top level classes.
 	 */
-	private boolean nestTables;
+	private boolean nestTables = false;
 	
 	/**
 	 * if TRUE view classes should be declared as inner classes of DBDatabase.<br/>
 	 * if FALSE view classes should be declared as top level classes.
 	 */
-	private boolean nestViews;
+	private boolean nestViews = false;
 	
 	/**
 	 * if TRUE record classes should have a getter and setter for each field.<br/>
@@ -195,6 +206,8 @@ public class CodeGenConfig extends XMLCo
 		// Read the properties file
 		if (super.init(filename, false) == false)
 			return false;
+        // Init Logging
+        initLogging();
 		// Done
 		if (readProperties(this, "properties") == false)
 			return false;
@@ -202,6 +215,30 @@ public class CodeGenConfig extends XMLCo
 		return true;
 	}
 
+    /**
+     * Init logging using Log4J's DOMConfigurator 
+     * @return
+     */
+    private boolean initLogging()
+    {
+        // Get configuration root node
+        Element rootNode = getRootNode();
+        if (rootNode == null)
+            return error(Errors.ObjectNotValid, getClass().getName());
+        // Find log configuration node
+        Element loggingNode = XMLUtil.findFirstChild(rootNode, loggingNodeName);
+        if (loggingNode == null)
+        {   // log configuration node not found
+            log.error("Log configuration node {} has not been found. Logging has not been
configured.", loggingNodeName);
+            return error(Errors.ItemNotFound, loggingNodeName);
+        }
+        // Init Log4J
+        DOMConfigurator.configure(loggingNode);
+        // done
+        log.info("Logging sucessfully configured from node {}.", loggingNodeName);
+        return success();
+    }
+
 	public String getJdbcClass() {
 		return jdbcClass;
 	}

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=1142593&r1=1142592&r2=1142593&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
Mon Jul  4 09:21:43 2011
@@ -234,7 +234,7 @@ public class CodeGenParser extends Error
 				
 				// add the relation
 				db.addRelation(fkCol.referenceOn(pkCol));
-				log.error("Added relation (FK-PK): "+relName);
+				log.info("Added relation (FK-PK): "+relName);
 			}
 		}
 	}



Mime
View raw message