Clover coverage report - Replica - 1.0-Alpha
Coverage timestamp: Dom Fev 1 2004 17:00:58 WET
file stats: LOC: 127   Methods: 5
NCLOC: 86   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
ValueUseReservationUse.java 0% 0% 0% 0%
coverage
 1   
 package mobisnap.common.reservation;
 2   
 
 3   
 import mobisnap.mobile_trx.*;
 4   
 import nmp.dbms.*;
 5   
 
 6   
 /**
 7   
  * Used to represent the usage of a value-use
 8   
  * 
 9   
  * @version 0.045 12-Dec-2000
 10   
  * @author Nuno Pregui�a
 11   
  */
 12   
 public class ValueUseReservationUse
 13   
     extends ReservationUseBase
 14   
     implements java.io.Serializable
 15   
 {
 16   
     transient Object beforeValue;
 17   
     
 18  0
     public ValueUseReservationUse( ValueUseReservation rsrv) {
 19  0
         super( rsrv);
 20   
     }
 21   
     
 22   
     /**
 23   
      * The associated transaction has been committed. Updates the associated
 24   
      * reservation accordingly.
 25   
      * Returns true if the reservation has been completely used
 26   
      */
 27  0
     public boolean commitCltRsrv() throws Exception {
 28  0
         return false;
 29   
     }
 30   
 
 31   
     /**
 32   
      * The associated transaction has been rollbacked. Updates the associated
 33   
      * reservation accordingly.
 34   
      */
 35  0
     public void rollbackCltRsrv(){
 36   
         // do nothing
 37   
     }
 38   
 
 39   
 
 40   
     /**
 41   
      * Updates the reservation and database according to the current usage - processed
 42   
      * BEFORE the transaction execution.
 43   
      * Returns false if the current usage is not compatoble with the associated
 44   
      * reservation.
 45   
      */
 46  0
     public boolean preSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception {
 47  0
         beforeValue = null;
 48  0
         if( ! ( rsrv0 instanceof ValueUseReservation)) 
 49  0
             throw new mobisnap.MobisnapException( "Escrow reservation expected in preSrvTrxExeUpdate");
 50  0
         ValueUseReservation rsrv = (ValueUseReservation)rsrv0;
 51   
 
 52  0
         StringBuffer buffer = new StringBuffer();
 53  0
         buffer.append( "select ");
 54  0
         buffer.append( rsrv.column);
 55  0
         buffer.append( " from ");
 56  0
         buffer.append( rsrv.table);
 57  0
         buffer.append( " where ");
 58  0
         int ncond = rsrv.conds.size();
 59  0
         for( int i = 0; i < ncond; i++) {
 60  0
             if( i != 0)
 61  0
                 buffer.append( " AND ");
 62  0
             ColumnCondition cond = (ColumnCondition)rsrv.conds.elementAt( i);
 63  0
             cond.sourceCode( buffer);
 64   
         }
 65  0
         buffer.append( ";");
 66  0
         SQLVectorResult result = database.executeQuery( buffer.toString());
 67  0
         if( result == null || result.rows == null || result.rows.size() != 1)
 68  0
             throw new mobisnap.MobisnapException( "Reservation specification error");
 69  0
         beforeValue =  ((Object[])result.rows.elementAt( 0))[0];
 70  0
         if( beforeValue == null)
 71  0
             beforeValue = mobisnap.mobile_trx.SQLNull.getInstance();
 72   
 
 73  0
         buffer.setLength( 0);
 74  0
         buffer.append( "update ");
 75  0
         buffer.append( rsrv.table);
 76  0
         buffer.append( " set ");
 77  0
         buffer.append( rsrv.column);
 78  0
         buffer.append( " = ");
 79  0
         buffer.append( rsrv.value);
 80  0
         buffer.append( " where ");
 81  0
         for( int i = 0; i < ncond; i++) {
 82  0
             if( i != 0)
 83  0
                 buffer.append( " AND ");
 84  0
             ColumnCondition cond = (ColumnCondition)rsrv.conds.elementAt( i);
 85  0
             cond.sourceCode( buffer);
 86   
         }
 87  0
         buffer.append( ";");
 88  0
         if( database.executeUpdate( buffer.toString()) != 1)
 89  0
             return false;
 90  0
         return true;
 91   
     }
 92   
 
 93   
     /**
 94   
      * Updates the reservation and database according to the current usage - processed
 95   
      * AFTER the transaction execution.
 96   
      * Returns true if the transaction has been completely used.
 97   
      */
 98  0
     public boolean postSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception {
 99  0
         if( ! ( rsrv0 instanceof ValueUseReservation)) 
 100  0
             throw new mobisnap.MobisnapException( "Escrow reservation expected in preSrvTrxExeUpdate");
 101  0
         if( beforeValue == null)
 102  0
             return false;
 103  0
         ValueUseReservation rsrv = (ValueUseReservation)rsrv0;
 104   
 
 105  0
         StringBuffer buffer = new StringBuffer();
 106  0
         buffer.append( "update ");
 107  0
         buffer.append( rsrv.table);
 108  0
         buffer.append( " set ");
 109  0
         buffer.append( rsrv.column);
 110  0
         buffer.append( " = ");
 111  0
         buffer.append( beforeValue);
 112  0
         buffer.append( " where ");
 113  0
         int ncond = rsrv.conds.size();
 114  0
         for( int i = 0; i < ncond; i++) {
 115  0
             if( i != 0)
 116  0
                 buffer.append( " AND ");
 117  0
             ColumnCondition cond = (ColumnCondition)rsrv.conds.elementAt( i);
 118  0
             cond.sourceCode( buffer);
 119   
         }
 120  0
         buffer.append( ";");
 121  0
         database.executeUpdate( buffer.toString());
 122  0
         return false;
 123   
     }
 124   
 
 125   
     
 126   
 }
 127