From 515fcf41b36496d33f9c8c034454137724add18a Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Wed, 26 Sep 2012 16:44:26 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngine@59093 82a268e6-3cf1-43bd-a215-b396298e98cf --- deployDesktop.jardesc | 16 ++++++++++++ .../test/checks/TestTransducers.java | 20 +++++++++------ .../latimeria/ExperimentsForLatimeria.java | 17 +++++++++---- .../OccurrencePointsDuplicatesDeleter.java | 1 + .../transducers/OccurrencePointsMerger.java | 25 +++++++++++++------ 5 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 deployDesktop.jardesc diff --git a/deployDesktop.jardesc b/deployDesktop.jardesc new file mode 100644 index 0000000..17c4cf9 --- /dev/null +++ b/deployDesktop.jardesc @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestTransducers.java b/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestTransducers.java index b82e6dd..71c66ce 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestTransducers.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/test/checks/TestTransducers.java @@ -36,21 +36,23 @@ public static void main(String[] args) throws Exception { trans = null; */ + /* trans = TransducerersFactory.getTransducerers(testConfigLocal8()); trans.get(0).init(); Regressor.process(trans.get(0)); trans = null; - /* + trans = TransducerersFactory.getTransducerers(testConfigLocal6()); trans.get(0).init(); Regressor.process(trans.get(0)); trans = null; - + */ + trans = TransducerersFactory.getTransducerers(testConfigLocal7()); trans.get(0).init(); Regressor.process(trans.get(0)); trans = null; - */ + } @@ -148,11 +150,15 @@ public static void main(String[] args) throws Exception { config.setParam("scientificNameColumn", "scientificname"); config.setParam("eventDateColumn", "eventdate"); config.setParam("lastModificationColumn", "modified"); - config.setParam("OccurrencePointsTableName", "occurrencetestduplicates"); + config.setParam("OccurrencePointsTableName", "occurrence_species_id5397d3c4_a7eb_4227_adb4_d9d7d36e8b21"); config.setParam("finalTableName", "occurrencesnoduplicates"); - config.setParam("spatialTolerance", "20"); - config.setParam("confidence", "60"); - + config.setParam("spatialTolerance", "0.5"); + config.setParam("confidence", "80"); + config.setParam("DatabaseUserName","utente"); + config.setParam("DatabasePassword","d4science"); + config.setParam("DatabaseURL","jdbc:postgresql://dbtest.next.research-infrastructures.eu/testdb"); + config.setParam("DatabaseDriver","org.postgresql.Driver"); + return config; } diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/test/experiments/latimeria/ExperimentsForLatimeria.java b/src/main/java/org/gcube/dataanalysis/ecoengine/test/experiments/latimeria/ExperimentsForLatimeria.java index 1448f40..f95c64d 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/test/experiments/latimeria/ExperimentsForLatimeria.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/test/experiments/latimeria/ExperimentsForLatimeria.java @@ -23,6 +23,7 @@ public class ExperimentsForLatimeria { static String absenceRandomTable = "absence_data_latimeria_random"; static String absenceStaticTable = "absence_data_latimeria"; static String presenceTable = "presence_data_latimeria"; + static String presenceTableNoEarth = "presence_data_latimeria_sea"; static String envelopeTable = "hspen_latimeria"; static String aquamapsSuitableTable = "hspec_suitable_latimeria_chalumnae"; @@ -215,7 +216,7 @@ public class ExperimentsForLatimeria { trans = null; } - public static void calcHRS(String hcaf,String absenceTable) throws Exception{ + public static void calcHRS(String hcaf,String absenceTable,String presenceTable) throws Exception{ System.out.println("*****************************HRS: "+absenceTable+","+presenceTable+" vs "+hcaf+"************************************"); List evaluators = null; evaluators = EvaluatorsFactory.getEvaluators(PresetConfigGenerator.configHRSAnalysis(filteredhcaf, absenceTable, presenceTable)); @@ -263,7 +264,7 @@ public class ExperimentsForLatimeria { //filter the hcaf on Indonesia - calcHRS(filteredhcaf,absenceStaticTable); +// calcHRS(filteredhcaf,absenceStaticTable); // calcHRS(filteredhcaf,absenceRandomTable); } @@ -285,6 +286,10 @@ public class ExperimentsForLatimeria { // generateAquamapsNativeSuitableNeuralNetwokrs(); //Analysis + calcdiscrepancy(aquamapsSuitableTable, nnsuitableTable); + calcdiscrepancy(aquamapsNativeTable, nnnativeTable); + + /* calcdiscrepancy(aquamapsSuitableTable, nnsuitableTable); calcdiscrepancy(aquamapsNativeTable, nnnativeTable); @@ -292,12 +297,14 @@ public class ExperimentsForLatimeria { calcquality(aquamapsSuitableTable, presenceTable, absenceStaticTable); calcquality(nnsuitableTable, presenceTable, absenceStaticTable); - calcHRS(filteredhcaf,absenceStaticTable); - calcHRS(filteredhcaf,null); - */ calcquality(aquamapsNativeTable, presenceTable, absenceStaticTable); calcquality(nnnativeTable, presenceTable, absenceStaticTable); + calcHRS(filteredhcaf,absenceStaticTable,presenceTableNoEarth); + calcHRS(filteredhcaf,null,presenceTableNoEarth); + */ + + } } diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsDuplicatesDeleter.java b/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsDuplicatesDeleter.java index 194f7f7..cf35f33 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsDuplicatesDeleter.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsDuplicatesDeleter.java @@ -176,6 +176,7 @@ public class OccurrencePointsDuplicatesDeleter extends OccurrencePointsMerger{ persist(); // close DB connection } catch (Exception e) { + AnalysisLogger.getLogger().trace("An error occurred "+e.getLocalizedMessage()); throw e; } finally { if (dbconnection != null) diff --git a/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsMerger.java b/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsMerger.java index 5177fad..887b52c 100644 --- a/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsMerger.java +++ b/src/main/java/org/gcube/dataanalysis/ecoengine/transducers/OccurrencePointsMerger.java @@ -146,33 +146,44 @@ public class OccurrencePointsMerger implements Transducerer { for (Object name : columnsNames) { String name$ = "" + name; - String value$ = "''"; + String value$ = "NULL"; if (name$.equalsIgnoreCase(lonFld)) { value$ = "'" + record.x + "'"; } else if (name$.equalsIgnoreCase(latFld)) { value$ = "'" + record.y + "'"; } else if (name$.equalsIgnoreCase(recordedByFld)) { if (record.recordedby != null) - value$ = "'" + record.recordedby + "'"; + value$ = "'" + record.recordedby.replace("'", "") + "'"; } else if (name$.equalsIgnoreCase(scientificNameFld)) { if (record.scientificName != null) - value$ = "'" + record.scientificName + "'"; + value$ = "'" + record.scientificName.replace("'", "") + "'"; } else if (name$.equalsIgnoreCase(eventDatFld)) { if (record.eventdate != null) { - value$ = "'" + convert2conventionalFormat(record.eventdate) + "'"; + String dat = convert2conventionalFormat(record.eventdate); + if ((dat!=null)&&(dat.length()>0)) + value$ = "'" + convert2conventionalFormat(record.eventdate) + "'"; + else + value$ = "NULL"; // value$="'"+record.eventdate.getTimeInMillis()+"'"; } } else if (name$.equalsIgnoreCase(modifDatFld)) { if (record.modifdate != null) { - value$ = "'" + convert2conventionalFormat(record.modifdate) + "'"; + String dat = convert2conventionalFormat(record.modifdate) ; + if ((dat!=null)&&(dat.length()>0)) + value$ = "'" + convert2conventionalFormat(record.modifdate) + "'"; + else + value$ = "NULL"; // value$="'"+record.modifdate.getTimeInMillis()+"'"; } } else { if (record.otherValues != null) { - value$ = "'" + record.otherValues.get(k) + "'"; + value$ = "'" + record.otherValues.get(k).replace("'", "") + "'"; k++; } } + if (value$.equals("'null'")) + value$ = "NULL"; + buffer.append(value$); if (index < nNames - 1) { buffer.append(","); @@ -404,7 +415,7 @@ public class OccurrencePointsMerger implements Transducerer { } String updateQ = DatabaseUtils.insertFromBuffer(finalTableName, columns.toString(), buffer); -// System.out.println("Update:\n"+updateQ); + System.out.println("Update:\n"+updateQ); AnalysisLogger.getLogger().debug("Update:\n"+updateQ); DatabaseFactory.executeSQLUpdate(updateQ, dbconnection); AnalysisLogger.getLogger().debug("Objects inserted");