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

Add update propagation for on site institution.

parent f166ccb9
Pipeline #22658 passed with stages
in 4 minutes and 55 seconds
......@@ -182,5 +182,18 @@ class KafkaTopology(
.filter { _, value -> value != null }
.mapValues { value -> JSON.queryToJson(value!!) }
.to(updateTopic)
schema.map { key, value ->
when (value) {
is RecordSetSearchDoc -> KeyValue(
"$key#update",
updateQueryBuilder.updateAccessInstitutionContainer(value.id, value.accessInstitution)
)
else -> KeyValue(key, null)
}
}
.filter { _, value -> value != null }
.mapValues { value -> JSON.queryToJson(value!!) }
.to(updateTopic)
}
}
......@@ -51,6 +51,7 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
var relatedRecordSets = LanguageContainer.EMPTY
var publicationTitles = LanguageContainer.EMPTY
var relatedDocumentTitles = LanguageContainer.EMPTY
val accessInstitutions = mutableListOf<FacetContainer>()
input.values.forEach {
when {
it[RICO.type.localName] == KEYS.LanguageType.metadata -> {
......@@ -74,6 +75,13 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
relatedDocumentTitles = relatedDocumentTitles.add(it[RICO.title.localName])
}
}
it[KEYS.atType] == RICO.RecordResourceHoldingRelation
&& it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.access -> {
val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String
val id = value.substringAfterLast("/")
val names = elasticSearchWrapper.getInstitutionName(id)
accessInstitutions.add(names)
}
}
}
// related record sets which are present in memobase.
......@@ -165,7 +173,8 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
relatedRecordSets = relatedRecordSets,
relatedPublications = publicationTitles,
relatedDocuments = relatedDocumentTitles,
dataImport = dataImport
dataImport = dataImport,
accessInstitution = accessInstitutions
)
}
......
......@@ -17,6 +17,7 @@
*/
package org.memobase.helpers
import org.memobase.model.FacetContainer
import org.memobase.model.LanguageContainer
import org.memobase.model.UpdateQuery
......@@ -49,4 +50,15 @@ class UpdateQueryBuilder {
)
)
}
fun updateAccessInstitutionContainer(recordSet: String, institution: List<FacetContainer>): UpdateQuery {
return UpdateQuery(
recordSetFacetTerm,
recordSet,
"ctx._source['institutionsOnSite'] = params.containers",
mapOf(
Pair("containers", institution)
)
)
}
}
\ No newline at end of file
......@@ -56,27 +56,35 @@ data class RecordSetSearchDoc(
val relatedRecordSets: LanguageContainer?,
val relatedPublications: LanguageContainer?,
val relatedDocuments: LanguageContainer?,
val dataImport: LanguageContainer?
val dataImport: LanguageContainer?,
// Support Field (required to be indexed in the record).
val accessInstitution: List<FacetContainer>
) : Schema(recordSetId) {
companion object {
const val lorem = "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."
const val lorem =
"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."
const val placeholderTitle = "Placeholder Title"
val DEFAULT = RecordSetSearchDoc(
recordSetId = "NoRecordSetId",
name = LanguageContainer.placeholder("TEST_RECORD_SET"),
isPublished = false,
documentType = listOf(FacetContainer(
documentType = listOf(
FacetContainer(
LanguageContainer.placeholder("TEST DOCUMENT TYPE"),
filter = "",
facet = emptyList()
)),
)
),
supportedByMemoriav = true,
languageOfMetadata = listOf(FacetContainer(
languageOfMetadata = listOf(
FacetContainer(
LanguageContainer.placeholder("TEST LANGUAGE"),
filter = "",
facet = emptyList()
)),
)
),
institution = FacetContainer(
LanguageContainer.placeholder("TEST INSTITUTION"),
filter = "INSTITUTION_IDENTIFIER",
......@@ -100,7 +108,8 @@ data class RecordSetSearchDoc(
relatedRecordSets = LanguageContainer.placeholder(placeholderTitle),
relatedPublications = LanguageContainer.placeholder(placeholderTitle),
relatedDocuments = LanguageContainer.placeholder(placeholderTitle),
dataImport = LanguageContainer.placeholder(lorem)
dataImport = LanguageContainer.placeholder(lorem),
accessInstitution = emptyList()
)
......
......@@ -21,5 +21,5 @@ data class UpdateQuery(
val term: String,
val value: String,
val source: String,
val params: Map<String, String>
val params: Map<String, Any>
)
......@@ -27,7 +27,7 @@
{
"@id": "_:b10",
"@type": "https://www.ica.org/standards/RiC/ontology#RecordResourceHoldingRelation",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/recordSet/completeInstitution",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/institution/completeInstitution",
"recordResourceHoldingRelationHasTarget": "https://memobase.ch/recordSet/testComplete",
"type": "original"
},
......@@ -233,14 +233,14 @@
{
"@id": "_:b7",
"@type": "https://www.ica.org/standards/RiC/ontology#RecordResourceHoldingRelation",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/recordSet/completeInstitution",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/institution/completeInstitution",
"recordResourceHoldingRelationHasTarget": "https://memobase.ch/recordSet/testComplete",
"type": "master"
},
{
"@id": "_:b8",
"@type": "https://www.ica.org/standards/RiC/ontology#RecordResourceHoldingRelation",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/recordSet/completeInstitution",
"recordResourceHoldingRelationHasSource": "https://memobase.ch/institution/completeInstitution",
"recordResourceHoldingRelationHasTarget": "https://memobase.ch/recordSet/testComplete",
"type": "access"
},
......
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