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