Code smells fix

This commit is contained in:
Claudio Maggioni (maggicl) 2020-05-24 12:31:39 +02:00
parent 2f9585bd20
commit 838aaf93ee
3 changed files with 23 additions and 23 deletions

View file

@ -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;
}

View file

@ -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) {

View file

@ -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() {