diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java index e315ff1..ffd39fa 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/DimmableLightController.java @@ -16,10 +16,10 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/dimmableLight") public class DimmableLightController extends GuestEnabledController { - private DimmableLightRepository dimmableLightRepository; - private SceneRepository sceneRepository; - private StateRepository> stateRepository; - private DeviceService deviceService; + private final DimmableLightRepository dimmableLightRepository; + private final SceneRepository sceneRepository; + private final StateRepository> stateRepository; + private final DeviceService deviceService; @Autowired public DimmableLightController( diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java index 8b7f648..79b61d2 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RoomController.java @@ -6,7 +6,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.RoomSaveRequest; import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import ch.usi.inf.sa4.sanmarinoes.smarthut.service.DeviceService; -import ch.usi.inf.sa4.sanmarinoes.smarthut.service.ThermostatService; import ch.usi.inf.sa4.sanmarinoes.smarthut.utils.Utils; import java.security.Principal; import java.util.*; @@ -20,19 +19,33 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/room") public class RoomController { - @Autowired private RoomRepository roomRepository; + private final RoomRepository roomRepository; - @Autowired private UserRepository userRepository; + private final UserRepository userRepository; - @Autowired private DeviceService deviceService; + private final DeviceService deviceService; - @Autowired private SwitchRepository switchRepository; + private final SwitchRepository switchRepository; - @Autowired private ButtonDimmerRepository buttonDimmerRepository; + private final ButtonDimmerRepository buttonDimmerRepository; - @Autowired private KnobDimmerRepository knobDimmerRepository; + private final KnobDimmerRepository knobDimmerRepository; - @Autowired private ThermostatService thermostatService; + @Autowired + public RoomController( + RoomRepository roomRepository, + UserRepository userRepository, + DeviceService deviceService, + SwitchRepository switchRepository, + ButtonDimmerRepository buttonDimmerRepository, + KnobDimmerRepository knobDimmerRepository) { + this.roomRepository = roomRepository; + this.userRepository = userRepository; + this.deviceService = deviceService; + this.switchRepository = switchRepository; + this.buttonDimmerRepository = buttonDimmerRepository; + this.knobDimmerRepository = knobDimmerRepository; + } private List fetchOwnerOrGuest( final List list, Long hostId, final Principal principal) throws NotFoundException { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SecurityCameraController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SecurityCameraController.java index 1bbc750..9716430 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SecurityCameraController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SecurityCameraController.java @@ -22,12 +22,22 @@ import org.springframework.web.bind.annotation.RestController; @EnableAutoConfiguration @RequestMapping("/securityCamera") public class SecurityCameraController { + private final DeviceService deviceService; + private final SecurityCameraRepository securityCameraService; + private final SceneRepository sceneRepository; + private final StateRepository> stateRepository; - @Autowired private DeviceService deviceService; - @Autowired private SecurityCameraRepository securityCameraService; - @Autowired private SceneRepository sceneRepository; - @Autowired private StateRepository> stateRepository; - @Autowired private RoomRepository roomRepository; + @Autowired + public SecurityCameraController( + DeviceService deviceService, + SecurityCameraRepository securityCameraService, + SceneRepository sceneRepository, + StateRepository> stateRepository) { + this.deviceService = deviceService; + this.securityCameraService = securityCameraService; + this.sceneRepository = sceneRepository; + this.stateRepository = stateRepository; + } private SecurityCamera save( SecurityCamera newSC, SwitchableSaveRequest sc, final Principal principal) { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java index 3833452..ff1677d 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/SensorController.java @@ -5,7 +5,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import ch.usi.inf.sa4.sanmarinoes.smarthut.service.DeviceService; import ch.usi.inf.sa4.sanmarinoes.smarthut.service.SensorService; -import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint; import java.math.BigDecimal; import java.security.Principal; import java.util.*; @@ -19,13 +18,21 @@ import org.springframework.web.bind.annotation.*; @RequestMapping("/sensor") public class SensorController { - @Autowired private DeviceService deviceService; + private final DeviceService deviceService; - @Autowired private SensorRepository sensorRepository; + private final SensorRepository sensorRepository; - @Autowired private SensorSocketEndpoint sensorSocketEndpoint; + private final SensorService sensorService; - @Autowired private SensorService sensorService; + @Autowired + public SensorController( + DeviceService deviceService, + SensorRepository sensorRepository, + SensorService sensorService) { + this.deviceService = deviceService; + this.sensorRepository = sensorRepository; + this.sensorService = sensorService; + } @PostMapping public Sensor create(@Valid @RequestBody SensorSaveRequest s, final Principal principal) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java index be6f897..3d6847f 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Device.java @@ -75,6 +75,14 @@ public abstract class Device { @SocketGsonExclude private Set> states; + public String getKind() { + return kind; + } + + public FlowType getFlowType() { + return flowType; + } + @Transient @GsonExclude private Long fromHostId = null; @Transient @GsonExclude private boolean fromGuest = false;