Merge branch 'master' of https://git.bukova.info/repos/git/isspst
This commit is contained in:
@@ -40,7 +40,12 @@ public abstract class BaseDaoJPA<T> implements BaseDao<T> {
|
||||
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
sessionFactory.getCurrentSession().delete(entity);
|
||||
try {
|
||||
sessionFactory.getCurrentSession().delete(entity);
|
||||
} catch (NonUniqueObjectException e) {
|
||||
Object o = sessionFactory.getCurrentSession().merge(entity);
|
||||
sessionFactory.getCurrentSession().delete(o);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
@Entity
|
||||
@@ -18,6 +25,14 @@ public class Building extends BaseData implements DataModel {
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "building", orphanRemoval = true)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Room> rooms;
|
||||
|
||||
public Building() {
|
||||
rooms = new ArrayList<Room>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the code
|
||||
@@ -64,4 +79,22 @@ public class Building extends BaseData implements DataModel {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<Room> getRooms() {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public void setRooms(List<Room> rooms) {
|
||||
this.rooms = rooms;
|
||||
}
|
||||
|
||||
public void addRoom(Room room) {
|
||||
room.setBuilding(this);
|
||||
rooms.add(room);
|
||||
}
|
||||
|
||||
public void removeRoom(Room room) {
|
||||
rooms.remove(room);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ROOM")
|
||||
public class Room {
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
@GeneratedValue
|
||||
private int id;
|
||||
@Column(name = "CODE")
|
||||
private String code;
|
||||
@Column(name = "SHORTCUT")
|
||||
private String shortcut;
|
||||
@Column(name = "NAME")
|
||||
private String name;
|
||||
@Column(name = "FLOOR")
|
||||
private Integer floor;
|
||||
@Column(name = "NUMBER")
|
||||
private Integer number;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "BUILDING_ID")
|
||||
private Building building;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getShortcut() {
|
||||
return shortcut;
|
||||
}
|
||||
|
||||
public void setShortcut(String shortcut) {
|
||||
this.shortcut = shortcut;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
public void setFloor(Integer floor) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Integer number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Building getBuilding() {
|
||||
return building;
|
||||
}
|
||||
|
||||
public void setBuilding(Building building) {
|
||||
this.building = building;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
return ((o instanceof Room) && (((Room)o).getId() == this.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package info.bukova.isspst.ui.buildings;
|
||||
|
||||
import info.bukova.isspst.data.Building;
|
||||
import info.bukova.isspst.data.Room;
|
||||
import info.bukova.isspst.ui.FormViewModel;
|
||||
|
||||
import org.zkoss.bind.annotation.BindingParam;
|
||||
import org.zkoss.bind.annotation.Command;
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.bind.annotation.NotifyChange;
|
||||
|
||||
public class BuildingForm extends FormViewModel<Building> {
|
||||
|
||||
@@ -11,5 +15,18 @@ public class BuildingForm extends FormViewModel<Building> {
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange("dataBean")
|
||||
public void addRoom() {
|
||||
Room r = new Room();
|
||||
getDataBean().addRoom(r);
|
||||
}
|
||||
|
||||
@Command
|
||||
@NotifyChange("dataBean")
|
||||
public void removeRoom(@BindingParam("room") Room room) {
|
||||
getDataBean().getRooms().remove(room);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
|
||||
return;
|
||||
}
|
||||
|
||||
getDataBean().removeMember(u);
|
||||
workgroupService.removeMember(getDataBean(), u);
|
||||
|
||||
if (!target.equals("users")) {
|
||||
moveUser(u.getMember(), event);
|
||||
|
||||
Reference in New Issue
Block a user