Minor code style fixes and global formatter run
This commit is contained in:
parent
204f7bf423
commit
6e98972a5b
10 changed files with 34 additions and 21 deletions
|
@ -24,7 +24,6 @@ public class ScenePriorityController {
|
||||||
|
|
||||||
@Autowired ScenePriorityRepository scenePriorityRepository;
|
@Autowired ScenePriorityRepository scenePriorityRepository;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/{automationId}")
|
@GetMapping("/{automationId}")
|
||||||
public List<ScenePriority> getByAutomationId(@PathVariable long automationId)
|
public List<ScenePriority> getByAutomationId(@PathVariable long automationId)
|
||||||
throws NotFoundException {
|
throws NotFoundException {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,8 +3,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a curtain. The intensity represents how much the curtains are opened,
|
* Represents a curtain. The intensity represents how much the curtains are opened, 0 is completely
|
||||||
* 0 is completely closed 100 is completely open
|
* closed 100 is completely open
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
public class Curtains extends Dimmable {
|
public class Curtains extends Dimmable {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
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 ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
@ -36,7 +35,7 @@ public class Room {
|
||||||
|
|
||||||
@OneToMany(mappedBy = "room", orphanRemoval = true)
|
@OneToMany(mappedBy = "room", orphanRemoval = true)
|
||||||
@GsonExclude
|
@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
|
* 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
|
* @param thermostatRoomId room ID of the thermostat
|
||||||
* @return an optional big decimal, empty if none found
|
* @return an optional big decimal, empty if none found
|
||||||
*/
|
*/
|
||||||
@Query(
|
@Query("SELECT AVG(s.value) FROM Sensor s JOIN s.room r WHERE s.sensor = ?2 AND r.id = ?1")
|
||||||
"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);
|
Optional<BigDecimal> getAverageTemperature(Long thermostatRoomId, Sensor.SensorType sensorType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,19 @@ import org.springframework.stereotype.Component;
|
||||||
@Component
|
@Component
|
||||||
public class DevicePropagationService {
|
public class DevicePropagationService {
|
||||||
|
|
||||||
@Autowired private SensorSocketEndpoint endpoint;
|
private final SensorSocketEndpoint endpoint;
|
||||||
@Autowired private EagerUserRepository userRepository;
|
private final EagerUserRepository userRepository;
|
||||||
@Autowired private DeviceRepository<Device> deviceRepository;
|
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) {
|
void propagateUpdateAsGuest(Device device, User host, User guest) {
|
||||||
final Set<User> guests = Set.copyOf(host.getGuests());
|
final Set<User> guests = Set.copyOf(host.getGuests());
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package ch.usi.inf.sa4.sanmarinoes.smarthut.service;
|
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.User;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.UserRepository;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.UserRepository;
|
||||||
|
import java.util.Set;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.*;
|
import org.springframework.security.core.*;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
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 ch.usi.inf.sa4.sanmarinoes.smarthut.models.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SceneService {
|
public class SceneService {
|
||||||
|
|
||||||
@Autowired private DeviceRepository<Device> deviceRepository;
|
private final DevicePopulationService devicePopulationService;
|
||||||
@Autowired private DevicePopulationService devicePopulationService;
|
private final DevicePropagationService devicePropagationService;
|
||||||
@Autowired private DevicePropagationService devicePropagationService;
|
private final StateRepository<State<?>> stateRepository;
|
||||||
@Autowired private 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) {
|
private List<Device> copyStatesToDevices(Scene fromScene) {
|
||||||
final List<Device> updated = new ArrayList<>(fromScene.getStates().size());
|
final List<Device> updated = new ArrayList<>(fromScene.getStates().size());
|
||||||
|
|
|
@ -77,7 +77,9 @@ public class ThermostatService {
|
||||||
Optional<BigDecimal> average;
|
Optional<BigDecimal> average;
|
||||||
|
|
||||||
if (thermostat.isUseExternalSensors()) {
|
if (thermostat.isUseExternalSensors()) {
|
||||||
average = thermostatRepository.getAverageTemperature(thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE);
|
average =
|
||||||
|
thermostatRepository.getAverageTemperature(
|
||||||
|
thermostat.getRoomId(), Sensor.SensorType.TEMPERATURE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return thermostat.getInternalSensorTemperature();
|
return thermostat.getInternalSensorTemperature();
|
||||||
|
|
Loading…
Reference in a new issue