From 7cb9b55c8f4bcfb1b65f77a2749fa21108c56cdf Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Sun, 1 Nov 2015 19:44:36 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/SeaDataNetConnector@120151 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../seadatanet/DivaAnalysisGetResponse.java | 8 ++++---- .../dataanalysis/seadatanet/DivaHTTPClient.java | 2 +- .../seadatanet/SeaDataNetConnector.java | 16 ++++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java b/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java index edfc496..16e843f 100644 --- a/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java +++ b/src/org/gcube/dataanalysis/seadatanet/DivaAnalysisGetResponse.java @@ -5,12 +5,12 @@ public class DivaAnalysisGetResponse { String identifier; Double vmin; Double vmax; - Double stat_obs_count_used; + Integer stat_obs_count_used; Double stat_posteriori_stn; public DivaAnalysisGetResponse(String identifier, Double vmin, Double vmax, - Double stat_obs_count_used, + Integer stat_obs_count_used, Double stat_posteriori_stn){ super(); @@ -48,11 +48,11 @@ public class DivaAnalysisGetResponse { this.vmax = vmax; } - public Double getStat_obs_count_used() { + public Integer getStat_obs_count_used() { return stat_obs_count_used; } - public void setStat_obs_count_used(Double stat_obs_count_used) { + public void setStat_obs_count_used(Integer stat_obs_count_used) { this.stat_obs_count_used = stat_obs_count_used; } diff --git a/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java b/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java index f2ebb0d..63e9fe6 100644 --- a/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java +++ b/src/org/gcube/dataanalysis/seadatanet/DivaHTTPClient.java @@ -166,7 +166,7 @@ public class DivaHTTPClient { 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()); + Integer stat_obs_count_used = Integer.parseInt(doc.getElementsByTagName("stat").item(2).getTextContent()); Double stat_posteriori_stn = Double.parseDouble(doc.getElementsByTagName("stat").item(3).getTextContent()); responseStream.close(); diff --git a/src/org/gcube/dataanalysis/seadatanet/SeaDataNetConnector.java b/src/org/gcube/dataanalysis/seadatanet/SeaDataNetConnector.java index 1fe7420..d97c7c6 100644 --- a/src/org/gcube/dataanalysis/seadatanet/SeaDataNetConnector.java +++ b/src/org/gcube/dataanalysis/seadatanet/SeaDataNetConnector.java @@ -127,7 +127,8 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm { String query = "select " + config.getParam("Longitude") + "," + config.getParam("Latitude") + "," + config.getParam("Quantity") + " From " + getInputParameter("InputTable") + " ORDER BY RANDOM() limit 100000"; - + + status = 10; AnalysisLogger.getLogger().debug("Query for extracting data from the DB: " + query); List dataList = DatabaseFactory.executeSQLQuery(query, dbconnection); int ndata = dataList.size(); @@ -145,22 +146,24 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm { // UPLOADFILE for DIVA DivaFilePostResponse response = DivaHTTPClient.uploadFile(fileForDiva); AnalysisLogger.getLogger().debug("DIVA Server Response for the Upload:\n" + response.getSessionid()); - + status = 50; AnalysisLogger.getLogger().debug("Requesting analysis to DIVA..."); long t0 = System.currentTimeMillis(); DivaAnalysisGetResponse respAnalysis = DivaHTTPClient.getAnalysis(response.getSessionid(), correlationVal, signalNoiseVal, longMinVal, longMaxVal, longResolutionVal, latMinVal, latMaxVal, latResolutionVal, depthLevelVal); long t1 = System.currentTimeMillis(); AnalysisLogger.getLogger().debug("Analysis finished in "+(t1-t0)+" ms"); - - statResultMap.put("Minimum value of the analysis", "" + respAnalysis.getVmin()); - statResultMap.put("Maximum value of the analysis", "" + respAnalysis.getVmax()); + status = 80; + statResultMap.put("Minimum value estimated by the model", "" + respAnalysis.getVmin()); + statResultMap.put("Maximum value estimated by the model", "" + respAnalysis.getVmax()); statResultMap.put("Number of observations used", "" + respAnalysis.getStat_obs_count_used()); - statResultMap.put("Posterior probability of the model", "" + respAnalysis.getStat_posteriori_stn()); + statResultMap.put("A posteriori estimate of signal-to-noise ratio", "" + respAnalysis.getStat_posteriori_stn()); AnalysisLogger.getLogger().debug("Map of results to be returned: "+statResultMap); AnalysisLogger.getLogger().debug("Downloading result file in "+neofile.getAbsolutePath()); // DOWNLOAD FILE DivaHTTPClient.downloadFileDiva(respAnalysis.getIdentifier(), neofile.getAbsolutePath()); + //put the output file in the output object + outputfile=neofile; AnalysisLogger.getLogger().debug("Downloading finished"); } catch (Exception e) { if (neofile.exists()){ @@ -173,6 +176,7 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm { fileForDiva.delete(); AnalysisLogger.getLogger().debug("Input file "+fileForDiva.getAbsolutePath()+" deleted!"); } + AnalysisLogger.getLogger().debug("DIVA process finished"); } }