package ciai.model; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; import com.fasterxml.jackson.annotation.JsonView; import ciai.view.Views; @Entity public class Edition { @Id @GeneratedValue(strategy = GenerationType.AUTO) @JsonView(Views.StudentView.class) private Long id; @ManyToOne @JoinColumn(name = "degree_id") private Degree degree; @ManyToOne @JoinColumn(name = "course_id") @JsonView(Views.StudentView.class) @JsonManagedReference private Course course; @JsonView(Views.StudentView.class) private int semester; @JsonView(Views.StudentView.class) private int year; @OneToMany(mappedBy = "edition", cascade = CascadeType.ALL) //@JsonView(Views.ProfessorView.class) @JsonManagedReference private Set evaluations; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "enrollment", joinColumns = @JoinColumn(name = "edition_id"), inverseJoinColumns = @JoinColumn(name = "student_id")) //@JsonView(Views.ProfessorView.class) @JsonBackReference private Set students; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "edition_professor", joinColumns = @JoinColumn(name = "edition_id"), inverseJoinColumns = @JoinColumn(name = "professor_id")) //@JsonView(Views.ProfessorView.class) @JsonManagedReference private Set professors; public Edition() { } public Edition(Degree degree, Course course, int semester, int year) { this.setDegree(degree); this.setCourse(course); this.setSemester(semester); this.setYear(year); } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Degree getDegree() { return degree; } public void setDegree(Degree degree) { this.degree = degree; } public Course getCourse() { return course; } public void setCourse(Course course) { this.course = course; } public int getSemester() { return semester; } public void setSemester(int semester) { this.semester = semester; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public Set getEvaluations() { return evaluations; } public void setEvaluations(Set evaluations) { this.evaluations = evaluations; } public Set getStudents() { return students; } public void setStudents(Set students) { this.students = students; } public Set getProfessors() { return professors; } public void setProfessors(Set professors) { this.professors = professors; } }