empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From benni...@apache.org
Subject svn commit: r1164987 - in /incubator/empire-db/trunk/empire-db-codegen/src: main/java/org/apache/empire/db/codegen/CodeGenParser.java test/java/org/apache/empire/db/codegen/CodeGenParserTest.java test/resources/hsqldb/sample.script
Date Sun, 04 Sep 2011 10:29:31 GMT
Author: benniven
Date: Sun Sep  4 10:29:31 2011
New Revision: 1164987

URL: http://svn.apache.org/viewvc?rev=1164987&view=rev
Log:
This commit is for EMPIREDB-114:
- integrated and tested the patch for the testcase supplied by "Matt DeHoust"
- added fix for EMPIREDB-114 solution as follows:
the subroutine "gatherRelations" was called for each tablePattern, although it should have
been called just once!

Modified:
    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/CodeGenParserTest.java
    incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script

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=1164987&r1=1164986&r2=1164987&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
Sun Sep  4 10:29:31 2011
@@ -168,10 +168,9 @@ public class CodeGenParser {
 						tableCount++;
 					}
 				}
-				
-				// Add all relations
-				gatherRelations(db, dbMeta, populatedTables);
 			}
+			// Add all relations
+			gatherRelations(db, dbMeta, populatedTables);
 
 			if (tableCount==0 && viewCount==0) {
 			    // getTables returned no result

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java?rev=1164987&r1=1164986&r2=1164987&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/java/org/apache/empire/db/codegen/CodeGenParserTest.java
Sun Sep  4 10:29:31 2011
@@ -42,9 +42,9 @@ public class CodeGenParserTest {
     public void setUp() throws Exception {
         final CodeGenConfig config = new CodeGenConfig();
         config.init("src/test/resources/testconfig.xml");
-        config.setDbSchema(null);
+        config.setDbSchema("PUBLIC");
+        config.setDbTablePattern("DEPARTMENTS,EMPLOYEES,ORGANIZATIONS");
         parser = new CodeGenParser(config);
-        parser.loadDbModel();
     }
 
     @Test
@@ -58,9 +58,9 @@ public class CodeGenParserTest {
 		assertNotNull("Expected EMPLOYEES table.", employees);
 
         final List<DBRelation> relations = db.getRelations();
-        assertEquals("Should have EMPLOYEES->DEPARTMENTS relation.", 1, relations.size());
+        assertEquals("Should have two relations.", 2, relations.size());
 
-        final DBRelation dbRelation = relations.get(0);
+        final DBRelation dbRelation = relations.get(1);
         assertEquals("EMPLOYEES_DEPARTMENT_I_FK", dbRelation.getName());
 
         final DBReference[] references = dbRelation.getReferences();

Modified: incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script?rev=1164987&r1=1164986&r2=1164987&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script (original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/test/resources/hsqldb/sample.script Sun
Sep  4 10:29:31 2011
@@ -18,7 +18,8 @@
 CREATE SCHEMA PUBLIC AUTHORIZATION DBA
 CREATE SEQUENCE DEP_ID_SEQUENCE AS INTEGER START WITH 3 
 CREATE SEQUENCE EMPLOYEE_ID_SEQUENCE AS INTEGER START WITH 4 
-CREATE MEMORY TABLE DEPARTMENTS(DEPARTMENT_ID BIGINT NOT NULL,NAME VARCHAR(80) NOT NULL,HEAD
VARCHAR(80),BUSINESS_UNIT VARCHAR(4) NOT NULL,UPDATE_TIMESTAMP TIMESTAMP NOT NULL,CONSTRAINT
DEPARTMENTS_PK PRIMARY KEY(DEPARTMENT_ID))
+CREATE MEMORY TABLE ORGANIZATIONS(ORGANIZATION_ID BIGINT NOT NULL,NAME VARCHAR(80) NOT NULL,CONSTRAINT
ORGANIZATIONS_PK PRIMARY KEY(ORGANIZATION_ID))
+CREATE MEMORY TABLE DEPARTMENTS(DEPARTMENT_ID BIGINT NOT NULL,ORGANIZATION_ID BIGINT NOT
NULL,NAME VARCHAR(80) NOT NULL,HEAD VARCHAR(80),BUSINESS_UNIT VARCHAR(4) NOT NULL,UPDATE_TIMESTAMP
TIMESTAMP NOT NULL,CONSTRAINT DEPARTMENTS_PK PRIMARY KEY(DEPARTMENT_ID),CONSTRAINT DEPARTMENTS_ORGANIZATION_I_FK
FOREIGN KEY(ORGANIZATION_ID) REFERENCES ORGANIZATIONS(ORGANIZATION_ID))
 CREATE UNIQUE INDEX DEARTMENT_NAME_IDX ON DEPARTMENTS(NAME)
 CREATE MEMORY TABLE EMPLOYEES(EMPLOYEE_ID BIGINT NOT NULL,SALUTATION VARCHAR(20),FIRSTNAME
VARCHAR(40) NOT NULL,LASTNAME VARCHAR(40) NOT NULL,DATE_OF_BIRTH DATE,DEPARTMENT_ID BIGINT
NOT NULL,GENDER VARCHAR(1),PHONE_NUMBER VARCHAR(40),EMAIL VARCHAR(80),SALARY DECIMAL(10,2),RETIRED
BOOLEAN NOT NULL,UPDATE_TIMESTAMP TIMESTAMP NOT NULL,CONSTRAINT EMPLOYEES_PK PRIMARY KEY(EMPLOYEE_ID),CONSTRAINT
EMPLOYEES_DEPARTMENT_I_FK FOREIGN KEY(DEPARTMENT_ID) REFERENCES DEPARTMENTS(DEPARTMENT_ID))
 CREATE UNIQUE INDEX EMPLOYEE_NAME_IDX ON EMPLOYEES(FIRSTNAME,LASTNAME,DATE_OF_BIRTH)
@@ -26,8 +27,9 @@ CREATE USER SA PASSWORD ""
 GRANT DBA TO SA
 SET WRITE_DELAY 10
 SET SCHEMA PUBLIC
-INSERT INTO DEPARTMENTS VALUES(1,'Development',NULL,'ITTK','2010-02-01 22:27:44.200000000')
-INSERT INTO DEPARTMENTS VALUES(2,'Sales',NULL,'ITTK','2010-02-01 22:27:44.212000000')
+INSERT INTO ORGANIZATIONS VALUES(1,'Top')
+INSERT INTO DEPARTMENTS VALUES(1,1,'Development',NULL,'ITTK','2010-02-01 22:27:44.200000000')
+INSERT INTO DEPARTMENTS VALUES(2,1,'Sales',NULL,'ITTK','2010-02-01 22:27:44.212000000')
 INSERT INTO EMPLOYEES VALUES(1,NULL,'Peter','Sharp',NULL,1,'M','+49-7531-457160',NULL,NULL,FALSE,'2010-02-01
22:27:44.226000000')
 INSERT INTO EMPLOYEES VALUES(2,NULL,'Fred','Bloggs',NULL,1,'M','+49-5555-505050',NULL,NULL,FALSE,'2010-02-01
22:27:44.240000000')
 INSERT INTO EMPLOYEES VALUES(3,NULL,'Emma','White',NULL,2,'F','+49-040-125486',NULL,NULL,FALSE,'2010-02-01
22:27:44.243000000')



Mime
View raw message