Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

Commit 49867e5d authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Refactor report to use the one from the library instead

parent eb921fcd
......@@ -16,6 +16,7 @@
*/
package ch.memobase
import ch.memobase.reporting.Report
import ch.memobase.settings.HeaderMetadata
class IndexReport(
......
......@@ -16,13 +16,14 @@
*/
package ch.memobase
import ch.memobase.reporting.Report
import ch.memobase.settings.HeaderExtractionTransformSupplier
import ch.memobase.settings.SettingsLoader
import com.beust.klaxon.Klaxon
import com.beust.klaxon.KlaxonException
import org.apache.kafka.streams.KeyValue
import org.apache.kafka.streams.StreamsBuilder
import org.apache.logging.log4j.LogManager
import ch.memobase.settings.SettingsLoader
import ch.memobase.settings.HeaderExtractionTransformSupplier
import java.io.StringReader
class KafkaTopology(
......@@ -55,11 +56,13 @@ class KafkaTopology(
emptyList<IndexReport>()
}
}
.map { key, value -> KeyValue("$key-${value.report.step}-${value.metadata.sessionId}", klaxon.toJsonString(value)) }
.map { key, value ->
KeyValue(
"$key-${value.report.step}-${value.metadata.sessionId}",
klaxon.toJsonString(value)
)
}
.to(settings.outputTopic)
return builder
}
}
\ No newline at end of file
/*
* Copyright (C) 2020-2021 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 ch.memobase
import com.beust.klaxon.Klaxon
import java.time.LocalDateTime
data class Report(
val id: String,
val status: String,
val message: String,
val step: String,
val timestamp: String
) {
fun toJson(): String {
return Klaxon().toJsonString(this)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Report
if (id != other.id) return false
if (status != other.status) return false
if (message != other.message) return false
if (step != other.step) return false
return true
}
override fun hashCode(): Int {
var result = id.hashCode()
result = 31 * result + status.hashCode()
result = 31 * result + message.hashCode()
result = 31 * result + step.hashCode()
return result
}
}
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