empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1299750 - in /empire-db/trunk/empire-db/src/main/java/org/apache/empire: data/bean/BeanClass.java data/bean/BeanProperty.java db/DBCommand.java db/expr/join/DBJoinExpr.java
Date Mon, 12 Mar 2012 17:32:19 GMT
Author: doebele
Date: Mon Mar 12 17:32:19 2012
New Revision: 1299750

URL: http://svn.apache.org/viewvc?rev=1299750&view=rev
Log:
EMPIREDB-126
more small minor changes

Modified:
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/join/DBJoinExpr.java

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java?rev=1299750&r1=1299749&r2=1299750&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java Mon
Mar 12 17:32:19 2012
@@ -58,13 +58,6 @@ public abstract class BeanClass
         prop.beanClass = this;
     }
 
-    protected final BeanProperty addProp(String propname, DataType dataType, double size,
DataMode dataMode)
-    {
-        BeanProperty prop = new BeanProperty(propname, dataType, size, dataMode, "text");
-        addProp(prop);
-        return prop;
-    }
-
     protected final BeanProperty addProp(String propname, DataType dataType, double size,
DataMode dataMode, String controlType)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, dataMode, controlType);
@@ -72,7 +65,6 @@ public abstract class BeanClass
         return prop;
     }
 
-    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size,
boolean required)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, "text",
false);
@@ -80,7 +72,6 @@ public abstract class BeanClass
         return prop;
     }
 
-    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size,
boolean required, String controlType)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType,
false);
@@ -88,7 +79,6 @@ public abstract class BeanClass
         return prop;
     }
 
-    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size,
boolean required, String controlType, boolean readOnly)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType,
readOnly);

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java?rev=1299750&r1=1299749&r2=1299750&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
Mon Mar 12 17:32:19 2012
@@ -63,7 +63,7 @@ public class BeanProperty implements Col
     }
 
     /**
-     * @deprecated use BeanProperty(String name, DataType dataType, double size, DataMode
dataMode, String controlType) instead.
+     * Constructs a bean property definition
      * @param name
      * @param dataType
      * @param size
@@ -71,20 +71,18 @@ public class BeanProperty implements Col
      * @param controlType
      * @param readOnly
      */
-    @Deprecated
     public BeanProperty(String name, DataType dataType, double size, boolean required, String
controlType, boolean readOnly)
     {
         this(name, dataType, size, (readOnly ? DataMode.ReadOnly : (required ? DataMode.NotNull
: DataMode.Nullable)), controlType);
     }
     
     /**
-     * @deprecated use BeanProperty(String name, DataType dataType, double size, DataMode
dataMode, String controlType) instead.
+     * Constructs a bean property definition
      * @param name
      * @param dataType
      * @param size
      * @param required
      */
-    @Deprecated
     public BeanProperty(String name, DataType dataType, double size, boolean required)
     {
         this(name, dataType, size, (required ? DataMode.NotNull : DataMode.Nullable), "text");

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java?rev=1299750&r1=1299749&r2=1299750&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java (original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommand.java Mon Mar 12
17:32:19 2012
@@ -454,8 +454,7 @@ public abstract class DBCommand extends 
     }
     
     /**
-     * Returns true if the command has a join on the given
-     * table or false otherwise.
+     * Returns true if the command has a join on the given table or false otherwise.
      * 
      * @param rowset rowset table or view to join
      * 
@@ -474,6 +473,69 @@ public abstract class DBCommand extends 
         // not found
         return false;
     }
+    
+    /**
+     * Returns true if the command has a join on the given column or false otherwise.
+     * 
+     * @param column the column to test
+     * 
+     * @return true if the command has a join on the given column or false otherwise
+     */
+    public boolean hasJoinOn(DBColumn column)
+    {
+        if (joins==null)
+            return false;
+        // Examine all joins
+        for (DBJoinExpr join : joins)
+        {
+            if (join.isJoinOn(column))
+                return true;
+        }
+        // not found
+        return false;
+    }
+    
+    /**
+     * removes all joins to a given table or view
+     * 
+     * @param rowset the table or view for which to remove all joins
+     * 
+     * @return true if any joins have been removed or false otherwise
+     */
+    public boolean removeJoinsOn(DBRowSet rowset)
+    {
+        if (joins==null)
+            return false;
+        // Examine all joins
+        int size = joins.size();
+        for (int i=size-1; i>=0; i--)
+        {
+            if (joins.get(i).isJoinOn(rowset))
+                joins.remove(i);
+        }
+        return (size!=joins.size());
+    }
+    
+    /**
+     * removes all joins to a given column
+     * 
+     * @param column the column for which to remove all joins
+     * 
+     * @return true if any joins have been removed or false otherwise
+     */
+    public boolean removeJoinsOn(DBColumn column)
+    {
+        if (joins==null)
+            return false;
+        // Examine all joins
+        int size = joins.size();
+        for (int i=size-1; i>=0; i--)
+        {
+            if (joins.get(i).isJoinOn(column))
+                joins.remove(i);
+        }
+        return (size!=joins.size());
+    }
 
     /**
      * Adds a compare expression to the list of constraints.
@@ -489,7 +551,7 @@ public abstract class DBCommand extends 
     }
 
     /**
-     * Returns true if the command has constaints or false if not.
+     * Returns true if the command has constraints or false if not.
      * 
      * @return true if constraints have been set on the command
      */

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/join/DBJoinExpr.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/join/DBJoinExpr.java?rev=1299750&r1=1299749&r2=1299750&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/join/DBJoinExpr.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/expr/join/DBJoinExpr.java
Mon Mar 12 17:32:19 2012
@@ -18,6 +18,9 @@
  */
 package org.apache.empire.db.expr.join;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBColumnExpr;
 import org.apache.empire.db.DBDatabase;
@@ -26,8 +29,6 @@ import org.apache.empire.db.DBJoinType;
 import org.apache.empire.db.DBRowSet;
 import org.apache.empire.db.expr.compare.DBCompareExpr;
 
-import java.util.Set;
-
 /**
  * This class is used for building a join expression of an SQL statement.
  * <P>
@@ -74,21 +75,33 @@ public class DBJoinExpr extends DBExpr
         return left.getDatabase();
     }
 
+    /**
+     * returns the left join expression
+     */
     public DBColumnExpr getLeft()
     {
         return left;
     }
 
+    /**
+     * returns the right join expression
+     */
     public DBColumnExpr getRight()
     {
         return right;
     }
 
+    /**
+     * returns the join type for this join
+     */
     public DBJoinType getType()
     {
         return type;
     }
     
+    /**
+     * returns true if this join is using the given table or view or false otherwise
+     */
     public boolean isJoinOn(DBRowSet rowset)
     {
         if (rowset==null)
@@ -99,6 +112,27 @@ public class DBJoinExpr extends DBExpr
         DBRowSet rsr = (r!=null ? r.getRowSet() : null);
         return rowset.equals(rsl) || rowset.equals(rsr);
     }
+    
+    /**
+     * returns true if this join is using the given column or false otherwise
+     */
+    public boolean isJoinOn(DBColumn column)
+    {
+        if (column==null)
+            return false;
+        // Check Update Columns
+        if (column.equals(left.getUpdateColumn()) ||
+            column.equals(right.getUpdateColumn()))
+            return true;
+        if (compExpr!=null)
+        {   // Check expression
+            HashSet<DBColumn> set = new HashSet<DBColumn>();
+            compExpr.addReferencedColumns(set);
+            return set.contains(column);
+        }
+        // not found
+        return false;
+    }
 
     /**
      * Returns the left table name if the data type= JOIN_LEFT and returns



Mime
View raw message