Merge branch 'tests' into 'dev'
Code smells fix See merge request sa4-2020/the-sanmarinoes/backend!175
This commit is contained in:
commit
7d06c5d886
3 changed files with 23 additions and 23 deletions
|
@ -18,23 +18,23 @@ public class Automation {
|
|||
@ApiModelProperty(hidden = true)
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", updatable = false, insertable = false)
|
||||
@GsonExclude
|
||||
private User user;
|
||||
|
||||
@Column(name = "user_id", nullable = false)
|
||||
@GsonExclude
|
||||
private Long userId;
|
||||
|
||||
@OneToMany(mappedBy = "automation", orphanRemoval = true, cascade = CascadeType.REMOVE)
|
||||
private Set<Trigger<?>> triggers = new HashSet<>();
|
||||
|
||||
@OneToMany(mappedBy = "automation", cascade = CascadeType.REMOVE)
|
||||
private Set<ScenePriority> scenes = new HashSet<>();
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id", updatable = false, insertable = false)
|
||||
@GsonExclude
|
||||
private User user;
|
||||
|
||||
@OneToMany(mappedBy = "automation", orphanRemoval = true, cascade = CascadeType.REMOVE)
|
||||
private Set<Condition<?>> conditions = new HashSet<>();
|
||||
|
||||
@Column(name = "user_id", nullable = false)
|
||||
@GsonExclude
|
||||
private Long userId;
|
||||
|
||||
@NotEmpty private String name;
|
||||
}
|
||||
|
|
|
@ -21,16 +21,25 @@ public abstract class Condition<D> {
|
|||
return kind;
|
||||
}
|
||||
|
||||
@ManyToOne(targetEntity = Device.class)
|
||||
@JoinColumn(name = "device_id", updatable = false, insertable = false)
|
||||
@GsonExclude
|
||||
private D device;
|
||||
|
||||
@Column(name = "automation_id", nullable = false)
|
||||
private Long automationId;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
@Column(name = "id", updatable = false, nullable = false, unique = true)
|
||||
@ApiModelProperty(hidden = true)
|
||||
private long id;
|
||||
|
||||
@ManyToOne(targetEntity = Device.class)
|
||||
@JoinColumn(name = "device_id", updatable = false, insertable = false)
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "automation_id", updatable = false, insertable = false)
|
||||
@GsonExclude
|
||||
private D device;
|
||||
@EqualsAndHashCode.Exclude
|
||||
private Automation automation;
|
||||
|
||||
/**
|
||||
* The device this condition belongs to, as a foreign key id. To use when updating and inserting
|
||||
|
@ -39,15 +48,6 @@ public abstract class Condition<D> {
|
|||
@Column(name = "device_id", nullable = false)
|
||||
private Long deviceId;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "automation_id", updatable = false, insertable = false)
|
||||
@GsonExclude
|
||||
@EqualsAndHashCode.Exclude
|
||||
private Automation automation;
|
||||
|
||||
@Column(name = "automation_id", nullable = false)
|
||||
private Long automationId;
|
||||
|
||||
public abstract boolean triggered();
|
||||
|
||||
public Condition<D> setAutomationId(Long automationId) {
|
||||
|
|
|
@ -17,12 +17,12 @@ public class RangeCondition extends Condition<RangeTriggerable> {
|
|||
@Getter
|
||||
@Setter
|
||||
@Column(nullable = false)
|
||||
private Operator operator;
|
||||
private double range;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Column(nullable = false)
|
||||
private double range;
|
||||
private Operator operator;
|
||||
|
||||
@Override
|
||||
public boolean triggered() {
|
||||
|
|
Loading…
Reference in a new issue