empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1182502 - /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
Date Wed, 12 Oct 2011 18:13:41 GMT
Author: doebele
Date: Wed Oct 12 18:13:41 2011
New Revision: 1182502

URL: http://svn.apache.org/viewvc?rev=1182502&view=rev
Log:
EMPIREDB-116
support for multi-column foreign keys to code generator

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

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=1182502&r1=1182501&r2=1182502&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
Wed Oct 12 18:13:41 2011
@@ -525,10 +525,13 @@ public abstract class DBDatabase extends
      */
     public void addRelation(String name, DBRelation.DBReference[] references)
     {
+    	// Check
+    	if (getRelation(name)!=null)
+            throw new ItemExistsException(name); // Relation already exists
         // Add a Relation
         DBRelation relation = new DBRelation(this, name, references);
         if (relations.contains(relation))
-            throw new ItemExistsException(name); // Itemn already exists
+            throw new ItemExistsException(name); // Relation already exists
         // Add Reference column to table
         for (DBRelation.DBReference ref : references)
         {   // add the reference column
@@ -550,6 +553,22 @@ public abstract class DBDatabase extends
     }
 
     /**
+     * Returns the relation of a given name
+     * 
+     * @return db the relation of the given name
+     */
+    public DBRelation getRelation(String relationName)
+    {
+        for (DBRelation r : relations)
+        {
+        	String name = r.getName();
+        	if (relationName.compareToIgnoreCase(name)==0)
+        		return r; 
+        }
+        return null;
+    }
+
+    /**
      * Adds a DBView object to list of database views.<BR>
      * There is usually no need to call this function directly 
      * since it is internally called from the DBView's constructor.



Mime
View raw message