diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ScenePriorityController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ScenePriorityController.java index 6e95f75..1449727 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ScenePriorityController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/ScenePriorityController.java @@ -24,7 +24,6 @@ public class ScenePriorityController { @Autowired ScenePriorityRepository scenePriorityRepository; - @GetMapping("/{automationId}") public List getByAutomationId(@PathVariable long automationId) throws NotFoundException { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Connector.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Connector.java index 701a010..325f0dd 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Connector.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Connector.java @@ -1,7 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import java.util.Set; -import java.util.function.BiConsumer; import java.util.function.Function; /** diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Curtains.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Curtains.java index d9e8d98..af2fd40 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Curtains.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Curtains.java @@ -3,8 +3,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import javax.persistence.Entity; /** - * Represents a curtain. The intensity represents how much the curtains are opened, - * 0 is completely closed 100 is completely open + * Represents a curtain. The intensity represents how much the curtains are opened, 0 is completely + * closed 100 is completely open */ @Entity public class Curtains extends Dimmable { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableRepository.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableRepository.java index be791c9..dffbbdb 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableRepository.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/DimmableRepository.java @@ -1,4 +1,3 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; -public interface DimmableRepository extends SwitchableRepository { -} +public interface DimmableRepository extends SwitchableRepository {} diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java index 73d7794..43b7e35 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java @@ -2,7 +2,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude; import io.swagger.annotations.ApiModelProperty; -import java.util.HashSet; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.NotNull; @@ -36,7 +35,7 @@ public class Room { @OneToMany(mappedBy = "room", orphanRemoval = true) @GsonExclude - private Set devices = new HashSet<>(); + private Set devices; /** * User that owns the house this room is in as a foreign key id. To use when updating and diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatRepository.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatRepository.java index 290ebf5..768b882 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatRepository.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/ThermostatRepository.java @@ -24,7 +24,6 @@ public interface ThermostatRepository extends DeviceRepository { * @param thermostatRoomId room ID of the thermostat * @return an optional big decimal, empty if none found */ - @Query( - "SELECT AVG(s.value) FROM Sensor s JOIN s.room r WHERE s.sensor = ?2 AND r.id = ?1") + @Query("SELECT AVG(s.value) FROM Sensor s JOIN s.room r WHERE s.sensor = ?2 AND r.id = ?1") Optional getAverageTemperature(Long thermostatRoomId, Sensor.SensorType sensorType); } diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/DevicePropagationService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/DevicePropagationService.java index 8df15ea..ae004a4 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/DevicePropagationService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/DevicePropagationService.java @@ -13,9 +13,19 @@ import org.springframework.stereotype.Component; @Component public class DevicePropagationService { - @Autowired private SensorSocketEndpoint endpoint; - @Autowired private EagerUserRepository userRepository; - @Autowired private DeviceRepository deviceRepository; + private final SensorSocketEndpoint endpoint; + private final EagerUserRepository userRepository; + private final DeviceRepository deviceRepository; + + @Autowired + public DevicePropagationService( + SensorSocketEndpoint endpoint, + EagerUserRepository userRepository, + DeviceRepository deviceRepository) { + this.endpoint = endpoint; + this.userRepository = userRepository; + this.deviceRepository = deviceRepository; + } void propagateUpdateAsGuest(Device device, User host, User guest) { final Set guests = Set.copyOf(host.getGuests()); diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/JWTUserDetailsService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/JWTUserDetailsService.java index 7dff142..8ab5f8a 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/JWTUserDetailsService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/JWTUserDetailsService.java @@ -1,9 +1,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.service; -import java.util.Set; - import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.UserRepository; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.*; import org.springframework.security.core.userdetails.UserDetails; diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneService.java index 71bf6d1..0fcf1f8 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/SceneService.java @@ -3,16 +3,23 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.service; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.*; import java.util.ArrayList; import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class SceneService { - @Autowired private DeviceRepository deviceRepository; - @Autowired private DevicePopulationService devicePopulationService; - @Autowired private DevicePropagationService devicePropagationService; - @Autowired private StateRepository> stateRepository; + private final DevicePopulationService devicePopulationService; + private final DevicePropagationService devicePropagationService; + private final StateRepository> stateRepository; + + public SceneService( + DevicePopulationService devicePopulationService, + DevicePropagationService devicePropagationService, + StateRepository> stateRepository) { + this.devicePopulationService = devicePopulationService; + this.devicePropagationService = devicePropagationService; + this.stateRepository = stateRepository; + } private List copyStatesToDevices(Scene fromScene) { final List updated = new ArrayList<>(fromScene.getStates().size()); diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/ThermostatService.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/ThermostatService.java index 100d77d..d11e76e 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/ThermostatService.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/service/ThermostatService.java @@ -77,7 +77,9 @@ public class ThermostatService { Optional average; if (thermostat.isUseExternalSensors()) { - average = thermostatRepository.getAverageTemperature(thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE); + average = + thermostatRepository.getAverageTemperature( + thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE); } else { return thermostat.getInternalSensorTemperature();