diff --git a/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java b/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java index 3109c55..57f935a 100644 --- a/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java +++ b/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java @@ -2,18 +2,19 @@ package org.gcube.dataanalysis.seadatanet; public class DivaAnalysisGetResponse { - + String identifier; Double vmin; Double vmax; Double stat_obs_count_used; Double stat_posteriori_stn; - public DivaAnalysisGetResponse(Double vmin, + public DivaAnalysisGetResponse(String identifier, Double vmin, Double vmax, Double stat_obs_count_used, Double stat_posteriori_stn){ super(); + this.identifier=identifier; this.vmin=vmin; this.vmax=vmax; 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() { return vmax; @@ -50,7 +59,7 @@ public class DivaAnalysisGetResponse { @Override 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 + "]"; } diff --git a/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java b/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java index 3acfebc..c849b24 100644 --- a/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java +++ b/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java @@ -24,6 +24,8 @@ import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import com.ibm.icu.util.RangeValueIterator.Element; + public class DivaHTTPClient { 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+="dy="+dy+"&"; get_url+="level="+level+""; - System.out.println("GET URL="+get_url); + //System.out.println("GET URL="+get_url); URL url = new URL(get_url); httpUrlConnection = (HttpURLConnection) url.openConnection(); @@ -158,7 +160,8 @@ public class DivaHTTPClient { //System.out.println("RESPONSE STRING: "+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 vmax = Double.parseDouble(doc.getElementsByTagName("stat").item(1).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); //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) { throw new Exception(e); @@ -199,7 +202,8 @@ public class DivaHTTPClient { //Create Document object by XMLResponse Document doc = loadXMLFromString(result_xml); //Print XML Response - System.out.println( result_xml); + AnalysisLogger.getLogger().debug(result_xml); + Node root = doc.getDocumentElement(); 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 { - 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(response); 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"); + } diff --git a/src/org/gcube/dataanalysis/seadatanet/Downloader.java b/src/org/gcube/dataanalysis/seadatanet/Downloader.java index 00849ca..3df97dc 100644 --- a/src/org/gcube/dataanalysis/seadatanet/Downloader.java +++ b/src/org/gcube/dataanalysis/seadatanet/Downloader.java @@ -34,6 +34,9 @@ public class Downloader { out.close(); } + /** + * + */ public static void main(String args[]) throws Exception{ downloadFile("https://dl.dropboxusercontent.com/u/12809149/2_Reviewed.jpg","test.jpg"); }