From 73dc082927a1bd2561bac10073c075a4575df690 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Thu, 5 Aug 2021 15:20:50 +0200 Subject: [PATCH] added new dumped field (openaccessroute, pid and alternate identifier at the level of the instance) and the bipFinder measure at the level of the result --- .../dhp/oa/graph/dump/ResultMapper.java | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 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 fe9b4e443..9f665c06d 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,6 +5,16 @@ import java.io.Serializable; import java.util.*; import java.util.stream.Collectors; +import eu.dnetlib.dhp.schema.dump.oaf.AccessRight; +import eu.dnetlib.dhp.schema.dump.oaf.Author; +import eu.dnetlib.dhp.schema.dump.oaf.Country; +import eu.dnetlib.dhp.schema.dump.oaf.GeoLocation; +import eu.dnetlib.dhp.schema.dump.oaf.Instance; +import eu.dnetlib.dhp.schema.dump.oaf.KeyValue; +import eu.dnetlib.dhp.schema.dump.oaf.OpenAccessRoute; +import eu.dnetlib.dhp.schema.dump.oaf.Qualifier; +import eu.dnetlib.dhp.schema.dump.oaf.Result; +import eu.dnetlib.dhp.schema.oaf.*; import org.apache.commons.lang3.StringUtils; import eu.dnetlib.dhp.schema.common.ModelConstants; @@ -13,10 +23,6 @@ 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; -import eu.dnetlib.dhp.schema.oaf.StructuredProperty; public class ResultMapper implements Serializable { @@ -130,6 +136,13 @@ public class ResultMapper implements Serializable { break; } + Optional> mes = Optional.ofNullable(input.getMeasures()); + if(mes.isPresent()){ + List measure = new ArrayList<>(); + mes.get().forEach(m -> m.getUnit().forEach(u -> measure.add(KeyValue.newInstance(u.getKey(), u.getValue())))); + out.setMeasures(measure); + } + Optional .ofNullable(input.getAuthor()) .ifPresent(ats -> out.setAuthor(ats.stream().map(at -> getAuthor(at)).collect(Collectors.toList()))); @@ -395,11 +408,12 @@ public class ResultMapper implements Serializable { } private static void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) { - Optional opAr = Optional - .ofNullable(i.getAccessright()); + Optional opAr = Optional.ofNullable(i.getAccessright()); + if (opAr.isPresent()) { if (Constants.accessRightsCoarMap.containsKey(opAr.get().getClassid())) { String code = Constants.accessRightsCoarMap.get(opAr.get().getClassid()); + instance .setAccessright( AccessRight @@ -407,9 +421,35 @@ public class ResultMapper implements Serializable { code, Constants.coarCodeLabelMap.get(code), Constants.COAR_ACCESS_RIGHT_SCHEMA)); + if (opAr.get().getOpenAccessRoute() != null){ + switch (opAr.get().getOpenAccessRoute()){ + case hybrid: + instance.getAccessright().setOpenAccessRoute(OpenAccessRoute.hybrid); + break; + case gold: + instance.getAccessright().setOpenAccessRoute(OpenAccessRoute.gold); + break; + case green: + instance.getAccessright().setOpenAccessRoute(OpenAccessRoute.green); + break; + case bronze: + instance.getAccessright().setOpenAccessRoute(OpenAccessRoute.bronze); + break; + + } + } } } + Optional.ofNullable(i.getPid()) + .ifPresent(pid -> instance.setPid( + pid.stream().map(p -> ControlledField.newInstance(p.getQualifier().getClassid(), p.getValue())) + .collect(Collectors.toList()))); + + Optional.ofNullable(i.getAlternateIdentifier()) + .ifPresent(ai -> instance.setAlternateIdentifier(ai.stream().map(p -> ControlledField. + newInstance(p.getQualifier().getClassid(), p.getValue())).collect(Collectors.toList()))); + Optional .ofNullable(i.getLicense()) .ifPresent(value -> instance.setLicense(value.getValue()));