From d33dfb854fad283a2c586ceecb35743dc508cae1 Mon Sep 17 00:00:00 2001 From: lucio Date: Mon, 9 Mar 2020 18:03:16 +0100 Subject: [PATCH] solved erros on occurences download --- .classpath | 40 ++++++++++++++++--- .settings/org.eclipse.jdt.core.prefs | 10 +++-- pom.xml | 15 +------ .../gbifplugin/search/OccurrenceSearch.java | 3 +- .../gbifplugin/search/query/MappingUtils.java | 7 +++- 5 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.classpath b/.classpath index 517bf32..002ad57 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,38 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 5d06b25..2f5cc74 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,8 @@ -#Tue Feb 14 11:06:25 CET 2012 eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index 8362ed5..3320972 100644 --- a/pom.xml +++ b/pom.xml @@ -5,13 +5,13 @@ maven-parent org.gcube.tools - 1.0.0 + 1.1.0 org.gcube.data.spd gbif-spd-plugin - 1.9.0-SNAPSHOT + 1.9.1-SNAPSHOT GBIFPlugin gbif plugin for species manager service @@ -45,17 +45,14 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} com.fasterxml.jackson.core jackson-annotations - ${jackson.version} com.fasterxml.jackson.core jackson-core - ${jackson.version} @@ -81,7 +78,6 @@ ch.qos.logback logback-classic - 1.0.13 test @@ -92,12 +88,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.1 - - 1.7 - 1.7 - 1.7 - org.apache.maven.plugins @@ -128,7 +118,6 @@ org.apache.maven.plugins maven-assembly-plugin - 2.2 ${distroDirectory}/descriptor.xml diff --git a/src/main/java/org/gcube/data/spd/gbifplugin/search/OccurrenceSearch.java b/src/main/java/org/gcube/data/spd/gbifplugin/search/OccurrenceSearch.java index 9ed9730..2d2de28 100644 --- a/src/main/java/org/gcube/data/spd/gbifplugin/search/OccurrenceSearch.java +++ b/src/main/java/org/gcube/data/spd/gbifplugin/search/OccurrenceSearch.java @@ -4,6 +4,7 @@ import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsCalen import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsDouble; import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsInteger; import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsString; +import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsLong; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -127,7 +128,7 @@ public class OccurrenceSearch { private OccurrencePoint retrieveElement(Map mappedObj) throws Exception{ long start = System.currentTimeMillis(); - String occurrenceId = getAsInteger(mappedObj, "key").toString(); + String occurrenceId = mappedObj.get("key").toString(); OccurrencePoint occurrence = new OccurrencePoint(occurrenceId); occurrence.setCollectionCode(getAsString(mappedObj, "collectionCode")); diff --git a/src/main/java/org/gcube/data/spd/gbifplugin/search/query/MappingUtils.java b/src/main/java/org/gcube/data/spd/gbifplugin/search/query/MappingUtils.java index bd3cdc9..d9941f8 100644 --- a/src/main/java/org/gcube/data/spd/gbifplugin/search/query/MappingUtils.java +++ b/src/main/java/org/gcube/data/spd/gbifplugin/search/query/MappingUtils.java @@ -65,6 +65,11 @@ public class MappingUtils { return (Integer) map.get(key); } + public static Long getAsLong(Map map, String key){ + if (!map.containsKey(key)) return 0l; + return (Long) map.get(key); + } + public static Calendar getAsCalendar(Map map, String key){ if (!map.containsKey(key)) return null; return parseCalendar((String) map.get(key)); @@ -73,7 +78,7 @@ public class MappingUtils { public static Calendar parseCalendar(String date){ try{ - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar= Calendar.getInstance(); calendar.setTime(df.parse(date)); return calendar;