Merge branch 'sonar-fix' into 'dev'
Minor code style fixes and global formatter run See merge request sa4-2020/the-sanmarinoes/backend!124
This commit is contained in:
commit
6fce31d1bf
10 changed files with 34 additions and 21 deletions
|
@ -24,7 +24,6 @@ public class ScenePriorityController {
|
|||
|
||||
@Autowired ScenePriorityRepository scenePriorityRepository;
|
||||
|
||||
|
||||
@GetMapping("/{automationId}")
|
||||
public List<ScenePriority> getByAutomationId(@PathVariable long automationId)
|
||||
throws NotFoundException {
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||
|
||||
public interface DimmableRepository<T extends Dimmable> extends SwitchableRepository<T> {
|
||||
}
|
||||
public interface DimmableRepository<T extends Dimmable> extends SwitchableRepository<T> {}
|
||||
|
|
|
@ -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<Device> devices = new HashSet<>();
|
||||
private Set<Device> devices;
|
||||
|
||||
/**
|
||||
* User that owns the house this room is in as a foreign key id. To use when updating and
|
||||
|
|
|
@ -24,7 +24,6 @@ public interface ThermostatRepository extends DeviceRepository<Thermostat> {
|
|||
* @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<BigDecimal> getAverageTemperature(Long thermostatRoomId, Sensor.SensorType sensorType);
|
||||
}
|
||||
|
|
|
@ -13,9 +13,19 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class DevicePropagationService {
|
||||
|
||||
@Autowired private SensorSocketEndpoint endpoint;
|
||||
@Autowired private EagerUserRepository userRepository;
|
||||
@Autowired private DeviceRepository<Device> deviceRepository;
|
||||
private final SensorSocketEndpoint endpoint;
|
||||
private final EagerUserRepository userRepository;
|
||||
private final DeviceRepository<Device> deviceRepository;
|
||||
|
||||
@Autowired
|
||||
public DevicePropagationService(
|
||||
SensorSocketEndpoint endpoint,
|
||||
EagerUserRepository userRepository,
|
||||
DeviceRepository<Device> deviceRepository) {
|
||||
this.endpoint = endpoint;
|
||||
this.userRepository = userRepository;
|
||||
this.deviceRepository = deviceRepository;
|
||||
}
|
||||
|
||||
void propagateUpdateAsGuest(Device device, User host, User guest) {
|
||||
final Set<User> guests = Set.copyOf(host.getGuests());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Device> deviceRepository;
|
||||
@Autowired private DevicePopulationService devicePopulationService;
|
||||
@Autowired private DevicePropagationService devicePropagationService;
|
||||
@Autowired private StateRepository<State<?>> stateRepository;
|
||||
private final DevicePopulationService devicePopulationService;
|
||||
private final DevicePropagationService devicePropagationService;
|
||||
private final StateRepository<State<?>> stateRepository;
|
||||
|
||||
public SceneService(
|
||||
DevicePopulationService devicePopulationService,
|
||||
DevicePropagationService devicePropagationService,
|
||||
StateRepository<State<?>> stateRepository) {
|
||||
this.devicePopulationService = devicePopulationService;
|
||||
this.devicePropagationService = devicePropagationService;
|
||||
this.stateRepository = stateRepository;
|
||||
}
|
||||
|
||||
private List<Device> copyStatesToDevices(Scene fromScene) {
|
||||
final List<Device> updated = new ArrayList<>(fromScene.getStates().size());
|
||||
|
|
|
@ -77,7 +77,9 @@ public class ThermostatService {
|
|||
Optional<BigDecimal> average;
|
||||
|
||||
if (thermostat.isUseExternalSensors()) {
|
||||
average = thermostatRepository.getAverageTemperature(thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE);
|
||||
average =
|
||||
thermostatRepository.getAverageTemperature(
|
||||
thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE);
|
||||
|
||||
} else {
|
||||
return thermostat.getInternalSensorTemperature();
|
||||
|
|
Loading…
Reference in a new issue