Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
Media Converter
Commits
8ca071e9
Unverified
Commit
8ca071e9
authored
Jul 21, 2020
by
Sebastian Schüpbach
Browse files
extract real eventType from message
Signed-off-by:
Sebastian Schüpbach
<
sebastian.schuepbach@unibas.ch
>
parent
92050c19
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/scala/ch/memobase/models/BinaryResourceMetadata.scala
View file @
8ca071e9
...
@@ -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
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment