1
0
Fork 0

added the creation of the openaireId from funder and grant number if the element is not present in the context profile

This commit is contained in:
Miriam Baglioni 2021-07-13 17:07:46 +02:00
parent 8f322a73cb
commit 084b4ef999
1 changed files with 63 additions and 5 deletions

View File

@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
import eu.dnetlib.dhp.utils.DHPUtils;
public class QueryInformationSystem { public class QueryInformationSystem {
@ -113,14 +114,71 @@ public class QueryInformationSystem {
@NotNull @NotNull
private List<String> getCategoryList(Element el, String prefix) { private List<String> getCategoryList(Element el, String prefix) {
List<String> datasourceList = new ArrayList<>(); List<String> datasourceList = new ArrayList<>();
for (Object node : el.selectNodes(".//param")) { for (Object node : el.selectNodes(".//concept")) {
Node n = (Node) node; String oid = getOpenaireId((Node) node, prefix);
if (n.valueOf("./@name").equals("openaireId")) { if (oid != null)
datasourceList.add(prefix + "|" + n.getText()); datasourceList.add(oid);
}
} }
return datasourceList; 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);
}
} }