git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/SeaDataNetConnector@120014 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6e6b0359e2
commit
34a770c4e9
|
@ -2,18 +2,19 @@ package org.gcube.dataanalysis.seadatanet;
|
||||||
|
|
||||||
public class DivaAnalysisGetResponse {
|
public class DivaAnalysisGetResponse {
|
||||||
|
|
||||||
|
String identifier;
|
||||||
Double vmin;
|
Double vmin;
|
||||||
Double vmax;
|
Double vmax;
|
||||||
Double stat_obs_count_used;
|
Double stat_obs_count_used;
|
||||||
Double stat_posteriori_stn;
|
Double stat_posteriori_stn;
|
||||||
|
|
||||||
public DivaAnalysisGetResponse(Double vmin,
|
public DivaAnalysisGetResponse(String identifier, Double vmin,
|
||||||
Double vmax,
|
Double vmax,
|
||||||
Double stat_obs_count_used,
|
Double stat_obs_count_used,
|
||||||
Double stat_posteriori_stn){
|
Double stat_posteriori_stn){
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
this.identifier=identifier;
|
||||||
this.vmin=vmin;
|
this.vmin=vmin;
|
||||||
this.vmax=vmax;
|
this.vmax=vmax;
|
||||||
this.stat_obs_count_used=stat_obs_count_used;
|
this.stat_obs_count_used=stat_obs_count_used;
|
||||||
|
@ -23,6 +24,14 @@ public class DivaAnalysisGetResponse {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getIdentifier() {
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentifier(String id) {
|
||||||
|
this.identifier = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getVmax() {
|
public Double getVmax() {
|
||||||
return vmax;
|
return vmax;
|
||||||
|
@ -50,7 +59,7 @@ public class DivaAnalysisGetResponse {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DivaFilePostResponse [VMAX=" + vmax + ", VMIN="
|
return "DivaFilePostResponse [ IDFILE="+ identifier +", VMAX=" + vmax + ", VMIN="
|
||||||
+ vmin + ", STAT_OBS_COUNT_USED=" + stat_obs_count_used + ", STAT_POSTERIORI_STN=" + stat_posteriori_stn
|
+ vmin + ", STAT_OBS_COUNT_USED=" + stat_obs_count_used + ", STAT_POSTERIORI_STN=" + stat_posteriori_stn
|
||||||
+ "]";
|
+ "]";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.w3c.dom.Node;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.ibm.icu.util.RangeValueIterator.Element;
|
||||||
|
|
||||||
public class DivaHTTPClient {
|
public class DivaHTTPClient {
|
||||||
|
|
||||||
public static String WEB_HTTP="http://gher-diva.phys.ulg.ac.be/web-vis/Python/web";
|
public static String WEB_HTTP="http://gher-diva.phys.ulg.ac.be/web-vis/Python/web";
|
||||||
|
@ -127,7 +129,7 @@ public class DivaHTTPClient {
|
||||||
get_url+="y1="+y1+"&";
|
get_url+="y1="+y1+"&";
|
||||||
get_url+="dy="+dy+"&";
|
get_url+="dy="+dy+"&";
|
||||||
get_url+="level="+level+"";
|
get_url+="level="+level+"";
|
||||||
System.out.println("GET URL="+get_url);
|
//System.out.println("GET URL="+get_url);
|
||||||
URL url = new URL(get_url);
|
URL url = new URL(get_url);
|
||||||
|
|
||||||
httpUrlConnection = (HttpURLConnection) url.openConnection();
|
httpUrlConnection = (HttpURLConnection) url.openConnection();
|
||||||
|
@ -158,7 +160,8 @@ public class DivaHTTPClient {
|
||||||
//System.out.println("RESPONSE STRING: "+response);
|
//System.out.println("RESPONSE STRING: "+response);
|
||||||
|
|
||||||
Document doc = loadXMLFromString(response);
|
Document doc = loadXMLFromString(response);
|
||||||
|
Node idNode = doc.getElementsByTagName("result").item(0);
|
||||||
|
String identifier = idNode.getAttributes().item(0).getNodeValue();
|
||||||
Double vmin = Double.parseDouble(doc.getElementsByTagName("stat").item(0).getTextContent());
|
Double vmin = Double.parseDouble(doc.getElementsByTagName("stat").item(0).getTextContent());
|
||||||
Double vmax = Double.parseDouble(doc.getElementsByTagName("stat").item(1).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_obs_count_used = Double.parseDouble(doc.getElementsByTagName("stat").item(2).getTextContent());
|
||||||
|
@ -169,7 +172,7 @@ public class DivaHTTPClient {
|
||||||
AnalysisLogger.getLogger().debug("Response "+response);
|
AnalysisLogger.getLogger().debug("Response "+response);
|
||||||
//return response;
|
//return response;
|
||||||
|
|
||||||
return new DivaAnalysisGetResponse(vmin, vmax, stat_obs_count_used, stat_posteriori_stn);
|
return new DivaAnalysisGetResponse(identifier, vmin, vmax, stat_obs_count_used, stat_posteriori_stn);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Exception(e);
|
throw new Exception(e);
|
||||||
|
@ -199,7 +202,8 @@ public class DivaHTTPClient {
|
||||||
//Create Document object by XMLResponse
|
//Create Document object by XMLResponse
|
||||||
Document doc = loadXMLFromString(result_xml);
|
Document doc = loadXMLFromString(result_xml);
|
||||||
//Print XML Response
|
//Print XML Response
|
||||||
System.out.println( result_xml);
|
AnalysisLogger.getLogger().debug(result_xml);
|
||||||
|
|
||||||
|
|
||||||
Node root = doc.getDocumentElement();
|
Node root = doc.getDocumentElement();
|
||||||
if(root== null) throw new SAXException("Error in HTTP response no root element found!");
|
if(root== null) throw new SAXException("Error in HTTP response no root element found!");
|
||||||
|
@ -223,11 +227,22 @@ public class DivaHTTPClient {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
DivaFilePostResponse response=uploadFile(new File("C:"+File.separator+"Users"+File.separator+"marbas"+File.separator+"Desktop"+File.separator+"temperature_argo.txt"));
|
DivaFilePostResponse response=uploadFile(new File("resources"+File.separator+"files"+File.separator+"temperature_argo.txt"));
|
||||||
|
|
||||||
//System.out.println(getAnalysis(response.getSessionid(),5,4,76,78,1,35,78,1,2));
|
//System.out.println(getAnalysis(response.getSessionid(),5,4,76,78,1,35,78,1,2));
|
||||||
//System.out.println(response);
|
//System.out.println(response);
|
||||||
DivaAnalysisGetResponse respAnalysis = getAnalysis(response.getSessionid(),5, 4, 76, 78, 1, 35, 78, 1, 2);
|
DivaAnalysisGetResponse respAnalysis = getAnalysis(response.getSessionid(),5, 4, 76, 78, 1, 35, 78, 1, 2);
|
||||||
|
System.out.println("Response: "+respAnalysis.toString());
|
||||||
|
|
||||||
|
|
||||||
|
Downloader downFileNC = new Downloader();
|
||||||
|
//System.out.println(System.getProperty("user.dir")+File.separator+"temp.nc");
|
||||||
|
File f=new File(System.getProperty("user.dir")+File.separator+"temp.nc");
|
||||||
|
|
||||||
|
if(!f.exists()) f.createNewFile();
|
||||||
|
downFileNC.downloadFile(WEB_HTTP+"/download?fieldname="+
|
||||||
|
respAnalysis.getIdentifier(),System.getProperty("user.dir")+File.separator+"temp.nc");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,9 @@ public class Downloader {
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public static void main(String args[]) throws Exception{
|
public static void main(String args[]) throws Exception{
|
||||||
downloadFile("https://dl.dropboxusercontent.com/u/12809149/2_Reviewed.jpg","test.jpg");
|
downloadFile("https://dl.dropboxusercontent.com/u/12809149/2_Reviewed.jpg","test.jpg");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue