forked from D-Net/dnet-hadoop
mapping relationship from trasformed records based on oaf:relation
This commit is contained in:
parent
116902c028
commit
4c8e820ff0
|
@ -284,42 +284,36 @@ public abstract class AbstractMdRecordToOafMapper {
|
||||||
for (Object o : doc.selectNodes("//oaf:relation")) {
|
for (Object o : doc.selectNodes("//oaf:relation")) {
|
||||||
Element element = (Element) o;
|
Element element = (Element) o;
|
||||||
|
|
||||||
final Relation rel = new Relation();
|
final String target = StringUtils.trim(element.getText());
|
||||||
rel.setCollectedfrom(entity.getCollectedfrom());
|
final String relType = element.attributeValue("relType");
|
||||||
rel.setDataInfo(entity.getDataInfo());
|
final String subRelType = element.attributeValue("subRelType");
|
||||||
rel.setLastupdatetimestamp(entity.getLastupdatetimestamp());
|
final String relClass = element.attributeValue("relClass");
|
||||||
|
|
||||||
String relType = element.attributeValue("relType");
|
if (StringUtils.isNotBlank(target) && StringUtils.isNotBlank(relType) && StringUtils.isNotBlank(subRelType)
|
||||||
String subRelType = element.attributeValue("subRelType");
|
&& StringUtils.isNotBlank(relClass)) {
|
||||||
String relClass = element.attributeValue("relClass");
|
|
||||||
String relClassInverse = ModelSupport
|
|
||||||
.findInverse(ModelSupport.rel(relType, subRelType, relClass))
|
|
||||||
.getInverseRelClass();
|
|
||||||
|
|
||||||
rel.setSource(entity.getId());
|
final String relClassInverse = ModelSupport
|
||||||
String target = StringUtils.trim(element.getText());
|
.findInverse(ModelSupport.rel(relType, subRelType, relClass))
|
||||||
|
.getInverseRelClass();
|
||||||
|
final String validationdDate = ((Node) o).valueOf("@validationDate");
|
||||||
|
|
||||||
final String validationdDate = ((Node) o).valueOf("@validationDate");
|
if (StringUtils.isNotBlank(target)) {
|
||||||
|
final String targetType = element.attributeValue("targetType");
|
||||||
if (StringUtils.isNotBlank(target)) {
|
if (StringUtils.isNotBlank(targetType)) {
|
||||||
|
final String targetId = createOpenaireId(targetType, target, true);
|
||||||
// TODO discover the target entity type with a dedicated attribute, e.g. @targetType.
|
rels
|
||||||
final String[] parts = relType.split("(?=\\p{Upper})");
|
.add(
|
||||||
final String targetType = parts[1].toLowerCase();
|
getRelation(
|
||||||
final String targetId = createOpenaireId(targetType, target, true);
|
entity.getId(), targetId, relType, subRelType, relClass, entity, validationdDate));
|
||||||
|
rels
|
||||||
rels
|
.add(
|
||||||
.add(
|
getRelation(
|
||||||
getRelation(
|
targetId, entity.getId(), relType, subRelType, relClassInverse, entity,
|
||||||
entity.getId(), targetId, relType, subRelType, relClass, entity, validationdDate));
|
validationdDate));
|
||||||
rels
|
}
|
||||||
.add(
|
}
|
||||||
getRelation(
|
|
||||||
targetId, entity.getId(), relType, subRelType, relClassInverse, entity, validationdDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rels;
|
return rels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,12 @@
|
||||||
<oaf:refereed>0001</oaf:refereed>
|
<oaf:refereed>0001</oaf:refereed>
|
||||||
<oaf:relation relClass="hasAuthorInstitution"
|
<oaf:relation relClass="hasAuthorInstitution"
|
||||||
relType="resultOrganization"
|
relType="resultOrganization"
|
||||||
subRelType="affiliation">ror_________::https://ror.org/02gdcn153</oaf:relation>
|
subRelType="affiliation"
|
||||||
|
targetType="organization">ror_________::https://ror.org/02gdcn153</oaf:relation>
|
||||||
<oaf:relation relClass="isProducedBy"
|
<oaf:relation relClass="isProducedBy"
|
||||||
relType="resultProject"
|
relType="resultProject"
|
||||||
subRelType="outcome"
|
subRelType="outcome"
|
||||||
|
targetType="project"
|
||||||
validationDate="2020-01-01">corda_______::226852</oaf:relation>
|
validationDate="2020-01-01">corda_______::226852</oaf:relation>
|
||||||
</metadata>
|
</metadata>
|
||||||
<about xmlns:oai="http://www.openarchives.org/OAI/2.0/">
|
<about xmlns:oai="http://www.openarchives.org/OAI/2.0/">
|
||||||
|
|
Loading…
Reference in New Issue