diff --git a/dhp-workflows/dhp-doiboost/src/main/scala/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala b/dhp-workflows/dhp-doiboost/src/main/scala/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala index a271f4c33..75aa4a024 100644 --- a/dhp-workflows/dhp-doiboost/src/main/scala/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala +++ b/dhp-workflows/dhp-doiboost/src/main/scala/eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala @@ -309,8 +309,6 @@ case object Crossref2Oaf { result } - - def generateAuhtor(given: String, family: String, orcid: String, index: Int): Author = { val a = new Author a.setName(given) @@ -372,28 +370,22 @@ case object Crossref2Oaf { case dataset: Dataset => convertDataset(dataset) } - - val doisReference:List[String] = for { - JObject(reference_json) <- json \ "reference" + val doisReference: List[String] = for { + JObject(reference_json) <- json \ "reference" JField("DOI", JString(doi_json)) <- reference_json } yield doi_json - - - if (doisReference!= null && doisReference.nonEmpty) { - val citation_relations:List[Relation] = generateCitationRelations(doisReference, result) + if (doisReference != null && doisReference.nonEmpty) { + val citation_relations: List[Relation] = generateCitationRelations(doisReference, result) resultList = resultList ::: citation_relations } resultList = resultList ::: List(result) resultList } + private def createCiteRelation(source: Result, targetPid: String, targetPidType: String): List[Relation] = { - - private def createCiteRelation(source:Result, targetPid:String, targetPidType:String) :List[Relation] = { - - - val targetId = IdentifierFactory.idFromPid("50",targetPidType, targetPid, true) + val targetId = IdentifierFactory.idFromPid("50", targetPidType, targetPid, true) val from = new Relation from.setSource(source.getId) @@ -405,7 +397,6 @@ case object Crossref2Oaf { from.setDataInfo(source.getDataInfo) from.setLastupdatetimestamp(source.getLastupdatetimestamp) - val to = new Relation to.setTarget(source.getId) to.setSource(targetId) @@ -416,10 +407,10 @@ case object Crossref2Oaf { to.setDataInfo(source.getDataInfo) to.setLastupdatetimestamp(source.getLastupdatetimestamp) - List(from,to) + List(from, to) } - def generateCitationRelations(dois:List[String], result:Result):List[Relation] = { + def generateCitationRelations(dois: List[String], result: Result): List[Relation] = { dois.flatMap(d => createCiteRelation(result, d, "doi")) } @@ -495,6 +486,7 @@ case object Crossref2Oaf { case "10.13039/501100000781" => generateSimpleRelationFromAward(funder, "corda_______", extractECAward) generateSimpleRelationFromAward(funder, "corda__h2020", extractECAward) + generateSimpleRelationFromAward(funder, "corda_____he", extractECAward) case "10.13039/100000001" => generateSimpleRelationFromAward(funder, "nsf_________", a => a) case "10.13039/501100001665" => generateSimpleRelationFromAward(funder, "anr_________", a => a) case "10.13039/501100002341" => generateSimpleRelationFromAward(funder, "aka_________", a => a) @@ -536,6 +528,34 @@ case object Crossref2Oaf { val targetId = getProjectId("wt__________", "1e5e62235d094afd01cd56e65112fc63") queue += generateRelation(sourceId, targetId, ModelConstants.IS_PRODUCED_BY) queue += generateRelation(targetId, sourceId, ModelConstants.PRODUCES) + //ASAP + case "10.13039/100018231" => generateSimpleRelationFromAward(funder, "asap________", a => a) + //CHIST-ERA + case "10.13039/501100001942" => + val targetId = getProjectId("chistera____", "1e5e62235d094afd01cd56e65112fc63") + queue += generateRelation(sourceId, targetId, ModelConstants.IS_PRODUCED_BY) + queue += generateRelation(targetId, sourceId, ModelConstants.PRODUCES) + //HE + case "10.13039/100018693" | "10.13039/100018694" | "10.13039/100019188" | "10.13039/100019180" | + "10.13039/100018695" | "10.13039/100019185" | "10.13039/100019186" | "10.13039/100019187" => + generateSimpleRelationFromAward(funder, "corda_____he", extractECAward) + //FCT + case "10.13039/501100001871" => + generateSimpleRelationFromAward(funder, "fct_________", extractECAward) + //NHMRC + case "10.13039/501100000925" => + generateSimpleRelationFromAward(funder, "mhmrc_______", extractECAward) + //NIH + case "10.13039/100000002" => + generateSimpleRelationFromAward(funder, "nih_________", extractECAward) + //NWO + case "10.13039/501100003246" => + generateSimpleRelationFromAward(funder, "nwo_________", extractECAward) + //UKRI + case "10.13039/100014013" | "10.13039/501100000267" | "10.13039/501100000268" | "10.13039/501100000269" | + "10.13039/501100000266" | "10.13039/501100006041" | "10.13039/501100000265" | "10.13039/501100000270" | + "10.13039/501100013589" | "10.13039/501100000271" => + generateSimpleRelationFromAward(funder, "nwo_________", extractECAward) case _ => logger.debug("no match for " + funder.DOI.get) diff --git a/dhp-workflows/dhp-doiboost/src/test/scala/eu/dnetlib/dhp/doiboost/crossref/CrossrefMappingTest.scala b/dhp-workflows/dhp-doiboost/src/test/scala/eu/dnetlib/dhp/doiboost/crossref/CrossrefMappingTest.scala index 572a48372..e0ef0e65c 100644 --- a/dhp-workflows/dhp-doiboost/src/test/scala/eu/dnetlib/dhp/doiboost/crossref/CrossrefMappingTest.scala +++ b/dhp-workflows/dhp-doiboost/src/test/scala/eu/dnetlib/dhp/doiboost/crossref/CrossrefMappingTest.scala @@ -114,8 +114,7 @@ class CrossrefMappingTest { } - - private def parseJson(input:String):JValue = { + private def parseJson(input: String): JValue = { implicit lazy val formats: DefaultFormats.type = org.json4s.DefaultFormats lazy val json: json4s.JValue = JsonMethods.parse(input) @@ -123,33 +122,37 @@ class CrossrefMappingTest { } @Test - def testCitationRelations():Unit = { - val json = Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/doiboost/crossref/publication_license_embargo.json")).mkString - + def testCitationRelations(): Unit = { + val json = Source + .fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/doiboost/crossref/publication_license_embargo.json")) + .mkString assertNotNull(json) assertFalse(json.isEmpty) - val result:List[Oaf] = Crossref2Oaf.convert(json) + val result: List[Oaf] = Crossref2Oaf.convert(json) assertTrue(result.nonEmpty) - val j = parseJson(json) val doisReference: List[String] = for { - JObject(reference_json) <- j \ "reference" + JObject(reference_json) <- j \ "reference" JField("DOI", JString(doi_json)) <- reference_json } yield doi_json - - - val relationList:List[Relation] = result.filter(s => s.isInstanceOf[Relation]).map(r=> r.asInstanceOf[Relation]).filter(r => r.getSubRelType.equalsIgnoreCase(ModelConstants.CITATION)) + val relationList: List[Relation] = result + .filter(s => s.isInstanceOf[Relation]) + .map(r => r.asInstanceOf[Relation]) + .filter(r => r.getSubRelType.equalsIgnoreCase(ModelConstants.CITATION)) assertNotNull(relationList) assertFalse(relationList.isEmpty) - assertEquals(doisReference.size*2, relationList.size) + assertEquals(doisReference.size * 2, relationList.size) + + mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT) + relationList.foreach(p => println(mapper.writeValueAsString(p))) } @Test