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