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

extract real eventType from message


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent 92050c19
......@@ -49,16 +49,16 @@ object BinaryResourceMetadata {
*/
def build(msg: String, externalBaseUrl: String): Try[BinaryResourceMetadata] = Try {
val jsonldGraph = ujson.read(msg).obj("@graph").arr.value
val eventType = getEventType(jsonldGraph)
buildKafkaMessage(jsonldGraph, externalBaseUrl, eventType)
buildKafkaMessage(jsonldGraph, externalBaseUrl)
}
private def getEventType(jsonldGraph: ArrayBuffer[Value]): Event = {
// FIXME Get real event type
Update
private def setEventType(eventAsString: String): Event = eventAsString match {
case "Create" => Create
case "Update" => Update
case "Delete" => Delete
}
private def buildKafkaMessage(jsonldGraph: ArrayBuffer[Value], baseUrl: String, eventType: Event): BinaryResourceMetadata = {
private def buildKafkaMessage(jsonldGraph: ArrayBuffer[Value], baseUrl: String): BinaryResourceMetadata = {
jsonldGraph.value
.withFilter(v => isDigitalBinaryObject(v.obj, baseUrl))
.map { o =>
......@@ -66,7 +66,7 @@ object BinaryResourceMetadata {
o("@id").str.substring(s"$baseUrl/instantiation/digital/".length).replaceFirst("/binary", ""),
o("@id").str,
o("hasMimeType").str,
eventType)
setEventType(o("eventType").str))
}
.head
}
......
Supports Markdown
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