Coverage Report - uk.ac.ebi.intenz.mapper.CommonProceduresMapper
 
Classes in this File Line Coverage Branch Coverage Complexity
CommonProceduresMapper
100%
14/14
25%
1/4
1.333
 
 1  
 package uk.ac.ebi.intenz.mapper;
 2  
 
 3  
 import java.sql.CallableStatement;
 4  
 import java.sql.Connection;
 5  
 import java.sql.SQLException;
 6  
 import java.sql.Types;
 7  
 
 8  
 /**
 9  
  * Provides methods for access to procedures not related to a specific package.
 10  
  *
 11  
  * @author Michael Darsow
 12  
  * @version $Revision: 1.2 $ $Date: 2008/01/28 12:33:07 $
 13  
  */
 14  
 public class CommonProceduresMapper {
 15  
 
 16  1
   public CommonProceduresMapper() {
 17  1
   }
 18  
 
 19  
   private String callCloneStatement() {
 20  1
     return "{CALL p_clone_enzyme(?, ?, ?, ?)}";
 21  
   }
 22  
 
 23  
   /**
 24  
    * Creates a clone of an enzyme by using its enzyme ID.
 25  
    *
 26  
    * @param enzymeId The enzyme's ID.
 27  
    * @param con      The connection.
 28  
    * @throws SQLException
 29  
    */
 30  
   public Long createClone(Long enzymeId, Connection con) throws SQLException {
 31  1
     int newEnzymeId = 0;
 32  1
     CallableStatement cStmt = null;
 33  
 
 34  
     try {
 35  1
       cStmt = con.prepareCall(callCloneStatement());
 36  1
       cStmt.setString(1, "" + enzymeId);
 37  1
       cStmt.registerOutParameter(2, Types.VARCHAR);
 38  1
       cStmt.setString(3, "OK");
 39  1
       cStmt.setString(4, "Y");
 40  1
       cStmt.execute();
 41  
 
 42  1
       newEnzymeId = Integer.parseInt(cStmt.getString(2));
 43  
     } finally {
 44  1
       if (cStmt != null) cStmt.close();
 45  
     }
 46  
 
 47  1
     return new Long(newEnzymeId);
 48  
   }
 49  
 
 50  
 }