git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/SeaDataNetConnector@119956 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
25da959635
commit
999db66eeb
|
@ -2,8 +2,7 @@ package org.gcube.dataanalysis.seadatanet;
|
||||||
|
|
||||||
public class DivaAnalysisGetResponse {
|
public class DivaAnalysisGetResponse {
|
||||||
|
|
||||||
public DivaAnalysisGetResponse(String id,double len,double stn,
|
public DivaAnalysisGetResponse(String) {
|
||||||
double x0,double x1, double dx,double y0,double y1,double dy,int level) {
|
|
||||||
super();
|
super();
|
||||||
this.x0 = x0;
|
this.x0 = x0;
|
||||||
this.x1 = x1;
|
this.x1 = x1;
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.dataanalysis.seadatanet;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
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 {
|
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;
|
HttpURLConnection httpUrlConnection = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String get_url=WEB_HTTP+"/make_analysis?";
|
String get_url=WEB_HTTP+"/make_analysis?";
|
||||||
get_url+="sessionid="+id+"&";
|
get_url+="sessionid="+id+"&";
|
||||||
|
@ -142,8 +144,12 @@ public class DivaHTTPClient {
|
||||||
new BufferedReader(new InputStreamReader(responseStream));
|
new BufferedReader(new InputStreamReader(responseStream));
|
||||||
|
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|
||||||
|
//DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
//ByteArrayInputStream input;
|
||||||
|
//DocumentBuilder builder = factory.newDocumentBuilder();
|
||||||
|
|
||||||
while ((line = responseStreamReader.readLine()) != null) {
|
while ((line = responseStreamReader.readLine()) != null) {
|
||||||
stringBuilder.append(line).append("\n");
|
stringBuilder.append(line).append("\n");
|
||||||
}
|
}
|
||||||
|
@ -153,10 +159,25 @@ public class DivaHTTPClient {
|
||||||
|
|
||||||
String response = stringBuilder.toString();
|
String response = stringBuilder.toString();
|
||||||
|
|
||||||
|
//input = new ByteArrayInputStream(stringBuilder.toString().getBytes("UTF-8"));
|
||||||
|
|
||||||
|
System.out.println("RESPONSE STRING: "+response);
|
||||||
|
|
||||||
Document doc = loadXMLFromString(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();
|
responseStream.close();
|
||||||
httpUrlConnection.disconnect();
|
httpUrlConnection.disconnect();
|
||||||
|
@ -169,6 +190,8 @@ public class DivaHTTPClient {
|
||||||
if (httpUrlConnection != null)
|
if (httpUrlConnection != null)
|
||||||
httpUrlConnection.disconnect();
|
httpUrlConnection.disconnect();
|
||||||
}
|
}
|
||||||
|
return new DivaAnalysisGetResponse(vmin, vmax, stat_obs_count_used, stat_posteriori_stn, sessionid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue