avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/client CommandConnection.java
Date Fri, 23 Nov 2001 13:32:32 GMT
hammant     01/11/23 05:32:32

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicDeleteRows.java
               apps/db/src/java/org/apache/avalon/db/basic/data
                        BasicView.java
               apps/db/src/java/org/apache/avalon/db/data View.java
               apps/db/src/java/org/apache/avalon/db/data/impl
                        AbstractView.java
               apps/db/src/java/org/apache/avalon/db/driver
                        AvalonDBResultSet.java
               apps/db/src/java/org/apache/avalon/db/test Tester.java
               apps/db/src/java/org/apache/avalon/db/transport/cmdstream/client
                        CommandConnection.java
  Log:
  Output better for Tester.
  
  Revision  Changes    Path
  1.5       +31 -3     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicDeleteRows.java
  
  Index: BasicDeleteRows.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicDeleteRows.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BasicDeleteRows.java	2001/11/23 07:24:57	1.4
  +++ BasicDeleteRows.java	2001/11/23 13:32:32	1.5
  @@ -12,6 +12,8 @@
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.actions.DeleteRows;
   import org.apache.avalon.db.data.impl.AbstractQueryable;
  +import org.apache.avalon.db.data.impl.AbstractTable;
  +import org.apache.avalon.db.data.impl.AbstractView;
   import org.apache.avalon.db.basic.data.BasicRow;
   import org.apache.avalon.framework.logger.LogEnabled;
   
  @@ -24,13 +26,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class BasicDeleteRows extends AbstractAction
           implements DeleteRows, LogEnabled {
   
       private SimpleWhereClause mWhereClause;
       private AbstractQueryable mQueryable;
  +    private AbstractTable mTable;
       private int mRecordCount;
   
       /**
  @@ -48,6 +51,30 @@
   
       public void initialize() throws ActionException {
           getLogger().debug("BasicDeleteRows.initialize()");
  +
  +        if (mQueryable instanceof AbstractTable) {
  +            mTable = (AbstractTable) mQueryable;
  +        } else if (mQueryable instanceof AbstractView) {
  +            boolean more = true;
  +            AbstractQueryable aq = mQueryable;
  +            AbstractView av = null;
  +            while (mTable == null & more) {
  +                av = (AbstractView) mQueryable;
  +                aq = (AbstractQueryable) av.getSourceQueryable();
  +                if (aq == null) {
  +                    more = false;
  +                } if (aq instanceof AbstractTable) {
  +                    mTable = (AbstractTable) aq;
  +                }
  +            }
  +        }
  +
  +        if (mTable == null) {
  +            throw new ActionException("Deletes can only be performed against Views that
map to single tables.");
  +        }
  +
  +
  +
       }
   
       /**
  @@ -70,8 +97,9 @@
           // TODO ConcurrentModificationException potential for other selects at the same
time
           it = pendingDeletes.iterator();
           while (it.hasNext()) {
  -            it.next();
  -            it.remove();
  +            BasicRow row = (BasicRow) it.next();
  +            mTable.deleteRow(row);
  +            mRecordCount++;
           }
       }
   
  
  
  
  1.6       +5 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/data/BasicView.java
  
  Index: BasicView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/data/BasicView.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicView.java	2001/11/18 20:50:28	1.5
  +++ BasicView.java	2001/11/23 13:32:32	1.6
  @@ -25,7 +25,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class BasicView extends AbstractView implements RowListener {
   
  @@ -130,5 +130,9 @@
           } catch (DataException de) {
               getLogger().debug("(BasicView) Some exception during rowsChanged",de);
           }
  +    }
  +
  +    public Queryable getSourceQueryable() {
  +        return mQueryable;
       }
   }
  
  
  
  1.4       +6 -4      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/View.java
  
  Index: View.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/View.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- View.java	2001/11/11 13:03:45	1.3
  +++ View.java	2001/11/23 13:32:32	1.4
  @@ -8,13 +8,15 @@
    */
   package org.apache.avalon.db.data;
   
  -
  -
   /**
    * Interface View
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.3 $
  + * @version * $Revision: 1.4 $
    */
  -public interface View extends Queryable {}
  +public interface View extends Queryable {
  +
  +    Queryable getSourceQueryable();
  +
  +}
  
  
  
  1.4       +3 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractView.java
  
  Index: AbstractView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractView.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractView.java	2001/11/11 13:03:45	1.3
  +++ AbstractView.java	2001/11/23 13:32:32	1.4
  @@ -23,7 +23,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public abstract class AbstractView extends AbstractQueryable implements View {
   
  @@ -53,5 +53,7 @@
       public Collection getRows() {
           return Collections.unmodifiableCollection(rows);
       }
  +
  +
   
   }
  
  
  
  1.7       +2 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBResultSet.java
  
  Index: AvalonDBResultSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/driver/AvalonDBResultSet.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AvalonDBResultSet.java	2001/11/11 14:48:10	1.6
  +++ AvalonDBResultSet.java	2001/11/23 13:32:32	1.7
  @@ -44,7 +44,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class AvalonDBResultSet extends AbstractDriver implements ResultSet {
   
  @@ -143,7 +143,7 @@
        * @exception SQLException if a database access error occurs
        */
       public String getString(int columnIndex) throws SQLException {
  -        return (String)mRow[columnIndex];
  +        return mRow[columnIndex].toString();
       }
   
       /**
  
  
  
  1.27      +20 -7     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java
  
  Index: Tester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/test/Tester.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Tester.java	2001/11/23 12:40:21	1.26
  +++ Tester.java	2001/11/23 13:32:32	1.27
  @@ -69,9 +69,24 @@
           System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
  -        System.err.println("SELECT 1");
  +
  +        System.err.println("SELECT 0 (all rows)");
           st = mCon.createStatement();
           String select = "<simple-select>" +
  +                           "<columns>*</columns>" +
  +                           "<from><table name=\"Flintstones\"/></from>"
+
  +                        "</simple-select>";
  +
  +        ResultSet rs = st.executeQuery(select);
  +        st.close();
  +        while (rs.next()) {
  +            System.out.println("  Row:" + rs.getString(0) + ", " + rs.getString(1) + ",
" + rs.getString(2));
  +        }
  +        rs.close();
  +
  +        System.err.println("SELECT 1 (age>40)");
  +        st = mCon.createStatement();
  +        select = "<simple-select>" +
                             "<columns><column name=\"forename\"/>" +
                             "<column name=\"surname\"/></columns>" +
                              //"<columns>*</columns>" +
  @@ -83,14 +98,14 @@
   
                           "</simple-select>";
   
  -        ResultSet rs = st.executeQuery(select);
  +        rs = st.executeQuery(select);
           st.close();
           while (rs.next()) {
               System.out.println("  Row:" + rs.getString(0) + ", " + rs.getString(1));
           }
           rs.close();
   
  -        System.err.println("VIEW 1");
  +        System.err.println("VIEW 1 (Wilma Flintstone)");
           st = mCon.createStatement();
           String view = "<create-view name=\"FlintstonesView\" on=\"Flintstones\">"
+
                            "<columns>" +
  @@ -137,10 +152,8 @@
           st.execute(index);
           System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
  -
  -
   
  -        System.err.println("DELETE 1");
  +        System.err.println("DELETE 1 (age>100)");
           st = mCon.createStatement();
           String delt = "<delete-rows from=\"Flintstones\">" +
                             "<where>" +
  @@ -165,7 +178,7 @@
           System.out.println("  Update Count : " + st.getUpdateCount());
           st.close();
   
  -        System.err.println("SELECT 3");
  +        System.err.println("SELECT 3 (all rows)");
           st = mCon.createStatement();
           select = "<simple-select>" +
                             "<columns><column name=\"forename\"/>" +
  
  
  
  1.11      +2 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/client/CommandConnection.java
  
  Index: CommandConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/transport/cmdstream/client/CommandConnection.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CommandConnection.java	2001/11/19 12:11:54	1.10
  +++ CommandConnection.java	2001/11/23 13:32:32	1.11
  @@ -34,7 +34,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    */
   public class CommandConnection extends AvalonDBConnection {
   
  @@ -66,7 +66,7 @@
                                              + " during connection creation", uhe);
           } catch (IOException ioe) {
               throw new AvalonDBSQLException(
  -                "Some IO Exception during connection creation to host/port" + mHost + "/"
+ mPort
  +                "Some IO Exception during connection creation to host/port " + mHost +
"/" + mPort
                   + " during connection creation", ioe);
           }
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message