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

Add basic record set search doc schema

parent c5ffd3d1
......@@ -100,7 +100,7 @@ class InstitutionSearchDocBuilder(path: String) {
teaserColor = institution[KEYS.teaserColor].let {
if (it == null) {
log.error("No teaser colour found for institution $id.")
"#ffffff"
""
}
else
it as String
......@@ -108,7 +108,7 @@ class InstitutionSearchDocBuilder(path: String) {
teaserColorComputed = institution[KEYS.teaserColorComputed].let {
if (it == null) {
log.error("No computed teaser colour found for institution $id.")
"#ffffff"
""
}
else
it as String
......
package org.memobase.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonInclude
@JsonInclude(JsonInclude.Include.NON_EMPTY)
data class RecordSetSearchDoc(
@JsonIgnore
val recordSetId: String,
val name: LanguageContainer,
val isPublished: Boolean,
// Facets
val documentType: FacetContainer,
val supportedByMemoriav: Boolean,
val languageOfMetadata: FacetContainer,
val institution: FacetContainer,
val periodOfTimeAsYear: String,
// search
val scopeAndContent: LanguageContainer
) : Schema(recordSetId) {
companion object {
val DEFAULT = RecordSetSearchDoc(
recordSetId = "NoRecordSetId",
name = LanguageContainer.placeholder("TEST_RECORD_SET"),
isPublished = false,
documentType = FacetContainer(
LanguageContainer.placeholder("TEST DOCUMENT TYPE"),
filter = "",
facet = emptyList()
),
supportedByMemoriav = true,
languageOfMetadata = FacetContainer(
LanguageContainer.placeholder("TEST LANGUAGE"),
filter = "",
facet = emptyList()
),
institution = FacetContainer(
LanguageContainer.placeholder("TEST INSTITUTION"),
filter = "",
facet = emptyList()
),
periodOfTimeAsYear = "2020",
scopeAndContent = LanguageContainer.placeholder("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
)
}
}
\ No newline at end of file
......@@ -13,6 +13,6 @@ open class Schema(val id: String) {
fun toJson(): String {
val stringWriter = StringWriter()
writer.writeValue(stringWriter, this)
return writer.toString()
return stringWriter.toString()
}
}
\ No newline at end of file
package org.memobase
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.memobase.model.RecordSetSearchDoc
import java.io.File
import java.nio.charset.Charset
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestRecordSetSearchDoc {
private val dataPath = "src/test/resources/data/recordSets"
private fun readFile(fileName: String): String {
return File("$dataPath/$fileName").readText(Charset.defaultCharset())
}
@Test
fun `test create default record set `() {
val searchDoc = RecordSetSearchDoc.DEFAULT
assertThat(searchDoc.toJson())
.isEqualTo(readFile("default_record_set.json"))
}
}
\ No newline at end of file
{
"name": {
"de": [
"TEST_RECORD_SET"
],
"fr": [
"TEST_RECORD_SET"
],
"it": [
"TEST_RECORD_SET"
],
"un": [
"TEST_RECORD_SET"
]
},
"isPublished": false,
"documentType": {
"name": {
"de": [
"TEST DOCUMENT TYPE"
],
"fr": [
"TEST DOCUMENT TYPE"
],
"it": [
"TEST DOCUMENT TYPE"
],
"un": [
"TEST DOCUMENT TYPE"
]
}
},
"supportedByMemoriav": true,
"languageOfMetadata": {
"name": {
"de": [
"TEST LANGUAGE"
],
"fr": [
"TEST LANGUAGE"
],
"it": [
"TEST LANGUAGE"
],
"un": [
"TEST LANGUAGE"
]
}
},
"institution": {
"name": {
"de": [
"TEST INSTITUTION"
],
"fr": [
"TEST INSTITUTION"
],
"it": [
"TEST INSTITUTION"
],
"un": [
"TEST INSTITUTION"
]
}
},
"periodOfTimeAsYear": "2020",
"scopeAndContent": {
"de": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
],
"fr": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
],
"it": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
],
"un": [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
]
},
"id": "NoRecordSetId"
}
\ No newline at end of file
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