solved erros on occurences download

This commit is contained in:
lucio 2020-03-09 18:03:16 +01:00
parent 6bab244632
commit d33dfb854f
5 changed files with 50 additions and 25 deletions

View File

@ -1,10 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/> <classpathentry kind="src" output="target/classes" path="src/main/java">
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> <attributes>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <attribute name="optional" value="true"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/> <attribute name="maven.pomderived" value="true"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> </attributes>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -1,6 +1,8 @@
#Tue Feb 14 11:06:25 CET 2012
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.6 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.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

15
pom.xml
View File

@ -5,13 +5,13 @@
<parent> <parent>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<version>1.0.0</version> <version>1.1.0</version>
<relativePath /> <relativePath />
</parent> </parent>
<groupId>org.gcube.data.spd</groupId> <groupId>org.gcube.data.spd</groupId>
<artifactId>gbif-spd-plugin</artifactId> <artifactId>gbif-spd-plugin</artifactId>
<version>1.9.0-SNAPSHOT</version> <version>1.9.1-SNAPSHOT</version>
<name>GBIFPlugin</name> <name>GBIFPlugin</name>
<description>gbif plugin for species manager service</description> <description>gbif plugin for species manager service</description>
@ -45,17 +45,14 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@ -81,7 +78,6 @@
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -92,12 +88,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -128,7 +118,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration> <configuration>
<descriptors> <descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor> <descriptor>${distroDirectory}/descriptor.xml</descriptor>

View File

@ -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.getAsDouble;
import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsInteger; 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.getAsString;
import static org.gcube.data.spd.gbifplugin.search.query.MappingUtils.getAsLong;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@ -127,7 +128,7 @@ public class OccurrenceSearch {
private OccurrencePoint retrieveElement(Map<String, Object> mappedObj) throws Exception{ private OccurrencePoint retrieveElement(Map<String, Object> mappedObj) throws Exception{
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
String occurrenceId = getAsInteger(mappedObj, "key").toString(); String occurrenceId = mappedObj.get("key").toString();
OccurrencePoint occurrence = new OccurrencePoint(occurrenceId); OccurrencePoint occurrence = new OccurrencePoint(occurrenceId);
occurrence.setCollectionCode(getAsString(mappedObj, "collectionCode")); occurrence.setCollectionCode(getAsString(mappedObj, "collectionCode"));

View File

@ -65,6 +65,11 @@ public class MappingUtils {
return (Integer) map.get(key); return (Integer) map.get(key);
} }
public static Long getAsLong(Map<String, Object> map, String key){
if (!map.containsKey(key)) return 0l;
return (Long) map.get(key);
}
public static Calendar getAsCalendar(Map<String, Object> map, String key){ public static Calendar getAsCalendar(Map<String, Object> map, String key){
if (!map.containsKey(key)) return null; if (!map.containsKey(key)) return null;
return parseCalendar((String) map.get(key)); return parseCalendar((String) map.get(key));
@ -73,7 +78,7 @@ public class MappingUtils {
public static Calendar parseCalendar(String date){ public static Calendar parseCalendar(String date){
try{ 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 calendar= Calendar.getInstance();
calendar.setTime(df.parse(date)); calendar.setTime(df.parse(date));
return calendar; return calendar;