Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Elasticsearch Services
Search Doc Service
Commits
ec4a54d4
Commit
ec4a54d4
authored
Dec 08, 2020
by
Jonas Waeber
Browse files
Remove unused function.
Replace constants with variables.
parent
0270b0fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/helpers/Extract.kt
View file @
ec4a54d4
...
...
@@ -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
[
"t
ype
"
].
let
{
identifier
->
it
[
KEYS
.
ricoT
ype
].
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment