@@ -60,10 +60,12 @@ |
|
public final String workspace = workspace().getPath().toString(); |
|
+ |
public String getWorkspace() { |
return workspace; |
} |
|
+ |
@Override |
protected void doProcess() throws Exception { |
PayloadParameter inputParams = parameter(); |
@@ -132,26 +134,31 @@ |
private final String end; |
private final String weatherFileName; |
|
+ |
Years(int start, String weatherFileName) { |
this.weatherFileName = weatherFileName + String.valueOf(start).substring(2) + "01"; |
this.start = start + "-01-01"; |
this.end = start + "-12-31"; |
} |
|
+ |
public String getStart() { |
return start; |
} |
|
+ |
public String getEnd() { |
return end; |
} |
|
+ |
public String getFileName() { |
return weatherFileName; |
} |
|
} |
|
+ |
private String getSimulationType(String simulation_type, String paramFile) throws IOException { |
switch (simulation_type.toLowerCase()) { |
case "single": |
@@ -171,6 +178,7 @@ |
} |
} |
|
+ |
private void parseXfile(XfileIDs ids, String paramFile) throws IOException { |
String file; |
if (paramFile.matches("(.*).v[1-9][0-9]")) { |
@@ -181,6 +189,7 @@ |
getSoilWeatherFileIds(ids, file); |
} |
|
+ |
private String getFileX(String paramFile) throws IOException { |
BufferedReader bf = new BufferedReader(new FileReader(workspace().getFile(paramFile))); |
|
@@ -204,6 +213,7 @@ |
return namex; |
} |
|
+ |
private void getSoilWeatherFileIds(XfileIDs ids, String fileName) throws IOException, FileNotFoundException { |
BufferedReader bf = new BufferedReader(new FileReader(workspace().getFile(fileName))); |
String line; |
@@ -234,20 +244,24 @@ |
bf.close(); |
} |
|
+ |
@Override |
protected void postProcess() throws Exception { |
File zip = ZipFiles.zip(new File(workspace().getDir().getAbsolutePath())); |
results().put(zip); |
} |
|
+ |
public static void onContextInit() { |
System.out.println("Init simple service"); |
} |
|
+ |
public static void onContextDestroy() { |
System.out.println("destroy simple service"); |
} |
|
+ |
private void fetchClimate(String weatherFile_name, double longitude, double latitude, String start_date, String end_date) { |
|
ModelDataServiceCall res; |
@@ -277,6 +291,7 @@ |
} |
} |
|
+ |
private void fetchSoil(XfileIDs ids, double longitude, double latitude, String cokey) throws Exception { |
String soilFile_name = ids.getSolID().substring(0, 2); |
|
@@ -298,6 +313,7 @@ |
} |
} |
|
+ |
private File renameInputTemplate(String template) { |
String sourcePath = workspace().getFile(template).getAbsolutePath(); |
String destPath = workspace().getDir().getAbsolutePath() + "/" + TMP_DSSAT; |
@@ -323,6 +339,7 @@ |
return sourceTemplate; |
} |
|
+ |
private File createConfig(String template) throws IOException { |
VelocityEngine velocity = new VelocityEngine(); |
velocityInit(velocity); |
@@ -338,6 +355,7 @@ |
return filledTemplate; |
} |
|
+ |
public void velocityInit(VelocityEngine velocity) { |
velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, |
workspace().getDir().getAbsolutePath()); |
@@ -349,18 +367,22 @@ |
private String solID; |
private String wthID; |
|
+ |
public void setSolID(String solID) { |
this.solID = solID; |
} |
|
+ |
public void setWthID(String wthID) { |
this.wthID = wthID; |
} |
|
+ |
public String getSolID() { |
return solID; |
} |
|
+ |
public String getWthID() { |
return wthID; |
} |