From 34fa96f3b17b0ba2a7bbeaa97a2fa83b245b060a Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Mon, 24 Aug 2020 17:00:20 +0200 Subject: [PATCH] - --- .../dhp/oa/graph/dump/ResultMapper.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java index 1d20eb36a..9bb6653d0 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/ResultMapper.java @@ -5,14 +5,14 @@ import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; -import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityInstance; -import eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult; import org.apache.commons.lang3.StringUtils; import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.dump.oaf.*; +import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityInstance; import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult; import eu.dnetlib.dhp.schema.dump.oaf.community.Context; +import eu.dnetlib.dhp.schema.dump.oaf.graph.GraphResult; import eu.dnetlib.dhp.schema.oaf.DataInfo; import eu.dnetlib.dhp.schema.oaf.Field; import eu.dnetlib.dhp.schema.oaf.Journal; @@ -216,16 +216,17 @@ public class ResultMapper implements Serializable { out.setId(input.getId()); out.setOriginalId(input.getOriginalId()); - Optional> oInst = Optional - .ofNullable(input.getInstance()); + .ofNullable(input.getInstance()); - if(oInst.isPresent()){ - if (graph){ - ((GraphResult)out).setInstance(oInst.get().stream().map(i -> getGraphInstance(i)).collect(Collectors.toList())); - } - else{ - ((CommunityResult)out).setInstance(oInst.get().stream().map(i -> getCommunityInstance(i)).collect(Collectors.toList())); + if (oInst.isPresent()) { + if (graph) { + ((GraphResult) out) + .setInstance(oInst.get().stream().map(i -> getGraphInstance(i)).collect(Collectors.toList())); + } else { + ((CommunityResult) out) + .setInstance( + oInst.get().stream().map(i -> getCommunityInstance(i)).collect(Collectors.toList())); } } @@ -369,7 +370,7 @@ public class ResultMapper implements Serializable { } - private static Instance getGraphInstance (eu.dnetlib.dhp.schema.oaf.Instance i){ + private static Instance getGraphInstance(eu.dnetlib.dhp.schema.oaf.Instance i) { Instance instance = new Instance(); setCommonValue(i, instance); @@ -378,28 +379,30 @@ public class ResultMapper implements Serializable { } - - private static CommunityInstance getCommunityInstance (eu.dnetlib.dhp.schema.oaf.Instance i){ + private static CommunityInstance getCommunityInstance(eu.dnetlib.dhp.schema.oaf.Instance i) { CommunityInstance instance = new CommunityInstance(); setCommonValue(i, instance); - instance.setCollectedfrom(KeyValue - .newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue())); - + instance + .setCollectedfrom( + KeyValue + .newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue())); instance - .setHostedby( - KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue())); + .setHostedby( + KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue())); return instance; } - - private static void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) {// I - // getInstance(eu.dnetlib.dhp.schema.oaf.Instance - // i, boolean graph) { + private static void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) {// + // I + // getInstance(eu.dnetlib.dhp.schema.oaf.Instance + // i, boolean graph) { Optional opAr = Optional .ofNullable(i.getAccessright()); if (opAr.isPresent()) { @@ -430,8 +433,6 @@ public class ResultMapper implements Serializable { .ifPresent(value -> instance.setType(value.getClassname())); Optional.ofNullable(i.getUrl()).ifPresent(value -> instance.setUrl(value)); - - } private static List getUniqueProvenance(List provenance) {