@@ -20,6 +20,7 @@ |
import java.text.NumberFormat; |
import java.util.*; |
import java.util.logging.Level; |
+import java.util.logging.Logger; |
import javax.ws.rs.Path; |
import man2weps.WepsTranslator; |
import man2weps.mcrew.ManageData; |
@@ -52,7 +53,6 @@ |
@Resource(type = EXECUTABLE, file = "/bin/${arch}/cligen.exe", id = CLIGEN) |
@Resource(type = FILE, file = "/data/upd_US_cligen_stations.par", id = STATION_PAR) |
|
- |
// windgen |
@Resource(type = EXECUTABLE, file = "/bin/win-x86/wind_gen4.exe", wine = true, id = WINDGEN) |
@Resource(type = EXECUTABLE, file = "/bin/${arch}/interpolate.exe", id = INTERPOLATE) |
@@ -112,9 +112,10 @@ |
public void preProcess() throws Exception { |
|
// required parameter - at least one of these must exist! |
- if (!(JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL)) && |
- !(JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL_FILE))) |
+ if (!(JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL)) |
+ && !(JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL_FILE))) { |
throw new ServiceException("No Value for " + WEPS_KEY_SOIL + " and " + WEPS_KEY_SOIL_FILE + ". At least one is required."); |
+ } |
|
// At least one of the two soil params must be populated |
// This version is used by IET |
@@ -215,7 +216,29 @@ |
// Z50 is required with calibration flag |
exe.addArguments("-C15", "-Z50"); |
} |
+ |
stdout = exe.stdout(); |
+ |
+ boolean handleProgress = Config.getBoolean("weps.progress", false); |
+ if (handleProgress) { |
+ exe.setStdoutHandler(new Executable.StdHandler() { |
+ @Override |
+ public void handle(String out) { |
+ if (out == null) |
+ return; |
+ int idx = out.lastIndexOf("Year"); |
+ if (idx > -1) { |
+ try { |
+ String a = out.substring(idx, out.indexOf('\n', idx)); |
+ setProgress(a); |
+ } catch (ServiceException ex) { |
+ System.out.println("Error setting progress info."); |
+ } |
+ } |
+ } |
+ }); |
+ } |
+ |
int result = exe.exec(); |
if (result != 0) { |
throw new ServiceException("WEPS exit error :" + result); |
@@ -242,10 +265,7 @@ |
// putResult(new File(getWorkspaceDir(), WEPS_EXE + "-stdout.txt")); |
// putResult(new File(getWorkspaceDir(), WEPS_EXE + "-stderr.txt")); |
// } |
- |
///////////////////////////////////////////////////////////////////////////// |
- |
- |
/* |
*/ |
private String loadWepsMgmt() throws ServiceException { |
@@ -549,7 +569,6 @@ |
// pcInterpolate.exe = "./interpolate.sh"; |
// pcInterpolate.args = new String[]{}; |
// pcInterpolate.execute(); |
- |
String dbpath = getResourceFile(WINDGEN_IDX).toString(); |
String polygon = getResourceFile(BOUNDARY_POL).toString(); |
|
@@ -914,7 +933,7 @@ |
// Load the file data. |
LOG.info("WorkingDir: " + getWorkspaceDir().toString()); |
//reportdata.loadFiles(getWorkspaceDir().toString()); |
- reportdata.loadFiles(getWorkspaceDir().toString(),stdout.getName()); |
+ reportdata.loadFiles(getWorkspaceDir().toString(), stdout.getName()); |
|
// // Dump the loaded data as text for debugging purposes. |
// LOG.info("hash map output=" + con.toString()); |
@@ -927,7 +946,7 @@ |
//LOG.info("COMPARISON for scalars: itemname='" + itemName + "'"); |
//if (itemName.length() >= 5) LOG.info("COMPARISON for scalars: itemname 0,5='" + itemName.substring(0,5) + "'"); |
//if (itemName.length() >= 11) LOG.info("COMPARISON for scalars: itemname 0,11='" + itemName.substring(0,11) + "'"); |
- LOG.info("Trying report value: "+ itemName); |
+ LOG.info("Trying report value: " + itemName); |
if ((itemName != null) && ((((itemName.length()) >= 5) && (itemName.substring(0, 5).contentEquals("runs."))) |
|| (((itemName.length()) >= 11) && (itemName.substring(0, 11).contentEquals("sci_energy."))))) { |
// Scalar values |
@@ -935,7 +954,7 @@ |
ArrayList<Object> scalar = m_reportdata.get(itemName); |
if (scalar != null) { |
//LOG.info("putting to jsonobj=" + scalar.get(0)); |
- LOG.info("Scalar value: "+ scalar.get(0)); |
+ LOG.info("Scalar value: " + scalar.get(0)); |
obj.put(REPORT_VALUE, scalar.get(0)); |
reportItems.put(i, obj); |
} else { |
@@ -1001,7 +1020,7 @@ |
LOG.info("WorkingDir: " + getWorkspaceDir().toString()); |
|
//reportdata.loadFiles(getWorkspaceDir().toString()); |
- reportdata.loadFiles(getWorkspaceDir().toString(),stdout.getName()); |
+ reportdata.loadFiles(getWorkspaceDir().toString(), stdout.getName()); |
|
// // Dump the loaded data as text for debugging purposes. |
// LOG.info("hash map output=" + con.toString()); |