Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Mapper Service
Commits
f135a1cc
Commit
f135a1cc
authored
Jul 16, 2020
by
Jonas Waeber
Browse files
Implement carrier type as entity
parent
0cf7b176
Pipeline
#11619
passed with stages
in 5 minutes and 20 seconds
Changes
11
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/builder/IResource.kt
View file @
f135a1cc
...
...
@@ -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
...
...
src/main/kotlin/builder/RecordResource.kt
View file @
f135a1cc
...
...
@@ -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
)
...
...
src/main/kotlin/mapping/KEYS.kt
View file @
f135a1cc
...
...
@@ -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"
...
...
src/main/kotlin/mapping/MappingConfig.kt
View file @
f135a1cc
...
...
@@ -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
)
...
...
src/main/kotlin/mapping/mappers/CarrierTypeMapper.kt
0 → 100644
View file @
f135a1cc
/*
* 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
src/main/kotlin/rdf/RICO.kt
View file @
f135a1cc
...
...
@@ -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"
)
...
...
src/test/kotlin/Tests.kt
View file @
f135a1cc
...
...
@@ -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."
)
)
)
)
...
...
src/test/resources/kafkaTest8.yml
0 → 100644
View file @
f135a1cc
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
src/test/resources/kafkaTests/8/config/mapping.yml
0 → 100644
View file @
f135a1cc
record
:
uri
:
id
type
:
const
:
Foto
physical
:
carrierType
:
carrier_type
src/test/resources/kafkaTests/8/input.json
0 → 100644
View file @
f135a1cc
{
"id"
:
"ID_1"
,
"carrier_type"
:
"16mm"
}
\ No newline at end of file
src/test/resources/kafkaTests/8/output1.nt
0 → 100644
View file @
f135a1cc
<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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment