From f468c7f0d7af6b4560316e74c9e941589384763f Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 9 Mar 2021 09:12:41 +0100 Subject: [PATCH] merged from master --- .../raw/AbstractMdRecordToOafMapper.java | 22 ++++++++++++++++--- .../dnetlib/dhp/oa/graph/raw/MappersTest.java | 8 +++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/AbstractMdRecordToOafMapper.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/AbstractMdRecordToOafMapper.java index 00a7f3a92..f03dcab7e 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/AbstractMdRecordToOafMapper.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/raw/AbstractMdRecordToOafMapper.java @@ -37,6 +37,8 @@ public abstract class AbstractMdRecordToOafMapper { protected static final Qualifier MAG_PID_TYPE = qualifier( "MAGIdentifier", "Microsoft Academic Graph Identifier", DNET_PID_TYPES, DNET_PID_TYPES); + protected static final String DEFAULT_TRUST_FOR_VALIDATED_RELS = "0.999"; + protected static final Map nsContext = new HashMap<>(); static { @@ -208,29 +210,41 @@ public abstract class AbstractMdRecordToOafMapper { final String originalId = ((Node) o).getText(); + final String validationdDate = ((Node) o).valueOf("@validationDate"); + if (StringUtils.isNotBlank(originalId)) { final String projectId = createOpenaireId(40, originalId, true); res .add( getRelation( - docId, projectId, RESULT_PROJECT, OUTCOME, IS_PRODUCED_BY, entity)); + docId, projectId, RESULT_PROJECT, OUTCOME, IS_PRODUCED_BY, entity, validationdDate)); res .add( getRelation( - projectId, docId, RESULT_PROJECT, OUTCOME, PRODUCES, entity)); + projectId, docId, RESULT_PROJECT, OUTCOME, PRODUCES, entity, validationdDate)); } } return res; } + protected Relation getRelation(final String source, + final String target, + final String relType, + final String subRelType, + final String relClass, + final OafEntity entity) { + return getRelation(source, target, relType, subRelType, relClass, entity, null); + } + protected Relation getRelation(final String source, final String target, final String relType, final String subRelType, final String relClass, - final OafEntity entity) { + final OafEntity entity, + final String validationDate) { final Relation rel = new Relation(); rel.setRelType(relType); rel.setSubRelType(subRelType); @@ -240,6 +254,8 @@ public abstract class AbstractMdRecordToOafMapper { rel.setCollectedfrom(entity.getCollectedfrom()); rel.setDataInfo(entity.getDataInfo()); rel.setLastupdatetimestamp(entity.getLastupdatetimestamp()); + rel.setValidated(StringUtils.isNotBlank(validationDate)); + rel.setValidationDate(StringUtils.isNotBlank(validationDate) ? validationDate : null); return rel; } diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java index baced2495..89ef7ed0e 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/raw/MappersTest.java @@ -71,8 +71,8 @@ public class MappersTest { assertValidId(p.getId()); - assertTrue(p.getOriginalId().size() == 1); - assertEquals("10.3897/oneeco.2.e13718", p.getOriginalId().get(0)); + assertEquals(2, p.getOriginalId().size()); + assertTrue(p.getOriginalId().contains("10.3897/oneeco.2.e13718")); assertValidId(p.getCollectedfrom().get(0).getKey()); assertTrue(StringUtils.isNotBlank(p.getTitle().get(0).getValue())); @@ -182,8 +182,8 @@ public class MappersTest { final Relation r2 = (Relation) list.get(2); assertValidId(d.getId()); - assertTrue(d.getOriginalId().size() == 1); - assertEquals("oai:zenodo.org:3234526", d.getOriginalId().get(0)); + assertEquals(2, d.getOriginalId().size()); + assertTrue(d.getOriginalId().contains("oai:zenodo.org:3234526")); assertValidId(d.getCollectedfrom().get(0).getKey()); assertTrue(StringUtils.isNotBlank(d.getTitle().get(0).getValue())); assertTrue(d.getAuthor().size() > 0);