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
.lookupTermBySynonym( .ofNullable(
ModelConstants.DNET_RESULT_TYPOLOGIES, vocs
i.getInstancetype().getClassid()); .lookupTermBySynonym(
ModelConstants.DNET_RESULT_TYPOLOGIES, i.getInstancetype().getClassid()))
if (Objects.isNull(expectedResultType)) { .orElse(ModelConstants.ORP_DEFAULT_RESULTTYPE)
throw new IllegalArgumentException( .getClassid();
"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())) {
try {
String resulttype = expectedResultType.getClassid(); Result result = (Result) Optional
if (EntityType.otherresearchproduct.toString().equals(resulttype)) { .ofNullable(ModelSupport.oafTypes.get(expectedResultType))
resulttype = "other"; .map(r -> {
} try {
Result result = (Result) ModelSupport.oafTypes.get(resulttype).newInstance(); return r.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;
} }