From 86fe886c1ac305da1af29e2ea464a1166c0f3eb8 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Mon, 15 May 2023 11:20:51 +0200 Subject: [PATCH 1/2] removed the inverse of the Citing relation --- .../opencitations/CreateActionSetSparkJob.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateActionSetSparkJob.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateActionSetSparkJob.java index 61bc3fbca..4c658e52f 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateActionSetSparkJob.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateActionSetSparkJob.java @@ -114,10 +114,10 @@ public class CreateActionSetSparkJob implements Serializable { if (!citing.equals(cited)) { relationList - .addAll( - getRelations( + .add( + getRelation( citing, - cited)); + cited, ModelConstants.CITES)); if (duplicate && value.getCiting().endsWith(".refs")) { citing = ID_PREFIX + IdentifierFactory @@ -125,7 +125,7 @@ public class CreateActionSetSparkJob implements Serializable { CleaningFunctions .normalizePidValue( "doi", value.getCiting().substring(0, value.getCiting().indexOf(".refs")))); - relationList.addAll(getRelations(citing, cited)); + relationList.add(getRelation(citing, cited, ModelConstants.CITES)); } } From 78b07400c0ba6685433c4b70bb32cb6c18345507 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Mon, 15 May 2023 11:37:08 +0200 Subject: [PATCH 2/2] changed test classes --- .../CreateOpenCitationsASTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateOpenCitationsASTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateOpenCitationsASTest.java index 3e4ce750e..523437950 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateOpenCitationsASTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/opencitations/CreateOpenCitationsASTest.java @@ -99,7 +99,7 @@ public class CreateOpenCitationsASTest { .map(value -> OBJECT_MAPPER.readValue(value._2().toString(), AtomicAction.class)) .map(aa -> ((Relation) aa.getPayload())); - assertEquals(62, tmp.count()); + assertEquals(31, tmp.count()); // tmp.foreach(r -> System.out.println(OBJECT_MAPPER.writeValueAsString(r))); @@ -131,7 +131,7 @@ public class CreateOpenCitationsASTest { .map(value -> OBJECT_MAPPER.readValue(value._2().toString(), AtomicAction.class)) .map(aa -> ((Relation) aa.getPayload())); - assertEquals(46, tmp.count()); + assertEquals(23, tmp.count()); // tmp.foreach(r -> System.out.println(OBJECT_MAPPER.writeValueAsString(r))); @@ -241,7 +241,7 @@ public class CreateOpenCitationsASTest { assertEquals("resultResult", r.getRelType()); }); assertEquals(23, tmp.filter(r -> r.getRelClass().equals("Cites")).count()); - assertEquals(23, tmp.filter(r -> r.getRelClass().equals("IsCitedBy")).count()); + assertEquals(0, tmp.filter(r -> r.getRelClass().equals("IsCitedBy")).count()); } @@ -318,15 +318,15 @@ public class CreateOpenCitationsASTest { JavaRDD check = tmp.filter(r -> r.getSource().equals(doi1) || r.getTarget().equals(doi1)); - assertEquals(10, check.count()); + assertEquals(5, check.count()); - check.foreach(r -> { - if (r.getSource().equals(doi2) || r.getSource().equals(doi3) || r.getSource().equals(doi4) || - r.getSource().equals(doi5) || r.getSource().equals(doi6)) { - assertEquals(ModelConstants.IS_CITED_BY, r.getRelClass()); - assertEquals(doi1, r.getTarget()); - } - }); +// check.foreach(r -> { +// if (r.getSource().equals(doi2) || r.getSource().equals(doi3) || r.getSource().equals(doi4) || +// r.getSource().equals(doi5) || r.getSource().equals(doi6)) { +// assertEquals(ModelConstants.IS_CITED_BY, r.getRelClass()); +// assertEquals(doi1, r.getTarget()); +// } +// }); assertEquals(5, check.filter(r -> r.getSource().equals(doi1)).count()); check.filter(r -> r.getSource().equals(doi1)).foreach(r -> assertEquals(ModelConstants.CITES, r.getRelClass()));