Commit e85da650 authored by Matthias's avatar Matthias
Browse files

make tests run

parent 86b718b3
Pipeline #15791 failed with stages
in 1 minute and 59 seconds
...@@ -77,7 +77,7 @@ class KafkaTopology(private val settings: SettingsLoader) { ...@@ -77,7 +77,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
.transformValues(HeaderExtractionTransformSupplier<String>()) .transformValues(HeaderExtractionTransformSupplier<String>())
.mapValues { value -> createModel(value) } .mapValues { value -> createModel(value) }
.mapValues { value -> extractSubjects(value) } .mapValues { value -> extractSubjects(value) }
.mapValues { value -> createThumbnail(value) } //.mapValues { value -> createThumbnail(value) }
.branch( .branch(
Predicate { _, value -> containsDigitalObjectWithoutLocator(value.second) }, Predicate { _, value -> containsDigitalObjectWithoutLocator(value.second) },
Predicate { _, _ -> true } Predicate { _, _ -> true }
...@@ -107,7 +107,7 @@ class KafkaTopology(private val settings: SettingsLoader) { ...@@ -107,7 +107,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
val unchangedWrittenResources = instantiationBranch[1] val unchangedWrittenResources = instantiationBranch[1]
.mapValues { value -> .mapValues { value ->
val out = StringWriter() val out = StringWriter()
value.first.write(out, Constant.rdfParserLang) value.first.first.write(out, Constant.rdfParserLang)
out.toString().trim() out.toString().trim()
} }
...@@ -156,15 +156,14 @@ class KafkaTopology(private val settings: SettingsLoader) { ...@@ -156,15 +156,14 @@ class KafkaTopology(private val settings: SettingsLoader) {
} }
val value = originalIdentifier.getProperty(RICO.identifier).string val value = originalIdentifier.getProperty(RICO.identifier).string
val files = createMediaFileList(data.first.second.recordSetId) val fileExtensions = arrayOf("jpg", "jpeg", "png", "mp3", "mp4")
for (extension in fileExtensions) {
// TODO: instead of looping 'files', loop only given uri below with a fixed set of extensions val filePath = data.first.second.recordSetId + "/" + value + "." + extension
sftpClient.exists(data.first.second.recordSetId + "/" + value + ".jpg") if (sftpClient.exists(filePath)) {
for (file in files) { link = "${Constant.sftpPathPrefix}$filePath"
if (file.contains(value)) {
link = "${Constant.sftpPathPrefix}$file"
val literal = ResourceFactory.createPlainLiteral(link) val literal = ResourceFactory.createPlainLiteral(link)
digitalObject.addLiteral(EBUCORE.locator, literal) digitalObject.addLiteral(EBUCORE.locator, literal)
data.first.first.createLiteral(digitalObject.toString(), true)
return Pair( return Pair(
data.first.first, data.first.first,
Report( Report(
...@@ -173,6 +172,7 @@ class KafkaTopology(private val settings: SettingsLoader) { ...@@ -173,6 +172,7 @@ class KafkaTopology(private val settings: SettingsLoader) {
ReportMessages.reportSuccess(digitalObject.uri, link) ReportMessages.reportSuccess(digitalObject.uri, link)
) )
) )
break
} }
} }
return Pair( return Pair(
...@@ -185,14 +185,17 @@ class KafkaTopology(private val settings: SettingsLoader) { ...@@ -185,14 +185,17 @@ class KafkaTopology(private val settings: SettingsLoader) {
) )
} }
private fun createThumbnail(key: String, data: Pair<Pair<Model, HeaderMetadata>, List<Resource>>): Pair<Model, Report> { /*
private fun createThumbnail(key: data: Pair<Pair<Model, HeaderMetadata>, List<Resource>>): Pair<Model, Report> {
// TODO: same here as in enrichSftpLocator but for thum // TODO: same here as in enrichSftpLocator but for thum
val thumbnail = data.first.first.createResource() val thumbnail = data.first.first.createResource()
thumbnail.addProperty(RDF.type, RICO.Instantiation) thumbnail.addProperty(RDF.type, RICO.Instantiation)
thumbnail.addProperty(RICO.type, "thumbnail") thumbnail.addProperty(RICO.type, "thumbnail")
thumbnail.addProperty(RICO.type, "thumbnail") thumbnail.addProperty(EBUCORE.locator, "locator of file")
return Pair(data.first.first, new Report("id00", "undefined","just a sample report"))
} }
*/
} }
...@@ -17,14 +17,9 @@ ...@@ -17,14 +17,9 @@
*/ */
package org.memobase package org.memobase
import ch.memobase.Effect
import ch.memobase.EffectsRegistry
import ch.memobase.ShutdownMessage
import org.apache.kafka.streams.KafkaStreams import org.apache.kafka.streams.KafkaStreams
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.memobase.settings.SettingsLoader import org.memobase.settings.SettingsLoader
import scala.Some
import scala.runtime.BoxedUnit
import kotlin.system.exitProcess import kotlin.system.exitProcess
class Service(file: String = "app.yml") { class Service(file: String = "app.yml") {
...@@ -44,18 +39,7 @@ class Service(file: String = "app.yml") { ...@@ -44,18 +39,7 @@ class Service(file: String = "app.yml") {
private val appId = settings.kafkaStreamsSettings.getProperty("application.id") private val appId = settings.kafkaStreamsSettings.getProperty("application.id")
val builder = KafkaTopology(settings).prepare() val builder = KafkaTopology(settings).prepare()
private val registry = EffectsRegistry()
private val shutdownEffect = Effect("shutdown", this::exit, Some("Shutting down application"))
fun run() { fun run() {
registry.register(
ShutdownMessage(
appId.replace("-normalization-service", ""),
"normalization-service",
"termination"
), shutdownEffect
)
registry.run(builder, "import-process-admin")
val stream = KafkaStreams(builder.build(), settings.kafkaStreamsSettings) val stream = KafkaStreams(builder.build(), settings.kafkaStreamsSettings)
stream.use { stream.use {
it.start() it.start()
...@@ -63,10 +47,7 @@ class Service(file: String = "app.yml") { ...@@ -63,10 +47,7 @@ class Service(file: String = "app.yml") {
log.info("Service is running.") log.info("Service is running.")
Thread.sleep(10_000L) Thread.sleep(10_000L)
} }
exitProcess(0)
} }
} }
private fun exit(): BoxedUnit {
exitProcess(0)
}
} }
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