1
0
Fork 0

merged from master

This commit is contained in:
Claudio Atzori 2021-03-09 09:12:41 +01:00
parent 76441f4edd
commit f468c7f0d7
2 changed files with 23 additions and 7 deletions

View File

@ -37,6 +37,8 @@ public abstract class AbstractMdRecordToOafMapper {
protected static final Qualifier MAG_PID_TYPE = qualifier( protected static final Qualifier MAG_PID_TYPE = qualifier(
"MAGIdentifier", "Microsoft Academic Graph Identifier", DNET_PID_TYPES, DNET_PID_TYPES); "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<String, String> nsContext = new HashMap<>(); protected static final Map<String, String> nsContext = new HashMap<>();
static { static {
@ -208,17 +210,19 @@ public abstract class AbstractMdRecordToOafMapper {
final String originalId = ((Node) o).getText(); final String originalId = ((Node) o).getText();
final String validationdDate = ((Node) o).valueOf("@validationDate");
if (StringUtils.isNotBlank(originalId)) { if (StringUtils.isNotBlank(originalId)) {
final String projectId = createOpenaireId(40, originalId, true); final String projectId = createOpenaireId(40, originalId, true);
res res
.add( .add(
getRelation( getRelation(
docId, projectId, RESULT_PROJECT, OUTCOME, IS_PRODUCED_BY, entity)); docId, projectId, RESULT_PROJECT, OUTCOME, IS_PRODUCED_BY, entity, validationdDate));
res res
.add( .add(
getRelation( getRelation(
projectId, docId, RESULT_PROJECT, OUTCOME, PRODUCES, entity)); projectId, docId, RESULT_PROJECT, OUTCOME, PRODUCES, entity, validationdDate));
} }
} }
@ -231,6 +235,16 @@ public abstract class AbstractMdRecordToOafMapper {
final String subRelType, final String subRelType,
final String relClass, final String relClass,
final OafEntity entity) { 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 String validationDate) {
final Relation rel = new Relation(); final Relation rel = new Relation();
rel.setRelType(relType); rel.setRelType(relType);
rel.setSubRelType(subRelType); rel.setSubRelType(subRelType);
@ -240,6 +254,8 @@ public abstract class AbstractMdRecordToOafMapper {
rel.setCollectedfrom(entity.getCollectedfrom()); rel.setCollectedfrom(entity.getCollectedfrom());
rel.setDataInfo(entity.getDataInfo()); rel.setDataInfo(entity.getDataInfo());
rel.setLastupdatetimestamp(entity.getLastupdatetimestamp()); rel.setLastupdatetimestamp(entity.getLastupdatetimestamp());
rel.setValidated(StringUtils.isNotBlank(validationDate));
rel.setValidationDate(StringUtils.isNotBlank(validationDate) ? validationDate : null);
return rel; return rel;
} }

View File

@ -71,8 +71,8 @@ public class MappersTest {
assertValidId(p.getId()); assertValidId(p.getId());
assertTrue(p.getOriginalId().size() == 1); assertEquals(2, p.getOriginalId().size());
assertEquals("10.3897/oneeco.2.e13718", p.getOriginalId().get(0)); assertTrue(p.getOriginalId().contains("10.3897/oneeco.2.e13718"));
assertValidId(p.getCollectedfrom().get(0).getKey()); assertValidId(p.getCollectedfrom().get(0).getKey());
assertTrue(StringUtils.isNotBlank(p.getTitle().get(0).getValue())); assertTrue(StringUtils.isNotBlank(p.getTitle().get(0).getValue()));
@ -182,8 +182,8 @@ public class MappersTest {
final Relation r2 = (Relation) list.get(2); final Relation r2 = (Relation) list.get(2);
assertValidId(d.getId()); assertValidId(d.getId());
assertTrue(d.getOriginalId().size() == 1); assertEquals(2, d.getOriginalId().size());
assertEquals("oai:zenodo.org:3234526", d.getOriginalId().get(0)); assertTrue(d.getOriginalId().contains("oai:zenodo.org:3234526"));
assertValidId(d.getCollectedfrom().get(0).getKey()); assertValidId(d.getCollectedfrom().get(0).getKey());
assertTrue(StringUtils.isNotBlank(d.getTitle().get(0).getValue())); assertTrue(StringUtils.isNotBlank(d.getTitle().get(0).getValue()));
assertTrue(d.getAuthor().size() > 0); assertTrue(d.getAuthor().size() > 0);