Refactor:
[jabaws.git] / engine / compbio / engine / client / Util.java
index afe2b6c..63181ea 100644 (file)
@@ -32,6 +32,7 @@ import compbio.engine.client.Executable.ExecProvider;
 import compbio.engine.conf.DirectoryManager;\r
 import compbio.engine.conf.PropertyHelperManager;\r
 import compbio.metadata.JobStatus;\r
+import compbio.metadata.LimitsManager;\r
 import compbio.metadata.ResultNotAvailableException;\r
 import compbio.util.FileUtil;\r
 import compbio.util.PropertyHelper;\r
@@ -303,4 +304,37 @@ public final class Util {
                return exec;\r
        }\r
 \r
+       /**\r
+        * For now just assume that all parameters which came in needs setting it\r
+        * will be a client responsibility to prepare RunnerConfig object then\r
+        * \r
+        * @param rconfig\r
+        * @return\r
+        * \r
+        *         public static List<String> toOptionString(RunnerConfig<?>\r
+        *         rconfig) { String option = ""; List<String> options = new\r
+        *         ArrayList<String>(); for (Parameter<?> par :\r
+        *         rconfig.getParameters()) { if (par.getPossibleValues().isEmpty())\r
+        *         { option = par.getOptionName(); } else { option =\r
+        *         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
+               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
+                       // its ok, limit may not be initialized\r
+               } catch (IOException e) {\r
+                       Util.log.warn("IO exception while attempting to read limits for "\r
+                                       + clazz + " executable! " + e.getLocalizedMessage(),\r
+                                       e.getCause());\r
+               }\r
+               return limits;\r
+       }\r
+\r
 }\r