From 084b4ef999eccd94a2c16eaffb372c2cf87c6950 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 13 Jul 2021 17:07:46 +0200 Subject: [PATCH] added the creation of the openaireId from funder and grant number if the element is not present in the context profile --- .../dump/complete/QueryInformationSystem.java | 68 +++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java index c33a693a5..7a69c1a0d 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/complete/QueryInformationSystem.java @@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; +import eu.dnetlib.dhp.utils.DHPUtils; public class QueryInformationSystem { @@ -113,14 +114,71 @@ public class QueryInformationSystem { @NotNull private List getCategoryList(Element el, String prefix) { List datasourceList = new ArrayList<>(); - for (Object node : el.selectNodes(".//param")) { - Node n = (Node) node; - if (n.valueOf("./@name").equals("openaireId")) { - datasourceList.add(prefix + "|" + n.getText()); - } + for (Object node : el.selectNodes(".//concept")) { + String oid = getOpenaireId((Node) node, prefix); + if (oid != null) + datasourceList.add(oid); } return datasourceList; } + private String getOpenaireId(Node el, String prefix) { + for (Object node : el.selectNodes(".//param")) { + Node n = (Node) node; + if (n.valueOf("./@name").equals("openaireId")) { + return prefix + "|" + n.getText(); + } + } + + return makeOpenaireId(el, prefix); + + } + + private String makeOpenaireId(Node el, String prefix) { + String funder = null; + String grantId = null; + String funding = null; + for (Object node : el.selectNodes(".//param")) { + Node n = (Node) node; + switch (n.valueOf("./@name")) { + case "funding": + funding = n.getText(); + break; + case "funder": + funder = n.getText(); + break; + case "CD_PROJECT_NUMBER": + grantId = n.getText(); + break; + } + } + String nsp = null; + switch (funder.toLowerCase()) { + case "ec": + if (funding == null) { + return null; + } + if (funding.toLowerCase().startsWith("h2020")) { + nsp = "corda__h2020::"; + } else { + nsp = "corda_______::"; + } + break; + case "tubitak": + nsp = "tubitakf____::"; + break; + case "dfg": + nsp = "dfgf________::"; + break; + default: + nsp = funder.toLowerCase(); + for (int i = funder.length(); i < 12; i++) + nsp += "_"; + nsp += "::"; + } + + return prefix + "|" + nsp + DHPUtils.md5(grantId); + } + }