empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1516764 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire/db: DBDatabase.java DBExpressionIndex.java DBTable.java
Date Fri, 23 Aug 2013 09:11:06 GMT
Author: doebele
Date: Fri Aug 23 09:11:05 2013
New Revision: 1516764

URL: http://svn.apache.org/r1516764
Log:
EMPIREDB-190
changed various method parameters from array to variable arguments

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

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java?rev=1516764&r1=1516763&r2=1516764&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java Fri Aug 23
09:11:05 2013
@@ -601,14 +601,14 @@ public abstract class DBDatabase extends
      * @param name the relation name
      * @param references a list of source and target column pairs
      */
-    public DBRelation addRelation(String name, DBRelation.DBReference[] references)
+    public DBRelation addRelation(String name, DBRelation.DBReference... references)
     {
     	// Check
     	if (getRelation(name)!=null)
             throw new ItemExistsException(name); // Relation already exists
     	// Get default cascade action
     	DBTable targetTable = (DBTable)references[0].getTargetColumn().getRowSet();
-    	DBCascadeAction deleteAction = (targetTable.isCascadeDelete() ? DBCascadeAction.CASCADE_RECORDS
: DBCascadeAction.NONE); 
+    	DBCascadeAction deleteAction = targetTable.getDefaultCascadeDeleteAction(); 
         // Add a Relation
         DBRelation relation = new DBRelation(this, name, references, deleteAction);
         if (relations.contains(relation))

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java?rev=1516764&r1=1516763&r2=1516764&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java Fri
Aug 23 09:11:05 2013
@@ -40,7 +40,7 @@ public class DBExpressionIndex extends D
      * @param unique true if the index has only unique values or false otherwise
      * @param columnExpressions an array of one or more column expressions of the index
      */
-    public DBExpressionIndex(String name, boolean unique, DBExpr[] columnExpressions)
+    public DBExpressionIndex(String name, boolean unique, DBExpr... columnExpressions)
     {
         super(name, (unique ? UNIQUE : STANDARD), null);
         // columnExpressions

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java?rev=1516764&r1=1516763&r2=1516764&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java Fri Aug 23 09:11:05
2013
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.empire.data.DataMode;
 import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBRelation.DBCascadeAction;
 import org.apache.empire.db.exceptions.NoPrimaryKeyException;
 import org.apache.empire.db.exceptions.RecordDeleteFailedException;
 import org.apache.empire.db.exceptions.RecordUpdateInvalidException;
@@ -50,13 +51,14 @@ public class DBTable extends DBRowSet im
     public static final int MEDIUMINT = 4;
     public static final int BIGINT    = 8;
 
-    private final static long serialVersionUID = 1L;
-    private static AtomicInteger tableCount  = new AtomicInteger(0);
-    private final String   name;
-    private String         alias;
-    private List<DBIndex>  indexes       = new ArrayList<DBIndex>();
-    private boolean        cascadeDelete = false;
-    private Boolean        quoteName     = null;
+    private final static long    serialVersionUID    = 1L;
+    private static AtomicInteger tableCount          = new AtomicInteger(0);
+
+    private final String         name;
+    private String               alias;
+    private final List<DBIndex>  indexes             = new ArrayList<DBIndex>();
+    private Boolean              quoteName           = null;
+    private DBCascadeAction      cascadeDeleteAction = DBCascadeAction.NONE;
     
 
     /**
@@ -286,7 +288,7 @@ public class DBTable extends DBRowSet im
      * 
      * @param columns a array with one or more DBColumn objects
      */
-    public void setPrimaryKey(DBColumn[] columns)
+    public void setPrimaryKey(DBColumn... columns)
     {
         if (columns==null || columns.length==0)
             throw new InvalidArgumentException("columns", columns);
@@ -301,39 +303,6 @@ public class DBTable extends DBRowSet im
     }
 
     /**
-     * Sets the primary key to a single column.
-     * 
-     * @param column the primary key column
-     */
-    public final void setPrimaryKey(DBColumn column)
-    {
-        setPrimaryKey(new DBColumn[] { column });
-    }
-
-    /**
-     * Adds two columns to the primary key list.
-     * 
-     * @param col1 the first column 
-     * @param col2 the second column
-     */
-    public final void setPrimaryKey(DBColumn col1, DBColumn col2)
-    {
-        setPrimaryKey(new DBColumn[] { col1, col2 });
-    }
-
-    /**
-     * Adds three columns to the primary key list.
-     * 
-     * @param col1 the first column
-     * @param col2 the second column
-     * @param col3 the third column
-     */
-    public final void setPrimaryKey(DBColumn col1, DBColumn col2, DBColumn col3)
-    {
-        setPrimaryKey(new DBColumn[] { col1, col2, col3 });
-    }
-
-    /**
      * Adds an index.
      * 
      * @param index the index to add
@@ -366,7 +335,7 @@ public class DBTable extends DBRowSet im
      * 
      * @return the Index object
      */
-    public final DBIndex addIndex(String name, boolean unique, DBColumn[] columns)
+    public final DBIndex addIndex(String name, boolean unique, DBColumn... columns)
     {
         if (name==null || columns==null || columns.length==0)
             throw new InvalidArgumentException("name|columns", null);
@@ -440,32 +409,24 @@ public class DBTable extends DBRowSet im
         // Init
         completeInitRecord(rec);
     }
-
+    
     /**
-     * @deprecated
-     * Deprecated flag that indicates whether cascaded deletes are enabled on this table.
-     * This property will be removed in future releases.
-     * Use DBRelation.getOnDeleteAction() instead.
-     * 
-     * @return true if cascade deletes (DBRelation.DBCascadeAction.CASCADE_RECORDS) are enabled
+     * returns the default cascade action for deletes on this table.
+     * This is used as the default for newly created relations on this table and does not
affect existing relations.
+     * @return the delete cascade action for new relations (DBRelation.DBCascadeAction.CASCADE_RECORDS)
are enabled
      */
-    public boolean isCascadeDelete()
+    public DBCascadeAction getDefaultCascadeDeleteAction()
     {
-        return cascadeDelete;
+        return cascadeDeleteAction;
     }
 
     /**
-     * @deprecated
-     * Deprecated flag that enables cascaded deletes on foreign key relations.
-     * WARING: The flag only affects newly created relations referring to this table.   
-     * This property will be removed in future releases.
-     * Use DBRelation.setOnDeleteAction() instead.
-     *  
-     * @param cascadeDelete use cascade deletes (DBRelation.DBCascadeAction.CASCADE_RECORDS)
+     * sets the default cascade action for deletes on foreign key relations.
+     * @param cascadeDeleteAction cascade action for deletes (DBRelation.DBCascadeAction.CASCADE_RECORDS)
      */
-    public void setCascadeDelete(boolean cascadeDelete)
+    public void setDefaultCascadeDeleteAction(DBCascadeAction cascadeDeleteAction)
     {
-        this.cascadeDelete = cascadeDelete;
+        this.cascadeDeleteAction = cascadeDeleteAction;
     }
 
     /**



Mime
View raw message