Commit 4d427842 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Catch empty fields exceptions.

parent 7faa9d2a
Pipeline #16122 passed with stages
in 5 minutes and 44 seconds
......@@ -33,15 +33,33 @@ object Filter {
* @param fullGraph
* @return The list of de-referenced JSON Objects.
*/
fun entitiesByProperty(sourceProperty: String, sourceResource: JsonObject?, fullGraph: Map<String, JsonObject>): List<JsonObject> {
fun entitiesByProperty(
sourceProperty: String,
sourceResource: JsonObject?,
fullGraph: Map<String, JsonObject>
): List<JsonObject> {
if (sourceResource == null) {
log.info("No results collected from property $sourceProperty, because resource does not exist.")
return emptyList()
}
return sourceResource[sourceProperty].let {
when (it) {
is String -> listOf(fullGraph[it] as JsonObject)
is JsonObject -> listOf(fullGraph[it["@id"]] as JsonObject)
is String ->
when (val newValue = fullGraph[it]) {
is JsonObject -> listOf(newValue)
else -> {
log.error("Could not extract json-object from entity $it in property $sourceProperty.")
emptyList()
}
}
is JsonObject ->
when (val newValue = fullGraph[it["@id"]]) {
is JsonObject -> listOf(newValue)
else -> {
log.error("Could not extract json-object from entity $it in property $sourceProperty.")
emptyList()
}
}
is JsonArray<*> ->
it.mapNotNull { child ->
when (child) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment