added new domain object for idea participation to be able to use an extra confirmed column on the join table between ideas and authors
This commit is contained in:
parent
12895d5bd8
commit
087dc6fb57
src/main/java/se/su/dsv/scipro
data/dataobjects
match/dataobject
project/panels
@ -1,9 +1,12 @@
|
||||
package se.su.dsv.scipro.data.dataobjects;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinTable;
|
||||
@ -14,6 +17,7 @@ import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.match.dataobject.Exemption;
|
||||
import se.su.dsv.scipro.match.dataobject.IdeaParticipation;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@se.su.dsv
|
||||
@ -30,6 +34,9 @@ public class Student extends Role {
|
||||
@JoinTable(name = "Student_Exemption")
|
||||
private Map<ProjectClass, Exemption> exemptions = new HashMap<ProjectClass, Exemption>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.student", cascade=CascadeType.ALL, orphanRemoval=true)
|
||||
private Set<IdeaParticipation> ideaParticipations = new HashSet<IdeaParticipation>();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@ -98,4 +105,20 @@ public class Student extends Role {
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdeaParticipations(Set<IdeaParticipation> ideaParticipations) {
|
||||
this.ideaParticipations = ideaParticipations;
|
||||
}
|
||||
|
||||
public Set<IdeaParticipation> getIdeaParticipations() {
|
||||
return ideaParticipations;
|
||||
}
|
||||
|
||||
public void addIdeaParticipation(IdeaParticipation ip){
|
||||
this.ideaParticipations.add(ip);
|
||||
}
|
||||
|
||||
public void removeIdeaParticipation(IdeaParticipation ip){
|
||||
this.ideaParticipations.remove(ip);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
@ -13,17 +11,16 @@ import javax.persistence.FetchType;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.dataproviders.SortableField;
|
||||
|
||||
import com.mysema.query.annotations.QueryInit;
|
||||
|
||||
@MappedSuperclass
|
||||
public abstract class Idea extends DomainObject {
|
||||
|
||||
@ -33,10 +30,10 @@ public abstract class Idea extends DomainObject {
|
||||
@SortableField
|
||||
private ProjectClass projectClass;
|
||||
|
||||
@ManyToMany
|
||||
@Sort(type=SortType.NATURAL)
|
||||
private SortedSet<Student> authors = new TreeSet<Student>();
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.supervisorIdea")
|
||||
@QueryInit("ideaParticipations.pk.student")
|
||||
private Set<IdeaParticipation> ideaParticipations = new HashSet<IdeaParticipation>();
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
private ApplicationPeriod applicationPeriod;
|
||||
|
||||
@ -128,22 +125,6 @@ public abstract class Idea extends DomainObject {
|
||||
this.watson = watson;
|
||||
}
|
||||
|
||||
public SortedSet<Student> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(SortedSet<Student> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public void addAuthor(Student s){
|
||||
this.authors.add(s);
|
||||
}
|
||||
|
||||
public void removeAuthor(Student s){
|
||||
this.authors.remove(s);
|
||||
}
|
||||
|
||||
public void setIdeaStatus(IdeaStatus ideaStatus) {
|
||||
this.ideaStatus = ideaStatus;
|
||||
}
|
||||
@ -167,4 +148,20 @@ public abstract class Idea extends DomainObject {
|
||||
public void removeKeyword(Keyword k){
|
||||
this.keywords.remove(k);
|
||||
}
|
||||
|
||||
public void setIdeaParticipations(Set<IdeaParticipation> ideaParticipations) {
|
||||
this.ideaParticipations = ideaParticipations;
|
||||
}
|
||||
|
||||
public Set<IdeaParticipation> getIdeaParticipations() {
|
||||
return ideaParticipations;
|
||||
}
|
||||
|
||||
public void addIdeaParticipation(IdeaParticipation ip){
|
||||
this.ideaParticipations.add(ip);
|
||||
}
|
||||
|
||||
public void removeIdeaParticipation(IdeaParticipation ip){
|
||||
this.ideaParticipations.remove(ip);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,89 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.AssociationOverrides;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.mysema.query.annotations.QueryInit;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
|
||||
@Entity
|
||||
@Table(name = "idea_student")
|
||||
@AssociationOverrides({
|
||||
@AssociationOverride(name = "pk.student",
|
||||
joinColumns = @JoinColumn(name = "role_id")),
|
||||
@AssociationOverride(name = "pk.supervisorIdea",
|
||||
joinColumns = @JoinColumn(name = "supervisoridea_id")) })
|
||||
public class IdeaParticipation implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4973657879468781878L;
|
||||
|
||||
@EmbeddedId
|
||||
@QueryInit("student")
|
||||
private IdeaParticipationId pk = new IdeaParticipationId();
|
||||
|
||||
@Column(name = "confirmed")
|
||||
private boolean confirmed;
|
||||
|
||||
public void setConfirmed(boolean confirmed) {
|
||||
this.confirmed = confirmed;
|
||||
}
|
||||
|
||||
public boolean isConfirmed() {
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public void setPk(IdeaParticipationId pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
public IdeaParticipationId getPk() {
|
||||
return pk;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public Student getStudent() {
|
||||
return getPk().getStudent();
|
||||
}
|
||||
|
||||
public void setStudent(Student student) {
|
||||
getPk().setStudent(student);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public SupervisorIdea getSupervisorIdea() {
|
||||
return getPk().getSupervisorIdea();
|
||||
}
|
||||
|
||||
public void setSupervisorIdea(SupervisorIdea idea) {
|
||||
getPk().setSupervisorIdea(idea);
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if(o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
IdeaParticipation idea = (IdeaParticipation) o;
|
||||
|
||||
if(getPk() != null ? !getPk().equals(idea.getPk()):idea.getPk()!=null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (getPk()!=null?getPk().hashCode() : 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
|
||||
@Embeddable
|
||||
public class IdeaParticipationId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5669990817168826918L;
|
||||
|
||||
@ManyToOne
|
||||
private Student student;
|
||||
|
||||
@ManyToOne
|
||||
private SupervisorIdea supervisorIdea;
|
||||
|
||||
public void setStudent(Student student) {
|
||||
this.student = student;
|
||||
}
|
||||
public Student getStudent() {
|
||||
return student;
|
||||
}
|
||||
public void setSupervisorIdea(SupervisorIdea supervisorIdea) {
|
||||
this.supervisorIdea = supervisorIdea;
|
||||
}
|
||||
public SupervisorIdea getSupervisorIdea() {
|
||||
return supervisorIdea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((student == null) ? 0 : student.hashCode());
|
||||
result = prime * result
|
||||
+ ((supervisorIdea == null) ? 0 : supervisorIdea.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IdeaParticipationId other = (IdeaParticipationId) obj;
|
||||
if (student == null) {
|
||||
if (other.student != null)
|
||||
return false;
|
||||
} else if (!student.equals(other.student))
|
||||
return false;
|
||||
if (supervisorIdea == null) {
|
||||
if (other.supervisorIdea != null)
|
||||
return false;
|
||||
} else if (!supervisorIdea.equals(other.supervisorIdea))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ import se.su.dsv.scipro.data.enums.StateOfMind;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.project.pages.ProjectDetailsPage;
|
||||
import se.su.dsv.scipro.project.pages.MyProjectIdeasPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectIdeaStartPage;
|
||||
import se.su.dsv.scipro.springdata.services.ProjectService;
|
||||
|
||||
public class ProjectsOverviewPanel extends Panel {
|
||||
@ -53,7 +54,7 @@ public class ProjectsOverviewPanel extends Panel {
|
||||
setResponsePage(ProjectDetailsPage.class, pp);
|
||||
}
|
||||
if(projects.size()==0){
|
||||
setResponsePage(MyProjectIdeasPage.class);
|
||||
setResponsePage(ProjectIdeaStartPage.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user