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.coreaccess; 022 023 import uk.ac.roslin.ensembl.dao.database.DBBaseDAO; 024 import uk.ac.roslin.ensembl.dao.database.DBCollectionSpecies; 025 import uk.ac.roslin.ensembl.dao.database.DBSpecies; 026 import uk.ac.roslin.ensembl.dao.database.factory.DBDAOCollectionCoreFactory; 027 import uk.ac.roslin.ensembl.dao.database.factory.DBDAOSingleSpeciesCoreFactory; 028 import uk.ac.roslin.ensembl.dao.factory.DAOCollectionCoreFactory; 029 import uk.ac.roslin.ensembl.dao.factory.DAOCollectionFactory; 030 import uk.ac.roslin.ensembl.dao.factory.DAOSingleSpeciesCoreFactory; 031 import uk.ac.roslin.ensembl.dao.factory.DAOSingleSpeciesFactory; 032 import uk.ac.roslin.ensembl.exception.DAOException; 033 034 /** 035 * 036 * @author paterson 037 */ 038 public abstract class DBCoreObjectDAO extends DBBaseDAO { 039 040 protected DBSpecies species = null; 041 protected Boolean singleSpecies = true; 042 protected DAOSingleSpeciesCoreFactory ssFactory = null; 043 protected DAOCollectionCoreFactory collFactory = null; 044 045 public DBCoreObjectDAO() { 046 super(); 047 } 048 049 050 public DBCoreObjectDAO(DAOSingleSpeciesCoreFactory factory) { 051 this(); 052 this.setFactory(factory); 053 } 054 055 public DBCoreObjectDAO(DAOCollectionCoreFactory factory) { 056 this(); 057 this.setFactory(factory); 058 } 059 060 061 public void setFactory(DAOSingleSpeciesCoreFactory factory) { 062 super.setFactory(factory); 063 //old databases for species removed from current ensembl don't have species associated! 064 //cos their is no current species for them 065 if (factory.getSpecies()!= null) { 066 species = (DBSpecies) factory.getSpecies(); 067 } 068 this.singleSpecies = true; 069 this.ssFactory = factory; 070 } 071 072 public void setFactory(DAOCollectionCoreFactory factory) { 073 super.setFactory(factory); 074 species = (DBCollectionSpecies) factory.getSpecies(); 075 this.singleSpecies = false; 076 this.collFactory = factory; 077 } 078 079 080 081 public Boolean isSingleSpecies() { 082 return this.singleSpecies; 083 } 084 085 // @Override 086 // public DBDAOSpeciesFactory getFactory() { 087 // return (DBDAOSpeciesFactory) this.daoFactory; 088 // } 089 090 public DBSpecies getSpecies() { 091 return species; 092 } 093 094 }