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