package org.ensembl.healthcheck.testcase.generic;

import org.ensembl.healthcheck.DatabaseRegistryEntry;
import org.ensembl.healthcheck.DatabaseType;
import org.ensembl.healthcheck.ReportManager;
import org.ensembl.healthcheck.testcase.AbstractTemplatedTestCase;

/**
 * Test to see if schema uses non-myisam storage engines
 * 
 * @author dstaines
 * 
 */
public class MySQLStorageEngine extends AbstractTemplatedTestCase {

	private final static String MYISAM = "MyISAM";

	private final static String ENGINE_QUERY = "select count(*) from information_schema.tables where table_schema=? and engine<>'" + MYISAM + "'";

	public MySQLStorageEngine() {

		addToGroup("post-compara-handover");

	}

	public void types() {
		this.addAppliesToType(DatabaseType.CORE);
		this.addAppliesToType(DatabaseType.VARIATION);
		this.addAppliesToType(DatabaseType.FUNCGEN);
		this.addAppliesToType(DatabaseType.COMPARA);
	}

	@Override
	protected boolean runTest(DatabaseRegistryEntry dbre) {
		int count = getTemplate(dbre).queryForDefaultObject(ENGINE_QUERY, Integer.class, dbre.getName());
		if (count > 0) {
			ReportManager.problem(this, dbre.getConnection(), count + " tables from " + dbre.getName() + " do not use " + MYISAM);
			return false;
		} else {
			return true;
		}
	}

}

@@ -189,16 +189,53 @@
 anager;%0A
+import org.ensembl.healthcheck.Team;%0A
 import o
@@ -720,16 +720,55 @@
 dover%22);
+%0A%09%09setTeamResponsible(Team.PRODUCTION);
 %0A%0A%09%7D%0A%0A%09p

Set a team responsible