Unverified Commit efd3fb9c authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

process media files without locator and access flag correctly


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent e345d9f5
Pipeline #18285 passed with stages
in 4 minutes and 33 seconds
......@@ -141,7 +141,8 @@ class KafkaTopology(private val settings: SettingsLoader) {
)
}
.branch(
Predicate { _, value -> hasDigitalObjectWithoutLocator(value.second) }, // Indicates a local media file
Predicate { _, value -> hasAccessibleDigitalObjectWithoutLocator(value.second) }, // Indicates a local media file
Predicate { _, value -> hasNoAccessProperty(value.second) },
Predicate { _, value -> isFaroResource(value.second) },
Predicate { _, _ -> true } // Indicates a possible remote media file
)
......@@ -155,7 +156,17 @@ class KafkaTopology(private val settings: SettingsLoader) {
enrichedModel
}
val faroResource = hasLocatorBranch[1]
val resourceWithoutAccessProp = hasLocatorBranch[1]
.mapValues { value ->
log.info("A digital object without access flag encountered!")
updateRecord(
value,
value.third.status,
digitalObjectMessage = "digital object without locator and access property"
)
}
val faroResource = hasLocatorBranch[2]
.mapValues { value ->
updateRecord(
value,
......@@ -164,7 +175,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
)
}
val remoteThumbnails = hasLocatorBranch[2]
val remoteThumbnails = hasLocatorBranch[3]
.mapValues { value ->
updateRecord(
value,
......@@ -177,6 +188,9 @@ class KafkaTopology(private val settings: SettingsLoader) {
Predicate { _, _ -> true } // Indicates a remote media file; check for youtube / vimeo thumbnail fetching
)
sendDownstream(resourceWithoutAccessProp)
report(resourceWithoutAccessProp)
sendDownstream(faroResource)
report(faroResource)
......@@ -320,7 +334,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
return Pair(input, input.first.listSubjects().toList())
}
private fun hasDigitalObjectWithoutLocator(res: List<Resource>): Boolean {
private fun hasAccessibleDigitalObjectWithoutLocator(res: List<Resource>): Boolean {
return res.any {
it.hasProperty(RICO.type, Constant.digitalObject) && !it.hasProperty(EBUCORE.locator) &&
it.hasProperty(RICO.regulatedBy) && !isFaroResource(res)
......@@ -342,6 +356,14 @@ class KafkaTopology(private val settings: SettingsLoader) {
} ?: false
}
private fun hasNoAccessProperty(res: List<Resource>): Boolean {
return res.any {
it.hasProperty(RICO.type, Constant.digitalObject) &&
!it.hasProperty(EBUCORE.locator) &&
!it.hasProperty(RICO.regulatedBy)
}
}
private fun getOriginalIdentifier(record: Resource): String? {
return record.listProperties(RICO.identifiedBy).toList().map { statement -> statement.`object`.asResource() }
.firstOrNull { resource ->
......
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