|
|
|
@ -22,6 +22,8 @@ import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.common.PacePerson;
|
|
|
|
|
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
|
|
|
|
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
|
|
|
|
import eu.dnetlib.dhp.schema.common.RelationInverse;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.*;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory;
|
|
|
|
@ -400,55 +402,12 @@ public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(originalId)) {
|
|
|
|
|
final String idType = ((Node) o).valueOf("@relatedIdentifierType");
|
|
|
|
|
final String reltype = ((Node) o).valueOf("@relationType");
|
|
|
|
|
final String relType = ((Node) o).valueOf("@relationType");
|
|
|
|
|
String otherId = guessRelatedIdentifier(idType, originalId);
|
|
|
|
|
if (StringUtils.isNotBlank(otherId)) {
|
|
|
|
|
if (reltype.equalsIgnoreCase(IS_SUPPLEMENT_TO)) {
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
docId, otherId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENT_TO, entity));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
otherId, docId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENTED_BY, entity));
|
|
|
|
|
} else {
|
|
|
|
|
if (reltype.equalsIgnoreCase(IS_SUPPLEMENTED_BY)) {
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
otherId, docId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENT_TO, entity));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
docId, otherId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENTED_BY, entity));
|
|
|
|
|
} else {
|
|
|
|
|
if (reltype.equalsIgnoreCase(IS_PART_OF)) {
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
docId, otherId, RESULT_RESULT, PART, IS_PART_OF, entity));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
otherId, docId, RESULT_RESULT, PART, HAS_PART, entity));
|
|
|
|
|
} else {
|
|
|
|
|
if (reltype.equalsIgnoreCase(HAS_PART)) {
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
otherId, docId, RESULT_RESULT, PART, IS_PART_OF, entity));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
docId, otherId, RESULT_RESULT, PART, HAS_PART, entity));
|
|
|
|
|
}
|
|
|
|
|
// else TODO catch more semantics
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res.addAll(getRelations(relType, docId, otherId, entity));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
@ -457,14 +416,33 @@ public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
|
|
|
|
|
protected String guessRelatedIdentifier(final String idType, final String value) {
|
|
|
|
|
if (StringUtils.isBlank(idType) || StringUtils.isBlank(value))
|
|
|
|
|
return null;
|
|
|
|
|
if (idType.equalsIgnoreCase("OPENAIRE")) return createOpenaireId(50, value, false);
|
|
|
|
|
if(pidTypeWithAuthority.contains(idType.toLowerCase())){
|
|
|
|
|
return IdentifierFactory.idFromPid("50", idType, value, true);
|
|
|
|
|
}
|
|
|
|
|
if (idType.equalsIgnoreCase("OPENAIRE"))
|
|
|
|
|
return createOpenaireId(50, value, false);
|
|
|
|
|
if (pidTypeWithAuthority.containsKey(idType.toLowerCase())) {
|
|
|
|
|
return IdentifierFactory.idFromPid("50", pidTypeWithAuthority.get(idType.toLowerCase()), value, true);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected List<Oaf> getRelations(final String reltype, final String entityId, final String otherId,
|
|
|
|
|
final OafEntity entity) {
|
|
|
|
|
final List<Oaf> res = new ArrayList<>();
|
|
|
|
|
RelationInverse rel = ModelSupport.findRelation(reltype);
|
|
|
|
|
if (rel != null) {
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
entityId, otherId, rel.getRelType(), rel.getSubReltype(), rel.getRelClass(), entity));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
getRelation(
|
|
|
|
|
otherId, entityId, rel.getRelType(), rel.getSubReltype(), rel.getInverseRelClass(), entity));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected Qualifier prepareResourceType(final Document doc, final DataInfo info) {
|
|
|
|
|
return prepareQualifier(
|
|
|
|
|