Coverage Report - uk.ac.ebi.intenz.mapper.EventPackageMapper
 
Classes in this File Line Coverage Branch Coverage Complexity
EventPackageMapper
100%
82/82
25%
8/32
1.471
 
 1  
 package uk.ac.ebi.intenz.mapper;
 2  
 
 3  
 import java.sql.CallableStatement;
 4  
 import java.sql.Connection;
 5  
 import java.sql.Date;
 6  
 import java.sql.SQLException;
 7  
 import java.sql.Timestamp;
 8  
 import java.util.GregorianCalendar;
 9  
 
 10  
 /**
 11  
  * Provides methods for event package access.
 12  
  *
 13  
  * @author Michael Darsow
 14  
  * @version $Revision: 1.2 $ $Date: 2008/01/28 12:33:08 $
 15  
  * @deprecated use {@link HistoryEventMapper} instead.
 16  
  */
 17  
 public class EventPackageMapper {
 18  
 
 19  8
   public EventPackageMapper() {
 20  8
   }
 21  
 
 22  
   private String callInsertFutureCreationStatement() {
 23  2
     return "{CALL event.p_insert_future_creation(?, ?)}";
 24  
   }
 25  
 
 26  
   private String callUpdateFutureCreationStatement() {
 27  2
     return "{CALL event.p_update_future_creation(?, ?, ?)}";
 28  
   }
 29  
 
 30  
   private String callInsertFutureTransferStatement() {
 31  2
     return "{CALL event.p_insert_future_transfer(?, ?, ?, ?, ?)}";
 32  
   }
 33  
 
 34  
   private String callUpdateFutureTransferStatement() {
 35  2
     return "{CALL event.p_update_future_transfer(?, ?, ?, ?, ?)}";
 36  
   }
 37  
 
 38  
   private String callInsertFutureDeletionStatement() {
 39  2
     return "{CALL event.p_insert_future_deletion(?, ?, ?, ?, ?)}";
 40  
   }
 41  
 
 42  
   private String callUpdateFutureDeletionStatement() {
 43  2
     return "{CALL event.p_update_future_deletion(?, ?, ?, ?)}";
 44  
   }
 45  
 
 46  
   private String callInsertFutureModificationStatement() {
 47  2
     return "{CALL event.p_insert_future_modification(?, ?, ?)}";
 48  
   }
 49  
 
 50  
   private String callUpdateFutureModificationStatement() {
 51  2
     return "{CALL event.p_update_future_modification(?, ?, ?)}";
 52  
   }
 53  
 
 54  
   /**
 55  
    * Inserts a new enzyme creation event into the <code>FUTURE_EVENTS</code> table.
 56  
    *
 57  
    * @param enzymeId The enzyme ID.
 58  
    * @param con      The connection.
 59  
    * @throws SQLException
 60  
    */
 61  
   public void insertFutureCreationEvent(Long enzymeId, Connection con) throws SQLException {
 62  2
     CallableStatement cStmt = null;
 63  
 
 64  
     try {
 65  2
       cStmt = con.prepareCall(callInsertFutureCreationStatement());
 66  2
       cStmt.setLong(1, enzymeId.longValue());
 67  2
       cStmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
 68  2
       cStmt.execute();
 69  
 //      con.commit();
 70  
 //    } catch (SQLException e) {
 71  
 //      con.rollback();
 72  
 //      throw e;
 73  
     } finally {
 74  2
       if (cStmt != null) cStmt.close();
 75  
     }
 76  2
   }
 77  
 
 78  
   /**
 79  
    * Updates a new enzyme creation event in the <code>FUTURE_EVENTS</code> table.
 80  
    *
 81  
    * @param groupId   The enzyme ID of the original enzyme.
 82  
    * @param eventId   The enzyme ID of the cloned enzyme.
 83  
    * @param newStatus ...
 84  
    * @param con       ...
 85  
    * @throws SQLException
 86  
    */
 87  
   public void updateFutureCreationEvent(int groupId, int eventId, String newStatus, Connection con) throws SQLException {
 88  2
     CallableStatement cStmt = null;
 89  
 
 90  
     try {
 91  2
       cStmt = con.prepareCall(callUpdateFutureCreationStatement());
 92  2
       cStmt.setInt(1, groupId);
 93  2
       cStmt.setInt(2, eventId);
 94  2
       cStmt.setString(3, newStatus);
 95  2
       cStmt.execute();
 96  
 //      con.commit();
 97  
 //    } catch (SQLException e) {
 98  
 //      con.rollback();
 99  
 //      throw e;
 100  
     } finally {
 101  2
             if (cStmt != null) cStmt.close();
 102  
     }
 103  2
   }
 104  
 
 105  
   /**
 106  
    * Inserts a new enzyme creation event into the <code>FUTURE_EVENTS</code> table.
 107  
    *
 108  
    * @param beforeId The enzyme ID of the original enzyme.
 109  
    * @param afterId  The enzyme ID of the cloned enzyme.
 110  
    * @param con      The connection.
 111  
    * @throws SQLException
 112  
    */
 113  
   public void insertFutureModificationEvent(Long beforeId, Long afterId, Connection con) throws SQLException {
 114  2
     CallableStatement cStmt = null;
 115  
 
 116  
     try {
 117  2
       cStmt = con.prepareCall(callInsertFutureModificationStatement());
 118  2
       cStmt.setLong(1, beforeId.longValue());
 119  2
       cStmt.setLong(2, afterId.longValue());
 120  2
       cStmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
 121  2
       cStmt.execute();
 122  
 //      con.commit();
 123  
 //    } catch (SQLException e) {
 124  
 //      con.rollback();
 125  
 //      throw e;
 126  
     } finally {
 127  2
             if (cStmt != null) cStmt.close();
 128  
     }
 129  2
   }
 130  
 
 131  
   /**
 132  
    * Updates a new enzyme creation event in the <code>FUTURE_EVENTS</code> table.
 133  
    *
 134  
    * @param groupId   The event group ID.
 135  
    * @param eventId   The event ID.
 136  
    * @param newStatus ...
 137  
    * @param con       ...
 138  
    * @throws SQLException
 139  
    */
 140  
   public void updateFutureModificationEvent(int groupId, int eventId, String newStatus, Connection con) throws SQLException {
 141  2
     CallableStatement cStmt = null;
 142  
 
 143  
     try {
 144  2
       cStmt = con.prepareCall(callUpdateFutureModificationStatement());
 145  2
       cStmt.setInt(1, groupId);
 146  2
       cStmt.setInt(2, eventId);
 147  2
       cStmt.setString(3, newStatus);
 148  2
       cStmt.execute();
 149  
 //      con.commit();
 150  
 //    } catch (SQLException e) {
 151  
 //      con.rollback();
 152  
 //      throw e;
 153  
     } finally {
 154  2
             if (cStmt != null) cStmt.close();
 155  
     }
 156  2
   }
 157  
 
 158  
   /**
 159  
    * Inserts a new transfer event into the <code>FUTURE_EVENTS</code> table.
 160  
    *
 161  
    * @param beforeId The enzyme ID of the original enzyme.
 162  
    * @param afterId  The enzyme ID of the cloned enzyme.
 163  
    * @param comment  History comment added to this transfer event.
 164  
    * @param con      The connection.
 165  
    * @throws SQLException
 166  
    */
 167  
   public void insertFutureTransferEvent(Long beforeId, Long afterId, String comment, Connection con) throws SQLException {
 168  2
     CallableStatement cStmt = null;
 169  2
     GregorianCalendar gc = new GregorianCalendar();
 170  2
     Date date = new Date(gc.getTimeInMillis());
 171  
 
 172  
     try {
 173  2
       cStmt = con.prepareCall(callInsertFutureTransferStatement());
 174  2
       cStmt.setLong(1, beforeId.longValue());
 175  2
       cStmt.setLong(2, afterId.longValue());
 176  2
       cStmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
 177  2
       cStmt.setString(4, comment);
 178  2
       cStmt.setString(5, "SU");
 179  2
       cStmt.execute();
 180  
 //      con.commit();
 181  
 //    } catch (SQLException e) {
 182  
 //      con.rollback();
 183  
 //      throw e;
 184  
     } finally {
 185  2
             if (cStmt != null) cStmt.close();
 186  
     }
 187  2
   }
 188  
 
 189  
   /**
 190  
    * Updates a transferred enzyme (target and origin) event in the <code>FUTURE_EVENTS</code> table.
 191  
    *
 192  
    * @param groupId           The enzyme ID of the original enzyme.
 193  
    * @param eventId           The enzyme ID of the cloned enzyme.
 194  
    * @param newHistoryComment ...
 195  
    * @param newStatus         ...
 196  
    * @param con               ...
 197  
    * @throws SQLException
 198  
    */
 199  
   public void updateFutureTransferEvent(int groupId, int eventId, String newHistoryComment, String newStatus, String historyLineOfDeletedEntry, Connection con) throws SQLException {
 200  2
     CallableStatement cStmt = null;
 201  
 
 202  
     try {
 203  2
       cStmt = con.prepareCall(callUpdateFutureTransferStatement());
 204  2
       cStmt.setInt(1, groupId);
 205  2
       cStmt.setInt(2, eventId);
 206  2
       cStmt.setString(3, newStatus);
 207  2
       cStmt.setString(4, newHistoryComment);
 208  2
       cStmt.setString(5, historyLineOfDeletedEntry);
 209  2
       cStmt.execute();
 210  
 //      con.commit();
 211  
 //    } catch (SQLException e) {
 212  
 //      con.rollback();
 213  
 //      throw e;
 214  
     } finally {
 215  2
             if (cStmt != null) cStmt.close();
 216  
     }
 217  2
   }
 218  
 
 219  
   /**
 220  
    * Inserts a new deletion event into the <code>FUTURE_EVENTS</code> table.
 221  
    *
 222  
    * @param beforeId The enzyme ID of the original enzyme.
 223  
    * @param afterId  The enzyme ID of the cloned enzyme.
 224  
    * @param comment  History comment added to this deletion event.
 225  
    * @param con      The connection.
 226  
    * @throws SQLException
 227  
    */
 228  
   public void insertFutureDeletionEvent(Long beforeId, Long afterId, String comment, Connection con) throws SQLException {
 229  2
     CallableStatement cStmt = null;
 230  
 
 231  
     try {
 232  2
       cStmt = con.prepareCall(callInsertFutureDeletionStatement());
 233  2
       cStmt.setLong(1, beforeId.longValue());
 234  2
       cStmt.setLong(2, afterId.longValue());
 235  2
       cStmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
 236  2
       cStmt.setString(4, comment);
 237  2
       cStmt.setString(5, "SU");
 238  2
       cStmt.execute();
 239  
 //      con.commit();
 240  
 //    } catch (SQLException e) {
 241  
 //      con.rollback();
 242  
 //      throw e;
 243  
     } finally {
 244  2
             if (cStmt != null) cStmt.close();
 245  
     }
 246  2
   }
 247  
 
 248  
   /**
 249  
    * Updates a future deletion event.
 250  
    *
 251  
    * @param groupId   ...
 252  
    * @param eventId   ...
 253  
    * @param comment   ...
 254  
    * @param newStatus The new status of the enzyme.
 255  
    * @param con       The connection.
 256  
    * @throws SQLException
 257  
    */
 258  
   public void updateFutureDeletionEvent(int groupId, int eventId, String comment, String newStatus, Connection con) throws SQLException {
 259  2
     CallableStatement cStmt = null;
 260  
 
 261  
     try {
 262  2
       cStmt = con.prepareCall(callUpdateFutureDeletionStatement());
 263  2
       cStmt.setInt(1, groupId);
 264  2
       cStmt.setInt(2, eventId);
 265  2
       cStmt.setString(3, newStatus);
 266  2
       cStmt.setString(4, comment);
 267  2
       cStmt.execute();
 268  
 //      con.commit();
 269  
 //    } catch (SQLException e) {
 270  
 //      con.rollback();
 271  
 //      throw e;
 272  
     } finally {
 273  2
             if (cStmt != null) cStmt.close();
 274  
     }
 275  2
   }
 276  
 }