forked from D-Net/dnet-hadoop
align MergeUtils with beta branch
This commit is contained in:
parent
4778a70478
commit
5d34432398
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue