1
0
Fork 0

align MergeUtils with beta branch

This commit is contained in:
Claudio Atzori 2024-11-19 15:12:04 +01:00
parent 4778a70478
commit 5d34432398
1 changed files with 21 additions and 21 deletions

View File

@ -74,29 +74,29 @@ public class MergeUtils {
if (!vocs.vocabularyExists(ModelConstants.DNET_RESULT_TYPOLOGIES)) { if (!vocs.vocabularyExists(ModelConstants.DNET_RESULT_TYPOLOGIES)) {
return (T) mergedResult; return (T) mergedResult;
} else { } else {
final Qualifier expectedResultType = vocs final String expectedResultType = Optional
.ofNullable(
vocs
.lookupTermBySynonym( .lookupTermBySynonym(
ModelConstants.DNET_RESULT_TYPOLOGIES, ModelConstants.DNET_RESULT_TYPOLOGIES, i.getInstancetype().getClassid()))
i.getInstancetype().getClassid()); .orElse(ModelConstants.ORP_DEFAULT_RESULTTYPE)
.getClassid();
if (Objects.isNull(expectedResultType)) {
throw new IllegalArgumentException(
"instance type not bound to any result type in dnet:result_typologies: " +
i.getInstancetype().getClassid());
}
// there is a clash among the result types // there is a clash among the result types
if (!expectedResultType.getClassid().equals(mergedResult.getResulttype().getClassid())) { if (!expectedResultType.equals(mergedResult.getResulttype().getClassid())) {
Result result = (Result) Optional
.ofNullable(ModelSupport.oafTypes.get(expectedResultType))
.map(r -> {
try { try {
String resulttype = expectedResultType.getClassid(); return r.newInstance();
if (EntityType.otherresearchproduct.toString().equals(resulttype)) {
resulttype = "other";
}
Result result = (Result) ModelSupport.oafTypes.get(resulttype).newInstance();
return (T) mergeResultFields(result, mergedResult);
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException | IllegalAccessException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
})
.orElse(new OtherResearchProduct());
result.setId(mergedResult.getId());
return (T) mergeResultFields(result, mergedResult);
} else { } else {
return (T) mergedResult; return (T) mergedResult;
} }