From df44db686a8b53e2769167e6329d0f4b9d605cbf Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Thu, 28 May 2020 10:07:00 +0200 Subject: [PATCH] refactoring --- .../project/PrepareProjects.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProjects.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProjects.java index df37f9286..7ca50b219 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProjects.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/PrepareProjects.java @@ -3,10 +3,7 @@ package eu.dnetlib.dhp.actionmanager.project; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; +import java.util.*; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -81,17 +78,14 @@ public class PrepareProjects { .flatMap(p -> { List csvProjectList = new ArrayList<>(); String[] programme = p.getProgramme().split(";"); - if (programme.length > 1) { - String id = p.getId(); - for (int i = 0; i < programme.length; i++) { + Arrays + .stream(programme) + .forEach(value -> { CSVProject csvProject = new CSVProject(); - csvProject.setProgramme(programme[i]); - csvProject.setId(id); + csvProject.setProgramme(value); + csvProject.setId(p.getId()); csvProjectList.add(csvProject); - } - } else { - csvProjectList.add(p); - } + }); return csvProjectList.iterator(); })