This commit is contained in:
Gianpaolo Coro 2015-10-22 09:48:29 +00:00
parent 25da959635
commit 999db66eeb
2 changed files with 26 additions and 4 deletions

View File

@ -2,8 +2,7 @@ package org.gcube.dataanalysis.seadatanet;
public class DivaAnalysisGetResponse {
public DivaAnalysisGetResponse(String id,double len,double stn,
double x0,double x1, double dx,double y0,double y1,double dy,int level) {
public DivaAnalysisGetResponse(String) {
super();
this.x0 = x0;
this.x1 = x1;

View File

@ -2,6 +2,7 @@ package org.gcube.dataanalysis.seadatanet;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
@ -113,6 +114,7 @@ public class DivaHTTPClient {
*/
public static String getAnalysis (String id,double len,double stn,double x0,double x1, double dx,double y0,double y1,double dy,double level) throws Exception {
HttpURLConnection httpUrlConnection = null;
try {
String get_url=WEB_HTTP+"/make_analysis?";
get_url+="sessionid="+id+"&";
@ -142,8 +144,12 @@ public class DivaHTTPClient {
new BufferedReader(new InputStreamReader(responseStream));
String line = "";
//DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
StringBuilder stringBuilder = new StringBuilder();
//ByteArrayInputStream input;
//DocumentBuilder builder = factory.newDocumentBuilder();
while ((line = responseStreamReader.readLine()) != null) {
stringBuilder.append(line).append("\n");
}
@ -153,10 +159,25 @@ public class DivaHTTPClient {
String response = stringBuilder.toString();
//input = new ByteArrayInputStream(stringBuilder.toString().getBytes("UTF-8"));
System.out.println("RESPONSE STRING: "+response);
Document doc = loadXMLFromString(response);
System.out.println("DENTRO: "+ doc.getFirstChild());
//Node root = doc.getDocumentElement();
System.out.println("ELEMENTBYTAG: "+doc.getElementsByTagName("stat").item(0).getTextContent());
//System.out.println("ROOT: "+root.getTextContent());
//System.out.println("INSIDE: "+ root.getChildNodes().item(2).getTextContent());
//System.out.println("BYID: "+doc.getElementById("vmin").getNodeValue());
//System.out.println("BYID: "+doc.getChildNodes().item(2));
Double vmin = Double.parseDouble(doc.getElementsByTagName("stat").item(0).getTextContent());
Double vmax = Double.parseDouble(doc.getElementsByTagName("stat").item(1).getTextContent());
Double stat_obs_count_used = Double.parseDouble(doc.getElementsByTagName("stat").item(2).getTextContent());
Double stat_posteriori_stn = Double.parseDouble(doc.getElementsByTagName("stat").item(3).getTextContent());
responseStream.close();
httpUrlConnection.disconnect();
@ -169,6 +190,8 @@ public class DivaHTTPClient {
if (httpUrlConnection != null)
httpUrlConnection.disconnect();
}
return new DivaAnalysisGetResponse(vmin, vmax, stat_obs_count_used, stat_posteriori_stn, sessionid);
}