Commit ec4a54d4 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Remove unused function.

Replace constants with variables.
parent 0270b0fb
......@@ -21,7 +21,6 @@ package org.memobase.helpers
import com.beust.klaxon.JsonArray
import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager
import org.memobase.model.FacetContainer
import org.memobase.model.LanguageContainer
object Extract {
......@@ -86,24 +85,13 @@ object Extract {
annotationField: String
): List<LanguageContainer> {
return entities.filter { it[field] == type }.flatMap {
languageContainer(it["@id"] as String, it[annotationField])
}
}
fun facetEntity(entities: List<JsonObject>, property: String): List<FacetContainer> {
return entities.mapNotNull {
val lang = languageContainer(it["@id"] as String, it[property])
if (lang.isEmpty()) {
null
} else {
FacetContainer(lang.first(), null, lang.first().toList())
}
languageContainer(it[KEYS.atType] as String, it[annotationField])
}
}
fun extractIdValue(entities: List<JsonObject>, type: String): String? {
return entities.first {
it["type"].let { identifier ->
it[KEYS.ricoType].let { identifier ->
if (identifier == null)
false
else
......@@ -131,12 +119,12 @@ object Extract {
fun identifiers(value: Any?): List<String> {
return when (value) {
is String -> listOf(value)
is JsonObject -> value["@id"].let { if (it is String) listOf(it) else emptyList() }
is JsonObject -> value[KEYS.atType].let { if (it is String) listOf(it) else emptyList() }
is JsonArray<*> ->
value.mapNotNull { item ->
when (item) {
is String -> item
is JsonObject -> value["@id"].let { id: Any? ->
is JsonObject -> value[KEYS.atType].let { id: Any? ->
if (id is String)
id
else null
......
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