Commit 62563e79 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Fix carrier type to format mapping

parent c2ff7a54
......@@ -32,7 +32,7 @@ ext {
}
dependencies {
implementation 'org.memobase:memobase-service-utilities:1.4.0'
implementation 'org.memobase:memobase-service-utilities:1.6.0'
// Logging Framework
implementation "org.apache.logging.log4j:log4j-api:${log4jV}"
......
/*
* mapper-service
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.memobase
class InvalidMappingException(message: String) : Exception(message)
......@@ -63,6 +63,10 @@ class SearchDocTransform {
val accessDigital = Extract.typedEntityByType(digitalRules, "rico:type", "access", "rico:name").flatMap { it.toList() }
val usageDigital = Extract.typedEntityByType(digitalRules, "rico:type", "usage", "schema:sameAs").flatMap { it.toList() }
val format = Extract.carrierType(Extract.getEntitiesFromIds("rico:hasCarrierType", physicalObject, input))
if (format.isEmpty()) {
log.error("Found no carrier types for record $id.")
}
return SearchDoc(
title = Extract.typedEntityByType(recordTitles, "rico:type", "main", "rico:title"),
......@@ -150,7 +154,7 @@ class SearchDocTransform {
creationRelationTypeParam = "creator",
agentTypeParam = "rico:CorporateBody"
),
// TODO: Implemented collected agents!
// TODO: Implement collected agents!
persons = emptyList(),
corporateBodies = emptyList(),
agents = emptyList(),
......@@ -176,7 +180,8 @@ class SearchDocTransform {
physicalObjectNote = Extract.extractLanguageContainer("rico:descriptiveNote", physicalObject?.get("rico:descriptiveNote")),
usageConditionsPhysical = Extract.extractLanguageContainer("rico:conditionsOfUse", physicalObject?.get("rico:conditionsOfUse")),
usagePhysical = Extract.typedEntityByType(physicalRules, "rico:type", "usage", "schema:sameAs").flatMap { it.toList() },
callNumber = Extract.typedEntityByType(physicalIdentifiers, "rico:type", "callNumber", "rico:identifier").flatMap { it.toList() }
callNumber = Extract.typedEntityByType(physicalIdentifiers, "rico:type", "callNumber", "rico:identifier").flatMap { it.toList() },
format = format
)
}
}
......@@ -154,8 +154,13 @@ object Extract {
val agent = getEntitiesFromIds("rico:creationRelationHasTarget", creationRelation, input).first()
val agentType = agent["@type"] as String
if (agentType != agentTypeParam) return@mapNotNull null
val agentName = extractLanguageContainer(agent["@id"] as String, agent["rico:name"]).first()
return@mapNotNull CreatorNameContainer(agentName, name)
val agentName = extractLanguageContainer(agent["@id"] as String, agent["rico:name"])
if (agentName.isEmpty()) {
log.error("Agent/Person/CorporateBody without rico:name found: ${agent["@id"]}.")
null
} else {
return@mapNotNull CreatorNameContainer(agentName.reduce { acc, languageContainer -> acc.merge(languageContainer) }, name)
}
}
}
......@@ -190,4 +195,17 @@ object Extract {
emptyList()
}
}
fun carrierType(items: List<JsonObject>): List<NameContainer> {
return items.map {
listOfStrings(it["schema:sameAs"]).let { value ->
val name = extractLanguageContainer("carrierType", it["rico:name"]).reduce { acc, languageContainer -> acc.merge(languageContainer) }
if (value.isEmpty()) {
NameContainer(name, emptyList())
} else {
NameContainer(name, value)
}
}
}
}
}
......@@ -102,6 +102,7 @@ data class SearchDoc(
val colourPhysical: List<LanguageContainer>,
val usageConditionsPhysical: List<LanguageContainer>,
val physicalObjectNote: List<LanguageContainer>,
val format: List<NameContainer>,
// Combined
val access: List<String>
......
{
"@context": {
"dc": "http://purl.org/dc/elements/1.1/",
"dct": "http://purl.org/dc/terms/",
"ebucore": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#",
"rdau": "http://rdaregistry.info/Elements/u/",
"rico": "https://www.ica.org/standards/RiC/ontology#"
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"rico": "https://www.ica.org/standards/RiC/ontology#",
"schema": "http://schema.org/",
"skos": "http://www.w3.org/2004/02/skos/core#"
},
"@graph": [
{
"@id": "https://memobase.ch/record/BAZ-MEI_49884",
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2",
"@type": "rico:Record",
"dct:created": {
"@id": "_:N75a34824fdfe472aa69225441c3de195"
"@id": "_:N595b45bbae2746f5b76f5ea2c2bcb5ce"
},
"dct:relation": "Bezug Findmittel: Auftragsregister Bd. 6; Bildverzeichnis Bd. 7",
"rdau:P60451": "Memoriav",
"rdau:P60556": {
"@id": "_:Nc0062ea95b3d4334a4ad69d1008febb7"
"dct:spatial": {
"@id": "_:N0757c0915c0a48bd9079de1b86f60c0d"
},
"ebucore:hasGenre": [
{
"@id": "_:N34ab820ac7d043718aaabb6b1d96289b"
},
{
"@id": "_:N49761152ca9a4aea8050f6237ab82aad"
}
],
"rdau:P60441": {
"@id": "_:Nb76d9211442a4a1992c36196bafc47d6"
},
"rdau:P60451": {
"@id": "https://memobase.ch/institution/Memoriav"
},
"rico:descriptiveNote": {
"@language": "de",
"@value": "Villa mit Garten und Brunnen im Vordergrund. Vermutlich von Architekt Walz"
"@value": "Darstellung der Mechanismen, die zur Isolation führen, anhand eines utopischen Beispiels. Überliefert sind: 84 Kleinbild-Diapositive, 1 Audiokassette, Leitfaden (Moderatorenleitfaden für das Informationsprogramm der EKA), 1 Videokopie (VHS, unvollständig), 1 Videokopie (U-Matic, unvollständig)"
},
"rico:hasInstantiation": [
{
"@id": "https://memobase.ch/instantiation/physical/BAZ-MEI_49884-0"
"@id": "https://memobase.ch/instantiation/physical/AFZ-IB_Becker_Audiovisuals_2-0"
},
{
"@id": "https://memobase.ch/instantiation/digital/AFZ-IB_Becker_Audiovisuals_2-1"
}
],
"rico:hasLanguage": {
"@id": "_:N64d25e7479d54620b3de2a9b6f906c37"
},
"rico:hasSubject": [
{
"@id": "_:N5e53b66c10784ac78f60fc7c93099fa9"
},
{
"@id": "_:N6ca9c74982d948f6bd612be965912ac4"
},
{
"@id": "_:Nefa803fc905a4d3e89ebd1b866bc5511"
},
{
"@id": "_:N1eb99944ef214619b80c41025742c5d1"
},
{
"@id": "_:N7cbff9a34e9240eaa3c3fbf4d1624457"
},
{
"@id": "_:N47a40901409a40759ed54bbff2fcb5ed"
},
{
"@id": "_:N4db5f66d90e347b7ba99408d8ae261b8"
},
{
"@id": "_:N74e7ac3b5a8e460a92fbd65130e7f4a8"
},
{
"@id": "https://memobase.ch/instantiation/digital/BAZ-MEI_49884-1"
"@id": "_:N03d072b37386428cbb822cfe83502acf"
},
{
"@id": "_:Na0efff02015f4b5b967017bd40dd96e1"
},
{
"@id": "_:Ne74babca25fa47f290f46f8c1d2588f1"
},
{
"@id": "_:N1c9e6fb25eca468093929cb7708aec2d"
}
],
"rico:hasTitle": {
"@id": "_:N35f354604b1745d59b1ad63a426f6c6a"
"@id": "_:N2c5ab23bbbdc4fa0aa962677a71bef8a"
},
"rico:heldBy": {
"@id": "https://memobase.ch/institution/BAZ"
},
"rico:hasSubject": {
"@id": "_:Bb9117dd4X2D7bccX2D4500X2Daab3X2D37ed2d136c26"
"@id": "https://memobase.ch/institution/AFZ"
},
"rico:identifiedBy": [
{
"@id": "_:Nb9da0f23b09a47e3b9ad346ff8c1d586"
"@id": "_:Nc25355484e8445b2afc96c6f3bfbc240"
},
{
"@id": "_:Nb3242bd2e2af41cbb45e1e9a8361b0d5"
"@id": "_:Nabd38b620aa245c4bf0372972d274ffc"
}
],
"rico:isPartOf": {
"@id": "https://memobase.ch/recordSet/BAZ-B_MEI"
"@id": "https://memobase.ch/recordSet/BECKER"
},
"rico:recordResourceOrInstantiationIsSourceOfCreationRelation": [
{
"@id": "_:Na2fdeb4326984672a63ae7ea468e9d9b"
"@id": "_:N3825a0b068cc4aa380708fa36d41a6cc"
},
{
"@id": "_:Nec9dfa5ba2704cd291cee38aa018e05f"
"@id": "_:N5cc8c495fb2f43abbbb8a5f6fd06fa06"
},
{
"@id": "_:N066c1cd32d4543aa80aab105e5c8005f"
}
],
"rico:regulatedBy": {
"@id": "_:Nfe03ee672afa4223921c79464904b674"
"@id": "_:Nf9a69c1720ae46e99e3c5ea0a869b677"
},
"rico:scopeAndContent": {
"@language": "de",
"@value": "Institutionelle Archive und Bestände / Becker Audiovisuals / 2. Tonbildschauen und Multimediaschauen (1968-1997) / 2.1. Programme zur Schulung, Sensibilisierung und Motivation / 2.1.1. Informationsprogramm Wir in der Schweiz (1973-1978)"
},
"rico:title": {
"@language": "de",
"@value": "«Villa Siegel», Zürich"
"@value": "Wir Menschen auf der Wega (Tonbildschau als Teil des Informationsprogramms der EKA 1978, Version von 1973 in gekürzter Form)"
},
"rico:type": "Foto"
"rico:type": "Tonbildschau",
"schema:sameAs": "http://onlinearchives.ethz.ch/load.aspx?guid=183eddff-1bc6-4e7b-838e-9d6d783c4104"
},
{
"@id": "_:Bb9117dd4X2D7bccX2D4500X2Daab3X2D37ed2d136c26",
"@type": "rico:Agent",
"rico:name": "Chubb"
"@id": "_:N5e53b66c10784ac78f60fc7c93099fa9",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Miteinander und Nebeneinander"
},
{
"@id": "_:Nfe03ee672afa4223921c79464904b674",
"@id": "_:Nf9a69c1720ae46e99e3c5ea0a869b677",
"@type": "rico:Rule",
"rico:name": "BAZ",
"rico:name": "Archiv für Zeitgeschichte (ETH Zürich)",
"rico:regulates": {
"@id": "https://memobase.ch/record/BAZ-MEI_49884"
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2"
},
"rico:type": "holder"
},
{
"@id": "_:N75a34824fdfe472aa69225441c3de195",
"@type": "rico:SingleDate",
"rico:normalizedDateValue": "1921-09-14"
"@id": "_:N3825a0b068cc4aa380708fa36d41a6cc",
"@type": "rico:CreationRelation",
"rico:creationRelationHasSource": {
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2"
},
"rico:creationRelationHasTarget": {
"@id": "_:Ne3d0328957144f8caab632f09e3a3aef"
},
"rico:name": "creator",
"rico:type": "creator"
},
{
"@id": "_:Nc0062ea95b3d4334a4ad69d1008febb7",
"@id": "_:Ne3d0328957144f8caab632f09e3a3aef",
"@type": "rico:Person",
"rico:agentIsTargetOfCreationRelation": {
"@id": "_:N3825a0b068cc4aa380708fa36d41a6cc"
},
"rico:name": {
"@language": "de",
"@value": "Egon Becker"
}
},
{
"@id": "_:N595b45bbae2746f5b76f5ea2c2bcb5ce",
"@type": "rico:DateRange",
"rico:normalizedDateValue": "1978"
},
{
"@id": "_:N5cc8c495fb2f43abbbb8a5f6fd06fa06",
"@type": "rico:CreationRelation",
"rico:creationRelationHasSource": {
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2"
},
"rico:creationRelationHasTarget": {
"@id": "_:N449e31ee4dd64f07a9bed3d431bc60d8"
},
"rico:name": "contributor",
"rico:type": "creator"
},
{
"@id": "_:N449e31ee4dd64f07a9bed3d431bc60d8",
"@type": "rico:Person",
"rico:agentIsTargetOfCreationRelation": {
"@id": "_:N5cc8c495fb2f43abbbb8a5f6fd06fa06"
},
"rico:name": {
"@language": "de",
"@value": "Egon Becker"
}
},
{
"@id": "_:N6ca9c74982d948f6bd612be965912ac4",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Fehlinterpretationen und Missverständnisse"
},
{
"@id": "_:N64d25e7479d54620b3de2a9b6f906c37",
"@type": "rico:Language",
"rico:name": "deutsch",
"rico:type": "content"
},
{
"@id": "_:N0757c0915c0a48bd9079de1b86f60c0d",
"@type": "rico:Place",
"rico:name": "Schweiz"
},
{
"@id": "_:Nefa803fc905a4d3e89ebd1b866bc5511",
"@type": "rico:Agent",
"rico:name": "Sozialpartner der Schweizer Maschinen- und Metallindustrie (SMMI)"
},
{
"@id": "_:N34ab820ac7d043718aaabb6b1d96289b",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Genre",
"skos:prefLabel": "Motivation"
},
{
"@id": "_:N49761152ca9a4aea8050f6237ab82aad",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Genre",
"skos:prefLabel": "Ausbildung"
},
{
"@id": "_:N1eb99944ef214619b80c41025742c5d1",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Arbeit"
},
{
"@id": "_:Nc25355484e8445b2afc96c6f3bfbc240",
"@type": "rico:Identifier",
"rico:identifier": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2",
"rico:type": "main"
},
{
"@id": "_:Nb76d9211442a4a1992c36196bafc47d6",
"@type": "rico:CorporateBody",
"rico:name": {
"@language": "de",
"@value": "Zürich"
"@value": "Becker Audio-Visuals (BAV)"
}
},
{
"@id": "_:N7cbff9a34e9240eaa3c3fbf4d1624457",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Integration und Segregation"
},
{
"@id": "_:N47a40901409a40759ed54bbff2fcb5ed",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Vorurteile und Fremdenhass"
},
{
"@id": "_:N4db5f66d90e347b7ba99408d8ae261b8",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Teilnahme und Teilhabe"
},
{
"@id": "_:N066c1cd32d4543aa80aab105e5c8005f",
"@type": "rico:CreationRelation",
"rico:creationRelationHasSource": {
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2"
},
"rico:creationRelationHasTarget": {
"@id": "_:N511589b7aaa24a06b7c15acf7ce46f25"
},
"rico:name": "contributor",
"rico:type": "creator"
},
{
"@id": "_:N511589b7aaa24a06b7c15acf7ce46f25",
"@type": "rico:Person",
"rico:agentIsTargetOfCreationRelation": {
"@id": "_:N066c1cd32d4543aa80aab105e5c8005f"
}
},
{
"@id": "_:Nb9da0f23b09a47e3b9ad346ff8c1d586",
"@id": "_:N74e7ac3b5a8e460a92fbd65130e7f4a8",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Planet Wega"
},
{
"@id": "_:N03d072b37386428cbb822cfe83502acf",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Ausbeutung"
},
{
"@id": "_:Na0efff02015f4b5b967017bd40dd96e1",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Heimat und Fremdheit"
},
{
"@id": "_:Nabd38b620aa245c4bf0372972d274ffc",
"@type": "rico:Identifier",
"rico:identifier": "MEI_49884",
"rico:type": "callNumber"
"rico:identifier": "IB Becker Audiovisuals / 2",
"rico:type": "original"
},
{
"@id": "_:Ne74babca25fa47f290f46f8c1d2588f1",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Familie"
},
{
"@id": "_:N35f354604b1745d59b1ad63a426f6c6a",
"@id": "_:N1c9e6fb25eca468093929cb7708aec2d",
"@type": "skos:Concept",
"skos:editorialNote": "Ursprungsfeld: Sachthemen",
"skos:prefLabel": "Umgang mit Ausländern"
},
{
"@id": "_:N2c5ab23bbbdc4fa0aa962677a71bef8a",
"@type": "rico:Title",
"rico:title": {
"@language": "de",
"@value": "«Villa Siegel», Zürich"
"@value": "Wir Menschen auf der Wega (Tonbildschau als Teil des Informationsprogramms der EKA 1978, Version von 1973 in gekürzter Form)"
},
"rico:type": "main"
},
{
"@id": "_:Nb3242bd2e2af41cbb45e1e9a8361b0d5",
"@id": "https://memobase.ch/instantiation/physical/AFZ-IB_Becker_Audiovisuals_2-0",
"@type": "rico:Instantiation",
"ebucore:duration": "12'50''",
"rdau:P60558": "farbig",
"rico:hasCarrierType": [
{
"@id": "_:N2827c63553724b119b79f0670ebadc78"
},
{
"@id": "_:N2f834f3f290b49ef8cde1e51b5fd917d"
},
{
"@id": "_:Na64cde976ad44761a50d23af5136d30f"
},
{
"@id": "_:N598543580f4d4472b6c4f244e994cf6b"
}
],
"rico:hasDerivedInstantiation": {
"@id": "https://memobase.ch/instantiation/digital/AFZ-IB_Becker_Audiovisuals_2-1"
},
"rico:identifiedBy": [
{
"@id": "_:N30ff9c7b43e24b7bb8e48d46291043a4"
},
{
"@id": "_:Nd59aabefc1a94ddda7e60921faee5946"
}
],
"rico:instantiates": {
"@id": "https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2"
},
"rico:physicalCharacteristics": [
{
"@language": "de",
"@value": "16:9"
},
{
"@language": "de",
"@value": "mkv ffv1"
}
],
"rico:regulatedBy": {
"@id": "_:N8690f091ae9e4562bce9f6815b2d40eb"
},
"rico:type": "physicalObject"
},
{
"@id": "_:N30ff9c7b43e24b7bb8e48d46291043a4",
"@type": "rico:Identifier",
"rico:identifier": "https://memobase.ch/record/BAZ-MEI_49884",
"rico:type": "main"
"rico:identifier": "IB Becker Audiovisuals / 2",
"rico:type": "callNumber"
},
{
"@id": "_:Na2fdeb4326984672a63ae7ea468e9d9b",
"@type": "rico:CreationRelation",
"rico:creationRelationHasSource": {
"@id": "https://memobase.ch/record/BAZ-MEI_49884"
"@id": "_:N2827c63553724b119b79f0670ebadc78",
"@type": "rico:CarrierType",
"rico:name": {
"@language": "de",
"@value": "Kompaktkassette"
},
"rico:creationRelationHasTarget": {
"@id": "_:Nea2f27453d394da9bf5ea68ddf5efac7"
"rico:resultsFrom": {
"@id": "_:N33c5538b828f418980ee82d1bdc31c76"
},
"rico:type": "Contributor",
"rico:name": "Auftraggeber"
"schema:sameAs": "http://www.wikidata.org/entity/Q149757"
},
{
"@id": "_:Nea2f27453d394da9bf5ea68ddf5efac7",
"@type": "rico:Agent",
"@id": "_:N33c5538b828f418980ee82d1bdc31c76",
"@type": "rico:Activity",
"rico:beginningDate": {
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
"@value": "2020-26-20T06:26:09+0000"
},
"rico:endDate": {
"@type": "http://www.w3.org/2001/XMLSchema#dateTime",
"@value": "2020-26-20T06:26:09+0000"
},
"rico:performedBy": {
"@id": "_:N72221cf2f6134fb295fd7aa2bc948861"
},
"rico:resultsIn": {
"@id": "_:N2827c63553724b119b79f0670ebadc78"
},
"rico:type": "enrichment"
},
{
"@id": "_:N72221cf2f6134fb295fd7aa2bc948861",
"@type": "rico:Mechanism",
"rico:name": "CarrierTypeNormalizer",
"rico:performs": {
"@id": "_:N33c5538b828f418980ee82d1bdc31c76"
}
},
{
"@id": "_:N2f834f3f290b49ef8cde1e51b5fd917d",
"@type": "rico:CarrierType",
"rico:name": {
"@language": "de",
"@value": "Walz"
"@value": "Kleinbild-Diapositive, Audiokassette, VHS, U-Matic, Mittelformat-Diapositive"
}
},
{
"@id": "_:Nec9dfa5ba2704cd291cee38aa018e05f",
"@type": "rico:CreationRelation",
"rico:creationRelationHasSource": {
"@id": "https://memobase.ch/record/BAZ-MEI_49884"
"@id": "_:N8690f091ae9e4562bce9f6815b2d40eb",
"@type": "rico:Rule",
"rico:name": "onsite",