more Sonarqube fixes

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-09 13:13:31 +02:00
parent a61e43a014
commit bd32a2aebb
6 changed files with 13 additions and 12 deletions

View file

@ -14,7 +14,7 @@ import org.springframework.stereotype.Component;
@Component
public class JWTTokenUtils {
/** The duration in seconds of the validity of a single token */
private static final long JWT_TOKEN_VALIDITY = 5 * 60 * 60;
private static final long JWT_TOKEN_VALIDITY = (long) 5 * 60 * 60;
/** The secret key used to encrypt all JWTs */
@Value("${jwt.secret}")

View file

@ -6,7 +6,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensor;
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.MotionSensorRepository;
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.DeviceService;
import ch.usi.inf.sa4.sanmarinoes.smarthut.service.MotionSensorService;
import ch.usi.inf.sa4.sanmarinoes.smarthut.socket.SensorSocketEndpoint;
import java.security.Principal;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,7 +20,6 @@ public class MotionSensorController {
@Autowired private DeviceService deviceService;
@Autowired private MotionSensorService motionSensorService;
@Autowired private MotionSensorRepository motionSensorRepository;
@Autowired private SensorSocketEndpoint sensorSocketEndpoint;
@PostMapping
public MotionSensor create(

View file

@ -76,8 +76,8 @@ public class SecurityCameraController {
.findByIdAndUsername(deviceId, principal.getName())
.orElseThrow(NotFoundException::new);
State<? extends Switchable> s = d.cloneState();
sceneRepository.findById(sceneId).orElseThrow(NotFoundException::new);
s.setSceneId(sceneId);
final Scene sc = sceneRepository.findById(sceneId).orElseThrow(NotFoundException::new);
s.setSceneId(sc.getId());
if (stateRepository.countByDeviceIdAndSceneId(deviceId, sceneId) > 0)
throw new DuplicateStateException();
return stateRepository.save(s);

View file

@ -4,7 +4,6 @@ import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.SocketGsonExclude;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.*;
@ -13,6 +12,14 @@ import javax.persistence.*;
@Inheritance(strategy = InheritanceType.JOINED)
public abstract class Device {
public Set<Trigger<? extends Device>> getTriggers() {
return triggers;
}
public Set<State<?>> getStates() {
return states;
}
/** Ways a device can behave in the automation flow. For now only input/output */
public enum FlowType {
@SerializedName("INPUT")
@ -38,7 +45,7 @@ public abstract class Device {
@OneToMany(mappedBy = "device", orphanRemoval = true)
@GsonExclude
@SocketGsonExclude
private Set<Trigger<? extends Device>> triggers = new HashSet<>();
private Set<Trigger<? extends Device>> triggers;
/**
* The room this device belongs in, as a foreign key id. To use when updating and inserting from
@ -66,7 +73,7 @@ public abstract class Device {
@OneToMany(mappedBy = "device", orphanRemoval = true)
@GsonExclude
@SocketGsonExclude
private Set<State<?>> states = new HashSet<>();
private Set<State<?>> states;
@Transient @GsonExclude private Long fromHostId = null;

View file

@ -3,7 +3,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import com.google.gson.annotations.SerializedName;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
@Entity
public class RangeTrigger<D extends Device & RangeTriggerable> extends Trigger<D> {
@ -46,7 +45,6 @@ public class RangeTrigger<D extends Device & RangeTriggerable> extends Trigger<D
@Column(nullable = false)
private Operator operator;
@NotNull
@Column(nullable = false)
private double range;

View file

@ -3,7 +3,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
import io.swagger.annotations.ApiModelProperty;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@ -45,7 +44,6 @@ public abstract class Trigger<D extends Device> {
private Automation automation;
@Column(name = "automation_id", nullable = false)
@NotNull
private Long automationId;
public long getId() {