@@ -0,0 +1,2804 @@
+/*%0A * Copyright %5B1999-2015%5D Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute%0A * Copyright %5B2016-2017%5D EMBL-European Bioinformatics Institute%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0A%0Apackage org.ensembl.healthcheck.testcase.variation;%0A%0Aimport java.sql.Connection;%0Aimport java.util.List;%0Aimport org.ensembl.healthcheck.DatabaseRegistryEntry;%0Aimport org.ensembl.healthcheck.ReportManager;%0Aimport org.ensembl.healthcheck.Team;%0Aimport org.ensembl.healthcheck.testcase.SingleDatabaseTestCase;%0Aimport org.ensembl.healthcheck.util.DBUtils;%0Aimport org.ensembl.healthcheck.util.RowMapper;%0Aimport org.ensembl.healthcheck.util.SqlTemplate;%0A%0A/**%0A * Checks database tables do not have only one value in key columns.%0A */%0Apublic class CheckNumerous extends SingleDatabaseTestCase %7B%0A%0A%09public CheckNumerous() %7B%0A%0A                addToGroup(%22variation-release%22);%0A%09%09setDescription(%22Check the database does not contain tables with columns with unexpectedly only one value%22);%0A%09%09setTeamResponsible(Team.VARIATION);%0A%0A%09%7D%0A%0A%09/**%0A  %09 * %0A  %09 * @param dbre%0A         * The database to check.%0A    %09 * @return True if the test passed%0A%09 */%0A         public boolean run(final DatabaseRegistryEntry dbre) %7B%0A%09     boolean result = true;%0A%0A%09%09Connection con = dbre.getConnection();%0A%0A%09%09try %7B%0A%0A                    // tables to check%0A                    String%5B%5D check_tab = %7B%22variation_feature%22, %22structural_variation_feature%22, %22phenotype_feature%22, %22variation%22%7D;%0A                    // columns to check%0A                    String%5B%5D check_col = %7B%22seq_region_id%22,     %22seq_region_id%22,                 %22seq_region_id%22,    %22class_attrib_id%22 %7D; %0A%0A                    for (int i =0; i%3C 4; i++)%7B%0A%0A%09%09       String stmt = %22select count(distinct %22 + check_col%5Bi%5D +%22)  from %22 + check_tab%5Bi%5D ;%0A%09%0A                       int rows = DBUtils.getRowCount(con,stmt);%0A                       if (rows == 1) %7B%0A            %09%09    result = false;%0A%09        %09    ReportManager.problem(this, con, %22Only %22 + String.valueOf(rows) + %22 different values in %22 + check_tab%5Bi%5D + %22.%22 + check_col%5Bi%5D );%0A                       %7D%09%0A%0A%09%09    %7D%09%09%0A%09%09%7D catch (Exception e) %7B%0A%09%09    ReportManager.problem(this, con, %22HealthCheck generated an exception: %22 + e.getMessage());%0A%09%09    result = false;%0A%09%09%7D%0A%0A            return result;%0A      %7D%0A%7D%0A%0A

check features have different locations