added base classes for dynamic checklists
This commit is contained in:
parent
3142cc3331
commit
94133f4bac
src/main/java/se/su/dsv/scipro/data
dao
interfaces
jpa
dataobjects
enums
@ -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> {
|
||||
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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> {
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
140
src/main/java/se/su/dsv/scipro/data/dataobjects/CheckList.java
Normal file
140
src/main/java/se/su/dsv/scipro/data/dataobjects/CheckList.java
Normal file
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package se.su.dsv.scipro.data.enums;
|
||||
|
||||
public enum CheckListQuestionAnswer {
|
||||
RED,
|
||||
GREEN,
|
||||
YELLOW
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user