From 8e1d43aab21a1e801c7eaf85f5d3b163b02efc2e Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Mon, 9 Nov 2020 11:53:55 +0100 Subject: [PATCH] Implemented ID generation using IdentifierRecordFactory on DOIBoost --- .../java/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala | 6 ++++++ .../main/java/eu/dnetlib/doiboost/mag/MagDataModel.scala | 6 +++++- .../main/java/eu/dnetlib/doiboost/orcid/ORCIDToOAF.scala | 8 ++++++++ .../main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala index 096217a55..4b67e08f2 100644 --- a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala +++ b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala @@ -1,6 +1,7 @@ package eu.dnetlib.doiboost.crossref import eu.dnetlib.dhp.schema.oaf._ +import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory import eu.dnetlib.dhp.utils.DHPUtils import eu.dnetlib.doiboost.DoiBoostMappingUtil._ import org.apache.commons.lang.StringUtils @@ -96,7 +97,12 @@ case object Crossref2Oaf { result.setOriginalId(tmp.filter(id => id != null).asJava) //Set identifier as 50 | doiboost____::md5(DOI) + + //IMPORTANT + //The old method result.setId(generateIdentifier(result, doi)) + //will be replaced using IdentifierFactory result.setId(generateIdentifier(result, doi)) + result.setId(IdentifierFactory.createIdentifier(result)) // Add DataInfo result.setDataInfo(generateDataInfo()) diff --git a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/mag/MagDataModel.scala b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/mag/MagDataModel.scala index 7bb4686cf..e0ff27421 100644 --- a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/mag/MagDataModel.scala +++ b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/mag/MagDataModel.scala @@ -1,6 +1,7 @@ package eu.dnetlib.doiboost.mag +import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory import eu.dnetlib.dhp.schema.oaf.{Instance, Journal, Publication, StructuredProperty} import eu.dnetlib.doiboost.DoiBoostMappingUtil import org.json4s @@ -190,8 +191,11 @@ case object ConversionUtil { pub.setPid(List(createSP(paper.Doi.toLowerCase, "doi", PID_TYPES)).asJava) pub.setOriginalId(List(paper.PaperId.toString, paper.Doi.toLowerCase).asJava) - //Set identifier as 50|doiboost____::md5(DOI) + //IMPORTANT + //The old method result.setId(generateIdentifier(result, doi)) + //will be replaced using IdentifierFactory pub.setId(generateIdentifier(pub, paper.Doi.toLowerCase)) + pub.setId(IdentifierFactory.createIdentifier(pub)) val mainTitles = createSP(paper.PaperTitle, "main title", "dnet:dataCite_title") val originalTitles = createSP(paper.OriginalTitle, "alternative title", "dnet:dataCite_title") diff --git a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/orcid/ORCIDToOAF.scala b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/orcid/ORCIDToOAF.scala index f230c604f..1e01ed16d 100644 --- a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/orcid/ORCIDToOAF.scala +++ b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/orcid/ORCIDToOAF.scala @@ -1,5 +1,6 @@ package eu.dnetlib.doiboost.orcid +import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory import eu.dnetlib.dhp.schema.oaf.{Author, Publication} import eu.dnetlib.doiboost.DoiBoostMappingUtil import eu.dnetlib.doiboost.DoiBoostMappingUtil.{ORCID, PID_TYPES, createSP, generateDataInfo, generateIdentifier} @@ -48,7 +49,14 @@ object ORCIDToOAF { val pub:Publication = new Publication pub.setPid(List(createSP(doi, "doi", PID_TYPES)).asJava) pub.setDataInfo(generateDataInfo()) + + //IMPORTANT + //The old method pub.setId(IdentifierFactory.createIdentifier(pub)) + //will be replaced using IdentifierFactory pub.setId(generateIdentifier(pub, doi.toLowerCase)) + pub.setId(IdentifierFactory.createIdentifier(pub)) + + try{ pub.setAuthor(input.authors.map(a=> { generateAuthor(a.name, a.surname, a.creditName, a.oid) diff --git a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala index 08cd4ee8e..c368c45a3 100644 --- a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala +++ b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala @@ -1,5 +1,6 @@ package eu.dnetlib.doiboost.uw +import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory import eu.dnetlib.dhp.schema.oaf.{Instance, Publication} import org.json4s import org.json4s.DefaultFormats @@ -33,7 +34,13 @@ object UnpayWallToOAF { val oaLocation:OALocation = (json \ "best_oa_location").extractOrElse[OALocation](null) pub.setPid(List(createSP(doi, "doi", PID_TYPES)).asJava) + + //IMPORTANT + //The old method pub.setId(IdentifierFactory.createIdentifier(pub)) + //will be replaced using IdentifierFactory pub.setId(generateIdentifier(pub, doi.toLowerCase)) + pub.setId(IdentifierFactory.createIdentifier(pub)) + pub.setCollectedfrom(List(createUnpayWallCollectedFrom()).asJava) pub.setDataInfo(generateDataInfo())