Början till peer-kod
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@278 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
d53e8e9137
commit
c086317e1a
pom.xml
src/main
java/se/su/dsv/scipro
SciProApplication.java
peer
data
dao
interfaces
AnswerDao.javaPeerQueueDao.javaPeerRequestDao.javaPeerReviewDao.javaQuestionDao.javaQuestionOptionDao.javaReviewRatingDao.javaReviewTemplateDao.java
jpa
dataobjects
Answer.javaPeerQueue.javaPeerRequest.javaPeerReview.javaQuestion.javaQuestionOption.javaReviewRating.javaReviewTemplate.java
entitylisteners
enums
pages
resources
3
pom.xml
3
pom.xml
@ -123,7 +123,7 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-entitymanager</artifactId>
|
||||
<version>3.5.6-Final</version>
|
||||
<version>3.6.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@ -256,6 +256,7 @@
|
||||
</testResources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<version>2.3.2</version>
|
||||
<inherited>true</inherited>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
@ -18,6 +18,7 @@ import se.su.dsv.scipro.basepages.SystemSettingsPage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LoginPage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
import se.su.dsv.scipro.message.pages.MessagePage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerTestPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectPage;
|
||||
import se.su.dsv.scipro.repository.RepositoryApplication;
|
||||
import se.su.dsv.scipro.repository.pages.ProjectFilePage;
|
||||
@ -74,6 +75,7 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
mountBookmarkablePage("logout", LogoutPage.class);
|
||||
mountBookmarkablePage("project", ProjectPage.class);
|
||||
mountBookmarkablePage("admin/settings/", SystemSettingsPage.class);
|
||||
mountBookmarkablePage("peer", PeerTestPage.class);
|
||||
mountBookmarkablePage("mess", MessagePage.class);
|
||||
|
||||
mount(new HybridUrlCodingStrategy("schedule", SchedulePage.class));
|
||||
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Answer;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface AnswerDao extends Dao<Answer> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerQueue;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface PeerQueueDao extends Dao<PeerQueue> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LazyDeleteDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface PeerRequestDao extends LazyDeleteDao<PeerRequest> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LazyDeleteDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface PeerReviewDao extends LazyDeleteDao<PeerReview> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface QuestionDao extends Dao<Question> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface QuestionOptionDao extends Dao<QuestionOption> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewRating;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface ReviewRatingDao extends Dao<ReviewRating> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LazyDeleteDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate;
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface ReviewTemplateDao extends LazyDeleteDao<ReviewTemplate> {
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Answer;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.AnswerDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("answerDao")
|
||||
public class AnswerDaoJPAImp extends AbstractDaoJPAImp<Answer> implements
|
||||
AnswerDao {
|
||||
|
||||
public AnswerDaoJPAImp() {
|
||||
super(Answer.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerQueue;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerQueueDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("peerQueueDao")
|
||||
public class PeerQueueDaoJPAImp extends AbstractDaoJPAImp<PeerQueue> implements
|
||||
PeerQueueDao {
|
||||
|
||||
public PeerQueueDaoJPAImp() {
|
||||
super(PeerQueue.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.LazyDeleteAbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerRequestDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("peerRequestDao")
|
||||
public class PeerRequestDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<PeerRequest> implements
|
||||
PeerRequestDao {
|
||||
|
||||
public PeerRequestDaoJPAImp() {
|
||||
super(PeerRequest.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.LazyDeleteAbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("peerReviewDao")
|
||||
public class PeerReviewDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<PeerReview> implements
|
||||
PeerReviewDao {
|
||||
|
||||
public PeerReviewDaoJPAImp() {
|
||||
super(PeerReview.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.QuestionDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("questionDao")
|
||||
public class QuestionDaoJPAImp extends AbstractDaoJPAImp<Question> implements
|
||||
QuestionDao {
|
||||
|
||||
public QuestionDaoJPAImp() {
|
||||
super(Question.class);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Question save(Question question){
|
||||
// validate(question);
|
||||
// return super.save(question);
|
||||
// }
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.QuestionOptionDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("questionOptionDao")
|
||||
public class QuestionOptionDaoJPAImp extends AbstractDaoJPAImp<QuestionOption> implements
|
||||
QuestionOptionDao {
|
||||
|
||||
public QuestionOptionDaoJPAImp() {
|
||||
super(QuestionOption.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewRating;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewRatingDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("reviewRarintDao")
|
||||
public class ReviewRatingDaoJPAImp extends AbstractDaoJPAImp<ReviewRating> implements
|
||||
ReviewRatingDao {
|
||||
|
||||
public ReviewRatingDaoJPAImp() {
|
||||
super(ReviewRating.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.LazyDeleteAbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewTemplateDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Repository("reviewTemplateDao")
|
||||
public class ReviewTemplateDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<ReviewTemplate> implements
|
||||
ReviewTemplateDao {
|
||||
|
||||
public ReviewTemplateDaoJPAImp() {
|
||||
super(ReviewTemplate.class);
|
||||
}
|
||||
|
||||
}
|
137
src/main/java/se/su/dsv/scipro/peer/data/dataobjects/Answer.java
Normal file
137
src/main/java/se/su/dsv/scipro/peer/data/dataobjects/Answer.java
Normal file
@ -0,0 +1,137 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
import se.su.dsv.scipro.peer.data.entitylisteners.AnswerValidationListener;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="answer")
|
||||
@EntityListeners({AnswerValidationListener.class})
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class Answer extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 2138276813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private PeerReview peerReview;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private Question question;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=true)
|
||||
private String freeTextAnswer;
|
||||
|
||||
@ManyToOne(optional=true)
|
||||
private QuestionOption radioChoice;
|
||||
|
||||
private boolean choosenNotApplicable = false;
|
||||
|
||||
public Answer() {}
|
||||
public Answer(PeerReview peerReview, Question question){
|
||||
this.peerReview = peerReview;
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PeerReview getPeerReview() {
|
||||
return peerReview;
|
||||
}
|
||||
|
||||
public void setPeerReview(PeerReview peerReview) {
|
||||
this.peerReview = peerReview;
|
||||
}
|
||||
|
||||
public Question getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(Question question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public String getFreeTextAnswer() {
|
||||
return freeTextAnswer;
|
||||
}
|
||||
|
||||
public void setFreeTextAnswer(String freeTextAnswer) {
|
||||
this.freeTextAnswer = freeTextAnswer;
|
||||
}
|
||||
|
||||
public QuestionOption getRadioChoice() {
|
||||
return radioChoice;
|
||||
}
|
||||
|
||||
public void setRadioChoice(QuestionOption radioChoice) {
|
||||
this.radioChoice = radioChoice;
|
||||
}
|
||||
|
||||
public void setChoosenNotApplicable(boolean choosenNotApplicable) {
|
||||
this.choosenNotApplicable = choosenNotApplicable;
|
||||
}
|
||||
|
||||
public boolean isChoosenNotApplicable() {
|
||||
return choosenNotApplicable;
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
Answer other = (Answer) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="peer_queue")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class PeerQueue extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
//TODO Implement this
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
PeerQueue other = (PeerQueue) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.LazyDeletableDomainObject;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.peer.enums.RequestStatus;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="peer_request")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class PeerRequest extends LazyDeletableDomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476815877870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
// @ManyToOne(optional=false) We can get this information via project-attribute
|
||||
// private ProjectClass projectClass;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=true)
|
||||
private String comment;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private Project project;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private Student requester;
|
||||
|
||||
@ManyToOne(optional=true) //Might possibly/probably want to set this to false
|
||||
private FileDescription file;
|
||||
|
||||
@ManyToOne(optional=true)
|
||||
private ReviewTemplate reviewTemplate;
|
||||
|
||||
@OneToMany(mappedBy="peerRequest")
|
||||
private List<PeerReview> peerReviews = new ArrayList<PeerReview>(1);
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private RequestStatus status = RequestStatus.WAITING;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public Student getRequester() {
|
||||
return requester;
|
||||
}
|
||||
|
||||
public void setRequester(Student requester) {
|
||||
this.requester = requester;
|
||||
}
|
||||
|
||||
public FileDescription getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(FileDescription file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public ReviewTemplate getReviewTemplate() {
|
||||
return reviewTemplate;
|
||||
}
|
||||
|
||||
public void setReviewTemplate(ReviewTemplate reviewTemplate) {
|
||||
this.reviewTemplate = reviewTemplate;
|
||||
}
|
||||
|
||||
public List<PeerReview> getPeerReviews() {
|
||||
return peerReviews;
|
||||
}
|
||||
|
||||
public void setPeerReviews(List<PeerReview> peerReviews) {
|
||||
this.peerReviews = peerReviews;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status the status to set
|
||||
*/
|
||||
public void setStatus(RequestStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public RequestStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
PeerRequest other = (PeerRequest) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dataobjects.LazyDeletableDomainObject;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="peer_review")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class PeerReview extends LazyDeletableDomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private Student reviewer;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private Project project;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private PeerRequest peerRequest;
|
||||
|
||||
@OneToMany(mappedBy="peerReview", orphanRemoval=true, cascade=CascadeType.ALL)
|
||||
private List<Answer> answers = new ArrayList<Answer>();
|
||||
|
||||
@OneToOne(optional=true)
|
||||
private FileDescription file;
|
||||
|
||||
@Lob
|
||||
private String comment;
|
||||
|
||||
@OneToOne(optional=true, mappedBy="peerReview")
|
||||
private ReviewRating reviewRating;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Student getReviewer() {
|
||||
return reviewer;
|
||||
}
|
||||
|
||||
public void setReviewer(Student reviewer) {
|
||||
this.reviewer = reviewer;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public PeerRequest getPeerRequest() {
|
||||
return peerRequest;
|
||||
}
|
||||
|
||||
public void setPeerRequest(PeerRequest peerRequest) {
|
||||
this.peerRequest = peerRequest;
|
||||
}
|
||||
|
||||
public List<Answer> getAnswers() {
|
||||
return answers;
|
||||
}
|
||||
|
||||
public void setAnswers(List<Answer> answers) {
|
||||
this.answers = answers;
|
||||
}
|
||||
|
||||
public FileDescription getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(FileDescription file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public ReviewRating getReviewRating() {
|
||||
return reviewRating;
|
||||
}
|
||||
|
||||
public void setReviewRating(ReviewRating reviewRating) {
|
||||
this.reviewRating = reviewRating;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
PeerReview other = (PeerReview) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityListeners;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
import se.su.dsv.scipro.peer.data.entitylisteners.QuestionValidationListener;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="question")
|
||||
@Cacheable(true)
|
||||
@EntityListeners({QuestionValidationListener.class})
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class Question extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=false)
|
||||
private String question;
|
||||
|
||||
private boolean notApplicableOption = false;
|
||||
private boolean freeTextQuestion = false;
|
||||
private boolean radioChoiceQuestion = false;
|
||||
|
||||
@Basic(optional=true)
|
||||
private String notApplicableHeading;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
private ReviewTemplate reviewTemplate;
|
||||
|
||||
@Basic(optional=true)
|
||||
private String freeTextHeading;
|
||||
|
||||
@OrderColumn
|
||||
@OneToMany(orphanRemoval=true, cascade=CascadeType.ALL)//mappedBy="question",
|
||||
private List<QuestionOption> radioOptions = new ArrayList<QuestionOption>();
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(String question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
public boolean isNotApplicableOption() {
|
||||
return notApplicableOption;
|
||||
}
|
||||
|
||||
public void setNotApplicableOption(boolean notApplicableOption) {
|
||||
this.notApplicableOption = notApplicableOption;
|
||||
}
|
||||
|
||||
public String getNotApplicableHeading() {
|
||||
return notApplicableHeading;
|
||||
}
|
||||
|
||||
public void setNotApplicableHeading(String notApplicableHeading) {
|
||||
this.notApplicableHeading = notApplicableHeading;
|
||||
}
|
||||
|
||||
public ReviewTemplate getReviewTemplate() {
|
||||
return reviewTemplate;
|
||||
}
|
||||
|
||||
public void setReviewTemplate(ReviewTemplate reviewTemplate) {
|
||||
this.reviewTemplate = reviewTemplate;
|
||||
}
|
||||
|
||||
public boolean isFreeTextQuestion() {
|
||||
return freeTextQuestion;
|
||||
}
|
||||
|
||||
public void setFreeTextQuestion(boolean freeTextQuestion) {
|
||||
this.freeTextQuestion = freeTextQuestion;
|
||||
}
|
||||
|
||||
public boolean isRadioChoiceQuestion() {
|
||||
return radioChoiceQuestion;
|
||||
}
|
||||
|
||||
public void setRadioChoiceQuestion(boolean radioChoiceQuestion) {
|
||||
this.radioChoiceQuestion = radioChoiceQuestion;
|
||||
}
|
||||
|
||||
public String getFreeTextHeading() {
|
||||
return freeTextHeading;
|
||||
}
|
||||
|
||||
public void setFreeTextHeading(String freeTextHeading) {
|
||||
this.freeTextHeading = freeTextHeading;
|
||||
}
|
||||
|
||||
public void setRadioOptions(List<QuestionOption> radioOptions) {
|
||||
this.radioOptions = radioOptions;
|
||||
}
|
||||
|
||||
public List<QuestionOption> getRadioOptions() {
|
||||
return radioOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "Question: "+question;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
Question other = (Question) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="question_option")
|
||||
//@EntityListeners({QuestionOptionValidationListener.class})
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class QuestionOption extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional=false)
|
||||
protected Question question;
|
||||
|
||||
@Column(name="option_string", nullable = false) //option is a reserved word in some dbms
|
||||
protected String option;
|
||||
|
||||
public QuestionOption(){ }
|
||||
|
||||
public QuestionOption(Question question, String option){
|
||||
this.question = question;
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param question the question to set
|
||||
*/
|
||||
public void setQuestion(Question question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the question
|
||||
*/
|
||||
public Question getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param option the option to set
|
||||
*/
|
||||
public void setOption(String option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the option
|
||||
*/
|
||||
public String getOption() {
|
||||
return option;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "QuestionOption: "+option+" (id="+id+")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((getId() == null) ? 0 : (int) (getId() ^ (getId() >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
QuestionOption other = (QuestionOption) obj;
|
||||
|
||||
if (getId() == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!getId().equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="review_rating")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class ReviewRating extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@OneToOne(optional=false)
|
||||
private PeerReview peerReview;
|
||||
|
||||
//TODO Implement this
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param peerReview the peerReview to set
|
||||
*/
|
||||
public void setPeerReview(PeerReview peerReview) {
|
||||
this.peerReview = peerReview;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the peerReview
|
||||
*/
|
||||
public PeerReview getPeerReview() {
|
||||
return peerReview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
ReviewRating other = (ReviewRating) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package se.su.dsv.scipro.peer.data.dataobjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.LazyDeletableDomainObject;
|
||||
|
||||
/**
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name="review_template")
|
||||
@Cacheable(true)
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class ReviewTemplate extends LazyDeletableDomainObject {
|
||||
|
||||
private static final long serialVersionUID = 8116476813957870372L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@Basic(optional=false)
|
||||
private String name;
|
||||
|
||||
private boolean published;
|
||||
|
||||
@Lob
|
||||
@Basic(optional=true)
|
||||
private String description;
|
||||
|
||||
@OrderColumn
|
||||
@OneToMany(orphanRemoval=true, cascade=CascadeType.ALL)//(mappedBy="reviewTemplate")
|
||||
private List<Question> questions = new ArrayList<Question>();
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(boolean published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<Question> getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
public void setQuestions(List<Question> questions) {
|
||||
this.questions = questions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int weight = 31;
|
||||
int result = 17;
|
||||
result = weight * result + ((id == null) ? 0 : (int) (id ^ (id >>> 32)));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this.getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
ReviewTemplate other = (ReviewTemplate) obj;
|
||||
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
24
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/AnswerValidationListener.java
Normal file
24
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/AnswerValidationListener.java
Normal file
@ -0,0 +1,24 @@
|
||||
package se.su.dsv.scipro.peer.data.entitylisteners;
|
||||
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Answer;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
|
||||
|
||||
public class AnswerValidationListener {
|
||||
|
||||
@PrePersist
|
||||
@PreUpdate
|
||||
public void validate(Object obj){
|
||||
Answer answer = (Answer) obj;
|
||||
Question question = answer.getQuestion();
|
||||
if(question.isNotApplicableOption() && answer.isChoosenNotApplicable())
|
||||
return;
|
||||
if(question.isRadioChoiceQuestion() && answer.getRadioChoice() == null)
|
||||
throw new RuntimeException("Answer:"+answer+" was marked radioChoiceQuestion but no choice was performed");
|
||||
|
||||
}
|
||||
|
||||
}
|
21
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/QuestionOptionValidationListener.java
Normal file
21
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/QuestionOptionValidationListener.java
Normal file
@ -0,0 +1,21 @@
|
||||
package se.su.dsv.scipro.peer.data.entitylisteners;
|
||||
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
|
||||
|
||||
public class QuestionOptionValidationListener {
|
||||
|
||||
@PrePersist
|
||||
@PreUpdate
|
||||
public void validate(Object obj){
|
||||
QuestionOption qo = (QuestionOption) obj;
|
||||
System.out.println(qo);
|
||||
System.out.println(qo.getQuestion().getRadioOptions());
|
||||
if(!qo.getQuestion().getRadioOptions().contains(qo))
|
||||
throw new RuntimeException("Attempt to persist a QuestionOption without adding it to it's parent questions list of options");
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/QuestionValidationListener.java
Normal file
29
src/main/java/se/su/dsv/scipro/peer/data/entitylisteners/QuestionValidationListener.java
Normal file
@ -0,0 +1,29 @@
|
||||
package se.su.dsv.scipro.peer.data.entitylisteners;
|
||||
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
|
||||
|
||||
public class QuestionValidationListener {
|
||||
|
||||
@PrePersist
|
||||
@PreUpdate
|
||||
public void validate(Object obj){
|
||||
Question question = (Question) obj;
|
||||
// TODO Investigate why this part doesn't work, because at one point it did. Collections are always empty inside the method!?
|
||||
/*
|
||||
if(question.isRadioChoiceQuestion()){
|
||||
if(question.getRadioOptions() == null || question.getRadioOptions().size() == 0)
|
||||
throw new RuntimeException("A radio choice question must have options to choose from, the following question didn't: "+question.getQuestion());
|
||||
}
|
||||
else{
|
||||
if(question.getRadioOptions().size() > 0)
|
||||
throw new RuntimeException("A question was given radio choice options while marked as not being a radio choice question");
|
||||
}
|
||||
*/
|
||||
if(!question.isRadioChoiceQuestion() && !question.isFreeTextQuestion())
|
||||
throw new RuntimeException("Tried to persist a question that was neither a free text nor a radio choice question");
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package se.su.dsv.scipro.peer.enums;
|
||||
|
||||
public enum RequestStatus {
|
||||
WAITING, TAKEN, FINISHED
|
||||
}
|
35
src/main/java/se/su/dsv/scipro/peer/pages/PeerTestPage.java
Normal file
35
src/main/java/se/su/dsv/scipro/peer/pages/PeerTestPage.java
Normal file
@ -0,0 +1,35 @@
|
||||
package se.su.dsv.scipro.peer.pages;
|
||||
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.basepages.MenuPage;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.QuestionDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewTemplateDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate;
|
||||
|
||||
public class PeerTestPage extends MenuPage {
|
||||
|
||||
@SpringBean
|
||||
private QuestionDao questionDao;
|
||||
@SpringBean
|
||||
private ReviewTemplateDao rtDao;
|
||||
|
||||
public PeerTestPage(){
|
||||
ReviewTemplate rt = new ReviewTemplate();
|
||||
rt.setName("Template for something");
|
||||
Question q = new Question();
|
||||
q.setQuestion("Really?");
|
||||
q.setRadioChoiceQuestion(true);
|
||||
q.setReviewTemplate(rt);
|
||||
q.getRadioOptions().add(new QuestionOption(q, "Yes"));
|
||||
q.getRadioOptions().add(new QuestionOption(q, "No"));
|
||||
|
||||
rt.getQuestions().add(q);
|
||||
rt = rtDao.save(rt);
|
||||
System.out.println(questionDao.findAll());
|
||||
System.out.println(questionDao.findAll().get(0).getRadioOptions());
|
||||
}
|
||||
|
||||
}
|
@ -45,6 +45,14 @@
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Comment</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectClass</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.FileDescription</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.Answer</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerQueue</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerReview</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerRequest</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.Question</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.ReviewRating</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.QuestionOption</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.CommentThread</class>
|
||||
|
||||
<properties>
|
||||
@ -62,18 +70,18 @@
|
||||
<!-- Local mysql test database -->
|
||||
<!--
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/scipro"></property>
|
||||
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:test"></property>
|
||||
<property name="hibernate.connection.username" value="root"></property>
|
||||
<property name="hibernate.connection.password" value="root"></property>
|
||||
<property name="hibernate.c3p0.idle_test_period" value="3306"></property>
|
||||
-->
|
||||
-->
|
||||
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
|
||||
<!-- <property name="hibernate.hbm2ddl.auto" value="update" />-->
|
||||
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:test"></property>
|
||||
<property name="hibernate.show_sql" value="false" />
|
||||
<property name="hibernate.format_sql" value="true" />
|
||||
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
@ -81,7 +89,7 @@
|
||||
<!-- A JPA Persistence Unit used for tests -->
|
||||
<persistence-unit name="testPersistenceUnit" transaction-type="RESOURCE_LOCAL">
|
||||
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||
|
||||
<!-- This list of persisted Entitys IS NOT updated by eclipes JPA facet,
|
||||
if some tests are failing, then copy paste exact list from the above persistence unit -->
|
||||
@ -119,6 +127,14 @@
|
||||
<class>se.su.dsv.scipro.data.dataobjects.Comment</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectClass</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.FileDescription</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.Answer</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerQueue</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerReview</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.PeerRequest</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.Question</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.ReviewRating</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate</class>
|
||||
<class>se.su.dsv.scipro.peer.data.dataobjects.QuestionOption</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.CommentThread</class>
|
||||
|
||||
<properties>
|
||||
@ -128,21 +144,27 @@
|
||||
<property name="net.sf.ehcache.configurationResourceName" value="/ehcache.xml" />
|
||||
<property name="hibernate.cache.use_query_cache" value="false" />
|
||||
<property name="hibernate.cache.use_second_level_cache" value="false" />
|
||||
<property name="hibernate.generate_statistics" value="false" />
|
||||
<property name="hibernate.generate_statistics" value="false" />
|
||||
|
||||
<!-- DEVELOPMENT VARIABLE, REMOVE FOR PRODUCTION USE -->
|
||||
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
|
||||
|
||||
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
|
||||
<property name="hibernate.hbm2ddl.auto" value="create" />
|
||||
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:test"></property>
|
||||
<property name="hibernate.show_sql" value="false" />
|
||||
<property name="hibernate.format_sql" value="true" />
|
||||
|
||||
|
||||
<!-- Local mysql test database -->
|
||||
<!--
|
||||
<property name="hibernate.hbm2ddl.auto" value="create" />
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/scipro"></property>
|
||||
<property name="hibernate.connection.username" value="root"></property>
|
||||
<property name="hibernate.connection.password" value="martin"></property>
|
||||
<property name="hibernate.connection.password" value="root"></property>
|
||||
<property name="hibernate.c3p0.idle_test_period" value="3600"></property>
|
||||
-->
|
||||
|
||||
|
@ -103,6 +103,33 @@
|
||||
<bean id="commentThreadDao" class="se.su.dsv.scipro.data.dao.jpa.CommentThreadDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<!-- Peer review beans -->
|
||||
<bean id="answerDao" class="se.su.dsv.scipro.peer.data.dao.jpa.AnswerDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="peerQueueDao" class="se.su.dsv.scipro.peer.data.dao.jpa.PeerQueueDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="peerRequestDao" class="se.su.dsv.scipro.peer.data.dao.jpa.PeerRequestDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="peerReviewDao" class="se.su.dsv.scipro.peer.data.dao.jpa.PeerReviewDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="questionDao" class="se.su.dsv.scipro.peer.data.dao.jpa.QuestionDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="questionOptionDao" class="se.su.dsv.scipro.peer.data.dao.jpa.QuestionOptionDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="reviewRatingDao" class="se.su.dsv.scipro.peer.data.dao.jpa.ReviewRatingDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="reviewTemplateDao" class="se.su.dsv.scipro.peer.data.dao.jpa.ReviewTemplateDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<!-- End of Peer-stuff -->
|
||||
|
||||
<bean class="se.su.dsv.scipro.DataInitialiser" init-method="dataInit" />
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user