/*
 * Copyright [1999-2015] Wellcome Trust Sanger Institute and the
 * EMBL-European Bioinformatics Institute
 * Copyright [2016] EMBL-European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.ensembl.healthcheck.testcase.funcgen;

import org.ensembl.healthcheck.Team;

/**
 * Check that every result_set has an associated BIGWIG file entry stored in
 * dbfile_registry table. Check that the file actually exists on the disk.
 * @author ilavidas
 */

public class ResultSetHasBigWigFile extends ResultSetHasBamFile {

    public ResultSetHasBigWigFile() {
        setTeamResponsible(Team.FUNCGEN);
        setDescription("Check that every result_set has an associated BIGWIG " +
                "file entry stored in dbfile_registry table. Check that the " +
                "file actually exists on the disk.");
    }

    @Override
    protected FileType getFileType() {
        return FileType.BIGWIG;
    }

}

@@ -812,49 +812,289 @@
 eck.
-Team;%0A%0A/**%0A * Check that every result_set
+DatabaseRegistryEntry;%0Aimport org.ensembl.healthcheck.Team;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.sql.Statement;%0Aimport java.util.HashMap;%0A%0A/**%0A * Check that every result_set which is linked to an annotated feature_set%0A *
  has
@@ -1135,19 +1135,16 @@
 tored in
-%0A *
  dbfile_
@@ -1156,32 +1156,35 @@
 try table. Check
+%0A *
  that the file a
@@ -1284,23 +1284,25 @@
 nds 
-ResultSetHasBam
+DBFileRegistryHas
 File
@@ -1437,16 +1437,81 @@
 ult_set 
+which is linked to an %22 +%0A                %22annotated feature_set 
 has an a
@@ -1527,16 +1527,27 @@
  BIGWIG 
+file entry 
 %22 +%0A    
@@ -1559,27 +1559,16 @@
        %22
-file entry 
 stored i
@@ -1607,16 +1607,21 @@
 hat the 
+file 
 %22 +%0A    
@@ -1633,21 +1633,16 @@
        %22
-file 
 actually
@@ -1764,10 +1764,996 @@
 %0A    %7D%0A%0A
+    @Override%0A    protected TableName getTableName() %7B%0A        return TableName.result_set;%0A    %7D%0A%0A    @Override%0A    HashMap%3CInteger, String%3E getTableIDs(DatabaseRegistryEntry dbre) %7B%0A        HashMap%3CInteger, String%3E tableIDs = new HashMap%3CInteger, String%3E();%0A%0A        Connection con = dbre.getConnection();%0A        try %7B%0A            Statement stmt = con.createStatement();%0A            ResultSet rs = stmt.executeQuery(%22SELECT result_set_id, %22 +%0A                    %22result_set.name FROM result_set JOIN supporting_set ON%22 +%0A                    %22(result_set_id=supporting_set_id AND type='result') JOIN%22 +%0A                    %22 data_set USING(data_set_id) JOIN feature_set USING%22 +%0A                    %22(feature_set_id) WHERE feature_set.type='annotated'%22);%0A%0A            while(rs!=null && rs.next())%7B%0A                tableIDs.put(rs.getInt(1),rs.getString(2));%0A            %7D%0A        %7D catch (SQLException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        return tableIDs;%0A    %7D%0A%0A
 %7D%0A

improve ResultSetHasBigWigFile