avoid NPEs
This commit is contained in:
parent
74b185d07b
commit
7c3041b276
|
@ -941,12 +941,18 @@ public class GraphCleaningFunctions extends CleaningFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Qualifier getMetaResourceType(final List<Instance> instances, final VocabularyGroup vocs) {
|
private static Qualifier getMetaResourceType(final List<Instance> instances, final VocabularyGroup vocs) {
|
||||||
|
return Optional
|
||||||
|
.ofNullable(instances)
|
||||||
|
.map(ii -> {
|
||||||
if (vocs.vocabularyExists(OPENAIRE_META_RESOURCE_TYPE)) {
|
if (vocs.vocabularyExists(OPENAIRE_META_RESOURCE_TYPE)) {
|
||||||
Optional<InstanceTypeMapping> itm = instances
|
Optional<InstanceTypeMapping> itm = ii
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
.flatMap(
|
.flatMap(
|
||||||
i -> Optional.ofNullable(i.getInstanceTypeMapping()).map(Collection::stream).orElse(Stream.empty()))
|
i -> Optional
|
||||||
|
.ofNullable(i.getInstanceTypeMapping())
|
||||||
|
.map(Collection::stream)
|
||||||
|
.orElse(Stream.empty()))
|
||||||
.filter(t -> OPENAIRE_COAR_RESOURCE_TYPES_3_1.equals(t.getVocabularyName()))
|
.filter(t -> OPENAIRE_COAR_RESOURCE_TYPES_3_1.equals(t.getVocabularyName()))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
|
@ -963,6 +969,8 @@ public class GraphCleaningFunctions extends CleaningFunctions {
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("vocabulary '" + OPENAIRE_META_RESOURCE_TYPE + "' not available");
|
throw new IllegalStateException("vocabulary '" + OPENAIRE_META_RESOURCE_TYPE + "' not available");
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue