22
22
import entity .room .RoomID ;
23
23
import infrastructure .digitaltwins .adtpresentation .ActuatorAdtPresentation ;
24
24
import infrastructure .digitaltwins .adtpresentation .MedicalTechnologyAdtPresentation ;
25
+ import infrastructure .digitaltwins .query .AdtQuery ;
25
26
import usecase .repository .ActuatorRepository ;
26
27
import usecase .repository .MedicalTechnologyRepository ;
27
28
@@ -69,13 +70,14 @@ public final Optional<MedicalTechnology> findBy(final MedicalTechnologyID medica
69
70
// Get the room if exists
70
71
return new MedicalTechnology (medicalTechnology .getId (),
71
72
medicalTechnology .getType (),
72
- client .query ("SELECT TOP(1) CT.$dtId"
73
- + " FROM DIGITALTWINS T"
74
- + " JOIN CT RELATED T."
75
- + MedicalTechnologyAdtPresentation .IS_LOCATED_IN_OPERATING_ROOM_RELATIONSHIP
76
- + " WHERE T.$dtId = '"
77
- + medicalTechnologyID .getId ()
78
- + "'" ,
73
+ client .query (new AdtQuery ().selectTop (1 , "CT.$dtId" )
74
+ .fromDigitalTwins ("T" )
75
+ .joinRelationship (
76
+ "CT" ,
77
+ "T" ,
78
+ MedicalTechnologyAdtPresentation .IS_LOCATED_IN_OPERATING_ROOM_RELATIONSHIP
79
+ ).where ("T.$dtId = '" + medicalTechnologyID .getId () + "'" )
80
+ .toQuery (),
79
81
String .class ).stream ()
80
82
.findFirst ()
81
83
.map (firstResult ->
@@ -89,15 +91,17 @@ public final Optional<MedicalTechnology> findBy(final MedicalTechnologyID medica
89
91
@ Override
90
92
public final Optional <ActuatorID > findActuatorInRoom (final ActuatorType actuatorType , final RoomID roomID ) {
91
93
return this .applySafeDigitalTwinOperation (Optional .empty (), client ->
92
- client .query ("SELECT TOP(1) CT.$dtId"
93
- + " FROM DIGITALTWINS T "
94
- + "JOIN CT RELATED T."
95
- + ActuatorAdtPresentation .HAS_ACTUATOR_RELATIONSHIP
96
- + " WHERE T.$dtId = '"
97
- + roomID .getId ()
98
- + "' AND CT.type = '"
99
- + ActuatorAdtPresentation .toActuatorDigitalTwinType (actuatorType )
100
- + "'" ,
94
+ client .query (new AdtQuery ().selectTop (1 , "CT.$dtId" )
95
+ .fromDigitalTwins ("T" )
96
+ .joinRelationship (
97
+ "CT" ,
98
+ "T" ,
99
+ ActuatorAdtPresentation .HAS_ACTUATOR_RELATIONSHIP
100
+ ).where ("T.$dtId = '" + roomID .getId () + "'" )
101
+ .and ("CT.type = '"
102
+ + ActuatorAdtPresentation .toActuatorDigitalTwinType (actuatorType )
103
+ + "'"
104
+ ).toQuery (),
101
105
String .class ).stream ()
102
106
.findFirst ()
103
107
.map (firstResult ->
0 commit comments