001 /** 002 * Copyright (C) 2010 The Roslin Institute <contact andy.law@roslin.ed.ac.uk> 003 * 004 * This file is part of the Ensembl Java API demonstration project developed by the 005 * Bioinformatics Group at The Roslin Institute, The Royal (Dick) School of 006 * Veterinary Studies, University of Edinburgh. 007 * 008 * This is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (version 3) as published by 010 * the Free Software Foundation. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU General Public License for more details. 016 * 017 * You should have received a copy of the GNU General Public License 018 * in this software distribution. If not, see <http://www.gnu.org/licenses/gpl-3.0.html/>. 019 */ 020 021 package uk.ac.roslin.ensembl.dao.database.factory; 022 023 import java.util.HashMap; 024 import uk.ac.roslin.ensembl.config.EnsemblComparaDivision; 025 import uk.ac.roslin.ensembl.dao.database.DBComparisonDatabase; 026 import uk.ac.roslin.ensembl.dao.database.DBSingleSpeciesCoreDatabase; 027 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBGeneDAO; 028 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBProteinFeatureDAO; 029 import uk.ac.roslin.ensembl.dao.factory.DAOCoreFactory; 030 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBChromosomeDAO; 031 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBAssemblyDAO; 032 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBDNASequenceDAO; 033 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBCoordinateSystemDAO; 034 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBExonDAO; 035 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBTranscriptDAO; 036 import uk.ac.roslin.ensembl.dao.database.coreaccess.DBTranslationDAO; 037 import uk.ac.roslin.ensembl.dao.factory.DAOSingleSpeciesCoreFactory; 038 import uk.ac.roslin.ensembl.exception.DAOException; 039 import uk.ac.roslin.ensembl.model.database.SingleSpeciesCoreDatabase; 040 import uk.ac.roslin.ensembl.model.database.SingleSpeciesDatabase; 041 042 043 044 public class DBDAOSingleSpeciesCoreFactory extends DBDAOSingleSpeciesFactory implements DAOSingleSpeciesCoreFactory { 045 046 private HashMap<String, DBDAOComparaFactory> comparaFactories = 047 new HashMap<String, DBDAOComparaFactory>(); 048 049 public DBDAOSingleSpeciesCoreFactory(){ 050 super(); 051 } 052 053 public DBDAOSingleSpeciesCoreFactory(SingleSpeciesDatabase database) throws DAOException { 054 super(database); 055 } 056 057 @Override 058 public SingleSpeciesCoreDatabase getDatabase() { 059 return (SingleSpeciesCoreDatabase) this.database; 060 } 061 062 063 @Override 064 public DBGeneDAO getGeneDAO() throws DAOException { 065 return new DBGeneDAO(this); 066 } 067 068 @Override 069 public DBProteinFeatureDAO getProteinFeatureDAO() throws DAOException{ 070 return new DBProteinFeatureDAO(this); 071 } 072 073 @Override 074 public DBChromosomeDAO getChromosomeDAO() throws DAOException{ 075 return new DBChromosomeDAO(this); 076 } 077 078 @Override 079 public DBCoordinateSystemDAO getCoordinateSystemDAO() throws DAOException { 080 return new DBCoordinateSystemDAO(this); 081 } 082 083 @Override 084 public DBAssemblyDAO getAssemblyDAO() throws DAOException{ 085 return new DBAssemblyDAO(this); 086 } 087 088 @Override 089 public DBDNASequenceDAO getSequenceDAO() throws DAOException { 090 return new DBDNASequenceDAO(this); 091 } 092 093 @Override 094 public DBTranslationDAO getTranslationDAO() throws DAOException { 095 return new DBTranslationDAO(this); 096 } 097 098 @Override 099 public DBTranscriptDAO getTranscriptDAO() throws DAOException{ 100 return new DBTranscriptDAO(this); 101 } 102 103 @Override 104 public DBExonDAO getExonDAO() throws DAOException{ 105 return new DBExonDAO(this); 106 } 107 108 @Override 109 public DBDAOComparaFactory getComparaFactory(EnsemblComparaDivision comparaDivision) { 110 111 112 if (comparaDivision == null) { 113 comparaDivision = EnsemblComparaDivision.MULTI; 114 } 115 116 DBDAOComparaFactory out = null; 117 118 if (this.comparaFactories.containsKey(comparaDivision.toString())) { 119 return this.comparaFactories.get(comparaDivision.toString()); 120 } 121 122 DBComparisonDatabase db = null; 123 124 if (this.getRegistry()!=null) { 125 db= (DBComparisonDatabase) this.getRegistry().getComparaDatabase(comparaDivision != null ? comparaDivision : EnsemblComparaDivision.MULTI , 126 dbVersion != null ? dbVersion : String.valueOf(this.getRegistry().getHighestDBVersion())); 127 } 128 129 if (db != null) { 130 out = db.getComparaFactory(); 131 } 132 133 this.comparaFactories.put(comparaDivision.toString(), out); 134 135 return out; 136 } 137 138 139 140 }