From ccac6a7f7509f1dae699db886ca4cd5bc19a1593 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Mon, 31 Jul 2023 12:35:05 +0200 Subject: [PATCH] rule out records with NULL dataInfo --- .../dhp/schema/oaf/utils/GraphCleaningFunctions.java | 2 +- .../dhp/oa/graph/clean/GraphCleaningFunctionsTest.java | 9 +++++++++ .../resources/eu/dnetlib/dhp/oa/graph/clean/project.json | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/clean/project.json diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java index 87a43c07e..831035d94 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/schema/oaf/utils/GraphCleaningFunctions.java @@ -236,7 +236,7 @@ public class GraphCleaningFunctions extends CleaningFunctions { d -> Optional .ofNullable(d.getInvisible()) .orElse(true)) - .orElse(true)) + .orElse(false)) .orElse(true))) { return true; } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/clean/GraphCleaningFunctionsTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/clean/GraphCleaningFunctionsTest.java index be8307b50..1492c60fe 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/clean/GraphCleaningFunctionsTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/clean/GraphCleaningFunctionsTest.java @@ -368,6 +368,15 @@ public class GraphCleaningFunctionsTest { Assertions.assertEquals(true, GraphCleaningFunctions.filter(cleaned)); } + @Test + public void testFilterProject() throws IOException { + String json = IOUtils + .toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/oa/graph/clean/project.json")); + Project p_in = MAPPER.readValue(json, Project.class); + + Assertions.assertEquals(false, GraphCleaningFunctions.filter(p_in)); + } + @Test public void testCleanDoiBoost2() throws IOException { String json = IOUtils diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/clean/project.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/clean/project.json new file mode 100644 index 000000000..9ab714376 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/oa/graph/clean/project.json @@ -0,0 +1 @@ +{"measures": [{"id": "downloads", "unit": [{"dataInfo": {"provenanceaction": {"classid": "measure:usage_counts", "classname": "measure:usage_counts", "schemeid": "dnet:provenanceActions", "schemename": "dnet:provenanceActions"}, "deletedbyinference": false, "inferred": true, "inferenceprovenance": "update", "invisible": false, "trust": ""}, "key": "count", "value": "1"}]}, {"id": "views", "unit": [{"dataInfo": {"provenanceaction": {"classid": "measure:usage_counts", "classname": "measure:usage_counts", "schemeid": "dnet:provenanceActions", "schemename": "dnet:provenanceActions"}, "deletedbyinference": false, "inferred": true, "inferenceprovenance": "update", "invisible": false, "trust": ""}, "key": "count", "value": "0"}]}], "id": "40|aka_________::591da07706352f1195afaeed4065f52e"} \ No newline at end of file