Changes to return type of Executable.getType() method to make it compile with Oracle...
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 1 Jun 2011 13:19:37 +0000 (13:19 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 1 Jun 2011 13:19:37 +0000 (13:19 +0000)
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

15 files changed:
engine/compbio/engine/client/ConfExecutable.java
engine/compbio/engine/client/SkeletalExecutable.java
engine/compbio/engine/client/Util.java
runner/compbio/runner/conservation/AACon.java
runner/compbio/runner/disorder/Disembl.java
runner/compbio/runner/disorder/GlobPlot.java
runner/compbio/runner/disorder/Jronn.java
runner/compbio/runner/msa/ClustalW.java
runner/compbio/runner/msa/Mafft.java
runner/compbio/runner/msa/Muscle.java
runner/compbio/runner/msa/Probcons.java
runner/compbio/runner/msa/Tcoffee.java
runner/compbio/runner/psiblast/PsiBlast.java
webservices/compbio/stat/collector/StatDB.java
webservices/compbio/stat/servlet/AnnualStat.java

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