1
0
Fork 0

refactoring

This commit is contained in:
Miriam Baglioni 2020-05-28 10:07:00 +02:00
parent 87b07f4af8
commit df44db686a
1 changed files with 7 additions and 13 deletions

View File

@ -3,10 +3,7 @@ package eu.dnetlib.dhp.actionmanager.project;
import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession; import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -81,17 +78,14 @@ public class PrepareProjects {
.flatMap(p -> { .flatMap(p -> {
List<CSVProject> csvProjectList = new ArrayList<>(); List<CSVProject> csvProjectList = new ArrayList<>();
String[] programme = p.getProgramme().split(";"); String[] programme = p.getProgramme().split(";");
if (programme.length > 1) { Arrays
String id = p.getId(); .stream(programme)
for (int i = 0; i < programme.length; i++) { .forEach(value -> {
CSVProject csvProject = new CSVProject(); CSVProject csvProject = new CSVProject();
csvProject.setProgramme(programme[i]); csvProject.setProgramme(value);
csvProject.setId(id); csvProject.setId(p.getId());
csvProjectList.add(csvProject); csvProjectList.add(csvProject);
} });
} else {
csvProjectList.add(p);
}
return csvProjectList.iterator(); return csvProjectList.iterator();
}) })