bunti/src/main/java/de/ctdo/bunti/model/Room.java

105 lines
2.2 KiB
Java

package de.ctdo.bunti.model;
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@Entity
@Table( name = "rooms" )
public final class Room {
private int id;
private String name;
private String floor;
private int xCord;
private int yCord;
private Set<BuntiDevice> devices = new HashSet<BuntiDevice>();
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ROOM_ID", updatable=false, nullable=false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column( name = "roomName")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getxCord() {
return xCord;
}
public void setxCord(int xCord) {
this.xCord = xCord;
}
public int getyCord() {
return yCord;
}
public void setyCord(int yCord) {
this.yCord = yCord;
}
public String getFloor() {
return floor;
}
public void setFloor(String floor) {
this.floor = floor;
}
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, targetEntity = BuntiDevice.class)
@JoinTable(name = "ROOM_BUNTIDEVICE",
joinColumns = { @JoinColumn(name = "ROOM_ID") },
inverseJoinColumns = { @JoinColumn(name = "BUNTIDEVICE_ID") })
public Set<BuntiDevice> getDevices() {
return this.devices;
}
public void setDevices(Set<BuntiDevice> devices) {
this.devices = devices;
}
// @Transient
// public boolean addDevice(BuntiDevice device) {
// return getDevices().add(device);
// }
//
// @Transient
// public boolean removeDevice(BuntiDevice device) {
// return getDevices().remove(device);
// }
//
// @Transient
// public BuntiDevice getDevice(int id) {
// for (BuntiDevice device: getDevices()) {
// if( device.getId() == id) {
// return device;
// }
// }
// return null;
// }
//
// @Transient
// public List<BuntiDevice> getDeviceList() {
// return Collections.unmodifiableList(getDevices());
// }
}