diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanConditionController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanConditionController.java index ddcb880..e605043 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanConditionController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanConditionController.java @@ -1,6 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; -import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.BooleanConditionSaveRequest; +import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.BooleanConditionOrTriggerSaveRequest; import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanCondition; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanConditionRepository; @@ -29,7 +29,7 @@ public class BooleanConditionController { return booleanConditionRepository.findAllByAutomationId(automationId); } - private BooleanCondition save(BooleanCondition newRL, BooleanConditionSaveRequest s) { + private BooleanCondition save(BooleanCondition newRL, BooleanConditionOrTriggerSaveRequest s) { newRL.setDeviceId(s.getDeviceId()); newRL.setAutomationId(s.getAutomationId()); newRL.setOn(s.isOn()); @@ -39,13 +39,13 @@ public class BooleanConditionController { @PostMapping public BooleanCondition create( - @Valid @RequestBody BooleanConditionSaveRequest booleanTriggerSaveRequest) { + @Valid @RequestBody BooleanConditionOrTriggerSaveRequest booleanTriggerSaveRequest) { return save(new BooleanCondition(), booleanTriggerSaveRequest); } @PutMapping public BooleanCondition update( - @Valid @RequestBody BooleanConditionSaveRequest booleanTriggerSaveRequest) + @Valid @RequestBody BooleanConditionOrTriggerSaveRequest booleanTriggerSaveRequest) throws NotFoundException { return save( booleanConditionRepository diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanTriggerController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanTriggerController.java index 46af99e..d31b8e2 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanTriggerController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/BooleanTriggerController.java @@ -1,6 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; -import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.BooleanTriggerSaveRequest; +import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.BooleanConditionOrTriggerSaveRequest; import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanTrigger; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.BooleanTriggerRepository; @@ -29,7 +29,7 @@ public class BooleanTriggerController { return booleanTriggerRepository.findAllByAutomationId(automationId); } - private BooleanTrigger save(BooleanTrigger newRL, BooleanTriggerSaveRequest s) { + private BooleanTrigger save(BooleanTrigger newRL, BooleanConditionOrTriggerSaveRequest s) { newRL.setDeviceId(s.getDeviceId()); newRL.setAutomationId(s.getAutomationId()); newRL.setOn(s.isOn()); @@ -39,13 +39,13 @@ public class BooleanTriggerController { @PostMapping public BooleanTrigger create( - @Valid @RequestBody BooleanTriggerSaveRequest booleanTriggerSaveRequest) { + @Valid @RequestBody BooleanConditionOrTriggerSaveRequest booleanTriggerSaveRequest) { return save(new BooleanTrigger(), booleanTriggerSaveRequest); } @PutMapping public BooleanTrigger update( - @Valid @RequestBody BooleanTriggerSaveRequest booleanTriggerSaveRequest) + @Valid @RequestBody BooleanConditionOrTriggerSaveRequest booleanTriggerSaveRequest) throws NotFoundException { return save( booleanTriggerRepository diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeConditionController.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeConditionController.java index 5055c61..ea9a911 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeConditionController.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/controller/RangeConditionController.java @@ -1,6 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; -import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.RangeConditionSaveRequest; +import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.RangeConditionOrTriggerSaveRequest; import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeCondition; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeConditionRepository; @@ -29,7 +29,7 @@ public class RangeConditionController { return rangeConditionRepository.findAllByAutomationId(automationId); } - private RangeCondition save(RangeCondition newRL, RangeConditionSaveRequest s) { + private RangeCondition save(RangeCondition newRL, RangeConditionOrTriggerSaveRequest s) { newRL.setDeviceId(s.getDeviceId()); newRL.setAutomationId(s.getAutomationId()); newRL.setOperator(s.getOperator()); @@ -40,13 +40,13 @@ public class RangeConditionController { @PostMapping public RangeCondition create( - @Valid @RequestBody RangeConditionSaveRequest booleanTriggerSaveRequest) { + @Valid @RequestBody RangeConditionOrTriggerSaveRequest booleanTriggerSaveRequest) { return save(new RangeCondition(), booleanTriggerSaveRequest); } @PutMapping public RangeCondition update( - @Valid @RequestBody RangeConditionSaveRequest booleanTriggerSaveRequest) + @Valid @RequestBody RangeConditionOrTriggerSaveRequest booleanTriggerSaveRequest) throws NotFoundException { return save( rangeConditionRepository 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 a86a386..c8c5589 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 @@ -1,6 +1,6 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.controller; -import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.RangeTriggerSaveRequest; +import ch.usi.inf.sa4.sanmarinoes.smarthut.dto.RangeConditionOrTriggerSaveRequest; import ch.usi.inf.sa4.sanmarinoes.smarthut.error.NotFoundException; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeTrigger; import ch.usi.inf.sa4.sanmarinoes.smarthut.models.RangeTriggerRepository; @@ -29,7 +29,7 @@ public class RangeTriggerController { return rangeTriggerRepository.findAllByAutomationId(automationId); } - private RangeTrigger save(RangeTrigger newRL, RangeTriggerSaveRequest s) { + private RangeTrigger save(RangeTrigger newRL, RangeConditionOrTriggerSaveRequest s) { newRL.setDeviceId(s.getDeviceId()); newRL.setAutomationId(s.getAutomationId()); newRL.setOperator(s.getOperator()); @@ -40,13 +40,13 @@ public class RangeTriggerController { @PostMapping public RangeTrigger create( - @Valid @RequestBody RangeTriggerSaveRequest booleanTriggerSaveRequest) { + @Valid @RequestBody RangeConditionOrTriggerSaveRequest booleanTriggerSaveRequest) { return save(new RangeTrigger(), booleanTriggerSaveRequest); } @PutMapping public RangeTrigger update( - @Valid @RequestBody RangeTriggerSaveRequest booleanTriggerSaveRequest) + @Valid @RequestBody RangeConditionOrTriggerSaveRequest booleanTriggerSaveRequest) throws NotFoundException { return save( rangeTriggerRepository diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionOrTriggerSaveRequest.java similarity index 82% rename from src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java rename to src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionOrTriggerSaveRequest.java index 8f57b22..de5b4c6 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanTriggerSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionOrTriggerSaveRequest.java @@ -4,7 +4,7 @@ import javax.validation.constraints.NotNull; import lombok.Data; @Data -public class BooleanTriggerSaveRequest { +public class BooleanConditionOrTriggerSaveRequest { private long id; diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionSaveRequest.java deleted file mode 100644 index 2abf6e0..0000000 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/BooleanConditionSaveRequest.java +++ /dev/null @@ -1,42 +0,0 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; - -import javax.validation.constraints.NotNull; - -public class BooleanConditionSaveRequest { - - @NotNull private long id; - - @NotNull private Long deviceId; - - @NotNull private Long automationId; - - @NotNull private boolean on; - - public long getId() { - return id; - } - - public Long getDeviceId() { - return deviceId; - } - - public void setDeviceId(Long deviceId) { - this.deviceId = deviceId; - } - - public Long getAutomationId() { - return automationId; - } - - public void setAutomationId(Long automationId) { - this.automationId = automationId; - } - - public boolean isOn() { - return on; - } - - public void setOn(boolean on) { - this.on = on; - } -} diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionOrTriggerSaveRequest.java similarity index 87% rename from src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java rename to src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionOrTriggerSaveRequest.java index 8c43ce6..a222202 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeTriggerSaveRequest.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionOrTriggerSaveRequest.java @@ -5,7 +5,7 @@ import javax.validation.constraints.NotNull; import lombok.Data; @Data -public class RangeTriggerSaveRequest { +public class RangeConditionOrTriggerSaveRequest { private long id; diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionSaveRequest.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionSaveRequest.java deleted file mode 100644 index 65fb3e4..0000000 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/dto/RangeConditionSaveRequest.java +++ /dev/null @@ -1,19 +0,0 @@ -package ch.usi.inf.sa4.sanmarinoes.smarthut.dto; - -import ch.usi.inf.sa4.sanmarinoes.smarthut.models.Operator; -import javax.validation.constraints.NotNull; -import lombok.Data; - -@Data -public class RangeConditionSaveRequest { - - @NotNull private long id; - - @NotNull private Long deviceId; - - @NotNull private Long automationId; - - @NotNull private Operator operator; - - @NotNull private double range; -}