UpdateQueryBuilder.kt 1.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package org.memobase.helpers

import org.memobase.model.LanguageContainer

class UpdateQueryBuilder {
    private val institutionFacetTerm = "institution.facet"
    private val recordSetFacetTerm = "recordSet.facet"

    fun updateInstitutionName(institution: String, names: LanguageContainer): UpdateQuery {
        return UpdateQuery(
            institutionFacetTerm,
            institution,
            "ctx._source['institution'][0]['name']['de'] = params.de; ctx._source['institution'][0]['name']['fr'] = params.fr; ctx._source['institution'][0]['name']['it'] = params.it",
            mapOf(
                Pair("de", names.de[0]),
                Pair("fr", names.fr[0]),
                Pair("it", names.it[0])
            )
        )
    }

    fun updateRecordSetName(recordSet: String, names: LanguageContainer): UpdateQuery {
        return UpdateQuery(
            recordSetFacetTerm,
            recordSet,
            "ctx._source['recordSet'][0]['name']['de'] = params.de; ctx._source['recordSet'][0]['name']['fr'] = params.fr; ctx._source['recordSet'][0]['name']['it'] = params.it",
            mapOf(
                Pair("de", names.de[0]),
                Pair("fr", names.fr[0]),
                Pair("it", names.it[0])
            )
        )
    }
}