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
46899bc9
Commit
46899bc9
authored
Sep 09, 2020
by
Jonas Waeber
Browse files
Remove terminators from facets
parent
f2f4c8cb
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/helpers/DateFacetBuildHelpers.kt
View file @
46899bc9
...
...
@@ -21,7 +21,6 @@ package org.memobase.helpers
object
DateFacetBuildHelpers
{
private
const
val
separator
=
"~"
private
const
val
terminator
=
"#"
private
const
val
level_1
=
"0"
private
const
val
level_2
=
"1"
...
...
@@ -34,7 +33,7 @@ object DateFacetBuildHelpers {
return
listOf
(
"$level_1$separator$century$separator"
,
"$level_2$separator$century$separator$decade$separator
$terminator
"
"$level_2$separator$century$separator$decade$separator"
)
}
...
...
@@ -56,7 +55,7 @@ object DateFacetBuildHelpers {
val
decade
=
getDecade
(
from
)
listOf
(
"$level_1$separator$century$separator"
,
"$level_2$separator$century$separator$decade$separator
$terminator
"
"$level_2$separator$century$separator$decade$separator"
)
}
else
{
val
fromCentury
=
getCentury
(
from
)
...
...
@@ -68,12 +67,12 @@ object DateFacetBuildHelpers {
if
(
fromCentury
==
untilCentury
&&
fromDecade
==
untilDecade
)
{
listOf
(
"$level_1$separator$fromCentury$separator"
,
"$level_2$separator$fromCentury$separator$fromDecade$separator
$terminator
"
"$level_2$separator$fromCentury$separator$fromDecade$separator"
)
}
else
if
(
fromCentury
==
untilCentury
&&
fromDecade
!=
untilDecade
)
{
val
results
=
mutableListOf
(
"$level_1$separator$fromCentury$separator"
,
"$level_2$separator$fromCentury$separator$fromDecade$separator
$terminator
"
"$level_2$separator$fromCentury$separator$fromDecade$separator"
)
var
fromDecadeAsInt
=
fromDecade
.
substring
(
0
,
4
).
toInt
()
val
untilDecadeAsInt
=
untilDecade
.
substring
(
0
,
4
).
toInt
()
...
...
@@ -83,7 +82,7 @@ object DateFacetBuildHelpers {
results
.
add
(
"$level_2$separator$fromCentury$separator${getDecade(
fromDecadeAsInt
)}
$
separator
$
terminator
"
)}
$
separator
"
)
}
results
...
...
@@ -103,7 +102,7 @@ object DateFacetBuildHelpers {
fromCenturyAsInt
+=
1
}
results
.
add
(
"$level_2$separator$fromCentury$separator$fromDecade$separator
$terminator
"
"$level_2$separator$fromCentury$separator$fromDecade$separator"
)
var
fromDecadeAsInt
=
fromDecade
.
substring
(
0
,
4
).
toInt
()
val
untilDecadeAsInt
=
untilDecade
.
substring
(
0
,
4
).
toInt
()
...
...
@@ -115,7 +114,7 @@ object DateFacetBuildHelpers {
fromDecadeAsInt
/
100
)}
$
separator
$
{
getDecade
(
fromDecadeAsInt
)}
$
separator
$
terminator
"
)}
$
separator
"
)
}
results
...
...
src/main/kotlin/helpers/FacetBuildHelpers.kt
View file @
46899bc9
...
...
@@ -24,7 +24,6 @@ import org.memobase.KEYS
object
FacetBuildHelpers
{
private
const
val
separator
=
"~"
private
const
val
terminator
=
"#"
private
const
val
level1
=
"0"
private
const
val
level2
=
"1"
...
...
@@ -51,8 +50,8 @@ object FacetBuildHelpers {
val
capitalLetter
=
getCapitalLetter
(
name
)
return
listOf
(
"$level1$separator$capitalLetter$separator
$terminator
"
,
"$level2$separator$capitalLetter$separator$displayName$separator
$terminator
"
"$level1$separator$capitalLetter$separator"
,
"$level2$separator$capitalLetter$separator$displayName$separator"
)
}
...
...
@@ -66,8 +65,8 @@ object FacetBuildHelpers {
val
capitalLetter
=
getCapitalLetter
(
name
)
return
listOf
(
"$level1$separator$capitalLetter$separator
$terminator
"
,
"$level2$separator$capitalLetter$separator$name$separator
$terminator
"
"$level1$separator$capitalLetter$separator"
,
"$level2$separator$capitalLetter$separator$name$separator"
)
}
...
...
src/test/kotlin/TestFacetBuilders.kt
View file @
46899bc9
...
...
@@ -73,8 +73,8 @@ class TestFacetBuilders {
KEYS
.
creator
,
""
,
listOf
(
"0~E~
#
"
,
"1~E~Einstein, Albert~
#
"
"0~E~"
,
"1~E~Einstein, Albert~"
)
),
PersonFacetBuilderParams
(
...
...
@@ -90,8 +90,8 @@ class TestFacetBuilders {
KEYS
.
contributor
,
""
,
listOf
(
"0~E~
#
"
,
"1~E~Einstein~
#
"
"0~E~"
,
"1~E~Einstein~"
)
)
)
...
...
@@ -120,7 +120,7 @@ class TestFacetBuilders {
.
isSortedAccordingTo
{
s
,
s2
->
s
.
substring
(
2
).
compareTo
(
s2
.
substring
(
2
))
}
.
containsAll
(
listOf
(
"0~A~
#
"
,
"1~A~Albert, Einstein~
#
"
,
"0~E~
#
"
,
"1~E~Einstein, Albert~
#
"
"0~A~"
,
"1~A~Albert, Einstein~"
,
"0~E~"
,
"1~E~Einstein, Albert~"
)
)
}
...
...
@@ -145,47 +145,47 @@ class TestFacetBuilders {
TestDate
(
"1921-09-14"
,
"single"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
)
),
TestDate
(
"1921"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
)
),
TestDate
(
"1921/1922"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
)
),
TestDate
(
"1921-05-01/02"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
)
),
TestDate
(
"1921-05-01/06-02"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
)
),
TestDate
(
"1921/1931"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
,
"1~20.Jahrhundert~1931-1940~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
,
"1~20.Jahrhundert~1931-1940~"
)
),
TestDate
(
"1921-04-01/1931-05-02"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
,
"1~20.Jahrhundert~1931-1940~
#
"
)
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~"
,
"1~20.Jahrhundert~1931-1940~"
)
),
TestDate
(
"1921/1951"
,
"range"
,
listOf
(
"0~20.Jahrhundert~"
,
"1~20.Jahrhundert~1921-1930~
#
"
,
"1~20.Jahrhundert~1931-1940~
#
"
,
"1~20.Jahrhundert~1941-1950~
#
"
,
"1~20.Jahrhundert~1951-1960~
#
"
"1~20.Jahrhundert~1921-1930~"
,
"1~20.Jahrhundert~1931-1940~"
,
"1~20.Jahrhundert~1941-1950~"
,
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate
(
...
...
@@ -195,30 +195,30 @@ class TestFacetBuilders {
"0~18.Jahrhundert~"
,
"0~19.Jahrhundert~"
,
"0~20.Jahrhundert~"
,
"1~18.Jahrhundert~1721-1730~
#
"
,
"1~18.Jahrhundert~1731-1740~
#
"
,
"1~18.Jahrhundert~1741-1750~
#
"
,
"1~18.Jahrhundert~1751-1760~
#
"
,
"1~18.Jahrhundert~1761-1770~
#
"
,
"1~18.Jahrhundert~1771-1780~
#
"
,
"1~18.Jahrhundert~1781-1790~
#
"
,
"1~18.Jahrhundert~1791-1800~
#
"
,
"1~19.Jahrhundert~1801-1810~
#
"
,
"1~19.Jahrhundert~1811-1820~
#
"
,
"1~19.Jahrhundert~1821-1830~
#
"
,
"1~19.Jahrhundert~1831-1840~
#
"
,
"1~19.Jahrhundert~1841-1850~
#
"
,
"1~19.Jahrhundert~1851-1860~
#
"
,
"1~19.Jahrhundert~1861-1870~
#
"
,
"1~19.Jahrhundert~1871-1880~
#
"
,
"1~19.Jahrhundert~1881-1890~
#
"
,
"1~19.Jahrhundert~1891-1900~
#
"
,
"1~20.Jahrhundert~1901-1910~
#
"
,
"1~20.Jahrhundert~1911-1920~
#
"
,
"1~20.Jahrhundert~1921-1930~
#
"
,
"1~20.Jahrhundert~1931-1940~
#
"
,
"1~20.Jahrhundert~1941-1950~
#
"
,
"1~20.Jahrhundert~1951-1960~
#
"
"1~18.Jahrhundert~1721-1730~"
,
"1~18.Jahrhundert~1731-1740~"
,
"1~18.Jahrhundert~1741-1750~"
,
"1~18.Jahrhundert~1751-1760~"
,
"1~18.Jahrhundert~1761-1770~"
,
"1~18.Jahrhundert~1771-1780~"
,
"1~18.Jahrhundert~1781-1790~"
,
"1~18.Jahrhundert~1791-1800~"
,
"1~19.Jahrhundert~1801-1810~"
,
"1~19.Jahrhundert~1811-1820~"
,
"1~19.Jahrhundert~1821-1830~"
,
"1~19.Jahrhundert~1831-1840~"
,
"1~19.Jahrhundert~1841-1850~"
,
"1~19.Jahrhundert~1851-1860~"
,
"1~19.Jahrhundert~1861-1870~"
,
"1~19.Jahrhundert~1871-1880~"
,
"1~19.Jahrhundert~1881-1890~"
,
"1~19.Jahrhundert~1891-1900~"
,
"1~20.Jahrhundert~1901-1910~"
,
"1~20.Jahrhundert~1911-1920~"
,
"1~20.Jahrhundert~1921-1930~"
,
"1~20.Jahrhundert~1931-1940~"
,
"1~20.Jahrhundert~1941-1950~"
,
"1~20.Jahrhundert~1951-1960~"
)
),
TestDate
(
...
...
@@ -227,17 +227,17 @@ class TestFacetBuilders {
listOf
(
"0~18.Jahrhundert~"
,
"0~19.Jahrhundert~"
,
"1~18.Jahrhundert~1721-1730~
#
"
,
"1~18.Jahrhundert~1731-1740~
#
"
,
"1~18.Jahrhundert~1741-1750~
#
"
,
"1~18.Jahrhundert~1751-1760~
#
"
,
"1~18.Jahrhundert~1761-1770~
#
"
,
"1~18.Jahrhundert~1771-1780~
#
"
,
"1~18.Jahrhundert~1781-1790~
#
"
,
"1~18.Jahrhundert~1791-1800~
#
"
,
"1~19.Jahrhundert~1801-1810~
#
"
,
"1~19.Jahrhundert~1811-1820~
#
"
,
"1~19.Jahrhundert~1821-1830~
#
"
"1~18.Jahrhundert~1721-1730~"
,
"1~18.Jahrhundert~1731-1740~"
,
"1~18.Jahrhundert~1741-1750~"
,
"1~18.Jahrhundert~1751-1760~"
,
"1~18.Jahrhundert~1761-1770~"
,
"1~18.Jahrhundert~1771-1780~"
,
"1~18.Jahrhundert~1781-1790~"
,
"1~18.Jahrhundert~1791-1800~"
,
"1~19.Jahrhundert~1801-1810~"
,
"1~19.Jahrhundert~1811-1820~"
,
"1~19.Jahrhundert~1821-1830~"
)
)
)
...
...
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