Commit 3cfd73d9 by Tuukka Kivilahti Committed by Tuukka Kivilahti

moar of database

1 parent d1976590
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.codecrew.moya.model;
import java.util.Calendar;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Group for lectures, so you can set limits how many of these the user can choose
*/
@Entity
@Table(name = "lectures")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Lecture extends GenericEntity {
private static final long serialVersionUID = 3L;
@Column(name = "name")
private String name;
@Lob
@Column(name = "description")
private String description;
@ManyToOne
@JoinColumn(name = "lecture_group_id", referencedColumnName = LectureGroup.ID_COLUMN)
private LectureGroup lectureGroup;
@ManyToMany()
@JoinTable(name = "lecture_participants",
joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "eventuser_id", referencedColumnName = EventUser.ID_COLUMN) })
private List<EventUser> participants;
@ManyToMany()
@JoinTable(name = "lecture_roles",
joinColumns = { @JoinColumn(name = "lecture_id", referencedColumnName = Lecture.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "role_id", referencedColumnName = Role.ID_COLUMN) })
private List<Role> openForRoles;
@Column(name = "max_participants_count")
private Integer maxParticipantsCount;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "start_time")
private Calendar startTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "end_time")
private Calendar endTime;
public Lecture() {
super();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LectureGroup getLectureGroup() {
return lectureGroup;
}
public void setLectureGroup(LectureGroup lectureGroup) {
this.lectureGroup = lectureGroup;
}
public List<EventUser> getParticipants() {
return participants;
}
public void setParticipants(List<EventUser> participants) {
this.participants = participants;
}
public List<Role> getOpenForRoles() {
return openForRoles;
}
public void setOpenForRoles(List<Role> openForRoles) {
this.openForRoles = openForRoles;
}
public Integer getMaxParticipantsCount() {
return maxParticipantsCount;
}
public void setMaxParticipantsCount(Integer maxParticipantsCount) {
this.maxParticipantsCount = maxParticipantsCount;
}
public Calendar getStartTime() {
return startTime;
}
public void setStartTime(Calendar startTime) {
this.startTime = startTime;
}
public Calendar getEndTime() {
return endTime;
}
public void setEndTime(Calendar endTime) {
this.endTime = endTime;
}
public boolean isFull() {
return (getParticipants().size() >= maxParticipantsCount);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.codecrew.moya.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
/**
* Group for lectures, so you can set limits how many of these the user can choose
*/
@Entity
@Table(name = "lecture_groups")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class LectureGroup extends GenericEntity {
private static final long serialVersionUID = 3L;
@Column(name = "select_count")
private Integer selectCount;
@Column(name = "name")
private String name;
@Lob
@Column(name = "description")
private String description;
@OneToMany(mappedBy = "lectureGroup")
private List<Lecture> lectures;
public LectureGroup() {
super();
}
public Integer getSelectCount() {
return selectCount;
}
public void setSelectCount(Integer selectCount) {
this.selectCount = selectCount;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!