Displaying differences for changeset
 
display as  

src/java/cfa/guiBaseflow_Model.java

@@ -1,6 +1,7 @@
 package cfa;
 
 import csip.Config;
+import csip.Executable;
 import csip.utils.Binaries;
 import java.awt.Color;
 import java.io.BufferedReader;
@@ -989,7 +990,7 @@
         throw new IOException("Error encountered. Please see the following message for details: \n" + errorContents);
     }
 
-    public void run() throws IOException, InterruptedException, Exception {
+    public void run(Executable e) throws IOException, InterruptedException, Exception {
         //If no date input, make it the maximum of available data
         if(beginDate == null || beginDate.equalsIgnoreCase("")){
             beginDate = "1850-01-01";
@@ -1045,19 +1046,23 @@
 
             //Call BFLOW model
             //Expected Input: "baseflow.txt" and "file.lst"
-            String binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");
-            File bflow = Binaries.unpackResource("/bin/win-x86/bflow.exe", new File(binDir));
-            ProcessComponent pc = new ProcessComponent();
-
-            if (File.pathSeparatorChar == ':') {
-                pc.exe = Config.getString("wine.path", "/usr/bin/wine");
-                pc.args = new String[]{bflow.toString()};
-            } else {
-                pc.exe = bflow.toString();
-                pc.args = new String[]{};
-            }
-            pc.working_dir = mainFolder;
-            pc.execute();
+//            String binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");
+//            File bflow = Binaries.unpackResource("/bin/win-x86/bflow.exe", new File(binDir));
+//            ProcessComponent pc = new ProcessComponent();
+//
+//            if (File.pathSeparatorChar == ':') {
+//                pc.exe = Config.getString("wine.path", "/usr/bin/wine");
+//                pc.args = new String[]{bflow.toString()};
+//            } else {
+//                pc.exe = bflow.toString();
+//                pc.args = new String[]{};
+//            }
+//            pc.working_dir = mainFolder;
+//            pc.execute();
+            
+            // this is all that is needed:
+            e.exec();
+            
             
             //Expected Output: "baseflow.dat" and "baseflow.out"
             if (!new File(mainFolder, "baseflow.dat").exists()) {
@@ -1101,6 +1106,6 @@
 //        baseflow_Model.setEndDate(args[7]);       //End date of analysis
 
         //Run model
-        baseflow_Model.run();
+        baseflow_Model.run(null);
     }
 }
\ No newline at end of file

src/java/m/cfa/Baseflow_V1_0.java

@@ -1,7 +1,10 @@
 package m.cfa;
 
 import cfa.guiBaseflow_Model;
+import csip.Executable;
 import csip.ModelDataService;
+import csip.annotations.Resource;
+import csip.annotations.Resources;
 import java.io.File;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
@@ -13,6 +16,9 @@
 @Description("baseflow")
 @VersionInfo("1.0")
 @Path("m/cfa/baseflow/1.0")
+@Resources({
+    @Resource(file="/bin/win-x86/bflow.exe", wine=true, id="bf")
+})
 public class Baseflow_V1_0 extends ModelDataService {
 
     guiBaseflow_Model model = new guiBaseflow_Model();
@@ -37,7 +43,8 @@
         model.setMergeMethod(getStringParam("merge_method"));
         model.setUserData(getStringParam("user_data"));
 
-        model.run();
+        Executable e = getResourceExe("bf");  // looking up the resource by id.
+        model.run(e);
         return EXEC_OK;
     }