Commit 2c9a7b09 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix hasSubject not mapping correctly

Added ability to add source field alternatives to entity transforms
with conditional target.
parent e7c6049f
Pipeline #10799 passed with stages
in 12 minutes and 27 seconds
......@@ -5,4 +5,4 @@ tag: "latest"
deploymentName: search-doc-service
configMapName: search-doc-mapping-config
kafkaConfigs: prod-kafka-bootstrap-servers
kafkaConfigs: prod-kafka-bootstrap-servers
\ No newline at end of file
......@@ -77,9 +77,18 @@ class SearchDocTransform(mapping: String) {
transform.conditionalTargets.isNotEmpty() -> {
transform.conditionalTargets.map {
if (entity.containsKey(it.conditionProperty) && entity[it.conditionProperty] == it.conditionPattern) {
val pair = extractPair(entity[transform.source], it.target)
if (pair != null) listOf(pair)
else emptyList()
if (transform.source.contains('|')) {
val sourceFields = transform.source.split('|')
sourceFields.mapNotNull { sourceField ->
extractPair(entity[sourceField], it.target)
}
} else {
val subPair = extractPair(entity[transform.source], it.target)
if (subPair == null)
emptyList()
else
listOf(subPair)
}
} else {
emptyList()
}
......
......@@ -35,6 +35,9 @@
"rico:heldBy": {
"@id": "https://memobase.ch/institution/BAZ"
},
"rico:hasSubject": {
"@id": "_:Bb9117dd4X2D7bccX2D4500X2Daab3X2D37ed2d136c26"
},
"rico:identifiedBy": [
{
"@id": "_:Nb9da0f23b09a47e3b9ad346ff8c1d586"
......@@ -63,6 +66,11 @@
},
"rico:type": "Foto"
},
{
"@id": "_:Bb9117dd4X2D7bccX2D4500X2Daab3X2D37ed2d136c26",
"@type": "rico:Agent",
"rico:name": "Chubb"
},
{
"@id": "_:Nfe03ee672afa4223921c79464904b674",
"@type": "rico:Rule",
......
{"id":"https://memobase.ch/record/BAZ-MEI_49884","dateCreated.date":"1921-09-14","dateCreated.facet":["0~20.Jahrhundert~","1~20.Jahrhundert~1921-1930#"],"relation":"Bezug Findmittel: Auftragsregister Bd. 6; Bildverzeichnis Bd. 7","placeCaptureRaw":{"de":"Zürich"},"descriptiveNote":{"de":"Villa mit Garten und Brunnen im Vordergrund. Vermutlich von Architekt Walz"},"title":{"de":"«Villa Siegel», Zürich"},"AgentContributorRaw.relation":"Auftraggeber","AgentContributorRaw.name":{"de":"Walz"},"CorporateBodyCreatorRaw.relation":"Fotograf","CorporateBodyCreatorRaw.name":{"de":"Atelier Meiner"},"rightsHolder":"BAZ","type.keyword":"Foto"}
\ No newline at end of file
{"id":"https://memobase.ch/record/BAZ-MEI_49884","dateCreated.date":"1921-09-14","dateCreated.facet":["0~20.Jahrhundert~","1~20.Jahrhundert~1921-1930#"],"relation":"Bezug Findmittel: Auftragsregister Bd. 6; Bildverzeichnis Bd. 7","placeCaptureRaw":{"de":"Zürich"},"descriptiveNote":{"de":"Villa mit Garten und Brunnen im Vordergrund. Vermutlich von Architekt Walz"},"title":{"de":"«Villa Siegel», Zürich"},"agentSubjectRaw":"Chubb","AgentContributorRaw.relation":"Auftraggeber","AgentContributorRaw.name":{"de":"Walz"},"CorporateBodyCreatorRaw.relation":"Fotograf","CorporateBodyCreatorRaw.name":{"de":"Atelier Meiner"},"rightsHolder":"BAZ","type.keyword":"Foto"}
\ No newline at end of file
......@@ -65,7 +65,7 @@ entities:
source: "rico:name"
isCreationRelation: true
- property: "rico:hasSubject"
source: "skos:prefLabel"
source: "skos:prefLabel|rico:name"
conditionalTargets:
- conditionPattern: "rico:Agent"
conditionProperty: "@type"
......@@ -75,7 +75,7 @@ entities:
target: "corporateBodySubjectRaw"
- conditionPattern: "rico:Person"
conditionProperty: "@type"
target: "agentSubjectRaw"
target: "personSubjectRaw"
- conditionPattern: "skos:Concept"
conditionProperty: "@type"
target: "keywords"
......
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