Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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
Media-Linker
Commits
c44bdf5e
Commit
c44bdf5e
authored
Sep 01, 2020
by
Jonas Waeber
Browse files
Fix original identifier source.
The original identifier can now be added to any resource.
parent
2655471f
Pipeline
#13536
passed with stages
in 4 minutes and 53 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/KafkaTopology.kt
View file @
c44bdf5e
...
...
@@ -73,7 +73,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
)
val
updateDigitalObjects
=
instantiationBranch
[
0
]
.
mapValues
{
value
->
enrichSftpLocator
(
value
)
}
.
mapValues
{
readOnlyKey
,
value
->
enrichSftpLocator
(
readOnlyKey
,
value
)
}
.
mapValues
{
value
->
val
out
=
StringWriter
()
value
.
first
.
write
(
out
,
Constant
.
rdfParserLang
)
...
...
@@ -120,7 +120,12 @@ class KafkaTopology(private val settings: SettingsLoader) {
}
private
fun
getOriginalIdentifiers
(
res
:
List
<
Resource
>):
List
<
Resource
>
{
return
res
.
filterNot
{
it
.
hasProperty
(
RDF
.
type
,
RICO
.
Identifier
)
&&
it
.
hasProperty
(
RICO
.
type
,
Constant
.
identifierType
)
}
return
res
.
filter
{
it
.
hasProperty
(
RDF
.
type
,
RICO
.
Identifier
)
&&
it
.
hasProperty
(
RICO
.
type
,
Constant
.
identifierType
)
}
}
private
fun
createModel
(
data
:
String
):
Model
{
...
...
@@ -129,47 +134,39 @@ class KafkaTopology(private val settings: SettingsLoader) {
return
model
}
private
fun
enrichSftpLocator
(
data
:
Pair
<
Model
,
List
<
Resource
>>):
Pair
<
Model
,
Report
>
{
private
fun
enrichSftpLocator
(
key
:
String
,
data
:
Pair
<
Model
,
List
<
Resource
>>):
Pair
<
Model
,
Report
>
{
var
link
=
""
val
digitalObject
=
data
.
second
.
first
{
it
.
hasProperty
(
RICO
.
type
,
Constant
.
digitalObject
)
&&
!
it
.
hasProperty
(
EBUCORE
.
locator
)
}
val
addedStatements
=
mutableListOf
<
Statement
>()
for
(
stmt
in
digitalObject
.
listProperties
(
RICO
.
identifiedBy
))
{
if
(
stmt
!=
null
)
{
if
(
stmt
.
`object`
.
isResource
)
{
val
resource
=
stmt
.
`object`
.
asResource
()
if
(
resource
.
hasLiteral
(
RICO
.
type
,
Constant
.
identifierType
))
{
val
value
=
resource
.
getProperty
(
RICO
.
identifier
).
literal
for
(
file
in
files
)
{
if
(
file
.
contains
(
value
.
string
))
{
link
=
"${Constant.sftpPathPrefix}$file"
val
literal
=
data
.
first
.
createLiteral
(
link
)
addedStatements
.
add
(
StatementImpl
(
digitalObject
,
EBUCORE
.
locator
,
literal
))
}
}
}
}
}
// This assumes that there is only one, and always one original identifier present!
val
originalIdentifier
=
try
{
getOriginalIdentifiers
(
data
.
second
)[
0
]
}
catch
(
ex
:
IndexOutOfBoundsException
)
{
return
Pair
(
data
.
first
,
Report
(
key
,
ReportStatus
.
failure
,
ReportMessages
.
noOriginalIdentifier
(
key
)))
}
if
(
addedStatements
.
size
>
0
)
{
data
.
first
.
add
(
addedStatements
)
return
Pair
(
data
.
first
,
Report
(
digitalObject
.
uri
,
ReportStatus
.
success
,
ReportMessages
.
reportSuccess
(
digitalObject
.
uri
,
link
)
val
value
=
originalIdentifier
.
getProperty
(
RICO
.
identifier
)
for
(
file
in
files
)
{
if
(
file
.
contains
(
value
.
string
))
{
link
=
"${Constant.sftpPathPrefix}$file"
val
literal
=
data
.
first
.
createLiteral
(
link
)
data
.
first
.
add
(
StatementImpl
(
digitalObject
,
EBUCORE
.
locator
,
literal
))
return
Pair
(
data
.
first
,
Report
(
digitalObject
.
uri
,
ReportStatus
.
success
,
ReportMessages
.
reportSuccess
(
digitalObject
.
uri
,
link
)
)
)
)
}
else
{
return
Pair
(
data
.
first
,
Report
(
digitalObject
.
id
.
labelString
,
ReportStatus
.
failure
,
ReportMessages
.
reportFailure
(
digitalObject
.
id
.
labelString
)
)
)
}
}
return
Pair
(
data
.
first
,
Report
(
digitalObject
.
uri
,
ReportStatus
.
failure
,
ReportMessages
.
reportFailure
(
digitalObject
.
uri
)
)
)
}
}
src/main/kotlin/reports/ReportMessages.kt
View file @
c44bdf5e
...
...
@@ -8,4 +8,8 @@ object ReportMessages {
fun
reportFailure
(
id
:
String
):
String
{
return
"Could not enrich sftp locator. Did no find a valid file for resource $id."
}
fun
noOriginalIdentifier
(
key
:
String
):
String
{
return
"The record $key does not contain a identifier with rico:type 'original'!"
}
}
\ No newline at end of file
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