@@ -0,0 +1,2688 @@
+/*%0A * Copyright (C) 2003 EBI, GRL%0A * %0A * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by%0A * the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.%0A * %0A * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or%0A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.%0A * %0A * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation,%0A * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA%0A */%0Apackage org.ensembl.healthcheck.testcase.generic;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0A%0Aimport org.ensembl.healthcheck.DatabaseRegistryEntry;%0Aimport org.ensembl.healthcheck.ReportManager;%0Aimport org.ensembl.healthcheck.testcase.Priority;%0Aimport org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;%0A%0A/**%0A * Check that not all xrefs have the same identifier.%0A */%0A%0Apublic class XrefIdentifiers extends SingleDatabaseTestCase %7B%0A%0A%09/**%0A%09 * Create a new XrefIdentifiers testcase.%0A%09 */%0A%09public XrefIdentifiers() %7B%0A%0A%09%09addToGroup(%22post_genebuild%22);%0A%09%09addToGroup(%22release%22);%0A%09%09addToGroup(%22core_xrefs%22);%0A%09%09setDescription(%22Check that not all xrefs have the same identifier.%22);%0A%09%09setPriority(Priority.AMBER);%0A%09%09setEffect(%22Web display and all other uses of xrefs are broken%22);%0A%09%09setFix(%22Re-import or recalculate xrefs%22);%0A%0A%09%7D%0A%0A%09/**%0A%09 * Run the test.%0A%09 * %0A%09 * @param dbre%0A%09 *          The database to use.%0A%09 * @return true if the test pased.%0A%09 * %0A%09 */%0A%09public boolean run(DatabaseRegistryEntry dbre) %7B%0A%0A%09%09boolean result = true;%0A%0A%09%09Connection con = dbre.getConnection();%0A%0A%09%09// TODO - do this on a per-xref-type basis%0A%09%09try %7B%0A%0A%09%09%09Statement stmt = con.createStatement();%0A%0A%09%09%09ResultSet rs = stmt.executeQuery(%22SELECT COUNT(DISTINCT(dbprimary_acc)) FROM xref%22);%0A%0A%09%09%09rs.next();%0A%09%09%09%0A%09%09%09int count = rs.getInt(1);%0A%09%09%09if (count == 1) %7B%0A%09%09%09%09ReportManager.problem(this, con, %22All xrefs appear to have the same identifier.%22);%0A%09%09%09%09result = false;%0A%09%09%09%7D else %7B%0A%09%09%09%09ReportManager.correct(this, con, %22Not all xrefs have the same identifier.%22);%0A%09%09%09%7D%0A%0A%09%09%09stmt.close();%0A%0A%09%09%7D catch (SQLException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09%09if (result) %7B%0A%0A%09%09%09ReportManager.correct(this, con, %22All external dbs are only associated with one Ensembl object type%22);%0A%0A%09%09%7D%0A%0A%09%09return result;%0A%0A%09%7D // run%0A%0A%09// ----------------------------------------------------------------------%0A%0A%7D // XrefIdentifiers%0A

Check that not all xrefs have the same identifier.