Skip to content

Commit

Permalink
chore: add parser to event parser
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-acampora committed Feb 23, 2023
1 parent eaeeada commit 781fe29
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import entities.events.EmptyEvent
import entities.events.Event
import infrastructure.digitaltwins.events.LifecycleEvents.LifecycleEvent
import infrastructure.digitaltwins.events.RelationshipEvents.RelationshipEvent
import infrastructure.digitaltwins.events.TwinProperties.DTEventTypes.CREATE
import infrastructure.digitaltwins.events.TwinProperties.DTEventTypes.RELATIONSHIP_CREATE
import infrastructure.digitaltwins.events.TwinProperties.DTEventTypes.RELATIONSHIP_DELETE
import infrastructure.digitaltwins.events.TwinProperties.DTEventTypes.UPDATE
Expand All @@ -26,6 +28,7 @@ class DTEventParser : EventParser<String> {

private val updateEventParser = UpdateEventParser()
private val relationshipEventParser = RelationshipEventParser()
private val lifecycleEventParser = LifecycleEventParser()

override fun parseEvent(inputEvent: String): Event<Any> {
val mapper = jacksonObjectMapper()
Expand All @@ -36,6 +39,11 @@ class DTEventParser : EventParser<String> {
mapper.readValue(inputEvent, UpdateTwinEvent::class.java)
)
}
CREATE.type -> {
lifecycleEventParser.manageEvent(
mapper.readValue(inputEvent.replace("$", ""), LifecycleEvent::class.java)
)
}
RELATIONSHIP_CREATE.type -> {
relationshipEventParser.manageCreatedRelationship(
mapper.readValue(inputEvent.replace("$", ""), RelationshipEvent::class.java)
Expand Down

0 comments on commit 781fe29

Please # to comment.