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

Implement carrier type as entity

parent 0cf7b176
Pipeline #11619 passed with stages
in 5 minutes and 20 seconds
......@@ -28,6 +28,7 @@ interface IResource {
fun addDate(property: String, value: String)
fun addCreationRelation(relationType: String, relationName: List<Literal>, agentClass: String, properties: List<Pair<String, Literal>>)
fun addRule(type: String, value: List<Pair<String, List<Literal>>>)
fun addRicoCarrierType(names: List<Literal>)
fun addAgent(relation: String, agentType: String, properties: List<Pair<String, Literal>>)
fun langLiteral(text: String, language: String): Literal
fun literal(text: String): Literal
......
......@@ -79,6 +79,15 @@ abstract class RecordResource(institutionId: String) : IResource {
resource.addProperty(resourceProperty, blank)
}
override fun addRicoCarrierType(names: List<Literal>) {
val blank = model.createResource()
blank.addProperty(RDF.type, RICO.CarrierType)
names.forEach {
blank.addProperty(RICO.name, it)
}
resource.addProperty(RICO.hasCarrierType, blank)
}
override fun addSkosConcept(type: String, properties: List<Pair<String, Literal>>) {
val blank = model.createResource()
blank.addProperty(RDF.type, SKOS.Concept)
......
......@@ -130,17 +130,24 @@ object KEYS {
Pair(languages, languageTypes)
)
// Physical Object Keys
const val medium = "medium"
const val physicalCharacteristics = "physicalCharacteristics"
const val colour = "colour"
const val duration = "duration"
// removed
const val displayAspectRatio = "displayAspectRatio"
const val audioTrackConfiguration = "audioTrackConfiguration"
const val playbackSpeed = "playbackSpeed"
const val hasStandard = "hasStandard"
// Carrier Type
const val carrierType = "carrierType"
// Digital Object Keys
const val locator = "locator"
......
......@@ -30,6 +30,7 @@ import org.memobase.mapping.fields.ListField
import org.memobase.mapping.fields.PrefixField
import org.memobase.mapping.fields.SimpleAnnotationField
import org.memobase.mapping.mappers.AgentFieldMapper
import org.memobase.mapping.mappers.CarrierTypeMapper
import org.memobase.mapping.mappers.ConstantFieldMapper
import org.memobase.mapping.mappers.DateFieldMapper
import org.memobase.mapping.mappers.IFieldMapper
......@@ -144,6 +145,8 @@ class MappingConfig(directory: String) {
physicalObjectFieldMappers.addAll(buildRicoConceptMappers(key, entry.value))
KEYS.rights ->
physicalObjectFieldMappers.addAll(buildRuleMappers(entry.value))
KEYS.carrierType ->
physicalObjectFieldMappers.add(buildCarrierTypeMapper(entry))
else -> throw InvalidMappingException("Unknown key '$key' in physical object mapping.")
}
}
......@@ -163,6 +166,10 @@ class MappingConfig(directory: String) {
}
}
private fun buildCarrierTypeMapper(value: Map.Entry<String, Any>): IFieldMapper {
return CarrierTypeMapper(FieldParsers.parseAnnotationField(value))
}
private fun buildAnnotationMappers(value: Any?): IFieldMapper {
return when (val field = FieldParsers.parseAnnotationField(value as Map.Entry<String, Any>)) {
is DirectMapField -> DirectFieldMapper(field)
......
/*
* 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.mapping.mappers
import org.memobase.builder.IResource
import org.memobase.mapping.fields.AnnotationField
import org.memobase.mapping.fields.ConstantField
import org.memobase.mapping.fields.LanguageField
import org.memobase.mapping.fields.ListField
import org.memobase.mapping.fields.MappedAnnotationField
class CarrierTypeMapper(private val field: AnnotationField) : IFieldMapper {
override fun apply(source: Map<String, String>, subject: IResource) {
when (field) {
is MappedAnnotationField ->
source[field.field].let {
if (it != null) {
subject.addRicoCarrierType(listOf(field.toLiteral(it)))
}
}
is ConstantField ->
subject.addRicoCarrierType(listOf(field.toLiteral()))
is LanguageField -> {
val fields = field.toLangLiterals(source)
if (fields.isNotEmpty()) {
subject.addRicoCarrierType(fields)
}
}
is ListField -> {
val fields = field.toLiterals(source)
if (fields.isNotEmpty()) {
subject.addRicoCarrierType(field.toLiterals(source))
}
}
}
}
}
\ No newline at end of file
......@@ -36,6 +36,7 @@ object RICO {
val Person = res("Person")
val CorporateBody = res("CorporateBody")
val Rule = res("Rule")
val CarrierType = res("CarrierType")
val CreationRelation = res("CreationRelation")
......@@ -70,6 +71,7 @@ object RICO {
val identifier: Property = prop("identifier")
val hasSubject: Property = prop( "hasSubject")
val hasCarrierType: Property = prop("hasCarrierType")
val publishedBy: Property = prop("publishedBy")
......
......@@ -251,6 +251,20 @@ class Tests {
"Successfully created a record from source."
)
)
),
KafkaTestParams(
8,
"ID_1",
listOf(
"https://memobase.ch/record/TEST-ID_1"
),
listOf(
Report(
"https://memobase.ch/record/TEST-ID_1",
"SUCCESS",
"Successfully created a record from source."
)
)
)
)
......
app:
institutionId: "TEST"
recordSetId: "TEST_RECORD_SET"
configs: src/test/resources/kafkaTests/8/config
kafka:
streams:
bootstrap.servers: localhost:12345
application.id: test-clinet-1234
topic:
in: test-topic-in
out: test-topic-out
process: test-topic-process
\ No newline at end of file
record:
uri: id
type:
const: Foto
physical:
carrierType: carrier_type
{
"id": "ID_1",
"carrier_type": "16mm"
}
\ No newline at end of file
<https://memobase.ch/instantiation/physical/TEST-ID_1-0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Instantiation> .
<https://memobase.ch/instantiation/physical/TEST-ID_1-0> <https://www.ica.org/standards/RiC/ontology#hasCarrierType> _:B .
<https://memobase.ch/instantiation/physical/TEST-ID_1-0> <https://www.ica.org/standards/RiC/ontology#identifiedBy> _:B .
<https://memobase.ch/instantiation/physical/TEST-ID_1-0> <https://www.ica.org/standards/RiC/ontology#instantiates> <https://memobase.ch/record/TEST-ID_1> .
<https://memobase.ch/instantiation/physical/TEST-ID_1-0> <https://www.ica.org/standards/RiC/ontology#type> "physicalObject" .
<https://memobase.ch/record/TEST-ID_1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Record> .
<https://memobase.ch/record/TEST-ID_1> <https://www.ica.org/standards/RiC/ontology#hasInstantiation> <https://memobase.ch/instantiation/physical/TEST-ID_1-0> .
<https://memobase.ch/record/TEST-ID_1> <https://www.ica.org/standards/RiC/ontology#heldBy> <https://memobase.ch/institution/TEST> .
<https://memobase.ch/record/TEST-ID_1> <https://www.ica.org/standards/RiC/ontology#identifiedBy> _:B .
<https://memobase.ch/record/TEST-ID_1> <https://www.ica.org/standards/RiC/ontology#isPartOf> <https://memobase.ch/recordSet/TEST_RECORD_SET> .
<https://memobase.ch/record/TEST-ID_1> <https://www.ica.org/standards/RiC/ontology#type> "Foto" .
_:B <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#CarrierType> .
_:B <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Identifier> .
_:B <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Identifier> .
_:B <https://www.ica.org/standards/RiC/ontology#identifier> "https://memobase.ch/instantiation/physical/TEST-ID_1-0" .
_:B <https://www.ica.org/standards/RiC/ontology#identifier> "https://memobase.ch/record/TEST-ID_1" .
_:B <https://www.ica.org/standards/RiC/ontology#name> "16mm" .
_:B <https://www.ica.org/standards/RiC/ontology#type> "main" .
_:B <https://www.ica.org/standards/RiC/ontology#type> "main" .
\ No newline at end of file
Supports Markdown
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