From da9d6f3887fb150efa5fe2c7e0c4fd4e19f870d4 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 11 May 2021 10:45:30 +0200 Subject: [PATCH] mapping datasource.journal only when an issn is available, null otherwhise --- .../dnetlib/dhp/schema/oaf/OafMapperUtils.java | 18 ++++++++++++------ .../raw/MigrateDbEntitiesApplication.java | 11 ----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/OafMapperUtils.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/OafMapperUtils.java index 4a66f91dc..19be8b9e4 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/OafMapperUtils.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/OafMapperUtils.java @@ -13,6 +13,8 @@ import java.util.stream.Collectors; import org.apache.commons.lang3.StringUtils; +import com.google.common.base.Joiner; + import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.utils.DHPUtils; @@ -183,7 +185,8 @@ public class OafMapperUtils { final String issnOnline, final String issnLinking, final DataInfo dataInfo) { - return journal( + + return hasIssn(issnPrinted, issnOnline, issnLinking) ? journal( name, issnPrinted, issnOnline, @@ -195,7 +198,7 @@ public class OafMapperUtils { null, null, null, - dataInfo); + dataInfo) : null; } public static Journal journal( @@ -212,10 +215,7 @@ public class OafMapperUtils { final String conferencedate, final DataInfo dataInfo) { - if (StringUtils.isNotBlank(name) - || StringUtils.isNotBlank(issnPrinted) - || StringUtils.isNotBlank(issnOnline) - || StringUtils.isNotBlank(issnLinking)) { + if (StringUtils.isNotBlank(name) || hasIssn(issnPrinted, issnOnline, issnLinking)) { final Journal j = new Journal(); j.setName(name); j.setIssnPrinted(issnPrinted); @@ -235,6 +235,12 @@ public class OafMapperUtils { } } + private static boolean hasIssn(String issnPrinted, String issnOnline, String issnLinking) { + return StringUtils.isNotBlank(issnPrinted) + || StringUtils.isNotBlank(issnOnline) + || StringUtils.isNotBlank(issnLinking); + } + public static DataInfo dataInfo( final Boolean deletedbyinference, final String inferenceprovenance, 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 3adbd244c..f14e966d1 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 @@ -586,17 +586,6 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i return res; } - private Journal prepareJournal(final ResultSet rs, final DataInfo info) throws SQLException { - if (Objects.isNull(rs)) { - return null; - } else { - - return journal( - rs.getString("officialname"), rs.getString("issnPrinted"), rs.getString("issnOnline"), - rs.getString("issnLinking"), info); - } - } - @Override public void close() throws IOException { super.close();