skip empty projects

This commit is contained in:
Michele Artini 2020-04-27 13:51:13 +02:00
parent fad94c2155
commit 1260d03eba
3 changed files with 110 additions and 84 deletions

View File

@ -164,29 +164,34 @@ public abstract class AbstractMdRecordToOafMapper {
final String docId = createOpenaireId(50, doc.valueOf("//dri:objIdentifier"), false); final String docId = createOpenaireId(50, doc.valueOf("//dri:objIdentifier"), false);
for (final Object o : doc.selectNodes("//oaf:projectid")) { for (final Object o : doc.selectNodes("//oaf:projectid")) {
final String projectId = createOpenaireId(40, ((Node) o).getText(), true);
final Relation r1 = new Relation(); final String originalId = ((Node) o).getText();
r1.setRelType("resultProject");
r1.setSubRelType("outcome");
r1.setRelClass("isProducedBy");
r1.setSource(docId);
r1.setTarget(projectId);
r1.setCollectedfrom(Arrays.asList(collectedFrom));
r1.setDataInfo(info);
r1.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r1);
final Relation r2 = new Relation(); if (StringUtils.isNotBlank(originalId)) {
r2.setRelType("resultProject"); final String projectId = createOpenaireId(40, originalId, true);
r2.setSubRelType("outcome");
r2.setRelClass("produces"); final Relation r1 = new Relation();
r2.setSource(projectId); r1.setRelType("resultProject");
r2.setTarget(docId); r1.setSubRelType("outcome");
r2.setCollectedfrom(Arrays.asList(collectedFrom)); r1.setRelClass("isProducedBy");
r2.setDataInfo(info); r1.setSource(docId);
r2.setLastupdatetimestamp(lastUpdateTimestamp); r1.setTarget(projectId);
res.add(r2); r1.setCollectedfrom(Arrays.asList(collectedFrom));
r1.setDataInfo(info);
r1.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r1);
final Relation r2 = new Relation();
r2.setRelType("resultProject");
r2.setSubRelType("outcome");
r2.setRelClass("produces");
r2.setSource(projectId);
r2.setTarget(docId);
r2.setCollectedfrom(Arrays.asList(collectedFrom));
r2.setDataInfo(info);
r2.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r2);
}
} }
return res; return res;

View File

@ -4,11 +4,21 @@ import static eu.dnetlib.dhp.oa.graph.raw.common.OafMapperUtils.createOpenaireId
import static eu.dnetlib.dhp.oa.graph.raw.common.OafMapperUtils.field; import static eu.dnetlib.dhp.oa.graph.raw.common.OafMapperUtils.field;
import eu.dnetlib.dhp.oa.graph.raw.common.PacePerson; import eu.dnetlib.dhp.oa.graph.raw.common.PacePerson;
import eu.dnetlib.dhp.schema.oaf.*; import eu.dnetlib.dhp.schema.oaf.Author;
import eu.dnetlib.dhp.schema.oaf.DataInfo;
import eu.dnetlib.dhp.schema.oaf.Field;
import eu.dnetlib.dhp.schema.oaf.GeoLocation;
import eu.dnetlib.dhp.schema.oaf.Instance;
import eu.dnetlib.dhp.schema.oaf.KeyValue;
import eu.dnetlib.dhp.schema.oaf.Oaf;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import eu.dnetlib.dhp.schema.oaf.Relation;
import eu.dnetlib.dhp.schema.oaf.StructuredProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.Node; import org.dom4j.Node;
@ -224,29 +234,35 @@ public class OafToOafMapper extends AbstractMdRecordToOafMapper {
final List<Oaf> res = new ArrayList<>(); final List<Oaf> res = new ArrayList<>();
for (final Object o : doc.selectNodes("//*[local-name()='relatedDataset']")) { for (final Object o : doc.selectNodes("//*[local-name()='relatedDataset']")) {
final String otherId = createOpenaireId(50, ((Node) o).getText(), false);
final Relation r1 = new Relation(); final String originalId = ((Node) o).getText();
r1.setRelType("resultResult");
r1.setSubRelType("publicationDataset");
r1.setRelClass("isRelatedTo");
r1.setSource(docId);
r1.setTarget(otherId);
r1.setCollectedfrom(Arrays.asList(collectedFrom));
r1.setDataInfo(info);
r1.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r1);
final Relation r2 = new Relation(); if (StringUtils.isNotBlank(originalId)) {
r2.setRelType("resultResult");
r2.setSubRelType("publicationDataset"); final String otherId = createOpenaireId(50, originalId, false);
r2.setRelClass("isRelatedTo");
r2.setSource(otherId); final Relation r1 = new Relation();
r2.setTarget(docId); r1.setRelType("resultResult");
r2.setCollectedfrom(Arrays.asList(collectedFrom)); r1.setSubRelType("publicationDataset");
r2.setDataInfo(info); r1.setRelClass("isRelatedTo");
r2.setLastupdatetimestamp(lastUpdateTimestamp); r1.setSource(docId);
res.add(r2); r1.setTarget(otherId);
r1.setCollectedfrom(Arrays.asList(collectedFrom));
r1.setDataInfo(info);
r1.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r1);
final Relation r2 = new Relation();
r2.setRelType("resultResult");
r2.setSubRelType("publicationDataset");
r2.setRelClass("isRelatedTo");
r2.setSource(otherId);
r2.setTarget(docId);
r2.setCollectedfrom(Arrays.asList(collectedFrom));
r2.setDataInfo(info);
r2.setLastupdatetimestamp(lastUpdateTimestamp);
res.add(r2);
}
} }
return res; return res;
} }

View File

@ -295,48 +295,53 @@ public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
for (final Object o : for (final Object o :
doc.selectNodes( doc.selectNodes(
"//datacite:relatedIdentifier[@relatedIdentifierType='OPENAIRE']")) { "//datacite:relatedIdentifier[@relatedIdentifierType='OPENAIRE']")) {
final String otherId = createOpenaireId(50, ((Node) o).getText(), false);
final String type = ((Node) o).valueOf("@relationType");
if (type.equals("IsSupplementTo")) { final String originalId = ((Node) o).getText();
res.add(
prepareOtherResultRel( if (StringUtils.isNotBlank(originalId)) {
collectedFrom, final String otherId = createOpenaireId(50, originalId, false);
info, final String type = ((Node) o).valueOf("@relationType");
lastUpdateTimestamp,
docId, if (type.equals("IsSupplementTo")) {
otherId, res.add(
"supplement", prepareOtherResultRel(
"isSupplementTo")); collectedFrom,
res.add( info,
prepareOtherResultRel( lastUpdateTimestamp,
collectedFrom, docId,
info, otherId,
lastUpdateTimestamp, "supplement",
otherId, "isSupplementTo"));
docId, res.add(
"supplement", prepareOtherResultRel(
"isSupplementedBy")); collectedFrom,
} else if (type.equals("IsPartOf")) { info,
res.add( lastUpdateTimestamp,
prepareOtherResultRel( otherId,
collectedFrom, docId,
info, "supplement",
lastUpdateTimestamp, "isSupplementedBy"));
docId, } else if (type.equals("IsPartOf")) {
otherId, res.add(
"part", prepareOtherResultRel(
"IsPartOf")); collectedFrom,
res.add( info,
prepareOtherResultRel( lastUpdateTimestamp,
collectedFrom, docId,
info, otherId,
lastUpdateTimestamp, "part",
otherId, "IsPartOf"));
docId, res.add(
"part", prepareOtherResultRel(
"HasParts")); collectedFrom,
} else { info,
lastUpdateTimestamp,
otherId,
docId,
"part",
"HasParts"));
} else {
}
} }
} }
return res; return res;