diff --git a/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListAnswerDao.java b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListAnswerDao.java new file mode 100644 index 0000000000..8fe29de76d --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListAnswerDao.java @@ -0,0 +1,7 @@ +package se.su.dsv.scipro.data.dao.interfaces; + +import se.su.dsv.scipro.data.dataobjects.CheckListAnswer; + +public interface CheckListAnswerDao extends Dao<CheckListAnswer> { + +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListDao.java b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListDao.java new file mode 100644 index 0000000000..0dab6f8068 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListDao.java @@ -0,0 +1,7 @@ +package se.su.dsv.scipro.data.dao.interfaces; + +import se.su.dsv.scipro.data.dataobjects.CheckList; + +public interface CheckListDao extends Dao<CheckList> { + +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListQuestionDao.java b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListQuestionDao.java new file mode 100644 index 0000000000..fbf00a0b71 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListQuestionDao.java @@ -0,0 +1,7 @@ +package se.su.dsv.scipro.data.dao.interfaces; + +import se.su.dsv.scipro.data.dataobjects.CheckListQuestion; + +public interface CheckListQuestionDao extends Dao<CheckListQuestion> { + +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListTemplateDao.java b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListTemplateDao.java new file mode 100644 index 0000000000..24885dffb9 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/interfaces/CheckListTemplateDao.java @@ -0,0 +1,8 @@ +package se.su.dsv.scipro.data.dao.interfaces; + +import se.su.dsv.scipro.data.dataobjects.CheckListTemplate; + + +public interface CheckListTemplateDao extends Dao<CheckListTemplate> { + +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListAnswerDaoJPAImp.java b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListAnswerDaoJPAImp.java new file mode 100644 index 0000000000..e30b653abd --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListAnswerDaoJPAImp.java @@ -0,0 +1,23 @@ +package se.su.dsv.scipro.data.dao.jpa; + +import org.springframework.stereotype.Repository; + +import se.su.dsv.scipro.data.dao.interfaces.CheckListAnswerDao; +import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao; +import se.su.dsv.scipro.data.dataobjects.CheckListAnswer; +import se.su.dsv.scipro.data.dataobjects.CheckListQuestion; + +/** + * + * @author Fredrik Norberg - fnorbe@dsv.su.se + * + */ + +@Repository("checkListAnswerDao") +public class CheckListAnswerDaoJPAImp extends AbstractDaoJPAImp<CheckListAnswer> + implements CheckListAnswerDao { + + public CheckListAnswerDaoJPAImp() { + super(CheckListAnswer.class); + } +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListDaoJPAImp.java b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListDaoJPAImp.java new file mode 100644 index 0000000000..4f0786dd92 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListDaoJPAImp.java @@ -0,0 +1,21 @@ +package se.su.dsv.scipro.data.dao.jpa; + +import org.springframework.stereotype.Repository; + +import se.su.dsv.scipro.data.dao.interfaces.CheckListDao; +import se.su.dsv.scipro.data.dataobjects.CheckList; + +/** + * + * @author Fredrik Norberg - fnorbe@dsv.su.se + * + */ + +@Repository("checkListDao") +public class CheckListDaoJPAImp extends AbstractDaoJPAImp<CheckList> + implements CheckListDao { + + public CheckListDaoJPAImp() { + super(CheckList.class); + } +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListQuestionDaoJPAImp.java b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListQuestionDaoJPAImp.java new file mode 100644 index 0000000000..35eda47251 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListQuestionDaoJPAImp.java @@ -0,0 +1,21 @@ +package se.su.dsv.scipro.data.dao.jpa; + +import org.springframework.stereotype.Repository; + +import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao; +import se.su.dsv.scipro.data.dataobjects.CheckListQuestion; + +/** + * + * @author Fredrik Norberg - fnorbe@dsv.su.se + * + */ + +@Repository("checkListQuestionDao") +public class CheckListQuestionDaoJPAImp extends AbstractDaoJPAImp<CheckListQuestion> + implements CheckListQuestionDao { + + public CheckListQuestionDaoJPAImp() { + super(CheckListQuestion.class); + } +} diff --git a/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListTemplateDaoJPAImp.java b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListTemplateDaoJPAImp.java new file mode 100644 index 0000000000..12e9a906e9 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dao/jpa/CheckListTemplateDaoJPAImp.java @@ -0,0 +1,23 @@ +package se.su.dsv.scipro.data.dao.jpa; + +import org.springframework.stereotype.Repository; + +import se.su.dsv.scipro.data.dao.interfaces.CheckListQuestionDao; +import se.su.dsv.scipro.data.dao.interfaces.CheckListTemplateDao; +import se.su.dsv.scipro.data.dataobjects.CheckListQuestion; +import se.su.dsv.scipro.data.dataobjects.CheckListTemplate; + +/** + * + * @author Fredrik Norberg - fnorbe@dsv.su.se + * + */ + +@Repository("checkListTemplateDao") +public class CheckListTemplateDaoJPAImp extends AbstractDaoJPAImp<CheckListTemplate> + implements CheckListTemplateDao { + + public CheckListTemplateDaoJPAImp() { + super(CheckListTemplate.class); + } +} diff --git a/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckList.java b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckList.java new file mode 100644 index 0000000000..9629983bbf --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckList.java @@ -0,0 +1,140 @@ +package se.su.dsv.scipro.data.dataobjects; + +import java.util.List; + +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; + +/** + + * @author Fredrik Norberg fnorbe@dsv.su.se + * + */ + +@Entity +@Table(name="checklist") +@Cacheable(true) +@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate +public abstract class CheckList extends LazyDeletableDomainObject{ + + private static final long serialVersionUID = 2959377496669050427L; + + @Id + @GeneratedValue + private Long id; + + @Column(nullable=false) + private String name; + + @ManyToOne(optional=false) + private User creator; + + @Column(nullable=false) + private List<CheckListQuestion> questions; + + @Column(nullable=false) + private ProjectClass level; + + public CheckList() {} + + public CheckList(String name, User creator, ProjectClass level) { + this.name = name; + this.creator = creator; + this.level = level; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getname() { + return name; + } + + public String getName(final int characters) { + String result = name; + if(name.length() > characters) + result = name.substring(0, characters)+".."; + return result; + } + + public void setName(String name) { + this.name = name; + } + + + public void setCreator(User creator) { + this.creator = creator; + } + + public User getCreator() { + return creator; + } + + public List<CheckListQuestion> getquestions(){ + return questions; + } + + public void setquestions(List<CheckListQuestion> questions){ + this.questions=questions; + } + + public void setLevel(ProjectClass level){ + this.level = level; + } + + public ProjectClass getLevel(){ + return level; + } + + @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 (obj instanceof CheckList){ + + CheckList other = (CheckList) obj; + + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + + return true; + } + return false; + } + + @Override + public String toString() { + return getname(); + } + +} + + \ No newline at end of file diff --git a/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListAnswer.java b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListAnswer.java new file mode 100644 index 0000000000..c979fecc97 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListAnswer.java @@ -0,0 +1,106 @@ +package se.su.dsv.scipro.data.dataobjects; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EntityManager; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.TypedQuery; + +import org.apache.wicket.markup.html.panel.Panel; + +import se.su.dsv.scipro.data.enums.CheckListQuestionAnswer; +import se.su.dsv.scipro.data.enums.EventStatus; +import se.su.dsv.scipro.schedule.baseevent.panels.EventScheduleDetailsPanel; +import se.su.dsv.scipro.util.IAjaxCallback; + +/** + * @author Fredrik Norberg fnorbe@dsv.su.se + * + */ +@Entity +@Table(name="checklist_answer") +public class CheckListAnswer extends DomainObject{ + + private static final long serialVersionUID = 2959377496669050427L; + + @Id + @GeneratedValue + private Long id; + + @Enumerated(EnumType.STRING) + private CheckListQuestionAnswer answer; + + @ManyToOne + private User user; + + + public CheckListAnswer() {} + + public CheckListAnswer(User user, CheckListQuestionAnswer answer) { + this.user = user; + this.answer = answer; + } + + public CheckListQuestionAnswer getAnswer() { + return answer; + } + + public void setAnswer(CheckListQuestionAnswer answer) { + this.answer = answer; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @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 (obj instanceof CheckListAnswer){ + + CheckListAnswer other = (CheckListAnswer) obj; + + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListQuestion.java b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListQuestion.java new file mode 100644 index 0000000000..fb9d0d90a9 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListQuestion.java @@ -0,0 +1,116 @@ +package se.su.dsv.scipro.data.dataobjects; + +import java.util.List; + +import javax.persistence.Cacheable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; + +/** + * @author Fredrik Norberg - fnorbe@dsv.su.se + */ + + +@Entity +@Table(name="checklist_question") +@Cacheable(true) +@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate +public abstract class CheckListQuestion extends DomainObject + implements Comparable<CheckListQuestion> { + + private static final long serialVersionUID = 2959377496669050427L; + + @Id + @GeneratedValue + private Long id; + + @Lob + @Column(nullable=false) + private String question; + + @Column(nullable=false) + private int questionNumber; + + @OneToMany + List<CheckListAnswer> answers; + + public CheckListQuestion() {} + + public CheckListQuestion(String question) { + this.question = question; + questionNumber = answers.size() + 1; + } + + public String getQuestion() { + return question; + } + + public void setQuestion(String question) { + this.question = question; + } + + public int getQuestionNumber() { + return questionNumber; + } + + public void setQuestionNumber(int questionNumber) { + this.questionNumber = questionNumber; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + @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 (obj instanceof CheckListQuestion){ + + CheckListQuestion other = (CheckListQuestion) obj; + + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + + return true; + } + return false; + } + + @Override + public String toString() { + return getQuestion(); + } + + @Override + public int compareTo(CheckListQuestion other) { + return questionNumber - other.questionNumber; + } +} \ No newline at end of file diff --git a/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListTemplate.java b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListTemplate.java new file mode 100644 index 0000000000..74a47ffacf --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/dataobjects/CheckListTemplate.java @@ -0,0 +1,107 @@ +package se.su.dsv.scipro.data.dataobjects; + +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * @author Fredrik Norberg - fnorbe@dsv.su.se + * + */ +@Entity +@Table(name="checklist_template") +public class CheckListTemplate extends DomainObject { + + private static final long serialVersionUID = 2959377496669050427L; + + @Id + @GeneratedValue + private Long id; + + @Column(nullable=false) + private String name; + + @Lob + @ElementCollection + List<String> questions; + + @ManyToOne(optional=false) + private User creator; + + public CheckListTemplate() {} + + public CheckListTemplate(String name, User creator) { + this.name = name; + this.creator = creator; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public void setCreator(User creator) { + this.creator = creator; + } + + public User getCreator() { + return creator; + } + + public List<String> getQuestions(){ + return questions; + } + + public void setQuestions(List<String> questions){ + this.questions = questions; + } + + @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 (obj instanceof CheckListTemplate){ + + CheckListTemplate other = (CheckListTemplate) obj; + + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + + return true; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/se/su/dsv/scipro/data/enums/CheckListQuestionAnswer.java b/src/main/java/se/su/dsv/scipro/data/enums/CheckListQuestionAnswer.java new file mode 100644 index 0000000000..397b191276 --- /dev/null +++ b/src/main/java/se/su/dsv/scipro/data/enums/CheckListQuestionAnswer.java @@ -0,0 +1,7 @@ +package se.su.dsv.scipro.data.enums; + +public enum CheckListQuestionAnswer { + RED, + GREEN, + YELLOW +}