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
libraries
Mapper Service Configuration
Commits
97b6a20d
Commit
97b6a20d
authored
Feb 08, 2021
by
Jonas Waeber
Browse files
Fix issue with missing roles.
parent
ee0908cd
Pipeline
#21405
passed with stage
in 2 minutes and 2 seconds
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/builder/ResourceBuilder.kt
View file @
97b6a20d
...
...
@@ -130,14 +130,14 @@ class ResourceBuilder(
private
fun
hasDigitalObject
():
Boolean
=
digitalObject
!=
null
fun
writeRecord
():
Pair
<
String
,
String
>
{
fun
writeRecord
(
format
:
RDFFormat
):
Pair
<
String
,
String
>
{
return
StringWriter
().
use
{
writer
->
RDFDataMgr
.
write
(
writer
,
record
!!
.
model
,
RDFF
ormat
.
NTRIPLES_UTF8
)
RDFDataMgr
.
write
(
writer
,
record
!!
.
model
,
f
ormat
)
if
(
hasPhysicalObject
())
{
RDFDataMgr
.
write
(
writer
,
physicalObject
!!
.
model
,
RDFF
ormat
.
NTRIPLES_UTF8
)
RDFDataMgr
.
write
(
writer
,
physicalObject
!!
.
model
,
f
ormat
)
}
if
(
hasDigitalObject
())
{
RDFDataMgr
.
write
(
writer
,
digitalObject
!!
.
model
,
RDFF
ormat
.
NTRIPLES_UTF8
)
RDFDataMgr
.
write
(
writer
,
digitalObject
!!
.
model
,
f
ormat
)
}
Pair
(
record
!!
.
resource
.
uri
,
writer
.
toString
().
trim
())
}
...
...
src/main/kotlin/mapping/mappers/TypeFieldMapper.kt
View file @
97b6a20d
...
...
@@ -54,7 +54,7 @@ abstract class TypeFieldMapper : AbstractFieldMapper() {
}
is
StringList
->
sourceElement
.
value
.
forEachIndexed
{
index
,
s
->
if
(
properties
.
size
=
=
index
+
1
)
{
if
(
properties
.
size
>
=
index
+
1
)
{
properties
[
index
].
add
(
Pair
(
field
.
key
,
field
.
toLiteral
(
s
)))
}
else
{
properties
.
add
(
index
,
mutableListOf
(
Pair
(
field
.
key
,
field
.
toLiteral
(
s
))))
...
...
src/test/kotlin/ch/memobase/test/LocalTestRun.kt
View file @
97b6a20d
...
...
@@ -23,6 +23,7 @@ import ch.memobase.settings.HeaderMetadata
import
com.beust.klaxon.Klaxon
import
java.io.File
import
java.io.FileOutputStream
import
org.apache.jena.riot.RDFFormat
import
org.junit.jupiter.api.Disabled
import
org.junit.jupiter.api.Test
import
org.junit.jupiter.api.TestInstance
...
...
@@ -41,6 +42,51 @@ class LocalTestRun {
0
,
0
,
0
,
0
)
@Test
@Disabled
fun
`test
a
single
file`
()
{
val
folder
=
"/home/jonas/memobase/data/snp-001"
val
inputPath
=
"/home/jonas/memobase/data/test/step-2/Fonoteca-18BD1047_A29"
val
outputPath
=
"/home/jonas/memobase/data/test/step-3/snp-001-18BD1047_A29"
val
mappingFile
=
"/config/mapping.yml"
val
klaxon
=
Klaxon
()
val
configurationParser
=
MappingConfigurationParser
(
File
(
folder
+
mappingFile
).
readBytes
())
val
configuration
=
configurationParser
.
get
()
val
item
=
klaxon
.
parse
<
Map
<
String
,
Any
>>(
File
(
inputPath
)).
orEmpty
()
val
builder
=
ResourceBuilder
(
item
,
configuration
,
headerMetadata
.
institutionId
,
headerMetadata
.
recordSetId
,
headerMetadata
.
isPublished
)
val
result
=
builder
.
extractRecordId
()
.
extractRecordTypeValue
()
.
generateRecord
()
.
generatePhysicalObject
()
.
generateDigitalObject
()
.
addDerivedConnection
()
val
writtenResult
=
result
.
writeRecord
(
RDFFormat
.
NTRIPLES_UTF8
)
val
writtenResultTurtle
=
result
.
writeRecord
(
RDFFormat
.
TURTLE_PRETTY
)
FileOutputStream
(
File
(
outputPath
)).
use
{
it
.
bufferedWriter
().
use
{
writer
->
writer
.
write
(
writtenResult
.
second
)
}
}
FileOutputStream
(
File
(
"output.ttl"
)).
use
{
it
.
bufferedWriter
().
use
{
writer
->
writer
.
write
(
writtenResultTurtle
.
second
)
}
}
}
@Test
@Disabled
fun
`test
local
folder`
()
{
...
...
@@ -68,12 +114,12 @@ class LocalTestRun {
headerMetadata
.
isPublished
)
builder
.
extractRecordId
()
builder
.
extractRecordTypeValue
()
.
extractRecordTypeValue
()
.
generateRecord
()
.
generatePhysicalObject
()
.
generateDigitalObject
()
.
addDerivedConnection
()
.
writeRecord
()
.
writeRecord
(
RDFFormat
.
NTRIPLES_UTF8
)
}
.
forEach
{
result
->
FileOutputStream
(
File
(
outputFolder
+
"/"
+
result
.
first
.
substringAfterLast
(
"/"
))).
use
{
...
...
@@ -84,3 +130,4 @@ class LocalTestRun {
}
}
}
src/test/resources/turtleOutput/agent-mapper-with-name-only.ttl
View file @
97b6a20d
...
...
@@ -5,6 +5,15 @@
@prefix
ebucore:
<http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#>
.
@prefix
skos:
<http://www.w3.org/2004/02/skos/core#>
.
_:
b0
a
rico:
CreationRelation
;
rico:
creationRelationHasSource
<https://memobase.ch/record/rs1-1>
;
rico:
creationRelationHasTarget
[
a
rico:
Person
;
rico:
agentIsTargetOfCreationRelation
_:
b0
;
rico:
name
"Hans Zimmer"
]
;
rico:
type
"creator"
.
<https://memobase.ch/record/rs1-1>
a
rico:
Record
;
rdau:
P60451
<https://memobase.ch/institution/mrv>
;
...
...
@@ -19,12 +28,3 @@
rico:
recordResourceOrInstantiationIsSourceOfCreationRelation
_:
b0
;
rico:
type
"Foto"
.
_:
b0
a
rico:
CreationRelation
;
rico:
creationRelationHasSource
<https://memobase.ch/record/rs1-1>
;
rico:
creationRelationHasTarget
[
a
rico:
Person
;
rico:
agentIsTargetOfCreationRelation
_:
b0
;
rico:
name
"Hans Zimmer"
]
;
rico:
type
"creator"
.
Write
Preview
Markdown
is supported
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