001/** 002 * Copyright (C) 2010-2015 The Roslin Institute <contact andy.law@roslin.ed.ac.uk> 003 * 004 * This file is part of JEnsembl: a Java API to Ensembl data sources developed by the 005 * Bioinformatics Group at The Roslin Institute, The Royal (Dick) School of 006 * Veterinary Studies, University of Edinburgh. 007 * 008 * Project hosted at: http://jensembl.sourceforge.net 009 * 010 * This is free software: you can redistribute it and/or modify 011 * it under the terms of the GNU General Public License (version 3) as published by 012 * the Free Software Foundation. 013 * 014 * This software is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public License 020 * in this software distribution. If not, see: http://opensource.org/licenses/gpl-3.0.html 021 */ 022package uk.ac.roslin.ensembl.mapper.handler; 023 024import org.apache.ibatis.type.TypeHandler; 025import java.sql.CallableStatement; 026import java.sql.PreparedStatement; 027import java.sql.ResultSet; 028import java.sql.SQLException; 029import org.apache.ibatis.type.JdbcType; 030import uk.ac.roslin.ensembl.dao.factory.DAOVariationFactory; 031import uk.ac.roslin.ensembl.datasourceaware.variation.DAVariationXRef; 032 033public class VariationXRefHandler implements TypeHandler { 034 035 DAOVariationFactory factory; 036 037 public VariationXRefHandler() { 038 super(); 039 } 040 041 public void setFactory(DAOVariationFactory factory) { 042 this.factory=factory; 043 } 044 045 @Override 046 public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) 047 throws SQLException { 048 } 049 050 @Override 051 public DAVariationXRef getResult(ResultSet rs, String columnName) 052 throws SQLException { 053 054 if (factory==null) { 055 return null; 056 } 057 058 int i; 059 060 try { 061 i = rs.getInt(columnName); 062 } catch (SQLException sQLException) { 063 return null; 064 } 065 066 return (DAVariationXRef) factory.getVariationXRef(i); 067 068 069 } 070 071 @Override 072 public Object getResult(CallableStatement cs, int columnIndex) 073 throws SQLException { 074 return null; 075 //return cs.getString(columnIndex); 076 } 077}