git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/SeaDataNetConnector@120152 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7cb9b55c8f
commit
d38b737479
|
@ -85,6 +85,8 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm {
|
|||
Double latResolutionVal = null;
|
||||
Double depthLevelVal = null;
|
||||
AnalysisLogger.getLogger().debug("Checking parameters");
|
||||
//->try - catch to manage case of NULL values
|
||||
//->the check on the values has been put before the initialization of the connection
|
||||
try {
|
||||
// ANALYSIS
|
||||
correlationVal = Double.parseDouble(config.getParam("CorrelationLength"));
|
||||
|
@ -123,11 +125,11 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm {
|
|||
AnalysisLogger.getLogger().debug("Parameters are OK");
|
||||
AnalysisLogger.getLogger().debug("Initializing DB connection");
|
||||
dbconnection = DatabaseUtils.initDBSession(config);
|
||||
|
||||
//->set limit to 100 000 - maximum allowed by DIVA
|
||||
String query = "select "
|
||||
+ config.getParam("Longitude") + "," + config.getParam("Latitude") + "," + config.getParam("Quantity") + " From " + getInputParameter("InputTable") +
|
||||
" ORDER BY RANDOM() limit 100000";
|
||||
|
||||
//->indicate the status of the computation
|
||||
status = 10;
|
||||
AnalysisLogger.getLogger().debug("Query for extracting data from the DB: " + query);
|
||||
List<Object> dataList = DatabaseFactory.executeSQLQuery(query, dbconnection);
|
||||
|
@ -144,6 +146,7 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm {
|
|||
AnalysisLogger.getLogger().debug("Sending data to DIVA: Uploading "+ndata+" records");
|
||||
// integration DivaHttpClient
|
||||
// UPLOADFILE for DIVA
|
||||
//->use the HTTPClient Class methods
|
||||
DivaFilePostResponse response = DivaHTTPClient.uploadFile(fileForDiva);
|
||||
AnalysisLogger.getLogger().debug("DIVA Server Response for the Upload:\n" + response.getSessionid());
|
||||
status = 50;
|
||||
|
@ -151,6 +154,7 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm {
|
|||
long t0 = System.currentTimeMillis();
|
||||
DivaAnalysisGetResponse respAnalysis = DivaHTTPClient.getAnalysis(response.getSessionid(), correlationVal, signalNoiseVal, longMinVal, longMaxVal, longResolutionVal, latMinVal, latMaxVal, latResolutionVal, depthLevelVal);
|
||||
long t1 = System.currentTimeMillis();
|
||||
//->Record the time of the analysis
|
||||
AnalysisLogger.getLogger().debug("Analysis finished in "+(t1-t0)+" ms");
|
||||
status = 80;
|
||||
statResultMap.put("Minimum value estimated by the model", "" + respAnalysis.getVmin());
|
||||
|
@ -162,16 +166,18 @@ public class SeaDataNetConnector extends StandardLocalExternalAlgorithm {
|
|||
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
|
||||
//->put the output file in the output object
|
||||
outputfile=neofile;
|
||||
AnalysisLogger.getLogger().debug("Downloading finished");
|
||||
} catch (Exception e) {
|
||||
//->ONLY in case of errors, delete the output file
|
||||
if (neofile.exists()){
|
||||
neofile.delete();
|
||||
AnalysisLogger.getLogger().debug("Output file "+neofile.getAbsolutePath()+" deleted!");
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
//->in any case, delete the input file because we don't need it anymore
|
||||
if (fileForDiva.exists()){
|
||||
fileForDiva.delete();
|
||||
AnalysisLogger.getLogger().debug("Input file "+fileForDiva.getAbsolutePath()+" deleted!");
|
||||
|
|
Loading…
Reference in New Issue