File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed
src/main/kotlin/infrastructure/digitaltwins Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -48,13 +48,38 @@ class DigitalTwinManager : RoomDigitalTwinManager {
48
48
}
49
49
50
50
override fun deleteRoomDigitalTwin (roomId : RoomID ): Boolean {
51
- TODO (" Not yet implemented" )
52
- }
51
+ fun deleteIncomingRelationships () {
52
+ this .dtClient.listIncomingRelationships(roomId.value).forEach {
53
+ this .dtClient.deleteRelationship(it.sourceId, it.relationshipId)
54
+ }
55
+ }
53
56
54
- override fun findBy (roomId : RoomID ): Room ? {
55
- TODO (" Not yet implemented" )
57
+ fun deleteOutgoingRelationships () {
58
+ this .dtClient.listRelationships(roomId.value, BasicRelationship ::class .java).forEach {
59
+ this .dtClient.deleteRelationship(it.sourceId, it.id)
60
+ }
61
+ }
62
+
63
+ return try {
64
+ deleteIncomingRelationships()
65
+ deleteOutgoingRelationships()
66
+ println (roomId.value)
67
+ dtClient.deleteDigitalTwin(roomId.value)
68
+ true
69
+ } catch (e: ErrorResponseException ) {
70
+ println (e) // log the exception.
71
+ false
72
+ }
56
73
}
57
74
75
+ override fun findBy (roomId : RoomID ): Room ? =
76
+ try {
77
+ this .dtClient.getDigitalTwin(roomId.value, BasicDigitalTwin ::class .java).toRoom()
78
+ } catch (e: ErrorResponseException ) {
79
+ println (e) // log the exception.
80
+ null
81
+ }
82
+
58
83
companion object {
59
84
private const val dtAppIdVariable = " AZURE_CLIENT_ID"
60
85
private const val dtTenantVariable = " AZURE_TENANT_ID"
You can’t perform that action at this time.
0 commit comments