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

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>
......
This diff is collapsed.
{"title":[{"de":["«Villa Siegel», Zürich"],"fr":[],"it":[],"un":[]}],"type":"Foto","sourceID":"NoSourceIdFound","id":"https://memobase.ch/record/BAZ-MEI_49884","descriptiveNote":[{"de":["Villa mit Garten und Brunnen im Vordergrund. Vermutlich von Architekt Walz"],"fr":[],"it":[],"un":[]}],"relatedMaterial":[{"de":[],"fr":[],"it":[],"un":["Bezug Findmittel: Auftragsregister Bd. 6; Bildverzeichnis Bd. 7"]}],"rightsHolder":[{"de":[],"fr":[],"it":[],"un":["BAZ"]}],"agentSubject":[{"de":[],"fr":[],"it":[],"un":["Chubb"]}],"placeCapture":[{"de":["Zürich"],"fr":[],"it":[],"un":[]}],"place":[{"name":{"de":["Zürich"],"fr":[],"it":[],"un":[]},"facet":["Zürich"]}],"dateCreated":[{"date":"1921-09-14","facet":["0~20.Jahrhundert~","1~20.Jahrhundert~1921-1930#"]}],"institution":[{"name":{"de":["Institution"],"fr":["institution"],"it":["istituzione"],"un":[]},"facet":["https://memobase.ch/institution/MEMORIAV"]}],"recordSet":{"name":{"de":["Bestand"],"fr":["collection"],"it":["fondo"],"un":[]},"facet":["https://memobase.ch/recordSet/EXAMPLE"]},"memoriavClaim":true}
\ No newline at end of file
{"title":[{"de":["Wir Menschen auf der Wega (Tonbildschau als Teil des Informationsprogramms der EKA 1978, Version von 1973 in gekürzter Form)"],"fr":[],"it":[],"un":[]}],"type":"Tonbildschau","sourceID":"IB Becker Audiovisuals / 2","id":"https://memobase.ch/record/AFZ-IB_Becker_Audiovisuals_2","descriptiveNote":[{"de":["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)"],"fr":[],"it":[],"un":[]}],"scopeAndContent":[{"de":["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)"],"fr":[],"it":[],"un":[]}],"rightsHolder":[{"de":[],"fr":[],"it":[],"un":["Archiv für Zeitgeschichte (ETH Zürich)"]}],"sameAs":["http://onlinearchives.ethz.ch/load.aspx?guid=183eddff-1bc6-4e7b-838e-9d6d783c4104"],"genre":[{"name":{"de":[],"fr":[],"it":[],"un":["Motivation"]},"facet":["Motivation"]},{"name":{"de":[],"fr":[],"it":[],"un":["Ausbildung"]},"facet":["Ausbildung"]}],"keywords":[{"name":{"de":[],"fr":[],"it":[],"un":["Miteinander und Nebeneinander"]},"facet":["Miteinander und Nebeneinander"]},{"name":{"de":[],"fr":[],"it":[],"un":["Fehlinterpretationen und Missverständnisse"]},"facet":["Fehlinterpretationen und Missverständnisse"]},{"name":{"de":[],"fr":[],"it":[],"un":["Arbeit"]},"facet":["Arbeit"]},{"name":{"de":[],"fr":[],"it":[],"un":["Integration und Segregation"]},"facet":["Integration und Segregation"]},{"name":{"de":[],"fr":[],"it":[],"un":["Vorurteile und Fremdenhass"]},"facet":["Vorurteile und Fremdenhass"]},{"name":{"de":[],"fr":[],"it":[],"un":["Teilnahme und Teilhabe"]},"facet":["Teilnahme und Teilhabe"]},{"name":{"de":[],"fr":[],"it":[],"un":["Planet Wega"]},"facet":["Planet Wega"]},{"name":{"de":[],"fr":[],"it":[],"un":["Ausbeutung"]},"facet":["Ausbeutung"]},{"name":{"de":[],"fr":[],"it":[],"un":["Heimat und Fremdheit"]},"facet":["Heimat und Fremdheit"]},{"name":{"de":[],"fr":[],"it":[],"un":["Familie"]},"facet":["Familie"]},{"name":{"de":[],"fr":[],"it":[],"un":["Umgang mit Ausländern"]},"facet":["Umgang mit Ausländern"]}],"languageContent":[{"de":[],"fr":[],"it":[],"un":["deutsch"]}],"language":[{"name":{"de":[],"fr":[],"it":[],"un":["deutsch"]},"facet":["deutsch"]}],"personCreator":[{"name":{"de":["Egon Becker"],"fr":[],"it":[],"un":[]},"relation":"creator"},{"name":{"de":["Egon Becker"],"fr":[],"it":[],"un":[]},"relation":"contributor"}],"corporateBodyProducer":[{"de":["Becker Audio-Visuals (BAV)"],"fr":[],"it":[],"un":[]}],"agentSubject":[{"de":[],"fr":[],"it":[],"un":["Sozialpartner der Schweizer Maschinen- und Metallindustrie (SMMI)"]}],"placeRelated":[{"de":[],"fr":[],"it":[],"un":["Schweiz"]}],"place":[{"name":{"de":[],"fr":[],"it":[],"un":["Schweiz"]},"facet":["Schweiz"]}],"dateCreated":[{"date":"1978","facet":["0~20.Jahrhundert~","1~20.Jahrhundert~1971-1980#"]}],"institution":[{"name":{"de":["Institution"],"fr":["institution"],"it":["istituzione"],"un":[]},"facet":["https://memobase.ch/institution/MEMORIAV"]}],"recordSet":{"name":{"de":["Bestand"],"fr":["collection"],"it":["fondo"],"un":[]},"facet":["https://memobase.ch/recordSet/EXAMPLE"]},"memoriavClaim":true,"locator":["http://digitalisate.afz.ethz.ch/?&guid=bccaf22f8d7f453cbd96469bd21840eb"],"accessDigital":["public"],"usageDigital":["http://rightsstatements.org/vocab/InC/1.0/"],"usageDigitalGroup":["Weiternutzbar unter Bedingungen (Copyright)"],"durationPhysical":["12'50''"],"callNumber":["IB Becker Audiovisuals / 2"],"accessPhysical":["onsite"],"physicalCharacteristics":[{"de":["16:9","mkv ffv1"],"fr":[],"it":[],"un":[]}],"colourPhysical":[{"de":[],"fr":[],"it":[],"un":["farbig"]}],"format":[{"name":{"de":["Kompaktkassette"],"fr":[],"it":[],"un":[]},"facet":["http://www.wikidata.org/entity/Q149757"]},{"name":{"de":["Kleinbild-Diapositive, Audiokassette, VHS, U-Matic, Mittelformat-Diapositive"],"fr":[],"it":[],"un":[]},"facet":[]},{"name":{"de":["VHS"],"fr":[],"it":[],"un":[]},"facet":["http://www.wikidata.org/entity/Q183976"]},{"name":{"de":["Diafilm"],"fr":[],"it":[],"un":[]},"facet":["http://www.wikidata.org/entity/Q166816"]}],"access":["onsite","public"]}
\ 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