Commit [a108a2] Maximize Restore History

Made data editing problems that concern update row counts more transparent by printing

out details to SQuirreL's message panel. This may help to fix bugs like #1086.

gerdwagner gerdwagner 2013-06-12

added sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/CountResult.java
changed sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java
changed sql12/app/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/AbstractAdhocTests.java
changed sql12/doc/src/main/resources/changes.txt
changed sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/AbstractWhereClausePart.java
changed sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/EmptyWhereClausePart.java
changed sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IWhereClausePart.java
changed sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IsNullWhereClausePart.java
changed sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/ParameterWhereClausePart.java
copied sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IWhereClausePartUtil.java -> sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/IWhereClausePartUtil.java
copied sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtil.java -> sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/WhereClausePartUtil.java
copied sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java -> sql12/app/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java
sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/CountResult.java Diff Switch to side-by-side view
Loading...
sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/DataSetUpdateableTableModelImpl.java Diff Switch to side-by-side view
Loading...
sql12/app/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/AbstractAdhocTests.java Diff Switch to side-by-side view
Loading...
sql12/doc/src/main/resources/changes.txt Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/AbstractWhereClausePart.java Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/EmptyWhereClausePart.java Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IWhereClausePart.java Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IsNullWhereClausePart.java Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/ParameterWhereClausePart.java Diff Switch to side-by-side view
Loading...
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IWhereClausePartUtil.java to sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/IWhereClausePartUtil.java
--- a/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/IWhereClausePartUtil.java
+++ b/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/IWhereClausePartUtil.java
@@ -1,4 +1,6 @@
-package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause;
+package net.sourceforge.squirrel_sql.client.session;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePart;
 
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
@@ -12,7 +14,7 @@
 public interface IWhereClausePartUtil {
 
 	/**
-	 * Creates an where clause from a list of {@link IWhereClausePart}
+	 * Creates an where clause from a list of {@link net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePart}
 	 * @param whereClauseParts list of where clause parts
 	 * @return the where clause, or <code>null</code>, if no suitable part of an where clause is avaiable
 	 */
@@ -22,14 +24,16 @@
 	/**
 	 * Sets the parameter values into the PreparedStatements, if any exists.
 	 * Setting the parameter value will start at the given position.
-	 * @param pstmt PreparedStatement, which contains the where clause.
-	 * @param whereClauseParts parts of the where clause from this prepared statement.
-	 * @param firstPosition The position of the first parameter, which should be set.
-	 * @return The next index-position after setting the parameters
+	 *
+    * @param pstmt PreparedStatement, which contains the where clause.
+    * @param whereClauseParts parts of the where clause from this prepared statement.
+    * @param firstPosition The position of the first parameter, which should be set.
+    * @param countResult
+    * @return The next index-position after setting the parameters
 	 * @throws SQLException If an exception occurs while setting the parameters
 	 */
 	public abstract int setParameters(PreparedStatement pstmt,
-			List<IWhereClausePart> whereClauseParts, int firstPosition)
+                                     List<IWhereClausePart> whereClauseParts, int firstPosition, CountResult countResult)
 			throws SQLException;
 
 	/**
sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtil.java to sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/WhereClausePartUtil.java
--- a/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtil.java
+++ b/sql12/app/src/main/java/net/sourceforge/squirrel_sql/client/session/WhereClausePartUtil.java
@@ -1,4 +1,6 @@
-package net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause;
+package net.sourceforge.squirrel_sql.client.session;
+
+import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.*;
 
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
@@ -9,9 +11,10 @@
  * @author Stefan Willinger
  *
  */
-public class WhereClausePartUtil implements IWhereClausePartUtil {
+public class WhereClausePartUtil implements IWhereClausePartUtil
+{
 	/**
-	 * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePartUtil#createWhereClause(java.util.List)
+	 * @see IWhereClausePartUtil#createWhereClause(java.util.List)
 	 */
 	@Override
 	public String createWhereClause(
@@ -31,28 +34,37 @@
 	}
 
 	/**
-	 * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePartUtil#setParameters(java.sql.PreparedStatement, java.util.List, int)
+	 * @see IWhereClausePartUtil#setParameters(java.sql.PreparedStatement, java.util.List
 	 */
 	@Override
-	public int setParameters(PreparedStatement pstmt,
-			List<IWhereClausePart> whereClauseParts, int firstPosition)
-			throws SQLException {
+   public int setParameters(PreparedStatement pstmt,
+                            List<IWhereClausePart> whereClauseParts, int firstPosition, CountResult countResult)
+         throws SQLException
+   {
 
-		int position = firstPosition;
-		for (IWhereClausePart whereClausePart : whereClauseParts) {
-			if(whereClausePart.shouldBeUsed()){
-				if (whereClausePart.isParameterUsed()) {
-					whereClausePart.setParameter(pstmt, position);
-					position++;
-				}	
-			}
-			
-		}
-		return position++;
-	}
-	
-	/**
-	 * @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.whereClause.IWhereClausePartUtil#hasUsableWhereClause(java.util.List)
+      int position = firstPosition;
+      for (IWhereClausePart whereClausePart : whereClauseParts)
+      {
+         if (whereClausePart.shouldBeUsed())
+         {
+            if (whereClausePart.isParameterUsed())
+            {
+               if (null != countResult)
+               {
+                  countResult.addWhereClausePart(whereClausePart.getWhereClause(), whereClausePart.getParamValue());
+               }
+
+               whereClausePart.setParameter(pstmt, position);
+               position++;
+            }
+         }
+
+      }
+      return position++;
+   }
+
+   /**
+	 * @see IWhereClausePartUtil#hasUsableWhereClause(java.util.List)
 	 */
 	@Override
 	public boolean hasUsableWhereClause(List<IWhereClausePart> whereClauseParts){
sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java to sql12/app/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java
--- a/sql12/fw/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java
+++ b/sql12/app/src/test/java/net/sourceforge/squirrel_sql/fw/datasetviewer/cellcomponent/whereClause/WhereClausePartUtilTest.java
@@ -11,6 +11,8 @@
 import java.util.List;
 
 import net.sourceforge.squirrel_sql.BaseSQuirreLJUnit4TestCase;
+import net.sourceforge.squirrel_sql.client.session.IWhereClausePartUtil;
+import net.sourceforge.squirrel_sql.client.session.WhereClausePartUtil;
 import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
 import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponent;
 
@@ -101,7 +103,7 @@
 		parts.add(parameterWhereClause);
 		parts.add(anotherParameterWhereClause);
 		
-		int nextIndex = whereClausePartUtil.setParameters(mockPstmt, parts , 2);
+		int nextIndex = whereClausePartUtil.setParameters(mockPstmt, parts , 2, null);
 		assertEquals(4, nextIndex);
 		EasyMock.verify(mockLongDataTypeComponent);
 		EasyMock.verify(mockStringDataTypeComponent);