From 0559d8b412a83e336ada2e10813b83412bac26fd Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 28 Feb 2023 10:57:32 +0100 Subject: [PATCH 1/2] WIP monodirectional citations --- .../eu/dnetlib/doiboost/crossref/Crossref2Oaf.scala | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) 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 8ef564a62..7b5f9fb91 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 @@ -397,17 +397,7 @@ case object Crossref2Oaf { from.setDataInfo(source.getDataInfo) from.setLastupdatetimestamp(source.getLastupdatetimestamp) - val to = new Relation - to.setTarget(source.getId) - to.setSource(targetId) - to.setRelType(ModelConstants.RESULT_RESULT) - to.setRelClass(ModelConstants.IS_CITED_BY) - to.setSubRelType(ModelConstants.CITATION) - to.setCollectedfrom(source.getCollectedfrom) - to.setDataInfo(source.getDataInfo) - to.setLastupdatetimestamp(source.getLastupdatetimestamp) - - List(from, to) + List(from) } def generateCitationRelations(dois: List[String], result: Result): List[Relation] = { From 2f7346e9cfbba21c1efb69852834d3c9fc066424 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 28 Feb 2023 13:30:51 +0100 Subject: [PATCH 2/2] WIP monodirectional citations, Datacite --- .../dhp/datacite/DataciteModelConstants.scala | 20 ------ .../DataciteToOAFTransformation.scala | 61 +++++++++++++------ 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteModelConstants.scala b/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteModelConstants.scala index a59779387..6e9d53aa3 100644 --- a/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteModelConstants.scala +++ b/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteModelConstants.scala @@ -78,16 +78,6 @@ object DataciteModelConstants { OafMapperUtils.keyValue(ModelConstants.DATACITE_ID, DATACITE_NAME) val subRelTypeMapping: Map[String, OAFRelations] = Map( - ModelConstants.REFERENCES -> OAFRelations( - ModelConstants.REFERENCES, - ModelConstants.IS_REFERENCED_BY, - ModelConstants.RELATIONSHIP - ), - ModelConstants.IS_REFERENCED_BY -> OAFRelations( - ModelConstants.IS_REFERENCED_BY, - ModelConstants.REFERENCES, - ModelConstants.RELATIONSHIP - ), ModelConstants.IS_SUPPLEMENTED_BY -> OAFRelations( ModelConstants.IS_SUPPLEMENTED_BY, ModelConstants.IS_SUPPLEMENT_TO, @@ -163,16 +153,6 @@ object DataciteModelConstants { ModelConstants.IS_SOURCE_OF, ModelConstants.VERSION ), - ModelConstants.CITES -> OAFRelations( - ModelConstants.CITES, - ModelConstants.IS_CITED_BY, - ModelConstants.CITATION - ), - ModelConstants.IS_CITED_BY -> OAFRelations( - ModelConstants.IS_CITED_BY, - ModelConstants.CITES, - ModelConstants.CITATION - ), ModelConstants.IS_VARIANT_FORM_OF -> OAFRelations( ModelConstants.IS_VARIANT_FORM_OF, ModelConstants.IS_DERIVED_FROM, diff --git a/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteToOAFTransformation.scala b/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteToOAFTransformation.scala index a7ad9e2d6..049910ade 100644 --- a/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteToOAFTransformation.scala +++ b/dhp-workflows/dhp-aggregation/src/main/scala/eu/dnetlib/dhp/datacite/DataciteToOAFTransformation.scala @@ -645,7 +645,7 @@ object DataciteToOAFTransformation { id: String, date: String ): List[Relation] = { - rels + val bidirectionalRels: List[Relation] = rels .filter(r => subRelTypeMapping .contains(r.relationType) && (r.relatedIdentifierType.equalsIgnoreCase("doi") || @@ -653,27 +653,48 @@ object DataciteToOAFTransformation { r.relatedIdentifierType.equalsIgnoreCase("arxiv")) ) .map(r => { - val rel = new Relation - rel.setCollectedfrom(List(DATACITE_COLLECTED_FROM).asJava) - rel.setDataInfo(dataInfo) - val subRelType = subRelTypeMapping(r.relationType).relType - rel.setRelType(REL_TYPE_VALUE) - rel.setSubRelType(subRelType) - rel.setRelClass(r.relationType) - - val dateProps: KeyValue = OafMapperUtils.keyValue(DATE_RELATION_KEY, date) - - rel.setProperties(List(dateProps).asJava) - - rel.setSource(id) - rel.setTarget( - DHPUtils.generateUnresolvedIdentifier(r.relatedIdentifier, r.relatedIdentifierType) - ) - rel.setCollectedfrom(List(DATACITE_COLLECTED_FROM).asJava) - rel.getCollectedfrom.asScala.map(c => c.getValue).toList - rel + val target = DHPUtils.generateUnresolvedIdentifier(r.relatedIdentifier, r.relatedIdentifierType) + relation(id, target, subRelType, r.relationType, date) }) + val citationRels:List[Relation] = rels + .filter(r => + (r.relatedIdentifierType.equalsIgnoreCase("doi") || + r.relatedIdentifierType.equalsIgnoreCase("pmid") || + r.relatedIdentifierType.equalsIgnoreCase("arxiv")) && + (r.relationType.toLowerCase.contains("cite") || r.relationType.toLowerCase.contains("reference"))) + .map(r => { + r.relationType match { + case ModelConstants.CITES | ModelConstants.REFERENCES => + val target = DHPUtils.generateUnresolvedIdentifier(r.relatedIdentifier, r.relatedIdentifierType) + relation(id, target, ModelConstants.CITATION, ModelConstants.CITES, date) + case ModelConstants.IS_CITED_BY | ModelConstants.IS_REFERENCED_BY => + val source = DHPUtils.generateUnresolvedIdentifier(r.relatedIdentifier, r.relatedIdentifierType) + relation(source, id, ModelConstants.CITATION, ModelConstants.CITES, date) + } + }) + + citationRels ::: bidirectionalRels + } + + def relation(source:String, target:String, subRelType:String, relClass:String, date:String): Relation = { + val rel = new Relation + rel.setCollectedfrom(List(DATACITE_COLLECTED_FROM).asJava) + rel.setDataInfo(dataInfo) + + rel.setRelType(REL_TYPE_VALUE) + rel.setSubRelType(subRelType) + rel.setRelClass(relClass) + + val dateProps: KeyValue = OafMapperUtils.keyValue(DATE_RELATION_KEY, date) + + rel.setProperties(List(dateProps).asJava) + + rel.setSource(source) + rel.setTarget(target) + rel.setCollectedfrom(List(DATACITE_COLLECTED_FROM).asJava) + rel.getCollectedfrom.asScala.map(c => c.getValue).toList + rel } def generateDSId(input: String): String = {