From b6814b6b8761dba56f9e5fe34164f783af1aca4f Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Wed, 1 Jun 2011 13:19:37 +0000 Subject: [PATCH] Changes to return type of Executable.getType() method to make it compile with Oracle javac. A few modifications to statistics package. git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4201 e3abac25-378b-4346-85de-24260fe3988d --- engine/compbio/engine/client/ConfExecutable.java | 21 +++++----- .../compbio/engine/client/SkeletalExecutable.java | 2 +- engine/compbio/engine/client/Util.java | 44 ++++++++++---------- runner/compbio/runner/conservation/AACon.java | 4 +- runner/compbio/runner/disorder/Disembl.java | 5 +-- runner/compbio/runner/disorder/GlobPlot.java | 6 +-- runner/compbio/runner/disorder/Jronn.java | 4 +- runner/compbio/runner/msa/ClustalW.java | 5 +-- runner/compbio/runner/msa/Mafft.java | 5 +-- runner/compbio/runner/msa/Muscle.java | 5 +-- runner/compbio/runner/msa/Probcons.java | 5 +-- runner/compbio/runner/msa/Tcoffee.java | 4 +- runner/compbio/runner/psiblast/PsiBlast.java | 3 +- webservices/compbio/stat/collector/StatDB.java | 12 ++++++ webservices/compbio/stat/servlet/AnnualStat.java | 9 ++++ 15 files changed, 75 insertions(+), 59 deletions(-) diff --git a/engine/compbio/engine/client/ConfExecutable.java b/engine/compbio/engine/client/ConfExecutable.java index 6cb5c4a..9477ecf 100644 --- a/engine/compbio/engine/client/ConfExecutable.java +++ b/engine/compbio/engine/client/ConfExecutable.java @@ -97,14 +97,15 @@ public class ConfExecutable implements ConfiguredExecutable { @Override public String getCommand(ExecProvider provider) throws UnsupportedRuntimeException { - String command = compbio.engine.client.Util.getCommand(provider, exec - .getClass()); + String command = compbio.engine.client.Util.getCommand(provider, + exec.getClass()); if (Util.isEmpty(command)) { throw new UnsupportedRuntimeException( "Executable " + this.exec.getClass().getSimpleName() + " is not supported by the current runtime environment! Current runtime environment is " - + (SysPrefs.isWindows ? "Windows " + + (SysPrefs.isWindows + ? "Windows " : "Linux/Unix/Mac")); } return command; @@ -251,8 +252,8 @@ public class ConfExecutable implements ConfiguredExecutable { * @return * @throws IOException */ - public static LimitsManager getRunnerLimits( - Class> clazz) throws IOException { + public static LimitsManager getRunnerLimits(Class clazz) + throws IOException { String parametersFile = clazz.getSimpleName().toLowerCase() + ".limits.file"; LimitsManager limits = (LimitsManager) getRunnerConfiguration( @@ -260,9 +261,9 @@ public class ConfExecutable implements ConfiguredExecutable { return limits; } - static Object getRunnerConfiguration( - Class> clazz, Class configurationHolder, - String propertyName) throws IOException { + static Object getRunnerConfiguration(Class clazz, + Class configurationHolder, String propertyName) + throws IOException { Object rconf = null; FileInputStream confFileStream = null; @@ -298,8 +299,8 @@ public class ConfExecutable implements ConfiguredExecutable { return Collections.emptyMap(); } - return EnvVariableProcessor.getEnvVariables(envProperty, this - .getClass()); + return EnvVariableProcessor.getEnvVariables(envProperty, + this.getClass()); } @Override diff --git a/engine/compbio/engine/client/SkeletalExecutable.java b/engine/compbio/engine/client/SkeletalExecutable.java index 744bb33..0e6422d 100644 --- a/engine/compbio/engine/client/SkeletalExecutable.java +++ b/engine/compbio/engine/client/SkeletalExecutable.java @@ -333,6 +333,6 @@ public abstract class SkeletalExecutable implements Executable { * * @return subclasses must return their type */ - public abstract Class> getType(); + public abstract Class getType(); } diff --git a/engine/compbio/engine/client/Util.java b/engine/compbio/engine/client/Util.java index 63181ea..9d0727b 100644 --- a/engine/compbio/engine/client/Util.java +++ b/engine/compbio/engine/client/Util.java @@ -69,8 +69,8 @@ public final class Util { // Work directory could be null for cancelled or incomplete jobs, just // ignore if (!compbio.util.Util.isEmpty(workDirectory)) { - writeFile(workDirectory, fileAndEventName, new Long(System - .currentTimeMillis()).toString(), false); + writeFile(workDirectory, fileAndEventName, + new Long(System.currentTimeMillis()).toString(), false); } } @@ -78,9 +78,8 @@ public final class Util { String content, boolean override) { File file = null; if (compbio.util.Util.isEmpty(workDirectory)) { - log - .debug("Calling compbio.engine.Util.writeFile() with not work directory." - + " Skipping writing statistics!"); + log.debug("Calling compbio.engine.Util.writeFile() with not work directory." + + " Skipping writing statistics!"); return; } assert !compbio.util.Util.isEmpty(content) : "Content expected!"; @@ -128,9 +127,10 @@ public final class Util { return sfile.createNewFile(); } } catch (IOException e) { - log.error("Could not record stat marker file " + fileType - + " into the directory " + workDirectory + " ! " - + e.getMessage(), e.getCause()); + log.error( + "Could not record stat marker file " + fileType + + " into the directory " + workDirectory + " ! " + + e.getMessage(), e.getCause()); } return false; } @@ -184,9 +184,8 @@ public final class Util { String absolute = relativePath; if (!PathValidator.isAbsolutePath(relativePath)) { absolute = PropertyHelperManager.getLocalPath() + relativePath; - Util.log - .trace("Changing local path in enviromental variable to absolute: FROM " - + relativePath + " TO " + absolute); + Util.log.trace("Changing local path in enviromental variable to absolute: FROM " + + relativePath + " TO " + absolute); } return absolute; } @@ -287,17 +286,19 @@ public final class Util { exec = ConfExecutable.newConfExecutable(rconf); fileInStream.close(); } catch (FileNotFoundException e) { - log.error("Could not find run configuration to load!" - + e.getLocalizedMessage(), e.getCause()); + log.error( + "Could not find run configuration to load!" + + e.getLocalizedMessage(), e.getCause()); throw new ResultNotAvailableException( "Could not find run configuration to load!" + e.getMessage(), e.getCause()); } catch (IOException e) { - log.error("IO Exception while reading run configuration file!" - + e.getLocalizedMessage(), e.getCause()); + log.error( + "IO Exception while reading run configuration file!" + + e.getLocalizedMessage(), e.getCause()); throw new ResultNotAvailableException( - "Could not load run configuration!" + e.getMessage(), e - .getCause()); + "Could not load run configuration!" + e.getMessage(), + e.getCause()); } finally { FileUtil.closeSilently(log, fileInStream); } @@ -319,15 +320,14 @@ public final class Util { * par.getOptionName() + "=" + par.getPossibleValues().get(0); } // * separate options options.add(option); } return options; } */ - - public static LimitsManager getLimits(Class> clazz) { + + public static LimitsManager getLimits(Class clazz) { LimitsManager limits = null; try { limits = ConfExecutable.getRunnerLimits(clazz); } catch (FileNotFoundException e) { - Util.log.warn( - "No limits are found for " + clazz + " executable! " - + e.getLocalizedMessage(), e.getCause()); + Util.log.warn("No limits are found for " + clazz + " executable! " + + e.getLocalizedMessage(), e.getCause()); // its ok, limit may not be initialized } catch (IOException e) { Util.log.warn("IO exception while attempting to read limits for " diff --git a/runner/compbio/runner/conservation/AACon.java b/runner/compbio/runner/conservation/AACon.java index 366b95f..a03dfd7 100644 --- a/runner/compbio/runner/conservation/AACon.java +++ b/runner/compbio/runner/conservation/AACon.java @@ -124,8 +124,8 @@ public class AACon extends SkeletalExecutable { @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } public static String getStatFile() { diff --git a/runner/compbio/runner/disorder/Disembl.java b/runner/compbio/runner/disorder/Disembl.java index 37cb2c1..7c54af1 100644 --- a/runner/compbio/runner/disorder/Disembl.java +++ b/runner/compbio/runner/disorder/Disembl.java @@ -25,7 +25,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.ScoreManager; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; @@ -114,8 +113,8 @@ public class Disembl extends SkeletalExecutable @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/disorder/GlobPlot.java b/runner/compbio/runner/disorder/GlobPlot.java index a5b887a..6530f5f 100644 --- a/runner/compbio/runner/disorder/GlobPlot.java +++ b/runner/compbio/runner/disorder/GlobPlot.java @@ -25,7 +25,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.ScoreManager; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; @@ -62,6 +61,7 @@ public class GlobPlot extends SkeletalExecutable // super.setInput(""); } + @Override @SuppressWarnings("unchecked") public ScoreManager getResults(String workDirectory) throws ResultNotAvailableException { @@ -100,8 +100,8 @@ public class GlobPlot extends SkeletalExecutable @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/disorder/Jronn.java b/runner/compbio/runner/disorder/Jronn.java index 3f668e3..8e1eb25 100644 --- a/runner/compbio/runner/disorder/Jronn.java +++ b/runner/compbio/runner/disorder/Jronn.java @@ -129,8 +129,8 @@ public class Jronn extends SkeletalExecutable { @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } public static String getStatFile() { diff --git a/runner/compbio/runner/msa/ClustalW.java b/runner/compbio/runner/msa/ClustalW.java index 88f6358..f43be73 100644 --- a/runner/compbio/runner/msa/ClustalW.java +++ b/runner/compbio/runner/msa/ClustalW.java @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; import compbio.runner.Util; @@ -114,8 +113,8 @@ public class ClustalW extends SkeletalExecutable { @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/msa/Mafft.java b/runner/compbio/runner/msa/Mafft.java index ee0e5cb..508d5f7 100644 --- a/runner/compbio/runner/msa/Mafft.java +++ b/runner/compbio/runner/msa/Mafft.java @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; @@ -91,8 +90,8 @@ public class Mafft extends SkeletalExecutable @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } /* diff --git a/runner/compbio/runner/msa/Muscle.java b/runner/compbio/runner/msa/Muscle.java index c37b73a..f3ac1c7 100644 --- a/runner/compbio/runner/msa/Muscle.java +++ b/runner/compbio/runner/msa/Muscle.java @@ -29,7 +29,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; import compbio.runner.Util; @@ -111,8 +110,8 @@ public class Muscle extends SkeletalExecutable { @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/msa/Probcons.java b/runner/compbio/runner/msa/Probcons.java index 2df7f92..58e4adb 100644 --- a/runner/compbio/runner/msa/Probcons.java +++ b/runner/compbio/runner/msa/Probcons.java @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; -import compbio.engine.client.Executable; import compbio.engine.client.PipedExecutable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; @@ -92,7 +91,7 @@ public class Probcons extends SkeletalExecutable @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/msa/Tcoffee.java b/runner/compbio/runner/msa/Tcoffee.java index 3b35875..98b2313 100644 --- a/runner/compbio/runner/msa/Tcoffee.java +++ b/runner/compbio/runner/msa/Tcoffee.java @@ -143,7 +143,7 @@ public class Tcoffee extends SkeletalExecutable @SuppressWarnings("unchecked") @Override - public Class> getType() { - return (Class>) this.getClass(); + public Class getType() { + return (Class) this.getClass(); } } diff --git a/runner/compbio/runner/psiblast/PsiBlast.java b/runner/compbio/runner/psiblast/PsiBlast.java index c51df24..95fb69d 100644 --- a/runner/compbio/runner/psiblast/PsiBlast.java +++ b/runner/compbio/runner/psiblast/PsiBlast.java @@ -18,7 +18,6 @@ package compbio.runner.psiblast; -import compbio.engine.client.Executable; import compbio.engine.client.SkeletalExecutable; import compbio.metadata.ResultNotAvailableException; @@ -40,7 +39,7 @@ public class PsiBlast extends SkeletalExecutable { } @Override - public Class> getType() { + public Class getType() { // TODO Auto-generated method stub return null; } diff --git a/webservices/compbio/stat/collector/StatDB.java b/webservices/compbio/stat/collector/StatDB.java index c2dd29a..2b7b66b 100644 --- a/webservices/compbio/stat/collector/StatDB.java +++ b/webservices/compbio/stat/collector/StatDB.java @@ -111,6 +111,16 @@ public class StatDB { conn.close(); } + static void clearStatTable() throws SQLException { + Connection conn = getDBConnection(); + String query = "delete from exec_stat"; + Statement st = conn.createStatement(); + st.executeUpdate(query); + st.close(); + conn.commit(); + conn.close(); + } + void insertData(Set jobstatus) throws SQLException { log.info("Inserting " + jobstatus.size() + " new records into the statistics database"); @@ -328,6 +338,8 @@ public class StatDB { } } public static void main(String[] args) throws SQLException { + // This is called from Ant cleanStatTable task + clearStatTable(); // new StatDB().createStatTable(); // insertData(null); /* diff --git a/webservices/compbio/stat/servlet/AnnualStat.java b/webservices/compbio/stat/servlet/AnnualStat.java index c25280c..cc3db41 100644 --- a/webservices/compbio/stat/servlet/AnnualStat.java +++ b/webservices/compbio/stat/servlet/AnnualStat.java @@ -1,6 +1,7 @@ package compbio.stat.servlet; import java.io.IOException; +import java.io.PrintWriter; import java.sql.SQLException; import java.util.Date; import java.util.Map; @@ -24,6 +25,14 @@ public class AnnualStat extends HttpServlet { try { StatDB db = new StatDB(); Date earliestRec = db.getEarliestRecord(); + if (earliestRec == null) { + PrintWriter writer = resp.getWriter(); + writer.println("No statistics found in the database. Please allow " + + "at least one hour after a server start for the statistics " + + "collector to collect the data. "); + writer.close(); + return; + } Map monthlyTotals = StatCollection .getStats(earliestRec); req.setAttribute("stat", monthlyTotals); -- 1.7.10.2