1 package mobisnap.common.reservation; 2 3 /*** 4 * Used to represent the usage of a slot reservation 5 * 6 * @version 7 * @author 8 */ 9 public class SlotReservationUse 10 extends ReservationUseBase 11 implements java.io.Serializable 12 { 13 transient boolean srvPreOK = false; 14 int triggerCode; 15 16 public SlotReservationUse( SlotReservation rsrv) { 17 super( rsrv); 18 triggerCode = rsrv.getTriggerCode(); 19 } 20 21 /*** 22 * The associated transaction has been committed. Updates the associated 23 * reservation accordingly. 24 * Returns true if the reservation has been completely used 25 */ 26 public boolean commitCltRsrv() throws Exception { 27 return false; 28 } 29 30 /*** 31 * The associated transaction has been rollbacked. Updates the associated 32 * reservation accordingly. 33 */ 34 public void rollbackCltRsrv(){ 35 // do nothing 36 } 37 38 39 /*** 40 * Updates the reservation and database according to the current usage - processed 41 * BEFORE the transaction execution. 42 * Returns false if the current usage is not compatible with the associated 43 * reservation. 44 */ 45 public boolean preSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception { 46 if( ! ( rsrv0 instanceof SlotReservation)) 47 throw new mobisnap.MobisnapException( "Slot reservation expected in preSrvTrxExeUpdate"); 48 SlotReservation rsrv = (SlotReservation)rsrv0; 49 50 StringBuffer buffer = new StringBuffer(); 51 buffer.append( "alter trigger mobi_sl_"); 52 buffer.append( "_"); 53 buffer.append( rsrv.table); 54 buffer.append( "_"); 55 buffer.append( rsrv.getTriggerCode()); 56 buffer.append(" disable;"); 57 if( database.executeUpdate( buffer.toString()) != 1) 58 return false; 59 return true; 60 } 61 62 /*** 63 * Updates the reservation and database according to the current usage - processed 64 * AFTER the transaction execution. 65 * Returns true if the transaction has been completely used. 66 */ 67 public boolean postSrvTrxExeUpdate( ReservationBase rsrv0, nmp.dbms.JDBC.Jdbc_Sql database) throws Exception { 68 if( ! ( rsrv0 instanceof SlotReservation)) 69 throw new mobisnap.MobisnapException( "Slot reservation expected in postSrvTrxExeUpdate"); 70 SlotReservation rsrv = (SlotReservation)rsrv0; 71 72 StringBuffer buffer = new StringBuffer(); 73 buffer.append( "alter trigger mobi_sl_"); 74 buffer.append( "_"); 75 buffer.append( rsrv.getTriggerCode()); 76 buffer.append( "_"); 77 buffer.append( rsrv.table); 78 buffer.append(" enable;"); 79 database.executeUpdate( buffer.toString()); 80 return true; 81 } 82 83 84 }

This page was automatically generated by Maven