From 579dcaacfdbf7c7fd8e102d91c0394d820bf5181 Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Mon, 27 Apr 2020 14:28:34 +0200 Subject: [PATCH] fix @SocketGsonExclude on device and children --- .../smarthut/controller/RangeTriggerController.java | 4 ++-- .../ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmable.java | 2 ++ .../ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java | 2 ++ .../ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switch.java | 2 ++ .../usi/inf/sa4/sanmarinoes/smarthut/models/Switchable.java | 2 ++ .../usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java | 2 ++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeTriggerController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeTriggerController.java index 7043566..655ce4b 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeTriggerController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeTriggerController.java @@ -29,7 +29,7 @@ public class RangeTriggerController { return rangeTriggerRepository.findAllByAutomationId(automationId); } - private RangeTrigger save(RangeTrigger newRL, RangeTriggerSaveRequest s) { + private RangeTrigger save(RangeTrigger newRL, RangeTriggerSaveRequest s) { newRL.setDeviceId(s.getDeviceId()); newRL.setAutomationId(s.getAutomationId()); newRL.setOperator(s.getOperator()); @@ -41,7 +41,7 @@ public class RangeTriggerController { @PostMapping public RangeTrigger create( @Valid @RequestBody RangeTriggerSaveRequest booleanTriggerSaveRequest) { - return save(new RangeTrigger(), booleanTriggerSaveRequest); + return save(new RangeTrigger<>(), booleanTriggerSaveRequest); } @PutMapping diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmable.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmable.java index ab49dd0..6ae3150 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmable.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmable.java @@ -1,6 +1,7 @@ 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.SocketGsonExclude; import java.util.Set; import javax.persistence.*; import javax.validation.constraints.Max; @@ -23,6 +24,7 @@ public class Dimmable extends Switchable implements RangeTriggerable { @ManyToMany(mappedBy = "dimmables", cascade = CascadeType.DETACH) @GsonExclude + @SocketGsonExclude private Set dimmers; /** The light intensity value. Goes from 0 (off) to 100 (on) */ diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java index 9b3d627..e920d2f 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Dimmer.java @@ -1,6 +1,7 @@ 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.SocketGsonExclude; import java.util.HashSet; import java.util.Set; import javax.persistence.*; @@ -15,6 +16,7 @@ public abstract class Dimmer extends InputDevice { @ManyToMany(cascade = CascadeType.DETACH) @GsonExclude + @SocketGsonExclude @JoinTable( name = "dimmer_dimmable", joinColumns = @JoinColumn(name = "dimmer_id"), diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switch.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switch.java index 0768d6b..4b9ef3a 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switch.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switch.java @@ -1,6 +1,7 @@ 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.SocketGsonExclude; import java.util.HashSet; import java.util.Set; import javax.persistence.*; @@ -11,6 +12,7 @@ public class Switch extends InputDevice implements BooleanTriggerable { @ManyToMany(cascade = CascadeType.DETACH) @GsonExclude + @SocketGsonExclude @JoinTable( name = "switch_switchable", joinColumns = @JoinColumn(name = "switch_id"), diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switchable.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switchable.java index 7fbc64a..c7abc7e 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switchable.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Switchable.java @@ -1,6 +1,7 @@ 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.SocketGsonExclude; import java.util.HashSet; import java.util.Set; import javax.persistence.*; @@ -15,6 +16,7 @@ public abstract class Switchable extends OutputDevice { @ManyToMany(mappedBy = "switchables", cascade = CascadeType.DETACH) @GsonExclude + @SocketGsonExclude private Set inputs = new HashSet<>(); protected Switchable(String kind) { diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java index 2dd3772..689c7ee 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Thermostat.java @@ -1,6 +1,7 @@ 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.SocketGsonExclude; import com.google.gson.annotations.SerializedName; import java.math.BigDecimal; import java.util.HashSet; @@ -87,6 +88,7 @@ public class Thermostat extends Switchable implements BooleanTriggerable { @OneToMany(mappedBy = "scene", orphanRemoval = true) @GsonExclude + @SocketGsonExclude private Set> triggers = new HashSet<>(); /** Creates a thermostat with a temperature sensor and its initial OFF state */