From 05fafa14082fd7dbedc70c19505026a9fea60d72 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Wed, 6 Apr 2022 15:23:50 +0200 Subject: [PATCH] [graph raw] avoid NPEs importing datasource consent fields --- .../oa/graph/raw/MigrateDbEntitiesApplication.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java index 1f8c23ac36..b5801ca5c5 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/MigrateDbEntitiesApplication.java @@ -42,10 +42,7 @@ import java.io.IOException; import java.sql.Array; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; @@ -311,7 +308,13 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i ds.setContentpolicies(prepareListOfQualifiers(rs.getArray("contentpolicies"))); ds.setConsenttermsofuse(rs.getBoolean("consenttermsofuse")); ds.setFulltextdownload(rs.getBoolean("fulltextdownload")); - ds.setConsenttermsofusedate(rs.getDate("consenttermsofusedate").toString()); + ds + .setConsenttermsofusedate( + Optional + .ofNullable( + rs.getDate("consenttermsofusedate")) + .map(c -> c.toString()) + .orElse(null)); return Arrays.asList(ds); } catch (final Exception e) {